ext.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // noinspection ES6ConvertVarToLetConst,JSUnresolvedVariable
  2. /*
  3. * Copyright 2019-2021 Mamoe Technologies and contributors.
  4. *
  5. * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
  6. * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
  7. *
  8. * https://github.com/mamoe/mirai/blob/dev/LICENSE
  9. */
  10. (function () {
  11. fetch(window.pathToRoot + "../versions.json").then(function (it) {
  12. return it.json()
  13. }).then(function (rsp) {
  14. console.log(rsp);
  15. var dir = document.getElementById("searchBar").parentElement;
  16. var select = document.createElement("select");
  17. dir.insertBefore(select, dir.firstElementChild);
  18. select.appendChild(document.createElement("option")).textContent = "other version";
  19. var toLatest = select.appendChild(document.createElement("option"));
  20. toLatest.textContent = "latest";
  21. toLatest.value = "";
  22. for (var v of rsp) {
  23. var c = select.appendChild(document.createElement("option"));
  24. c.textContent = v;
  25. c.value = v;
  26. }
  27. select.addEventListener("change", function (event) {
  28. location.href = window.pathToRoot + "../" + c.value
  29. })
  30. }).catch(function (error) {
  31. console.log(error);
  32. })
  33. })()