This commit is contained in:
GordonDaFreeman 2018-01-17 14:56:44 +01:00
parent 8ac7c29b2d
commit 399c6749c8
1 changed files with 39 additions and 0 deletions

View File

@ -47,6 +47,8 @@ function loadHTML() {
console.log(id + " allready exists!") console.log(id + " allready exists!")
return return
} }
$("#tocraft") $("#tocraft")
.append( .append(
@ -71,6 +73,11 @@ function loadHTML() {
}); });
$("#" + tagid).val(1) $("#" + tagid).val(1)
}) })
$("#menu li ul").each(function(){
$(this).html($(this).children('li').sort(function(a, b){
return ($(b).data('position')) < ($(a).data('position')) ? 1 : -1;
}));
});
} }
function loadJSON(itemname) { function loadJSON(itemname) {
@ -125,6 +132,8 @@ $(document)
+ " allready exists!") + " allready exists!")
return return
} }
$("#tocraft") $("#tocraft")
.append( .append(
@ -255,3 +264,33 @@ function updateoutput() {
} }
}) })
} }
function sortUnorderedList(ul, sortDescending) {
if (typeof ul == "string")
ul = document.getElementById(ul);
// Idiot-proof, remove if you want
if (!ul) {
alert("The UL object is null!");
return;
}
// Get the list items and setup an array for sorting
var lis = ul.getElementsByTagName("LI");
var vals = [];
// Populate the array
for (var i = 0, l = lis.length; i < l; i++)
vals.push(lis[i].innerHTML);
// Sort it
vals.sort();
// Sometimes you gotta DESC
if (sortDescending)
vals.reverse();
// Change the list on the page
for (var i = 0, l = lis.length; i < l; i++)
lis[i].innerHTML = vals[i];
}