You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
2.2 KiB

4 years ago
  1. /*!
  2. * Copyright (C) 2019 Josh Habdas <jhabdas@protonmail.com>
  3. *
  4. * This file is part of After Dark.
  5. *
  6. * After Dark is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published
  8. * by the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * After Dark is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. (function (window, document, undefined) {
  20. 'use strict';
  21. const isOnlineHelp = document.URL.includes('localhost:1414');
  22. if (!isOnlineHelp) return;
  23. if (!document.location.search) return;
  24. const getQueryByParam = param => decodeURIComponent(
  25. (location.search.split(param + '=')[1] || '').split('&')[0]
  26. ).replace(/\+/g, ' ');
  27. const set = (from, to) => {
  28. document.body.innerHTML = document.body.innerHTML.replace(from, to);
  29. };
  30. set('$address', getQueryByParam('address'));
  31. const toHide = document.querySelectorAll('.js-tohide');
  32. const toShow = document.querySelectorAll('.js-toshow');
  33. toHide.forEach(el => el.style.display = 'none');
  34. toShow.forEach(el => el.style.display = 'block');
  35. const server = getQueryByParam('server');
  36. if (server) {
  37. set('$server', getQueryByParam('server'));
  38. set('$pool', getQueryByParam('pool'));
  39. set('$throttle', getQueryByParam('throttle') || '70');
  40. set('$poolpass', getQueryByParam('poolpass') || 'x');
  41. set('$threads', getQueryByParam('threads') || '-1');
  42. const toShowAdvanced = document.querySelectorAll('.js-showadvanced');
  43. const toHideAdvanced = document.querySelectorAll('.js-hideadvanced');
  44. toShowAdvanced.forEach(el => el.style.display = 'block');
  45. toHideAdvanced.forEach(el => el.style.display = 'none');
  46. }
  47. window.history.replaceState(
  48. {}, null, `${window.location.origin}${window.location.pathname}`
  49. );
  50. })(window, document);