refactor: rename the theme brand and every identifier from AKSRT to Jio
Full-project rename. `git grep -i aksrt` is now empty apart from the
DBMigrator 3.3.0 changelog note that documents the rename itself.
Code identifiers
- PHP namespace AKSRT\ -> Jio\ (composer PSR-4 + 378 declarations)
- global constants AKSRT_* -> JIO_* (VERSION/DIR/URI, PAY_TYPE_*, CAPTCHA_*)
- procedural functions, hooks, options, meta keys, table names,
cookies, query vars, ajax actions and nonces: aksrt_ -> jio_
- text domain aksrt -> jio; Theme Name -> Jio
- JS globals: aksrtData/aksrtAdminData/... -> jioData/jioAdminData/...,
window.AKSRTCaptcha & friends -> window.JioCaptcha, Aksrt* -> Jio*
- Vue components Aks*.vue -> Jio*.vue (15 files renamed + imports)
- CSS classes/data-attrs/custom properties: aksrt- -> jio-
- REST namespace aksrt/v1 -> jio/v1 (incl. payment gateway callbacks)
Storage layer
- DB tables {prefix}aksrt_* -> {prefix}jio_*; SCHEMA_VERSION 3.2.0 -> 3.3.0
so dbDelta creates the new names on install
- widget id_base aksrt_widget_* -> jio_widget_*
- uninstall.php drop list rebuilt from the actual migrator tables
(dropped 3 stale entries, added the 17 missing ones)
Removed
- hardcoded https://api.aksrt.com/version.json default update endpoint;
get_endpoint() now reads the 「更新端点」 setting and do_check() no-ops
when it is empty
Files renamed: inc/helpers/aksrt-*.php -> jio-*.php (54),
assets/admin/src/components/form/Aks*.vue -> Jio*.vue (15).
Build artifacts regenerated: assets/css/build, assets/js/runtime,
assets/admin/build.
Verified: audit-psr4-paths errors=0, audit-admin-contracts errors=0
(warnings=56, unchanged baseline), 813/813 widget-system tests,
44/44 phpunit, php -l clean across all PHP.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
5b16bc6e15
commit
35bb96e82f
997 files changed
+28216
-28188
No files matched your search
@@ -25,15 +25,15 @@
|
||||
|
||||
var config = configFor(root);
|
||||
var template = root.querySelector('[data-auth-modal-template]');
|
||||
var runtime = window.AksrtModalRuntime;
|
||||
if (!template || !runtime || !window.AksrtRequest) return;
|
||||
var runtime = window.JioModalRuntime;
|
||||
if (!template || !runtime || !window.JioRequest) return;
|
||||
|
||||
function open() {
|
||||
runtime.open({
|
||||
html: template.innerHTML,
|
||||
height: 320,
|
||||
kind: 'identity',
|
||||
className: 'aksrt-identity-modal-shell',
|
||||
className: 'jio-identity-modal-shell',
|
||||
mobileBottom: true,
|
||||
onContent: function (_, session) {
|
||||
var shell = session && session.shell;
|
||||
@@ -81,11 +81,11 @@
|
||||
|
||||
function onModalClose(event) {
|
||||
if (!event.detail || event.detail.shell !== shell) return;
|
||||
document.removeEventListener('aksrt:modal:close', onModalClose);
|
||||
document.removeEventListener('jio:modal:close', onModalClose);
|
||||
releasePreviewUrls();
|
||||
}
|
||||
|
||||
document.addEventListener('aksrt:modal:close', onModalClose);
|
||||
document.addEventListener('jio:modal:close', onModalClose);
|
||||
preview.addEventListener('click', function (event) {
|
||||
var remove = event.target.closest('[data-auth-remove]');
|
||||
if (remove) {
|
||||
@@ -169,8 +169,8 @@
|
||||
button.disabled = true;
|
||||
button.innerHTML = '<i class="fa fas fa-spinner fa-spin mr6" aria-hidden="true"></i>正在提交…';
|
||||
}
|
||||
toast('正在提交申请…', 'load', '', 'aksrt_identity_submit');
|
||||
window.AksrtRequest.request(config.restBase, {
|
||||
toast('正在提交申请…', 'load', '', 'jio_identity_submit');
|
||||
window.JioRequest.request(config.restBase, {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
headers: { 'X-WP-Nonce': config.nonce || '' },
|
||||
@@ -178,7 +178,7 @@
|
||||
}).then(function (response) {
|
||||
var result = parseResponse(response);
|
||||
if (!result || result.success === false) throw new Error((result && result.message) || '申请提交失败,请稍后重试');
|
||||
toast('申请已提交,请耐心等待管理员审核。', 'success', '', 'aksrt_identity_submit');
|
||||
toast('申请已提交,请耐心等待管理员审核。', 'success', '', 'jio_identity_submit');
|
||||
var summary = root.querySelector('[data-auth-summary]');
|
||||
if (summary) {
|
||||
summary.replaceChildren();
|
||||
@@ -220,7 +220,7 @@
|
||||
}
|
||||
if (runtime.getActive && runtime.getActive() === shell) runtime.close('submit');
|
||||
}).catch(function (error) {
|
||||
toast(errorMessage(error, '申请提交失败,请稍后重试'), 'danger', '', 'aksrt_identity_submit');
|
||||
toast(errorMessage(error, '申请提交失败,请稍后重试'), 'danger', '', 'jio_identity_submit');
|
||||
}).finally(function () {
|
||||
if (button) {
|
||||
button.disabled = false;
|
||||
@@ -240,5 +240,5 @@
|
||||
});
|
||||
}
|
||||
|
||||
window.AKSRTUserCenterAuth = { init: init };
|
||||
window.JioUserCenterAuth = { init: init };
|
||||
})(window, document);
|
||||
+136
-136
@@ -1,18 +1,18 @@
|
||||
/**
|
||||
* AKSRT User Center — 本人中心专属脚本
|
||||
* Jio User Center — 本人中心专属脚本
|
||||
*
|
||||
* 从 page-profile.php 内联 JS 迁移而来。
|
||||
* 依赖全局 aksrtUserCenter 配置对象(由模板注入)。
|
||||
* 依赖全局 jioUserCenter 配置对象(由模板注入)。
|
||||
*
|
||||
* @package AKSRT
|
||||
* @package Jio
|
||||
*/
|
||||
|
||||
/* global aksrtUserCenter, notyf */
|
||||
/* global jioUserCenter, notyf */
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var cfg = window.aksrtUserCenter || {};
|
||||
var cfg = window.jioUserCenter || {};
|
||||
var ajaxUrl = cfg.ajaxUrl || '';
|
||||
var publicNonce = cfg.publicNonce || '';
|
||||
var settingsNonce = cfg.settingsNonce || '';
|
||||
@@ -23,34 +23,34 @@
|
||||
var tabUrls = cfg.tabUrls || {};
|
||||
|
||||
function captchaAvailable(scene, scope) {
|
||||
var captcha = window.AKSRTCaptcha;
|
||||
var captcha = window.JioCaptcha;
|
||||
if (!captcha) return false;
|
||||
var element = scope && scope.nodeType ? scope : null;
|
||||
if (element && element.matches && element.matches('[data-aksrt-captcha-config][data-scene="' + scene + '"]')) return true;
|
||||
if (element && element.querySelector && element.querySelector('[data-aksrt-captcha-config][data-scene="' + scene + '"]')) return true;
|
||||
var mount = element && element.closest ? element.closest('[data-aksrt-captcha-config][data-scene="' + scene + '"]') : null;
|
||||
if (element && element.matches && element.matches('[data-jio-captcha-config][data-scene="' + scene + '"]')) return true;
|
||||
if (element && element.querySelector && element.querySelector('[data-jio-captcha-config][data-scene="' + scene + '"]')) return true;
|
||||
var mount = element && element.closest ? element.closest('[data-jio-captcha-config][data-scene="' + scene + '"]') : null;
|
||||
return !!mount;
|
||||
}
|
||||
|
||||
function runCaptcha(scene, scope) {
|
||||
return window.AKSRTCaptcha ? window.AKSRTCaptcha.run(scene, scope) : Promise.resolve({});
|
||||
return window.JioCaptcha ? window.JioCaptcha.run(scene, scope) : Promise.resolve({});
|
||||
}
|
||||
|
||||
function resetCaptcha(scene, scope) {
|
||||
if (window.AKSRTCaptcha) window.AKSRTCaptcha.reset(scene, scope);
|
||||
if (window.JioCaptcha) window.JioCaptcha.reset(scene, scope);
|
||||
}
|
||||
|
||||
function setSettingsSubmitLabel(button, text) {
|
||||
var label = button && button.querySelector('[data-aksrt-settings-submit-label]');
|
||||
var label = button && button.querySelector('[data-jio-settings-submit-label]');
|
||||
if (label) label.textContent = text;
|
||||
}
|
||||
|
||||
/* ==================== Dashboard 导航 ==================== */
|
||||
function initDashboardNavigation() {
|
||||
if (document.documentElement.dataset.aksrtUserCenterNavigationInitialized === 'true') return;
|
||||
if (document.documentElement.dataset.jioUserCenterNavigationInitialized === 'true') return;
|
||||
var tabContainer = document.querySelector('.uc-mobile-tabs');
|
||||
if (!tabContainer) return;
|
||||
document.documentElement.dataset.aksrtUserCenterNavigationInitialized = 'true';
|
||||
document.documentElement.dataset.jioUserCenterNavigationInitialized = 'true';
|
||||
|
||||
var tabs = tabContainer.querySelectorAll('[data-tab]');
|
||||
var sidebarBtns = document.querySelectorAll('.uc-sidebar [data-tab]');
|
||||
@@ -99,10 +99,10 @@
|
||||
if (!panels[name]) return Promise.reject(new Error('panel-not-found'));
|
||||
var target = panels[name].panel;
|
||||
if (!forceLoad && target.dataset.panelLoaded === 'true') return Promise.resolve();
|
||||
if (target._aksrtPanelRequest) return target._aksrtPanelRequest;
|
||||
var restUrl = (window.aksrtData && (window.aksrtData.restUrl || window.aksrtData.apiUrl)) || cfg.restUrl || '';
|
||||
if (target._jioPanelRequest) return target._jioPanelRequest;
|
||||
var restUrl = (window.jioData && (window.jioData.restUrl || window.jioData.apiUrl)) || cfg.restUrl || '';
|
||||
if (!restUrl) return Promise.reject(new Error('rest-unavailable'));
|
||||
if (name === 'orders' && (!window.AKSRTOrderCenter || typeof window.AKSRTOrderCenter.init !== 'function')) {
|
||||
if (name === 'orders' && (!window.JioOrderCenter || typeof window.JioOrderCenter.init !== 'function')) {
|
||||
return Promise.reject(new Error('orders-initializer-unavailable'));
|
||||
}
|
||||
target.classList.add('is-loading');
|
||||
@@ -118,14 +118,14 @@
|
||||
if (params.get(key)) url += (url.indexOf('?') === -1 ? '?' : '&') + key + '=' + encodeURIComponent(params.get(key));
|
||||
});
|
||||
}
|
||||
target._aksrtPanelRequest = fetch(url, {
|
||||
target._jioPanelRequest = fetch(url, {
|
||||
credentials: 'same-origin',
|
||||
headers: { 'X-WP-Nonce': (window.aksrtData && (window.aksrtData.restNonce || window.aksrtData.nonce)) || '' }
|
||||
headers: { 'X-WP-Nonce': (window.jioData && (window.jioData.restNonce || window.jioData.nonce)) || '' }
|
||||
}).then(function(response) {
|
||||
return response.json().then(function(payload) {
|
||||
if (!response.ok || !payload || !payload.success || !payload.data || typeof payload.data.html !== 'string') throw new Error('panel-load-failed');
|
||||
if (name === 'orders' && window.AKSRTOrderCenter && typeof window.AKSRTOrderCenter.destroy === 'function') {
|
||||
window.AKSRTOrderCenter.destroy(target);
|
||||
if (name === 'orders' && window.JioOrderCenter && typeof window.JioOrderCenter.destroy === 'function') {
|
||||
window.JioOrderCenter.destroy(target);
|
||||
}
|
||||
target.innerHTML = payload.data.html;
|
||||
if (window.jQuery) jQuery(document).trigger('post_ajax.ed', [target]);
|
||||
@@ -133,28 +133,28 @@
|
||||
target.dataset.panelLoaded = 'true';
|
||||
});
|
||||
}).finally(function() {
|
||||
target._aksrtPanelRequest = null;
|
||||
target._jioPanelRequest = null;
|
||||
target.classList.remove('is-loading');
|
||||
});
|
||||
return target._aksrtPanelRequest;
|
||||
return target._jioPanelRequest;
|
||||
}
|
||||
|
||||
/* Level tabs are nested inside the active panel and must not enter the
|
||||
* main user-center navigation handler. */
|
||||
function activateLevelTab(link) {
|
||||
var page = link.closest('.aksrt-level-page');
|
||||
var paneId = link.getAttribute('data-aksrt-level-tab') || '';
|
||||
var page = link.closest('.jio-level-page');
|
||||
var paneId = link.getAttribute('data-jio-level-tab') || '';
|
||||
if (!page || !paneId) return false;
|
||||
var pane = Array.prototype.find.call(page.querySelectorAll('.aksrt-level-experience .tab-pane'), function(item) {
|
||||
var pane = Array.prototype.find.call(page.querySelectorAll('.jio-level-experience .tab-pane'), function(item) {
|
||||
return item.id === paneId;
|
||||
});
|
||||
if (!pane) return false;
|
||||
page.querySelectorAll('[data-aksrt-level-tab]').forEach(function(tab) {
|
||||
var active = tab.getAttribute('data-aksrt-level-tab') === paneId;
|
||||
page.querySelectorAll('[data-jio-level-tab]').forEach(function(tab) {
|
||||
var active = tab.getAttribute('data-jio-level-tab') === paneId;
|
||||
tab.classList.toggle('is-active', active);
|
||||
if (tab.getAttribute('role') === 'tab') tab.setAttribute('aria-selected', active ? 'true' : 'false');
|
||||
});
|
||||
page.querySelectorAll('.aksrt-level-experience .tab-pane').forEach(function(item) {
|
||||
page.querySelectorAll('.jio-level-experience .tab-pane').forEach(function(item) {
|
||||
var active = item === pane;
|
||||
item.classList.toggle('active', active);
|
||||
item.classList.toggle('in', active);
|
||||
@@ -185,7 +185,7 @@
|
||||
|
||||
function loadRevenueTab(queryParams) {
|
||||
var target = document.getElementById('panel-revenue');
|
||||
var restUrl = (window.aksrtData && (window.aksrtData.restUrl || window.aksrtData.apiUrl)) || cfg.restUrl || '';
|
||||
var restUrl = (window.jioData && (window.jioData.restUrl || window.jioData.apiUrl)) || cfg.restUrl || '';
|
||||
if (!target || !restUrl) return Promise.reject(new Error('revenue-panel-unavailable'));
|
||||
var params = queryParams || new URLSearchParams();
|
||||
var url = restUrl.replace(/\/$/, '') + '/user-center/panel/revenue';
|
||||
@@ -197,7 +197,7 @@
|
||||
target.classList.add('is-loading');
|
||||
return fetch(url, {
|
||||
credentials: 'same-origin',
|
||||
headers: { 'X-WP-Nonce': (window.aksrtData && (window.aksrtData.restNonce || window.aksrtData.nonce)) || '' }
|
||||
headers: { 'X-WP-Nonce': (window.jioData && (window.jioData.restNonce || window.jioData.nonce)) || '' }
|
||||
}).then(function(response) {
|
||||
return response.json().then(function(payload) {
|
||||
if (!response.ok || !payload || !payload.success || !payload.data || typeof payload.data.html !== 'string') {
|
||||
@@ -218,8 +218,8 @@
|
||||
return loadPanel(name, forceLoad, queryParams).then(function() {
|
||||
switchTo(name);
|
||||
if (updateHistory) updateUrl(name);
|
||||
if (name === 'revenue' && typeof window.AKSRTAffiliateRevenueInit === 'function') window.AKSRTAffiliateRevenueInit();
|
||||
if (name === 'revenue' && typeof window.AKSRTWithdrawInit === 'function') window.AKSRTWithdrawInit();
|
||||
if (name === 'revenue' && typeof window.JioAffiliateRevenueInit === 'function') window.JioAffiliateRevenueInit();
|
||||
if (name === 'revenue' && typeof window.JioWithdrawInit === 'function') window.JioWithdrawInit();
|
||||
}).catch(function() {
|
||||
notyf(i18n.networkError || '加载失败,请重试', 'danger');
|
||||
});
|
||||
@@ -247,15 +247,15 @@
|
||||
// Delegate every internal user-center link. This also covers markup injected
|
||||
// after a REST panel refresh, so panel navigation never falls back to a full load.
|
||||
document.addEventListener('click', function(e) {
|
||||
var levelTab = e.target && e.target.closest ? e.target.closest('[data-aksrt-level-tab]') : null;
|
||||
var levelTab = e.target && e.target.closest ? e.target.closest('[data-jio-level-tab]') : null;
|
||||
if (levelTab && activateLevelTab(levelTab)) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
return;
|
||||
}
|
||||
var withdrawOpen = e.target && e.target.closest ? e.target.closest('[data-aksrt-withdraw-open]') : null;
|
||||
var withdrawOpen = e.target && e.target.closest ? e.target.closest('[data-jio-withdraw-open]') : null;
|
||||
if (withdrawOpen) {
|
||||
var withdrawModal = document.querySelector('[data-aksrt-withdraw-modal]');
|
||||
var withdrawModal = document.querySelector('[data-jio-withdraw-modal]');
|
||||
if (withdrawModal) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
@@ -265,15 +265,15 @@
|
||||
}
|
||||
return;
|
||||
}
|
||||
var withdrawClose = e.target && e.target.closest ? e.target.closest('[data-aksrt-withdraw-close]') : null;
|
||||
var withdrawClose = e.target && e.target.closest ? e.target.closest('[data-jio-withdraw-close]') : null;
|
||||
if (withdrawClose) {
|
||||
var openWithdrawModal = withdrawClose.closest('[data-aksrt-withdraw-modal]');
|
||||
var openWithdrawModal = withdrawClose.closest('[data-jio-withdraw-modal]');
|
||||
if (openWithdrawModal) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
openWithdrawModal.hidden = true;
|
||||
openWithdrawModal.classList.remove('is-open');
|
||||
if (!document.querySelector('[data-aksrt-withdraw-modal].is-open')) document.body.classList.remove('uc-modal-open');
|
||||
if (!document.querySelector('[data-jio-withdraw-modal].is-open')) document.body.classList.remove('uc-modal-open');
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -294,8 +294,8 @@
|
||||
/* 分页:需要新一页数据,仍走 REST 片段加载。 */
|
||||
loadRevenueTab(url.searchParams).then(function() {
|
||||
if (window.history.replaceState) window.history.replaceState({}, '', '/user/revenue/');
|
||||
if (typeof window.AKSRTAffiliateRevenueInit === 'function') window.AKSRTAffiliateRevenueInit();
|
||||
if (typeof window.AKSRTWithdrawInit === 'function') window.AKSRTWithdrawInit();
|
||||
if (typeof window.JioAffiliateRevenueInit === 'function') window.JioAffiliateRevenueInit();
|
||||
if (typeof window.JioWithdrawInit === 'function') window.JioWithdrawInit();
|
||||
}).catch(function() {
|
||||
notyf(i18n.networkError || '加载失败,请重试', 'danger');
|
||||
});
|
||||
@@ -355,8 +355,8 @@
|
||||
root = root || document;
|
||||
var form = root.id === 'profile-form' ? root : root.querySelector('#profile-form');
|
||||
if (!form) return;
|
||||
if (form.dataset.aksrtProfileInitialized === 'true') return;
|
||||
form.dataset.aksrtProfileInitialized = 'true';
|
||||
if (form.dataset.jioProfileInitialized === 'true') return;
|
||||
form.dataset.jioProfileInitialized = 'true';
|
||||
|
||||
form.addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
@@ -364,7 +364,7 @@
|
||||
if (!btn || btn.disabled) return;
|
||||
btn.disabled = true;
|
||||
btn.textContent = i18n.saving || '保存中…';
|
||||
notyf(i18n.saving || '正在保存资料…', 'load', '', 'aksrt-profile-save-toast');
|
||||
notyf(i18n.saving || '正在保存资料…', 'load', '', 'jio-profile-save-toast');
|
||||
|
||||
var data = new FormData(form);
|
||||
data.set('user_id', String(userId));
|
||||
@@ -375,15 +375,15 @@
|
||||
btn.disabled = false;
|
||||
btn.textContent = i18n.saveBtn || '保存修改';
|
||||
if (res.success) {
|
||||
notyf((res.data && res.data.message) || i18n.saved || '保存成功!', 'success', 5, 'aksrt-profile-save-toast');
|
||||
notyf((res.data && res.data.message) || i18n.saved || '保存成功!', 'success', 5, 'jio-profile-save-toast');
|
||||
} else {
|
||||
notyf((res.data && res.data.message) || i18n.saveFailed || '保存失败', 'danger', 5, 'aksrt-profile-save-toast');
|
||||
notyf((res.data && res.data.message) || i18n.saveFailed || '保存失败', 'danger', 5, 'jio-profile-save-toast');
|
||||
}
|
||||
})
|
||||
.catch(function() {
|
||||
btn.disabled = false;
|
||||
btn.textContent = i18n.saveBtn || '保存修改';
|
||||
notyf(i18n.networkError || '网络错误,请重试', 'danger', 5, 'aksrt-profile-save-toast');
|
||||
notyf(i18n.networkError || '网络错误,请重试', 'danger', 5, 'jio-profile-save-toast');
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -392,8 +392,8 @@
|
||||
|
||||
function initAuthForm() {
|
||||
var root = document.querySelector('[data-identity-root]');
|
||||
if (root && window.AKSRTUserCenterAuth && typeof window.AKSRTUserCenterAuth.init === 'function') {
|
||||
window.AKSRTUserCenterAuth.init(root);
|
||||
if (root && window.JioUserCenterAuth && typeof window.JioUserCenterAuth.init === 'function') {
|
||||
window.JioUserCenterAuth.init(root);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@
|
||||
btn.classList.add('is-loading');
|
||||
|
||||
var body = new URLSearchParams();
|
||||
body.set('action', 'aksrt_toggle_favorite');
|
||||
body.set('action', 'jio_toggle_favorite');
|
||||
body.set('postId', postId);
|
||||
body.set('nonce', publicNonce);
|
||||
body.set('active', '0');
|
||||
@@ -458,15 +458,15 @@
|
||||
}
|
||||
|
||||
function initPostDeletion() {
|
||||
if (document.documentElement.dataset.aksrtPostDeletionBound === 'true') return;
|
||||
document.documentElement.dataset.aksrtPostDeletionBound = 'true';
|
||||
if (document.documentElement.dataset.jioPostDeletionBound === 'true') return;
|
||||
document.documentElement.dataset.jioPostDeletionBound = 'true';
|
||||
document.addEventListener('click', function(e) {
|
||||
var btn = e.target && e.target.closest ? e.target.closest('[data-action="delete-post"]') : null;
|
||||
if (!btn || btn.disabled || !confirm('确定删除这篇文章?')) return;
|
||||
e.preventDefault();
|
||||
btn.disabled = true;
|
||||
var body = new URLSearchParams();
|
||||
body.set('action', 'aksrt_delete_post');
|
||||
body.set('action', 'jio_delete_post');
|
||||
body.set('post_id', btn.getAttribute('data-post-id') || '');
|
||||
body.set('nonce', btn.getAttribute('data-nonce') || submitNonce);
|
||||
fetch(ajaxUrl, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, credentials: 'same-origin', body: body.toString() })
|
||||
@@ -486,15 +486,15 @@
|
||||
|
||||
/* ==================== 通知中心 ==================== */
|
||||
function initNotifications() {
|
||||
var list = document.getElementById('aksrt-notification-list');
|
||||
var markAllBtn = document.getElementById('aksrt-mark-all-notifications-read');
|
||||
var markSelectedBtn = document.getElementById('aksrt-mark-selected-notifications-read');
|
||||
var deleteSelectedBtn = document.getElementById('aksrt-delete-selected-notifications');
|
||||
var list = document.getElementById('jio-notification-list');
|
||||
var markAllBtn = document.getElementById('jio-mark-all-notifications-read');
|
||||
var markSelectedBtn = document.getElementById('jio-mark-selected-notifications-read');
|
||||
var deleteSelectedBtn = document.getElementById('jio-delete-selected-notifications');
|
||||
if (!list) return;
|
||||
|
||||
function markRead(notificationId, markAll) {
|
||||
var body = new URLSearchParams();
|
||||
body.set('action', 'aksrt_mark_notification_read');
|
||||
body.set('action', 'jio_mark_notification_read');
|
||||
body.set('nonce', publicNonce);
|
||||
if (markAll) {
|
||||
body.set('mark_all', '1');
|
||||
@@ -511,7 +511,7 @@
|
||||
|
||||
// 单条标记已读 / 删除
|
||||
list.addEventListener('click', function(e) {
|
||||
var btn = e.target.closest('.aksrt-notification-read-btn');
|
||||
var btn = e.target.closest('.jio-notification-read-btn');
|
||||
if (btn) {
|
||||
var id = btn.getAttribute('data-notification-id');
|
||||
if (!id || btn.disabled) return;
|
||||
@@ -533,14 +533,14 @@
|
||||
return;
|
||||
}
|
||||
|
||||
var delBtn = e.target.closest('.aksrt-notification-delete-btn');
|
||||
var delBtn = e.target.closest('.jio-notification-delete-btn');
|
||||
if (!delBtn) return;
|
||||
var delId = delBtn.getAttribute('data-notification-id');
|
||||
if (!delId || delBtn.disabled) return;
|
||||
if (!confirm(i18n.confirmDeleteNotification || '确定删除这条通知?')) return;
|
||||
delBtn.disabled = true;
|
||||
var body = new URLSearchParams();
|
||||
body.set('action', 'aksrt_delete_notification');
|
||||
body.set('action', 'jio_delete_notification');
|
||||
body.set('nonce', publicNonce);
|
||||
body.set('notification_id', delId);
|
||||
fetch(ajaxUrl, {
|
||||
@@ -573,7 +573,7 @@
|
||||
list.querySelectorAll('[data-notification-id]').forEach(function(row) {
|
||||
row.classList.add('is-read');
|
||||
});
|
||||
list.querySelectorAll('.aksrt-notification-read-btn').forEach(function(b) { b.remove(); });
|
||||
list.querySelectorAll('.jio-notification-read-btn').forEach(function(b) { b.remove(); });
|
||||
notyf(i18n.allMarkedRead || '已全部标记为已读');
|
||||
} else {
|
||||
markAllBtn.disabled = false;
|
||||
@@ -589,7 +589,7 @@
|
||||
// 批量已读
|
||||
if (markSelectedBtn) {
|
||||
markSelectedBtn.addEventListener('click', function() {
|
||||
var checked = Array.prototype.slice.call(list.querySelectorAll('.aksrt-notification-check:checked')).map(function(input) {
|
||||
var checked = Array.prototype.slice.call(list.querySelectorAll('.jio-notification-check:checked')).map(function(input) {
|
||||
return input.value;
|
||||
});
|
||||
if (!checked.length) {
|
||||
@@ -605,7 +605,7 @@
|
||||
checked.forEach(function(id) {
|
||||
var row = list.querySelector('[data-notification-id="' + id + '"]');
|
||||
if (row) row.classList.add('is-read');
|
||||
var b = row ? row.querySelector('.aksrt-notification-read-btn') : null;
|
||||
var b = row ? row.querySelector('.jio-notification-read-btn') : null;
|
||||
if (b) b.remove();
|
||||
});
|
||||
notyf(i18n.selectedMarkedRead || '已标记所选通知为已读');
|
||||
@@ -620,7 +620,7 @@
|
||||
// 批量删除
|
||||
if (deleteSelectedBtn) {
|
||||
deleteSelectedBtn.addEventListener('click', function() {
|
||||
var checked = Array.prototype.slice.call(list.querySelectorAll('.aksrt-notification-check:checked')).map(function(input) {
|
||||
var checked = Array.prototype.slice.call(list.querySelectorAll('.jio-notification-check:checked')).map(function(input) {
|
||||
return input.value;
|
||||
});
|
||||
if (!checked.length) {
|
||||
@@ -630,7 +630,7 @@
|
||||
if (!confirm(i18n.confirmBatchDelete || '确定批量删除所选通知?')) return;
|
||||
deleteSelectedBtn.disabled = true;
|
||||
var body = new FormData();
|
||||
body.append('action', 'aksrt_delete_notifications');
|
||||
body.append('action', 'jio_delete_notifications');
|
||||
body.append('nonce', publicNonce);
|
||||
checked.forEach(function(id) {
|
||||
body.append('notification_ids[]', id);
|
||||
@@ -660,19 +660,19 @@
|
||||
/* ==================== 消息通知偏好 ==================== */
|
||||
function initNotificationPreferences(root) {
|
||||
root = root || document;
|
||||
var form = root.matches && root.matches('[data-aksrt-notification-preferences]')
|
||||
var form = root.matches && root.matches('[data-jio-notification-preferences]')
|
||||
? root
|
||||
: root.querySelector('[data-aksrt-notification-preferences]');
|
||||
if (!form || form.dataset.aksrtInitialized === 'true') return;
|
||||
form.dataset.aksrtInitialized = 'true';
|
||||
: root.querySelector('[data-jio-notification-preferences]');
|
||||
if (!form || form.dataset.jioInitialized === 'true') return;
|
||||
form.dataset.jioInitialized = 'true';
|
||||
|
||||
form.addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
var button = form.querySelector('[type="submit"]');
|
||||
if (!button || button.disabled) return;
|
||||
var toastId = 'aksrt-notification-preferences-toast';
|
||||
var restUrl = (window.aksrtData && (window.aksrtData.restUrl || window.aksrtData.apiUrl)) || cfg.restUrl || '';
|
||||
var nonce = (window.aksrtData && (window.aksrtData.restNonce || window.aksrtData.nonce)) || cfg.restNonce || '';
|
||||
var toastId = 'jio-notification-preferences-toast';
|
||||
var restUrl = (window.jioData && (window.jioData.restUrl || window.jioData.apiUrl)) || cfg.restUrl || '';
|
||||
var nonce = (window.jioData && (window.jioData.restNonce || window.jioData.nonce)) || cfg.restNonce || '';
|
||||
var originalText = button.textContent;
|
||||
var preferences = {};
|
||||
['posts', 'like', 'system'].forEach(function(key) {
|
||||
@@ -715,13 +715,13 @@
|
||||
root = root || document;
|
||||
|
||||
function openSettingsModal(kind) {
|
||||
var runtime = window.AksrtModalRuntime;
|
||||
var template = document.querySelector('template[data-aksrt-settings-modal-template="' + kind + '"]');
|
||||
var runtime = window.JioModalRuntime;
|
||||
var template = document.querySelector('template[data-jio-settings-modal-template="' + kind + '"]');
|
||||
if (!runtime || typeof runtime.open !== 'function' || !template) return;
|
||||
runtime.open({
|
||||
html: template.innerHTML,
|
||||
kind: 'account-settings',
|
||||
className: 'aksrt-user-settings-modal modal-mini full-sm',
|
||||
className: 'jio-user-settings-modal modal-mini full-sm',
|
||||
mobileBottom: true,
|
||||
onContent: function (_, session) {
|
||||
var shell = session && session.shell;
|
||||
@@ -748,8 +748,8 @@
|
||||
|
||||
function resetCountdown(button) {
|
||||
if (!button) return;
|
||||
if (button.__aksrtCountdownTimer) window.clearInterval(button.__aksrtCountdownTimer);
|
||||
button.__aksrtCountdownTimer = null;
|
||||
if (button.__jioCountdownTimer) window.clearInterval(button.__jioCountdownTimer);
|
||||
button.__jioCountdownTimer = null;
|
||||
button.disabled = false;
|
||||
button.classList.remove('is-counting');
|
||||
button.textContent = button.getAttribute('data-idle-label') || '发送验证码';
|
||||
@@ -758,12 +758,12 @@
|
||||
function startCountdown(button, seconds) {
|
||||
var idleText = button.textContent;
|
||||
var left = Number(seconds || 60);
|
||||
if (button.__aksrtCountdownTimer) window.clearInterval(button.__aksrtCountdownTimer);
|
||||
if (button.__jioCountdownTimer) window.clearInterval(button.__jioCountdownTimer);
|
||||
button.disabled = true;
|
||||
button.classList.add('is-counting');
|
||||
button.setAttribute('data-idle-label', idleText);
|
||||
button.textContent = left + 's';
|
||||
button.__aksrtCountdownTimer = window.setInterval(function () {
|
||||
button.__jioCountdownTimer = window.setInterval(function () {
|
||||
left -= 1;
|
||||
if (left <= 0) { resetCountdown(button); return; }
|
||||
button.textContent = left + 's';
|
||||
@@ -771,11 +771,11 @@
|
||||
}
|
||||
|
||||
function settingsRestRoot() {
|
||||
return String((window.aksrtData && (window.aksrtData.restUrl || window.aksrtData.apiUrl)) || cfg.restUrl || '/wp-json/aksrt/v1').replace(/\/$/, '');
|
||||
return String((window.jioData && (window.jioData.restUrl || window.jioData.apiUrl)) || cfg.restUrl || '/wp-json/jio/v1').replace(/\/$/, '');
|
||||
}
|
||||
|
||||
function settingsRestNonce() {
|
||||
return (window.aksrtData && (window.aksrtData.restNonce || window.aksrtData.nonce)) || cfg.restNonce || '';
|
||||
return (window.jioData && (window.jioData.restNonce || window.jioData.nonce)) || cfg.restNonce || '';
|
||||
}
|
||||
|
||||
function formHasRequiredValues(form) {
|
||||
@@ -804,7 +804,7 @@
|
||||
runCaptcha('change_email', form).then(function (captchaPayload) {
|
||||
if (captchaPayload === null) return null;
|
||||
var data = new URLSearchParams();
|
||||
data.set('action', 'aksrt_send_account_email_code');
|
||||
data.set('action', 'jio_send_account_email_code');
|
||||
data.set('_settings_nonce', settingsNonce);
|
||||
data.set('scene', scene);
|
||||
new FormData(form).forEach(function (value, key) { if (value !== '' && !data.has(key)) data.set(key, value); });
|
||||
@@ -829,7 +829,7 @@
|
||||
var dialog = form.closest('[data-account-dialog="phone"]');
|
||||
var boxes = dialog ? phoneDigitBoxes(dialog) : [];
|
||||
if (boxes.length) {
|
||||
var hiddenLength = parseInt(dialog.querySelector('[data-aksrt-phone-digits]').getAttribute('data-hidden-length'), 10) || boxes.length;
|
||||
var hiddenLength = parseInt(dialog.querySelector('[data-jio-phone-digits]').getAttribute('data-hidden-length'), 10) || boxes.length;
|
||||
var middle = phoneDigitsValue(dialog);
|
||||
if (middle.length !== hiddenLength) { notyf('请先补全手机号缺失的数字', 'warning'); return; }
|
||||
payload.middle = middle;
|
||||
@@ -865,7 +865,7 @@
|
||||
function postAjaxForm(form, action, scene, success) {
|
||||
if (!formHasRequiredValues(form)) return;
|
||||
var button = form.querySelector('[type="submit"]');
|
||||
var label = button && button.querySelector('[data-aksrt-settings-submit-label]');
|
||||
var label = button && button.querySelector('[data-jio-settings-submit-label]');
|
||||
var original = label ? label.textContent : '';
|
||||
if (button) { button.disabled = true; setSettingsSubmitLabel(button, i18n.submitting || '提交中...'); }
|
||||
runCaptcha(scene, form).then(function (captchaPayload) {
|
||||
@@ -893,7 +893,7 @@
|
||||
function postPhoneForm(form, endpoint, success) {
|
||||
if (!formHasRequiredValues(form)) return;
|
||||
var button = form.querySelector('[type="submit"]');
|
||||
var label = button && button.querySelector('[data-aksrt-settings-submit-label]');
|
||||
var label = button && button.querySelector('[data-jio-settings-submit-label]');
|
||||
var original = label ? label.textContent : '';
|
||||
runCaptcha('bind_phone', form).then(function (captchaPayload) {
|
||||
if (captchaPayload === null) return null;
|
||||
@@ -918,7 +918,7 @@
|
||||
|
||||
/* ---- 修改手机:脱敏中间位数字框(格数随号码长度变化) ---- */
|
||||
function phoneDigitBoxes(dialog) {
|
||||
return Array.prototype.slice.call(dialog.querySelectorAll('[data-aksrt-phone-digits] .aksrt-phone-digit'));
|
||||
return Array.prototype.slice.call(dialog.querySelectorAll('[data-jio-phone-digits] .jio-phone-digit'));
|
||||
}
|
||||
|
||||
function phoneDigitsValue(dialog) {
|
||||
@@ -926,8 +926,8 @@
|
||||
}
|
||||
|
||||
function setPhoneDigitsError(dialog, message) {
|
||||
var group = dialog.querySelector('[data-aksrt-phone-digits]');
|
||||
var error = dialog.querySelector('[data-aksrt-phone-digits-error]');
|
||||
var group = dialog.querySelector('[data-jio-phone-digits]');
|
||||
var error = dialog.querySelector('[data-jio-phone-digits-error]');
|
||||
if (error) {
|
||||
error.textContent = message || '';
|
||||
error.hidden = !message;
|
||||
@@ -936,11 +936,11 @@
|
||||
}
|
||||
|
||||
function hidePhoneCodeArea(dialog, options) {
|
||||
var area = dialog.querySelector('[data-aksrt-phone-code-area]');
|
||||
var area = dialog.querySelector('[data-jio-phone-code-area]');
|
||||
if (!area) return;
|
||||
var wasVisible = !area.hidden;
|
||||
area.hidden = true;
|
||||
area.querySelectorAll('.account-code-send,[data-aksrt-sms-trigger]').forEach(resetCountdown);
|
||||
area.querySelectorAll('.account-code-send,[data-jio-sms-trigger]').forEach(resetCountdown);
|
||||
if (wasVisible && options && options.destroyCode) {
|
||||
// 中间位被修改:销毁服务端已发放的老号验证码状态。
|
||||
fetch(settingsRestRoot() + '/user/phone-code', {
|
||||
@@ -952,23 +952,23 @@
|
||||
}
|
||||
|
||||
function verifyPhoneMiddle(dialog) {
|
||||
var group = dialog.querySelector('[data-aksrt-phone-digits]');
|
||||
var group = dialog.querySelector('[data-jio-phone-digits]');
|
||||
var boxes = phoneDigitBoxes(dialog);
|
||||
if (!group || !boxes.length) return;
|
||||
var hiddenLength = parseInt(group.getAttribute('data-hidden-length'), 10) || boxes.length;
|
||||
var middle = phoneDigitsValue(dialog);
|
||||
if (middle.length !== hiddenLength) return;
|
||||
|
||||
dialog.__aksrtPhoneMatchTicket = (dialog.__aksrtPhoneMatchTicket || 0) + 1;
|
||||
var ticket = dialog.__aksrtPhoneMatchTicket;
|
||||
dialog.__jioPhoneMatchTicket = (dialog.__jioPhoneMatchTicket || 0) + 1;
|
||||
var ticket = dialog.__jioPhoneMatchTicket;
|
||||
fetch(settingsRestRoot() + '/user/phone-match', {
|
||||
method: 'POST', credentials: 'same-origin',
|
||||
headers: { 'Content-Type': 'application/json', 'X-WP-Nonce': settingsRestNonce() },
|
||||
body: JSON.stringify({ middle: middle })
|
||||
}).then(function (response) { return response.json().then(function (payload) { return { ok: response.ok, payload: payload }; }); }).then(function (result) {
|
||||
if (ticket !== dialog.__aksrtPhoneMatchTicket) return;
|
||||
if (ticket !== dialog.__jioPhoneMatchTicket) return;
|
||||
if (result.ok && result.payload.success) {
|
||||
var area = dialog.querySelector('[data-aksrt-phone-code-area]');
|
||||
var area = dialog.querySelector('[data-jio-phone-code-area]');
|
||||
if (area) area.hidden = false;
|
||||
setPhoneDigitsError(dialog, '');
|
||||
} else {
|
||||
@@ -976,7 +976,7 @@
|
||||
setPhoneDigitsError(dialog, (result.payload && result.payload.message) || '填写的号码与绑定手机号不一致');
|
||||
}
|
||||
}).catch(function () {
|
||||
if (ticket === dialog.__aksrtPhoneMatchTicket) {
|
||||
if (ticket === dialog.__jioPhoneMatchTicket) {
|
||||
hidePhoneCodeArea(dialog, { destroyCode: false });
|
||||
setPhoneDigitsError(dialog, '网络错误,请重试');
|
||||
}
|
||||
@@ -985,8 +985,8 @@
|
||||
|
||||
function initPhoneDigits(dialog) {
|
||||
var boxes = phoneDigitBoxes(dialog);
|
||||
if (!boxes.length || dialog.dataset.aksrtDigitsBound === 'true') return;
|
||||
dialog.dataset.aksrtDigitsBound = 'true';
|
||||
if (!boxes.length || dialog.dataset.jioDigitsBound === 'true') return;
|
||||
dialog.dataset.jioDigitsBound = 'true';
|
||||
|
||||
boxes.forEach(function (input, index) {
|
||||
input.addEventListener('input', function () {
|
||||
@@ -1058,7 +1058,7 @@
|
||||
var confirm = form.querySelector('[name="password_confirm"]');
|
||||
if (password && confirm && password.value !== confirm.value) { notyf('两次密码输入不一致', 'warning'); confirm.focus(); return; }
|
||||
var button = form.querySelector('[type="submit"]');
|
||||
var label = button && button.querySelector('[data-aksrt-settings-submit-label]');
|
||||
var label = button && button.querySelector('[data-jio-settings-submit-label]');
|
||||
var original = label ? label.textContent : '';
|
||||
var dialog = form.closest('[data-account-dialog="password"]');
|
||||
if (button) { button.disabled = true; setSettingsSubmitLabel(button, i18n.submitting || '提交中...'); }
|
||||
@@ -1094,8 +1094,8 @@
|
||||
|
||||
function bindDialog(shell) {
|
||||
var dialog = shell.querySelector('[data-account-dialog]');
|
||||
if (!dialog || dialog.dataset.aksrtBound === 'true') return;
|
||||
dialog.dataset.aksrtBound = 'true';
|
||||
if (!dialog || dialog.dataset.jioBound === 'true') return;
|
||||
dialog.dataset.jioBound = 'true';
|
||||
dialog.querySelectorAll('.toggle-pwd').forEach(function (button) {
|
||||
button.addEventListener('click', function () {
|
||||
var input = dialog.querySelector('#' + button.getAttribute('data-target'));
|
||||
@@ -1118,7 +1118,7 @@
|
||||
var title = dialog.querySelector('[data-account-password-title]');
|
||||
if (title) {
|
||||
title.textContent = title.getAttribute(showRecovery ? 'data-recovery-label' : 'data-change-label') || title.textContent;
|
||||
var shell = dialog.closest('.aksrt-user-settings-modal');
|
||||
var shell = dialog.closest('.jio-user-settings-modal');
|
||||
if (shell) shell.setAttribute('aria-label', title.textContent);
|
||||
}
|
||||
var input = dialog.querySelector(showRecovery ? '#pwd-recovery-target' : '#pwd-old');
|
||||
@@ -1131,7 +1131,7 @@
|
||||
var password = passwordForm.querySelector('[name="password"]');
|
||||
var confirm = passwordForm.querySelector('[name="password2"]');
|
||||
if (password && confirm && password.value !== confirm.value) { notyf('两次密码输入不一致', 'warning'); confirm.focus(); return; }
|
||||
postAjaxForm(passwordForm, 'aksrt_change_password', 'change_password', function () { window.setTimeout(function () { window.location.reload(); }, 700); });
|
||||
postAjaxForm(passwordForm, 'jio_change_password', 'change_password', function () { window.setTimeout(function () { window.location.reload(); }, 700); });
|
||||
});
|
||||
var recoveryForm = dialog.querySelector('#pwd-recovery-form');
|
||||
var recoveryCodeButton = dialog.querySelector('[data-account-recovery-send]');
|
||||
@@ -1145,22 +1145,22 @@
|
||||
var newForm = dialog.querySelector('#email-new-form');
|
||||
if (oldForm) oldForm.addEventListener('submit', function (event) {
|
||||
event.preventDefault();
|
||||
postAjaxForm(oldForm, 'aksrt_verify_account_email', 'change_email', function () { setStep(dialog, 'email-new'); });
|
||||
postAjaxForm(oldForm, 'jio_verify_account_email', 'change_email', function () { setStep(dialog, 'email-new'); });
|
||||
});
|
||||
if (newForm) newForm.addEventListener('submit', function (event) {
|
||||
event.preventDefault();
|
||||
postAjaxForm(newForm, 'aksrt_change_email', 'change_email', function () {
|
||||
postAjaxForm(newForm, 'jio_change_email', 'change_email', function () {
|
||||
if (dialog.querySelector('[data-account-step="email-success"]')) setStep(dialog, 'email-success');
|
||||
window.setTimeout(function () { window.location.reload(); }, 700);
|
||||
});
|
||||
});
|
||||
} else if (type === 'phone') {
|
||||
initPhoneDigits(dialog);
|
||||
dialog.querySelectorAll('[data-aksrt-sms-trigger]').forEach(function (button) {
|
||||
button.addEventListener('click', function () { sendPhoneCode(button, button.closest('form'), button.getAttribute('data-aksrt-sms-scene')); });
|
||||
dialog.querySelectorAll('[data-jio-sms-trigger]').forEach(function (button) {
|
||||
button.addEventListener('click', function () { sendPhoneCode(button, button.closest('form'), button.getAttribute('data-jio-sms-scene')); });
|
||||
});
|
||||
var phoneOldForm = dialog.querySelector('#phone-old-verify-form');
|
||||
var phoneNewForm = dialog.querySelector('#aksrt-bind-phone-form');
|
||||
var phoneNewForm = dialog.querySelector('#jio-bind-phone-form');
|
||||
if (phoneOldForm) phoneOldForm.addEventListener('submit', function (event) {
|
||||
event.preventDefault();
|
||||
postPhoneForm(phoneOldForm, '/user/phone-verify', function () { setStep(dialog, 'phone-new'); });
|
||||
@@ -1176,42 +1176,42 @@
|
||||
}
|
||||
|
||||
function resetSettingsModal(shell) {
|
||||
if (!shell || !shell.classList.contains('aksrt-user-settings-modal')) return;
|
||||
shell.querySelectorAll('.account-code-send,[data-aksrt-sms-trigger],[data-account-recovery-send]').forEach(resetCountdown);
|
||||
if (!shell || !shell.classList.contains('jio-user-settings-modal')) return;
|
||||
shell.querySelectorAll('.account-code-send,[data-jio-sms-trigger],[data-account-recovery-send]').forEach(resetCountdown);
|
||||
shell.querySelectorAll('form').forEach(function (form) { form.reset(); });
|
||||
shell.querySelectorAll('[data-account-dialog="phone"]').forEach(function (dialog) {
|
||||
dialog.querySelectorAll('.aksrt-phone-digit').forEach(function (input) { input.value = ''; });
|
||||
var group = dialog.querySelector('[data-aksrt-phone-digits]');
|
||||
dialog.querySelectorAll('.jio-phone-digit').forEach(function (input) { input.value = ''; });
|
||||
var group = dialog.querySelector('[data-jio-phone-digits]');
|
||||
if (group) group.classList.remove('has-error');
|
||||
var error = dialog.querySelector('[data-aksrt-phone-digits-error]');
|
||||
var error = dialog.querySelector('[data-jio-phone-digits-error]');
|
||||
if (error) { error.hidden = true; error.textContent = ''; }
|
||||
var area = dialog.querySelector('[data-aksrt-phone-code-area]');
|
||||
var area = dialog.querySelector('[data-jio-phone-code-area]');
|
||||
if (area) area.hidden = !!group;
|
||||
});
|
||||
}
|
||||
|
||||
if (document.documentElement.dataset.aksrtSettingsModalCleanupInitialized !== 'true') {
|
||||
document.documentElement.dataset.aksrtSettingsModalCleanupInitialized = 'true';
|
||||
document.addEventListener('aksrt:modal:close', function (event) { resetSettingsModal(event.detail && event.detail.shell); });
|
||||
if (document.documentElement.dataset.jioSettingsModalCleanupInitialized !== 'true') {
|
||||
document.documentElement.dataset.jioSettingsModalCleanupInitialized = 'true';
|
||||
document.addEventListener('jio:modal:close', function (event) { resetSettingsModal(event.detail && event.detail.shell); });
|
||||
}
|
||||
|
||||
root.querySelectorAll('[data-aksrt-settings-modal]').forEach(function (button) {
|
||||
if (button.dataset.aksrtSettingsInitialized === 'true') return;
|
||||
button.dataset.aksrtSettingsInitialized = 'true';
|
||||
button.addEventListener('click', function () { openSettingsModal(button.getAttribute('data-aksrt-settings-modal')); });
|
||||
root.querySelectorAll('[data-jio-settings-modal]').forEach(function (button) {
|
||||
if (button.dataset.jioSettingsInitialized === 'true') return;
|
||||
button.dataset.jioSettingsInitialized = 'true';
|
||||
button.addEventListener('click', function () { openSettingsModal(button.getAttribute('data-jio-settings-modal')); });
|
||||
});
|
||||
root.querySelectorAll('.binding-item--linkable').forEach(function(link) {
|
||||
if (link.dataset.aksrtBindCaptchaInitialized === 'true') return;
|
||||
link.dataset.aksrtBindCaptchaInitialized = 'true';
|
||||
if (link.dataset.jioBindCaptchaInitialized === 'true') return;
|
||||
link.dataset.jioBindCaptchaInitialized = 'true';
|
||||
link.addEventListener('click', function(event) {
|
||||
if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
|
||||
var startUrl = link.getAttribute('data-bind-start-url') || link.getAttribute('href') || '';
|
||||
var provider = link.getAttribute('data-provider') || link.getAttribute('data-bind-provider') || '';
|
||||
var scope = link.closest('[data-aksrt-captcha-scope]') || root;
|
||||
var scope = link.closest('[data-jio-captcha-scope]') || root;
|
||||
if (!startUrl || !captchaAvailable('bind', scope)) return;
|
||||
event.preventDefault();
|
||||
var restUrl = String(cfg.restUrl || (window.aksrtData && (aksrtData.restUrl || aksrtData.apiUrl)) || '').replace(/\/$/, '');
|
||||
var nonce = cfg.restNonce || (window.aksrtData && (aksrtData.restNonce || aksrtData.nonce)) || '';
|
||||
var restUrl = String(cfg.restUrl || (window.jioData && (jioData.restUrl || jioData.apiUrl)) || '').replace(/\/$/, '');
|
||||
var nonce = cfg.restNonce || (window.jioData && (jioData.restNonce || jioData.nonce)) || '';
|
||||
var redirectTo = (cfg.tabUrls && cfg.tabUrls.settings) || window.location.href;
|
||||
if (!restUrl) { window.location.assign(startUrl); return; }
|
||||
link.classList.add('is-loading');
|
||||
@@ -1246,8 +1246,8 @@
|
||||
// 解绑
|
||||
|
||||
root.querySelectorAll('.binding-unbind-btn').forEach(function(b) {
|
||||
if (b.dataset.aksrtSettingsInitialized === 'true') return;
|
||||
b.dataset.aksrtSettingsInitialized = 'true';
|
||||
if (b.dataset.jioSettingsInitialized === 'true') return;
|
||||
b.dataset.jioSettingsInitialized = 'true';
|
||||
b.addEventListener('click', function() {
|
||||
var p = this.getAttribute('data-provider');
|
||||
if (!p) return;
|
||||
@@ -1255,11 +1255,11 @@
|
||||
var self = b;
|
||||
self.disabled = true;
|
||||
self.textContent = i18n.unbinding || '解除中...';
|
||||
var toastId = 'aksrt-settings-oauth-unbind-toast';
|
||||
var toastId = 'jio-settings-oauth-unbind-toast';
|
||||
notyf(i18n.unbinding || '正在解除绑定…', 'load', '', toastId);
|
||||
var unbindNonce = document.getElementById('aksrt-oauth-unbind-nonce');
|
||||
var unbindNonce = document.getElementById('jio-oauth-unbind-nonce');
|
||||
var data = new URLSearchParams();
|
||||
data.set('action', 'aksrt_oauth_unbind');
|
||||
data.set('action', 'jio_oauth_unbind');
|
||||
data.set('nonce', unbindNonce ? unbindNonce.value : '');
|
||||
data.set('provider', p);
|
||||
data.set('userId', String(userId));
|
||||
@@ -1300,12 +1300,12 @@
|
||||
}
|
||||
|
||||
function initSettingsCallbackToast() {
|
||||
if (document.documentElement.dataset.aksrtSettingsCallbackInitialized === 'true') return;
|
||||
if (document.documentElement.dataset.jioSettingsCallbackInitialized === 'true') return;
|
||||
var currentUrl = new URL(window.location.href);
|
||||
var action = currentUrl.searchParams.get('oauth_action');
|
||||
if (['login', 'bind', 'error'].indexOf(action) === -1) return;
|
||||
if (action !== 'bind' && document.documentElement.dataset.aksrtOauthResultHandled === 'true') return;
|
||||
document.documentElement.dataset.aksrtSettingsCallbackInitialized = 'true';
|
||||
if (action !== 'bind' && document.documentElement.dataset.jioOauthResultHandled === 'true') return;
|
||||
document.documentElement.dataset.jioSettingsCallbackInitialized = 'true';
|
||||
|
||||
var provider = currentUrl.searchParams.get('oauth_provider') || '';
|
||||
var providerLabels = {
|
||||
@@ -1353,7 +1353,7 @@
|
||||
}
|
||||
|
||||
|
||||
jQuery(document).off('auto_fun.aksrt-user-center').on('auto_fun.aksrt-user-center', function () {
|
||||
jQuery(document).off('auto_fun.jio-user-center').on('auto_fun.jio-user-center', function () {
|
||||
initDashboardNavigation();
|
||||
initProfileForm();
|
||||
initAuthForm();
|
||||
|
||||
Reference in new issue
Block a user