Update index.js

This commit is contained in:
uparrows 2020-11-09 21:47:12 +08:00 committed by GitHub
parent 3a1700aacf
commit 643b6fa2f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -231,7 +231,7 @@ function loadCategories() {
//If more than 10 categories, the rest goes into a dropdown
if (data.length > 10) {
html += `<select class="favtag-btn">
html += `<select id="catdropdown" class="favtag-btn">
<option selected disabled>...</option>`;
for (var i = 10; i < data.length; i++) {
@ -239,7 +239,7 @@ function loadCategories() {
category = data[i];
catName = encode(category.name);
html += `<option id='${category.id}' onclick='toggleCategory(this)'>
html += `<option id='${category.id}'>
${catName}
</option>`;
@ -249,6 +249,9 @@ function loadCategories() {
$("#category-container").html(html);
// Add a listener on dropdown selection
$("#catdropdown").on("change", () => toggleCategory($("#catdropdown")[0].selectedOptions[0]));
}).fail(data => showErrorToast("Couldn't load categories", data.error));
}
@ -259,4 +262,4 @@ function encode(r) {
return r[0].replace(/[\x26\x0A\<>'"]/g, function (r) { return "&#" + r.charCodeAt(0) + ";" });
else
return r.replace(/[\x26\x0A\<>'"]/g, function (r) { return "&#" + r.charCodeAt(0) + ";" })
}
}