Update from Git Manager GUI
This commit is contained in:
@@ -3,6 +3,10 @@
|
||||
|
||||
/* ── Utilities ──────────────────────────────────────────────── */
|
||||
function wbfPost(action, data, cb, errCb) {
|
||||
if (typeof WBF === 'undefined' || !WBF.ajax_url || !WBF.nonce) {
|
||||
if (errCb) errCb({message: 'Forum-Fehler: AJAX-Setup fehlt. Bitte Seite neu laden.'});
|
||||
return;
|
||||
}
|
||||
data.action = action;
|
||||
data.nonce = WBF.nonce;
|
||||
$.post(WBF.ajax_url, data, function (res) {
|
||||
@@ -52,12 +56,18 @@
|
||||
/* ── Registrieren ───────────────────────────────────────────── */
|
||||
$(document).on('click', '.wbf-reg-submit-btn', function () {
|
||||
var $btn = $(this).prop('disabled', true).html('<i class="fas fa-spinner fa-spin"></i>');
|
||||
var $invite = $(this).closest('.wbf-auth-box').find('.wbf-field-invite-code');
|
||||
var inviteVal = '';
|
||||
if ($invite.length > 0) {
|
||||
var raw = $invite.val();
|
||||
if (typeof raw === 'string') inviteVal = raw.toUpperCase().trim();
|
||||
}
|
||||
wbfPost('wbf_register', {
|
||||
username: $(this).closest('.wbf-auth-box').find('.wbf-field-reg-user').val(),
|
||||
display_name: $(this).closest('.wbf-auth-box').find('.wbf-field-reg-name').val(),
|
||||
email: $(this).closest('.wbf-auth-box').find('.wbf-field-reg-email').val(),
|
||||
password: $(this).closest('.wbf-auth-box').find('.wbf-field-reg-pass').val(),
|
||||
invite_code: $(this).closest('.wbf-auth-box').find('.wbf-field-invite-code').val().toUpperCase().trim(),
|
||||
invite_code: inviteVal,
|
||||
rules_accepted: $(this).closest('.wbf-auth-box').find('.wbf-field-rules-accept').is(':checked') ? '1' : ''
|
||||
}, function () {
|
||||
location.reload();
|
||||
@@ -609,6 +619,48 @@
|
||||
});
|
||||
});
|
||||
|
||||
// ── Banner-Upload ─────────────────────────────────────────────────────────
|
||||
$(document).on('change', '#wbfBannerFile', function () {
|
||||
var file = this.files[0];
|
||||
if (!file) return;
|
||||
|
||||
// Sofort-Vorschau
|
||||
var objectUrl = URL.createObjectURL(file);
|
||||
var $wrap = $('#wbfProfileBannerWrap');
|
||||
var $existing = $wrap.find('.wbf-profile-banner__img');
|
||||
|
||||
// Falls noch kein Banner-Bild existiert, eins einfügen
|
||||
if ($existing.length === 0) {
|
||||
$wrap.prepend('<img src="' + objectUrl + '" alt="" id="wbfProfileBanner" class="wbf-profile-banner__img" style="opacity:.4">');
|
||||
} else {
|
||||
$existing.attr('src', objectUrl).css('opacity', '.4');
|
||||
}
|
||||
|
||||
var fd = new FormData();
|
||||
fd.append('action', 'wbf_upload_banner');
|
||||
fd.append('nonce', WBF.nonce);
|
||||
fd.append('banner', file);
|
||||
|
||||
$.ajax({
|
||||
url: WBF.ajax_url,
|
||||
type: 'POST',
|
||||
data: fd,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function (res) {
|
||||
var $img = $wrap.find('.wbf-profile-banner__img');
|
||||
if (res.success) {
|
||||
URL.revokeObjectURL(objectUrl);
|
||||
$img.attr('src', res.data.banner_url + '?v=' + Date.now());
|
||||
}
|
||||
$img.css('opacity', '');
|
||||
},
|
||||
error: function () {
|
||||
$wrap.find('.wbf-profile-banner__img').css('opacity', '');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/* ══════════════════════════════════════════════════════════
|
||||
FEATURE: Ungelesene Beiträge
|
||||
══════════════════════════════════════════════════════════ */
|
||||
@@ -2163,4 +2215,132 @@
|
||||
$bar.hide();
|
||||
});
|
||||
|
||||
}(jQuery));
|
||||
|
||||
|
||||
// ── Discord-Integration (3-Schritt Verifikation) ─────────────────────────
|
||||
|
||||
var wbfDcStep = 1; // aktueller Schritt
|
||||
|
||||
function wbfDcMsg(text, color) {
|
||||
var $m = $('#wbf-discord-msg');
|
||||
$m.css('color', color || 'var(--c-muted)').html(text);
|
||||
}
|
||||
|
||||
function wbfDcSetBadge(connected) {
|
||||
var $badge = $('.wbf-connection-card--discord .wbf-connection-badge');
|
||||
if (connected) {
|
||||
$badge.removeClass('wbf-connection-badge--disconnected')
|
||||
.addClass('wbf-connection-badge--connected')
|
||||
.html('<i class="fas fa-check-circle"></i> Verbunden');
|
||||
} else {
|
||||
$badge.removeClass('wbf-connection-badge--connected')
|
||||
.addClass('wbf-connection-badge--disconnected')
|
||||
.html('<i class="fas fa-circle-xmark"></i> Nicht verbunden');
|
||||
}
|
||||
}
|
||||
|
||||
// Schritt 1 → Code senden
|
||||
$(document).on('click', '#wbf-discord-send-code', function () {
|
||||
var username = $('#wbf-discord-input').val().trim();
|
||||
if (!username) { wbfDcMsg('<i class="fas fa-triangle-exclamation"></i> Bitte Benutzername eingeben.', '#f97316'); return; }
|
||||
var $btn = $(this).prop('disabled', true).html('<i class="fas fa-spinner fa-spin"></i> Sende…');
|
||||
wbfDcMsg('');
|
||||
$.post(WBF.ajax_url, {
|
||||
action: 'wbf_discord_send_code',
|
||||
nonce: WBF.nonce,
|
||||
discord_username: username,
|
||||
}, function (res) {
|
||||
$btn.prop('disabled', false).html('<i class="fab fa-discord"></i> Code senden');
|
||||
if (res.success) {
|
||||
wbfDcMsg('<i class="fas fa-check" style="color:#16a34a"></i> ' + (res.data.message || 'Code gesendet!'), '#16a34a');
|
||||
$('#wbf-dc-step1').slideUp(200, function () { $('#wbf-dc-step2').slideDown(200); });
|
||||
$('#wbf-discord-code-input').val('').focus();
|
||||
wbfDcStep = 2;
|
||||
} else {
|
||||
wbfDcMsg('<i class="fas fa-circle-xmark"></i> ' + ((res.data && res.data.message) || 'Fehler.'), '#dc2626');
|
||||
}
|
||||
}).fail(function () {
|
||||
$btn.prop('disabled', false).html('<i class="fab fa-discord"></i> Code senden');
|
||||
wbfDcMsg('<i class="fas fa-circle-xmark"></i> Netzwerkfehler.', '#dc2626');
|
||||
});
|
||||
});
|
||||
|
||||
// Schritt 2 → Code bestätigen
|
||||
$(document).on('click', '#wbf-discord-verify', function () {
|
||||
var code = $('#wbf-discord-code-input').val().trim().toUpperCase();
|
||||
if (code.length < 4) { wbfDcMsg('<i class="fas fa-triangle-exclamation"></i> Bitte Code eingeben.', '#f97316'); return; }
|
||||
var $btn = $(this).prop('disabled', true).html('<i class="fas fa-spinner fa-spin"></i> Prüfe…');
|
||||
$.post(WBF.ajax_url, {
|
||||
action: 'wbf_discord_verify_code',
|
||||
nonce: WBF.nonce,
|
||||
verify_code: code,
|
||||
}, function (res) {
|
||||
$btn.prop('disabled', false).html('<i class="fas fa-check"></i> Bestätigen');
|
||||
if (res.success) {
|
||||
wbfDcMsg('<i class="fas fa-check-circle"></i> ' + (res.data.message || 'Verbunden!'), '#16a34a');
|
||||
wbfDcSetBadge(true);
|
||||
// UI auf "Verbunden"-Ansicht umschalten
|
||||
var name = res.data.display_name || '';
|
||||
$('#wbf-discord-form').slideUp(200);
|
||||
// Verbunden-Info einfügen/aktualisieren
|
||||
var $info = $('.wbf-discord-connected-info');
|
||||
if ($info.length) {
|
||||
$info.find('.wbf-discord-linked-name').html('<i class="fab fa-discord" style="color:#5865f2"></i> ' + $('<span>').text(name).html());
|
||||
} else {
|
||||
// Frisch laden damit die PHP-Struktur stimmt
|
||||
setTimeout(function(){ location.reload(); }, 1200);
|
||||
}
|
||||
} else {
|
||||
wbfDcMsg('<i class="fas fa-circle-xmark"></i> ' + ((res.data && res.data.message) || 'Fehler.'), '#dc2626');
|
||||
}
|
||||
}).fail(function () {
|
||||
$btn.prop('disabled', false).html('<i class="fas fa-check"></i> Bestätigen');
|
||||
wbfDcMsg('<i class="fas fa-circle-xmark"></i> Netzwerkfehler.', '#dc2626');
|
||||
});
|
||||
});
|
||||
|
||||
// Enter-Taste auf Code-Feld
|
||||
$(document).on('keydown', '#wbf-discord-code-input', function (e) {
|
||||
if (e.key === 'Enter') { e.preventDefault(); $('#wbf-discord-verify').trigger('click'); }
|
||||
});
|
||||
|
||||
// Enter-Taste auf Username-Feld
|
||||
$(document).on('keydown', '#wbf-discord-input', function (e) {
|
||||
if (e.key === 'Enter') { e.preventDefault(); $('#wbf-discord-send-code').trigger('click'); }
|
||||
});
|
||||
|
||||
// „Zurück" in Schritt 2
|
||||
$(document).on('click', '#wbf-discord-code-back', function () {
|
||||
$('#wbf-dc-step2').slideUp(200, function () { $('#wbf-dc-step1').slideDown(200); });
|
||||
wbfDcMsg('');
|
||||
wbfDcStep = 1;
|
||||
});
|
||||
|
||||
// „Neu verknüpfen" bei bereits verbundenem Account
|
||||
$(document).on('click', '#wbf-discord-relink', function () {
|
||||
$('#wbf-discord-form').slideDown(200);
|
||||
$('#wbf-discord-input').val('').focus();
|
||||
});
|
||||
|
||||
// Verbindung trennen
|
||||
$(document).on('click', '#wbf-discord-disconnect', function () {
|
||||
if (!confirm('Discord-Verbindung wirklich trennen?')) return;
|
||||
var $btn = $(this).prop('disabled', true);
|
||||
$.post(WBF.ajax_url, {
|
||||
action: 'wbf_save_discord',
|
||||
nonce: WBF.nonce,
|
||||
sub_action: 'disconnect',
|
||||
}, function (res) {
|
||||
$btn.prop('disabled', false);
|
||||
if (res.success) {
|
||||
wbfDcMsg('<i class="fas fa-check"></i> ' + (res.data.message || 'Getrennt.'), '#16a34a');
|
||||
wbfDcSetBadge(false);
|
||||
setTimeout(function () { location.reload(); }, 900);
|
||||
} else {
|
||||
wbfDcMsg('<i class="fas fa-circle-xmark"></i> ' + ((res.data && res.data.message) || 'Fehler.'), '#dc2626');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}(jQuery));
|
||||
// Overwrite last line — Discord handlers appended via patch:
|
||||
Reference in New Issue
Block a user