Initial AD port
This commit is contained in:
57
themes/after-dark/docs/assets/js/config-generator.js
Normal file
57
themes/after-dark/docs/assets/js/config-generator.js
Normal file
@@ -0,0 +1,57 @@
|
||||
/*!
|
||||
* Copyright (C) 2019 Josh Habdas <jhabdas@protonmail.com>
|
||||
*
|
||||
* This file is part of After Dark.
|
||||
*
|
||||
* After Dark is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* After Dark is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
(function (window, document, undefined) {
|
||||
'use strict';
|
||||
const form = document.forms.generator;
|
||||
form.reset();
|
||||
const isOnlineHelp = document.URL.includes('localhost:1414');
|
||||
if (!isOnlineHelp) return;
|
||||
form.querySelector('.js-useonlinehelp').style.display = 'none';
|
||||
if (window.navigator.onLine) {
|
||||
form.querySelector('.js-disconnect').style.display = 'block';
|
||||
}
|
||||
const activate = () => {
|
||||
form.querySelector('.js-disconnect').style.display = 'block';
|
||||
form.generate.disabled = true;
|
||||
form.address.disabled = true;
|
||||
form.address.value = '';
|
||||
form.generate.classList.add('muted');
|
||||
};
|
||||
const deactivate = () => {
|
||||
form.querySelector('.js-disconnect').style.display = 'none';
|
||||
form.generate.disabled = false;
|
||||
form.address.disabled = false;
|
||||
form.generate.classList.remove('muted');
|
||||
};
|
||||
window.addEventListener('online', activate);
|
||||
window.addEventListener('offline', deactivate);
|
||||
if (!window.navigator.onLine) deactivate();
|
||||
form.addEventListener('submit', evt => {
|
||||
evt.preventDefault();
|
||||
const isLocal = document.location.host.includes('localhost');
|
||||
const hasSameOrigin = form.action.includes(document.location.origin);
|
||||
if (isLocal && hasSameOrigin) {
|
||||
evt.target.submit();
|
||||
} else {
|
||||
form.querySelector('.js-usesameorigin').style.display = 'block';
|
||||
deactivate();
|
||||
}
|
||||
})
|
||||
})(window, document);
|
||||
51
themes/after-dark/docs/assets/js/configuration.js
Normal file
51
themes/after-dark/docs/assets/js/configuration.js
Normal file
@@ -0,0 +1,51 @@
|
||||
/*!
|
||||
* Copyright (C) 2019 Josh Habdas <jhabdas@protonmail.com>
|
||||
*
|
||||
* This file is part of After Dark.
|
||||
*
|
||||
* After Dark is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* After Dark is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
(function (window, document, undefined) {
|
||||
'use strict';
|
||||
const isOnlineHelp = document.URL.includes('localhost:1414');
|
||||
if (!isOnlineHelp) return;
|
||||
if (!document.location.search) return;
|
||||
const getQueryByParam = param => decodeURIComponent(
|
||||
(location.search.split(param + '=')[1] || '').split('&')[0]
|
||||
).replace(/\+/g, ' ');
|
||||
const set = (from, to) => {
|
||||
document.body.innerHTML = document.body.innerHTML.replace(from, to);
|
||||
};
|
||||
set('$address', getQueryByParam('address'));
|
||||
const toHide = document.querySelectorAll('.js-tohide');
|
||||
const toShow = document.querySelectorAll('.js-toshow');
|
||||
toHide.forEach(el => el.style.display = 'none');
|
||||
toShow.forEach(el => el.style.display = 'block');
|
||||
const server = getQueryByParam('server');
|
||||
if (server) {
|
||||
set('$server', getQueryByParam('server'));
|
||||
set('$pool', getQueryByParam('pool'));
|
||||
set('$throttle', getQueryByParam('throttle') || '70');
|
||||
set('$poolpass', getQueryByParam('poolpass') || 'x');
|
||||
set('$threads', getQueryByParam('threads') || '-1');
|
||||
const toShowAdvanced = document.querySelectorAll('.js-showadvanced');
|
||||
const toHideAdvanced = document.querySelectorAll('.js-hideadvanced');
|
||||
toShowAdvanced.forEach(el => el.style.display = 'block');
|
||||
toHideAdvanced.forEach(el => el.style.display = 'none');
|
||||
}
|
||||
window.history.replaceState(
|
||||
{}, null, `${window.location.origin}${window.location.pathname}`
|
||||
);
|
||||
})(window, document);
|
||||
Reference in New Issue
Block a user