diff --git a/app/public/static/package_create.js b/app/public/static/package_create.js index 3dbf0ed..243bc02 100644 --- a/app/public/static/package_create.js +++ b/app/public/static/package_create.js @@ -22,7 +22,7 @@ $(function() { function setField(id, value) { if (value && value != "") { - var ele = $(id); + const ele = $(id); ele.val(value); ele.trigger("change"); } diff --git a/app/public/static/package_edit.js b/app/public/static/package_edit.js index dfd9de0..a7d09aa 100644 --- a/app/public/static/package_edit.js +++ b/app/public/static/package_edit.js @@ -11,8 +11,8 @@ $(function() { $("#forums").on('paste', function(e) { try { - var pasteData = e.originalEvent.clipboardData.getData('text') - var url = new URL(pasteData); + const pasteData = e.originalEvent.clipboardData.getData('text'); + const url = new URL(pasteData); if (url.hostname == "forum.minetest.net") { $(this).val(url.searchParams.get("t")); e.preventDefault(); @@ -42,7 +42,7 @@ $(function() { there's no need to use phrases such as \"adds X to the game\".` $("#short_desc").on("change paste keyup", function() { - var val = $(this).val().toLowerCase(); + const val = $(this).val().toLowerCase(); if (val.indexOf("minetest") >= 0 || val.indexOf("mod") >= 0 || val.indexOf("modpack") >= 0 || val.indexOf("mod pack") >= 0) { showHint($(this), hint_mtmods); @@ -54,9 +54,9 @@ $(function() { } }) - var btn = $("#forums").parent().find("label").append("Open"); + const btn = $("#forums").parent().find("label").append("Open"); btn.click(function() { - var id = $("#forums").val(); + const id = $("#forums").val(); if (/^\d+$/.test(id)) { window.open("https://forum.minetest.net/viewtopic.php?t=" + id, "_blank"); } diff --git a/app/public/static/polltask.js b/app/public/static/polltask.js index 8bdd9be..5d7104f 100644 --- a/app/public/static/polltask.js +++ b/app/public/static/polltask.js @@ -19,7 +19,8 @@ function getJSON(url, method) { function pollTask(poll_url, disableTimeout) { return new Promise(function(resolve, reject) { - var tries = 0; + let tries = 0; + function retry() { tries++; if (!disableTimeout && tries > 30) { diff --git a/app/public/static/release_minmax.js b/app/public/static/release_minmax.js index 5e63de3..559adb8 100644 --- a/app/public/static/release_minmax.js +++ b/app/public/static/release_minmax.js @@ -1,11 +1,11 @@ -var min = $("#min_rel"); -var max = $("#max_rel"); -var none = $("#min_rel option:first-child").attr("value"); -var warning = $("#minmax_warning"); +const min = $("#min_rel"); +const max = $("#max_rel"); +const none = $("#min_rel option:first-child").attr("value"); +const warning = $("#minmax_warning"); function ver_check() { - var minv = min.val(); - var maxv = max.val(); + const minv = min.val(); + const maxv = max.val(); if (minv != none && maxv != none && minv > maxv) { warning.show(); diff --git a/app/public/static/tagselector.js b/app/public/static/tagselector.js index 566f88a..916d830 100644 --- a/app/public/static/tagselector.js +++ b/app/public/static/tagselector.js @@ -6,12 +6,12 @@ */ (function($) { function hide_error(input) { - var err = input.parent().parent().find(".invalid-remaining"); + const err = input.parent().parent().find(".invalid-remaining"); err.hide(); } function show_error(input, msg) { - var err = input.parent().parent().find(".invalid-remaining"); + const err = input.parent().parent().find(".invalid-remaining"); console.log(err.length); err.text(msg); err.show(); @@ -19,12 +19,12 @@ $.fn.selectSelector = function(source, select) { return this.each(function() { - var selector = $(this), + const selector = $(this), input = $('input[type=text]', this); selector.click(function() { input.focus(); }) .delegate('.badge a', 'click', function() { - var id = $(this).parent().data("id"); + const id = $(this).parent().data("id"); select.find("option[value=" + id + "]").attr("selected", false) recreate(); }); @@ -55,8 +55,8 @@ } recreate(); - input.focusout(function(e) { - var value = input.val().trim() + input.focusout(function() { + const value = input.val().trim(); if (value != "") { show_error(input, "Please select an existing tag, it;s not possible to add custom ones."); } @@ -102,19 +102,19 @@ $.fn.csvSelector = function(source, name, result, allowSlash) { return this.each(function() { - var selector = $(this), - input = $('input[type=text]', this); + const selector = $(this), + input = $('input[type=text]', this); - var selected = []; - var lookup = {}; - for (var i = 0; i < source.length; i++) { + let selected = []; + const lookup = {}; + for (var i = 0; i < source.length; i++) { lookup[source[i].id] = source[i]; } selector.click(function() { input.focus(); }) .delegate('.badge a', 'click', function() { - var id = $(this).parent().data("id"); - for (var i = 0; i < selected.length; i++) { + const id = $(this).parent().data("id"); + for (let i = 0; i < selected.length; i++) { if (selected[i] == id) { selected.splice(i, 1); } @@ -123,7 +123,7 @@ }); function selectItem(id) { - for (var i = 0; i < selected.length; i++) { + for (let i = 0; i < selected.length; i++) { if (selected[i] == id) { return false; } @@ -133,7 +133,7 @@ } function addTag(id, value) { - var tag = $('') + const tag = $('') .text(value) .data("id", id) .append(' x') @@ -145,8 +145,8 @@ function recreate() { selector.find("span").remove(); - for (var i = 0; i < selected.length; i++) { - var value = lookup[selected[i]] || { value: selected[i] }; + for (let i = 0; i < selected.length; i++) { + const value = lookup[selected[i]] || {value: selected[i]}; addTag(selected[i], value.value); } result.val(selected.join(",")) @@ -154,9 +154,9 @@ function readFromResult() { selected = []; - var selected_raw = result.val().split(","); - for (var i = 0; i < selected_raw.length; i++) { - var raw = selected_raw[i].trim(); + const selected_raw = result.val().split(","); + for (let i = 0; i < selected_raw.length; i++) { + const raw = selected_raw[i].trim(); if (lookup[raw] || raw.match(/^([a-z0-9_]+)$/)) { selected.push(raw); } @@ -169,7 +169,7 @@ result.change(readFromResult); input.focusout(function() { - var item = input.val(); + const item = input.val(); if (item.length == 0) { input.data("ui-autocomplete").search(""); } else if (item.match(/^([a-z0-9_]+)$/)) { @@ -238,17 +238,17 @@ $(function() { $(".multichoice_selector").each(function() { - var ele = $(this); - var sel = ele.parent().find("select"); + const ele = $(this); + const sel = ele.parent().find("select"); sel.hide(); - var options = []; + const options = []; sel.find("option").each(function() { - var text = $(this).text(); + const text = $(this).text(); options.push({ id: $(this).attr("value"), value: text, - selected: $(this).attr("selected") ? true : false, + selected: !!$(this).attr("selected"), toString: function() { return text; }, }); }); @@ -257,13 +257,13 @@ }); $(".metapackage_selector").each(function() { - var input = $(this).parent().children("input[type='text']"); + const input = $(this).parent().children("input[type='text']"); input.hide(); $(this).csvSelector(meta_packages, input.attr("name"), input); }); $(".deps_selector").each(function() { - var input = $(this).parent().children("input[type='text']"); + const input = $(this).parent().children("input[type='text']"); input.hide(); $(this).csvSelector(all_packages, input.attr("name"), input); }); diff --git a/app/public/static/topic_discard.js b/app/public/static/topic_discard.js index efc4272..6e89452 100644 --- a/app/public/static/topic_discard.js +++ b/app/public/static/topic_discard.js @@ -1,7 +1,7 @@ $(".topic-discard").click(function() { - var ele = $(this); - var tid = ele.attr("data-tid"); - var discard = !ele.parent().parent().hasClass("discardtopic"); + const ele = $(this); + const tid = ele.attr("data-tid"); + const discard = !ele.parent().parent().hasClass("discardtopic"); fetch(new Request("/api/topic_discard/?tid=" + tid + "&discard=" + (discard ? "true" : "false"), { method: "post", diff --git a/app/templates/packages/release_bulk_change.html b/app/templates/packages/release_bulk_change.html index 52b8440..b987814 100644 --- a/app/templates/packages/release_bulk_change.html +++ b/app/templates/packages/release_bulk_change.html @@ -45,7 +45,8 @@ {% endblock %} diff --git a/app/templates/users/profile.html b/app/templates/users/profile.html index 64102b9..c42c0ee 100644 --- a/app/templates/users/profile.html +++ b/app/templates/users/profile.html @@ -242,7 +242,7 @@ {% block scriptextra %} {% endblock %}