diff --git a/static/script.js b/static/script.js index 336bfff..f08aa8d 100644 --- a/static/script.js +++ b/static/script.js @@ -1,3 +1,22 @@ +Array.prototype.stableSort = function(cmp) { + cmp = !!cmp ? cmp : (a, b) => { + if (a < b) return -1; + if (a > b) return 1; + return 0; + }; + let stabilizedThis = this.map((el, index) => [el, index]); + let stableCmp = (a, b) => { + let order = cmp(a[0], b[0]); + if (order != 0) return order; + return a[1] - b[1]; + } + stabilizedThis.sort(stableCmp); + for (let i=0; i bValue) return 1; + return 0; +} +function orderStringSorter(a,b) { + var aValue=a.children[1].innerHTML.substring(0,3); + var bValue=b.children[1].innerHTML.substring(0,3); + if ( aValue == "[x]" && bValue == "[ ]" ) return 1; + if ( aValue == "[ ]" && bValue == "[x]" ) return -1; + return 0; +} + diff --git a/templates/show_shop.html b/templates/show_shop.html index 83e733d..b42f0fa 100644 --- a/templates/show_shop.html +++ b/templates/show_shop.html @@ -52,9 +52,9 @@
{% if autosort %} - + {% else %} - + {% endif %}
@@ -99,6 +99,6 @@
{% if autosort %} - + {% endif %} {% endblock %}