Remove direct use of jQuery

jQuery is still required by jQuery UI
This commit is contained in:
rubenwardy 2023-08-26 12:34:55 +01:00
parent 9eb03c6a57
commit 2f458ba40e
22 changed files with 233 additions and 191 deletions

@ -6,17 +6,17 @@ toc: False
Please reconsider the choice of WTFPL as a license. Please reconsider the choice of WTFPL as a license.
<script src="/static/libs/jquery.min.js"></script>
<script> <script>
// @author rubenwardy // @author rubenwardy
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later // @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
var params = new URLSearchParams(location.search); var params = new URLSearchParams(location.search);
var r = params.get("r"); var r = params.get("r");
if (r) if (r) {
document.write("<a class='alert_right button' href='" + r + "'>Okay</a>"); document.write("<a class='alert_right button' href='" + r + "'>Okay</a>");
else } else {
$("#warning").hide(); document.getElementById("warning").style.display = "none";
}
</script> </script>
</div> </div>

@ -1,6 +1,8 @@
// @author rubenwardy // @author rubenwardy
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later // @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
"use strict";
function updateOrder() { function updateOrder() {
const elements = [...document.querySelector(".sortable").children]; const elements = [...document.querySelector(".sortable").children];
@ -33,7 +35,9 @@ function restorePackage(id) {
return false; return false;
} }
const card = idElement.parentNode.parentNode; const card = idElement.parentNode.parentNode.parentNode.parentNode;
console.assert(card.classList.contains("card"));
card.classList.remove("d-none"); card.classList.remove("d-none");
card.querySelector("input[name^=package_removed]").value = "0"; card.querySelector("input[name^=package_removed]").value = "0";
card.scrollIntoView(); card.scrollIntoView();
@ -176,7 +180,9 @@ function onPackageQueryUpdate() {
window.addEventListener("load", () => { window.addEventListener("load", () => {
document.querySelectorAll(".remove-package").forEach(button => { document.querySelectorAll(".remove-package").forEach(button => {
const card = button.parentNode.parentNode; const card = button.parentNode.parentNode.parentNode.parentNode;
console.assert(card.classList.contains("card"));
const field = card.querySelector("input[name^=package_removed]"); const field = card.querySelector("input[name^=package_removed]");
// Reloading/validation errors will cause this to be 1 at load // Reloading/validation errors will cause this to be 1 at load
@ -191,6 +197,12 @@ window.addEventListener("load", () => {
addPackageQuery.value = ""; addPackageQuery.value = "";
addPackageQuery.classList.remove("d-none"); addPackageQuery.classList.remove("d-none");
addPackageQuery.addEventListener("input", onPackageQueryUpdate); addPackageQuery.addEventListener("input", onPackageQueryUpdate);
addPackageQuery.addEventListener('keydown',(e)=>{
if (e.key === "Enter") {
onPackageQueryUpdate();
e.preventDefault();
}
})
updateOrder(); updateOrder();
$(".sortable").sortable({ $(".sortable").sortable({

@ -1,7 +1,9 @@
// @author rubenwardy // @author rubenwardy
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later // @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
$("textarea.markdown").each(function() { "use strict";
document.querySelectorAll("textarea.markdown").forEach((element) => {
async function render(plainText, preview) { async function render(plainText, preview) {
const response = await fetch(new Request("/api/markdown/", { const response = await fetch(new Request("/api/markdown/", {
method: "POST", method: "POST",
@ -16,18 +18,8 @@ $("textarea.markdown").each(function() {
} }
let timeout_id = null; let timeout_id = null;
element.easy_mde = new EasyMDE({
function urlInserter(url) { element: element,
return (editor) => {
var cm = editor.codemirror;
var stat = getState(cm);
var options = editor.options;
_replaceSelection(cm, stat.table, `[](${url})`);
};
}
this.easy_mde = new EasyMDE({
element: this,
hideIcons: ["image"], hideIcons: ["image"],
showIcons: ["code", "table"], showIcons: ["code", "table"],
forceSync: true, forceSync: true,
@ -49,20 +41,6 @@ $("textarea.markdown").each(function() {
"fullscreen", "fullscreen",
"|", "|",
"guide", "guide",
// {
// name: "rules",
// className: "fa fa-book",
// title: "others buttons",
// children: [
// {
// name: "rules",
// action: urlInserter("/policy_and_guidance/#2-accepted-content"),
// className: "fa fa-star",
// title: "2. Accepted content",
// text: "2. Accepted content",
// },
// ]
// },
], ],
previewRender: (plainText, preview) => { previewRender: (plainText, preview) => {
if (timeout_id) { if (timeout_id) {
@ -70,7 +48,7 @@ $("textarea.markdown").each(function() {
} }
timeout_id = setTimeout(() => { timeout_id = setTimeout(() => {
render(plainText, preview); render(plainText, preview).catch(console.error);
timeout_id = null; timeout_id = null;
}, 500); }, 500);

@ -3,7 +3,6 @@
"use strict"; "use strict";
const labelColor = "#bbb"; const labelColor = "#bbb";
const annotationColor = "#bbb"; const annotationColor = "#bbb";
const annotationLabelBgColor = "#444"; const annotationLabelBgColor = "#444";
@ -304,4 +303,4 @@ function setup_chart(ctx, data, annotations) {
} }
$(load_data); window.addEventListener("load", load_data);

@ -1,36 +1,47 @@
// @author rubenwardy // @author rubenwardy
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later // @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
$(function() { "use strict";
function hide(sel) {
document.querySelectorAll(sel).forEach(x => x.classList.add("d-none"));
}
function show(sel) {
document.querySelectorAll(sel).forEach(x => x.classList.remove("d-none"));
}
window.addEventListener("load", () => {
function finish() { function finish() {
$(".pkg_wiz_1").hide() hide(".pkg_wiz_1");
$(".pkg_wiz_2").hide() hide(".pkg_wiz_2");
$(".pkg_repo").show() show(".pkg_repo");
$(".pkg_meta").show() show(".pkg_meta");
} }
$(".pkg_meta").hide() hide(".pkg_meta");
$(".pkg_wiz_1").show() show(".pkg_wiz_1");
$("#pkg_wiz_1_skip").click(finish) document.getElementById("pkg_wiz_1_skip").addEventListener("click", finish);
$("#pkg_wiz_1_next").click(function() { document.getElementById("pkg_wiz_1_next").addEventListener("click", () => {
const repoURL = $("#repo").val(); const repoURL = document.getElementById("repo").value;
if (repoURL.trim() != "") { if (repoURL.trim() !== "") {
$(".pkg_wiz_1").hide() hide(".pkg_wiz_1");
$(".pkg_wiz_2").show() show(".pkg_wiz_2");
$(".pkg_repo").hide() hide(".pkg_repo");
function setField(id, value) { function setField(sel, value) {
if (value && value != "") { if (value && value !== "") {
const ele = $(id); const ele = document.querySelector(sel);
ele.val(value); ele.value = value;
ele.trigger("change"); ele.dispatchEvent(new Event("change"));
// EasyMDE doesn't always refresh the codemirror correctly // EasyMDE doesn't always refresh the codemirror correctly
if (ele[0].easy_mde) { if (ele.easy_mde) {
setTimeout(() => { setTimeout(() => {
ele[0].easy_mde.value(value); ele.easy_mde.value(value);
ele[0].easy_mde.codemirror.refresh() ele.easy_mde.codemirror.refresh()
}, 100); }, 100);
} }
} }
@ -45,19 +56,19 @@ $(function() {
setField("#short_desc", result.short_desc); setField("#short_desc", result.short_desc);
setField("#forums", result.forums); setField("#forums", result.forums);
if (result.type && result.type.length > 2) { if (result.type && result.type.length > 2) {
$("#type").val(result.type); setField("[name='type']", result.type);
} }
finish(); finish();
}).catch(function(e) { }).catch(function(e) {
alert(e); alert(e);
$(".pkg_wiz_1").show(); show(".pkg_wiz_1");
$(".pkg_wiz_2").hide(); hide(".pkg_wiz_2");
$(".pkg_repo").show(); show(".pkg_repo");
// finish() // finish()
}); });
} else { } else {
finish() finish();
} }
}) })
}) })

@ -1,20 +1,33 @@
// @author rubenwardy // @author rubenwardy
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later // @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
$(function() { "use strict";
$("#type").change(function() {
$(".not_mod, .not_game, .not_txp").show()
$(".not_" + this.value.toLowerCase()).hide()
})
$(".not_mod, .not_game, .not_txp").show()
$(".not_" + $("#type").val().toLowerCase()).hide()
$("#forums").on('paste', function(e) { function hide(sel) {
document.querySelectorAll(sel).forEach(x => x.classList.add("d-none"));
}
function show(sel) {
document.querySelectorAll(sel).forEach(x => x.classList.remove("d-none"));
}
window.addEventListener("load", () => {
const typeEle = document.getElementById("type");
typeEle.addEventListener("change", () => {
show(".not_mod, .not_game, .not_txp");
hide(".not_" + typeEle.value.toLowerCase());
})
show(".not_mod, .not_game, .not_txp");
hide(".not_" + typeEle.value.toLowerCase());
const forumsField = document.getElementById("forums");
forumsField.addEventListener("paste", function(e) {
try { try {
const pasteData = e.originalEvent.clipboardData.getData('text'); const pasteData = e.clipboardData.getData('text');
const url = new URL(pasteData); const url = new URL(pasteData);
if (url.hostname == "forum.minetest.net") { if (url.hostname === "forum.minetest.net") {
$(this).val(url.searchParams.get("t")); forumsField.value = url.searchParams.get("t");
e.preventDefault(); e.preventDefault();
} }
} catch (e) { } catch (e) {
@ -22,8 +35,9 @@ $(function() {
} }
}); });
$("#forums-button").click(function(e) { const openForums = document.getElementById("forums-button");
window.open("https://forum.minetest.net/viewtopic.php?t=" + $("#forums").val(), "_blank"); openForums.addEventListener("click", () => {
window.open("https://forum.minetest.net/viewtopic.php?t=" + forumsField.value, "_blank");
}); });
let hint = null; let hint = null;
@ -32,9 +46,13 @@ $(function() {
hint.remove(); hint.remove();
} }
hint = ele.parent() hint = document.createElement("div");
.append(`<div class="alert alert-warning my-3">${text}</div>`) hint.classList.add("alert");
.find(".alert"); hint.classList.add("alert-warning");
hint.classList.add("my-1");
hint.innerHTML = text;
ele.parentNode.appendChild(hint);
} }
let hint_mtmods = `Tip: let hint_mtmods = `Tip:
@ -43,26 +61,24 @@ $(function() {
let hint_thegame = `Tip: let hint_thegame = `Tip:
It's obvious that this adds something to Minetest, It's obvious that this adds something to Minetest,
there's no need to use phrases such as \"adds X to the game\".` there's no need to use phrases such as \"adds X to the game\".`;
$("#short_desc").on("change paste keyup", function() { const shortDescField = document.getElementById("short_desc");
const val = $(this).val().toLowerCase();
function handleShortDescChange() {
const val = shortDescField.value.toLowerCase();
if (val.indexOf("minetest") >= 0 || val.indexOf("mod") >= 0 || if (val.indexOf("minetest") >= 0 || val.indexOf("mod") >= 0 ||
val.indexOf("modpack") >= 0 || val.indexOf("mod pack") >= 0) { val.indexOf("modpack") >= 0 || val.indexOf("mod pack") >= 0) {
showHint($(this), hint_mtmods); showHint(shortDescField, hint_mtmods);
} else if (val.indexOf("the game") >= 0) { } else if (val.indexOf("the game") >= 0) {
showHint($(this), hint_thegame); showHint(shortDescField, hint_thegame);
} else if (hint) { } else if (hint) {
hint.remove(); hint.remove();
hint = null; hint = null;
} }
}) }
const btn = $("#forums").parent().find("label").append("<a class='ms-3 btn btn-sm btn-primary'>Open</a>"); shortDescField.addEventListener("change", handleShortDescChange);
btn.click(function() { shortDescField.addEventListener("paste", handleShortDescChange);
const id = $("#forums").val(); shortDescField.addEventListener("keyup", handleShortDescChange);
if (/^\d+$/.test(id)) {
window.open("https://forum.minetest.net/viewtopic.php?t=" + id, "_blank");
}
});
}) })

@ -1,16 +1,18 @@
// @author rubenwardy // @author rubenwardy
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later // @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
"use strict";
function getJSON(url, method) { function getJSON(url, method) {
return new Promise(function(resolve, reject) { return new Promise((resolve, reject) => {
fetch(new Request(url, { fetch(new Request(url, {
method: method || "get", method: method || "get",
credentials: "same-origin", credentials: "same-origin",
headers: { headers: {
"Accept": "application/json", "Accept": "application/json",
}, },
})).then(function(response) { })).then((response) => {
response.text().then(function(txt) { response.text().then((txt) => {
resolve(JSON.parse(txt)) resolve(JSON.parse(txt))
}).catch(reject) }).catch(reject)
}).catch(reject) }).catch(reject)
@ -18,7 +20,7 @@ function getJSON(url, method) {
} }
function pollTask(poll_url, disableTimeout) { function pollTask(poll_url, disableTimeout) {
return new Promise(function(resolve, reject) { return new Promise((resolve, reject) => {
let tries = 0; let tries = 0;
function retry() { function retry() {
@ -32,11 +34,11 @@ function pollTask(poll_url, disableTimeout) {
} }
} }
function step() { function step() {
getJSON(poll_url).then(function(res) { getJSON(poll_url).then((res) => {
if (res.status == "SUCCESS") { if (res.status === "SUCCESS") {
console.log("Got result") console.log("Got result")
resolve(res.result) resolve(res.result)
} else if (res.status == "FAILURE" || res.status == "REVOKED") { } else if (res.status === "FAILURE" || res.status === "REVOKED") {
reject(res.error || "Unknown server error") reject(res.error || "Unknown server error")
} else { } else {
retry() retry()
@ -49,8 +51,8 @@ function pollTask(poll_url, disableTimeout) {
function performTask(url) { function performTask(url) {
return new Promise(function(resolve, reject) { return new Promise((resolve, reject) => {
getJSON(url, "post").then(function(startResult) { getJSON(url, "post").then((startResult) => {
console.log(startResult) console.log(startResult)
if (typeof startResult.poll_url == "string") { if (typeof startResult.poll_url == "string") {
pollTask(startResult.poll_url).then(resolve).catch(reject) pollTask(startResult.poll_url).then(resolve).catch(reject)

@ -0,0 +1,28 @@
// @author rubenwardy
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
"use strict";
window.addEventListener("load", () => {
function setup_toggle(type) {
const toggle = document.getElementById("set_" + type);
function on_change() {
const rel = document.getElementById(type + "_rel");
if (toggle.checked) {
rel.parentElement.style.opacity = "1";
} else {
// $("#" + type + "_rel").attr("disabled", "disabled");
rel.parentElement.style.opacity = "0.4";
rel.value = document.querySelector(`#${type}_rel option:first-child`).value;
rel.dispatchEvent(new Event("change"));
}
}
toggle.addEventListener("change", on_change);
on_change();
}
setup_toggle("min");
setup_toggle("max");
});

@ -1,21 +1,25 @@
// @author rubenwardy // @author rubenwardy
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later // @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
const min = $("#min_rel"); "use strict";
const max = $("#max_rel");
const none = parseInt($("#min_rel option:first-child").attr("value"));
const warning = $("#minmax_warning");
function ver_check() { window.addEventListener("load", () => {
const minv = parseInt(min.val()); const min = document.getElementById("min_rel");
const maxv = parseInt(max.val()); const max = document.getElementById("max_rel");
const none = parseInt(document.querySelector("#min_rel option:first-child").value);
const warning = document.getElementById("minmax_warning");
if (minv != none && maxv != none && minv > maxv) { function ver_check() {
warning.show(); const minv = parseInt(min.value);
} else { const maxv = parseInt(max.value);
warning.hide(); if (minv != none && maxv != none && minv > maxv) {
warning.style.display = "block";
} else {
warning.style.display = "none";
}
} }
}
min.change(ver_check); min.addEventListener("change", ver_check);
max.change(ver_check); max.addEventListener("change", ver_check);
ver_check();
});

@ -0,0 +1,19 @@
// @author rubenwardy
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
"use strict";
window.addEventListener("load", () => {
function check_opt() {
if (document.querySelector("input[name='uploadOpt']:checked").value === "vcs") {
document.getElementById("file_upload").parentElement.classList.add("d-none");
document.getElementById("vcsLabel").parentElement.classList.remove("d-none");
} else {
document.getElementById("file_upload").parentElement.classList.remove("d-none");
document.getElementById("vcsLabel").parentElement.classList.add("d-none");
}
}
document.querySelectorAll("input[name='uploadOpt']").forEach(x => x.addEventListener("change", check_opt));
check_opt();
});

@ -0,0 +1,17 @@
// @author rubenwardy
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
"use strict";
window.addEventListener("load", () => {
function update() {
const elements = [...document.querySelector(".sortable").children];
const ids = elements.map(x => x.dataset.id).filter(x => x);
document.querySelector("input[name='order']").value = ids.join(",");
}
update();
$(".sortable").sortable({
update: update
});
})

@ -3,6 +3,9 @@
* License: MIT * License: MIT
* https://petprojects.googlecode.com/svn/trunk/MIT-LICENSE.txt * https://petprojects.googlecode.com/svn/trunk/MIT-LICENSE.txt
*/ */
"use strict";
(function($) { (function($) {
function make_bold(text) { function make_bold(text) {
const idx = text.indexOf(":"); const idx = text.indexOf(":");

@ -1,10 +1,12 @@
// @author rubenwardy // @author rubenwardy
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later // @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
$(".topic-discard").click(function() { "use strict";
const ele = $(this);
const tid = ele.attr("data-tid"); document.querySelectorAll(".topic-discard").forEach(ele => ele.addEventListener("click", (e) => {
const discard = !ele.parent().parent().hasClass("discardtopic"); const row = ele.parentNode.parentNode;
const tid = ele.getAttribute("data-tid");
const discard = !row.classList.contains("discardtopic");
fetch(new Request("/api/topic_discard/?tid=" + tid + fetch(new Request("/api/topic_discard/?tid=" + tid +
"&discard=" + (discard ? "true" : "false"), { "&discard=" + (discard ? "true" : "false"), {
method: "post", method: "post",
@ -15,18 +17,17 @@ $(".topic-discard").click(function() {
}, },
})).then(function(response) { })).then(function(response) {
response.text().then(function(txt) { response.text().then(function(txt) {
console.log(JSON.parse(txt));
if (JSON.parse(txt).discarded) { if (JSON.parse(txt).discarded) {
ele.parent().parent().addClass("discardtopic"); row.classList.add("discardtopic");
ele.removeClass("btn-danger"); ele.classList.remove("btn-danger");
ele.addClass("btn-success"); ele.classList.add("btn-success");
ele.text("Show"); ele.innerText = "Show";
} else { } else {
ele.parent().parent().removeClass("discardtopic"); row.classList.remove("discardtopic");
ele.removeClass("btn-success"); ele.classList.remove("btn-success");
ele.addClass("btn-danger"); ele.classList.add("btn-danger");
ele.text("Discard"); ele.innerText = "Discard";
} }
}).catch(console.log) }).catch(console.error);
}).catch(console.log) }).catch(console.error);
}); }));

@ -1,6 +1,8 @@
// @author rubenwardy // @author rubenwardy
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later // @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
"use strict";
document.querySelectorAll(".video-embed").forEach(ele => { document.querySelectorAll(".video-embed").forEach(ele => {
try { try {
const href = ele.getAttribute("href"); const href = ele.getAttribute("href");

@ -65,10 +65,6 @@
font-size: 120%; font-size: 120%;
} }
.pkg_wiz_1, .pkg_wiz_2 {
display: none;
}
.plsearchform { .plsearchform {
padding: 0.5em; padding: 0.5em;
} }

@ -276,7 +276,6 @@
{% endif %} {% endif %}
</footer> </footer>
<script src="/static/libs/jquery.min.js?v=2"></script>
<script src="/static/libs/bootstrap.min.js?v=2"></script> <script src="/static/libs/bootstrap.min.js?v=2"></script>
<script src="/static/libs/easymde.min.js"></script> <script src="/static/libs/easymde.min.js"></script>
<link rel="stylesheet" type="text/css" href="/static/libs/easymde.min.css"> <link rel="stylesheet" type="text/css" href="/static/libs/easymde.min.css">

@ -9,6 +9,7 @@
{% endblock %} {% endblock %}
{% block scriptextra %} {% block scriptextra %}
<script src="/static/libs/jquery.min.js?v=2"></script>
<script src="/static/libs/jquery-ui.min.js?v=2"></script> <script src="/static/libs/jquery-ui.min.js?v=2"></script>
<script src="/static/collection_editor.js?v=8"></script> <script src="/static/collection_editor.js?v=8"></script>
{% endblock %} {% endblock %}

@ -70,6 +70,7 @@
{% macro form_scripts() -%} {% macro form_scripts() -%}
<link href="/static/libs/jquery-ui.min.css?v=2" rel="stylesheet" type="text/css"> <link href="/static/libs/jquery-ui.min.css?v=2" rel="stylesheet" type="text/css">
<script src="/static/libs/jquery.min.js?v=2"></script>
<script src="/static/libs/jquery-ui.min.js?v=2"></script> <script src="/static/libs/jquery-ui.min.js?v=2"></script>
<script src="/static/tagselector.js?v=5"></script> <script src="/static/tagselector.js?v=5"></script>
{% endmacro %} {% endmacro %}

@ -88,7 +88,7 @@
<fieldset class="mt-4"> <fieldset class="mt-4">
<legend class="pkg_meta">{{ _("Repository and Links") }}</legend> <legend class="pkg_meta">{{ _("Repository and Links") }}</legend>
<div class="pkg_wiz_1"> <div class="pkg_wiz_1 d-none">
<p>{{ _("Enter the repo URL for the package. <p>{{ _("Enter the repo URL for the package.
If the repo uses git then the metadata will be automatically imported.") }}</p> If the repo uses git then the metadata will be automatically imported.") }}</p>
@ -98,12 +98,12 @@
{{ render_field(form.website, class_="pkg_meta") }} {{ render_field(form.website, class_="pkg_meta") }}
{{ render_field(form.repo, class_="pkg_repo", hint=_("HTTP URL to a Git, Mercurial, or other repository")) }} {{ render_field(form.repo, class_="pkg_repo", hint=_("HTTP URL to a Git, Mercurial, or other repository")) }}
<div class="pkg_wiz_1"> <div class="pkg_wiz_1 d-none">
<a id="pkg_wiz_1_next" class="btn btn-primary">{{ _("Next (Autoimport)") }}</a> <a id="pkg_wiz_1_next" class="btn btn-primary">{{ _("Next (Autoimport)") }}</a>
<a id="pkg_wiz_1_skip" class="btn btn-default">{{ _("Skip Autoimport") }}</a> <a id="pkg_wiz_1_skip" class="btn btn-default">{{ _("Skip Autoimport") }}</a>
</div> </div>
<div class="pkg_wiz_2"> <div class="pkg_wiz_2 d-none">
{{ _("Importing... (This may take a while)") }} {{ _("Importing... (This may take a while)") }}
</div> </div>

@ -42,26 +42,5 @@
{% block scriptextra %} {% block scriptextra %}
<script src="/static/release_minmax.js?v=2"></script> <script src="/static/release_minmax.js?v=2"></script>
<script> <script src="/static/release_bulk_change.js"></script>
function setup_toggle(type) {
const toggle = $("#set_" + type);
function on_change() {
if (toggle.is(":checked")) {
// $("#" + type + "_rel").removeAttr("disabled");
$("#" + type + "_rel").parent().css("opacity", "1");
} else {
// $("#" + type + "_rel").attr("disabled", "disabled");
$("#" + type + "_rel").parent().css("opacity", "0.4");
$("#" + type + "_rel").val($("#" + type + "_rel option:first-child").attr("value"));
$("#" + type + "_rel").change();
}
}
toggle.change(on_change);
on_change();
}
setup_toggle("min");
setup_toggle("max");
</script>
{% endblock %} {% endblock %}

@ -86,22 +86,9 @@
{{ render_submit_field(form.submit) }} {{ render_submit_field(form.submit) }}
</p> </p>
</form> </form>
{% endblock %} {% endblock %}
{% block scriptextra %} {% block scriptextra %}
<script src="/static/release_minmax.js?v=2"></script> <script src="/static/release_minmax.js?v=2"></script>
<script> <script src="/static/release_new.js"></script>
function check_opt() {
if ($("input[name=uploadOpt]:checked").val() == "vcs") {
$("#file_upload").parent().hide();
$("#vcsLabel").parent().show();
} else {
$("#file_upload").parent().show();
$("#vcsLabel").parent().hide();
}
}
$("input[name=uploadOpt]").change(check_opt);
check_opt();
</script>
{% endblock %} {% endblock %}

@ -131,20 +131,7 @@
{% endblock %} {% endblock %}
{% block scriptextra %} {% block scriptextra %}
<script src="/static/libs/jquery.min.js?v=2"></script>
<script src="/static/libs/jquery-ui.min.js?v=2"></script> <script src="/static/libs/jquery-ui.min.js?v=2"></script>
<script> <script src="/static/screenshots_editor.js"></script>
function update() {
const elements = Array.from(document.getElementsByClassName("sortable")[0].children);
const ids = elements.map(x => x.dataset.id).filter(x => x);
$("input[name='order']").val(ids.join(","))
}
update();
$(function() {
$(".sortable").sortable({
update: update
});
});
</script>
{% endblock %} {% endblock %}