From 85a76728039bebfcdc6be99d1b71a194e7272748 Mon Sep 17 00:00:00 2001 From: Stuart Langridge Date: Tue, 14 Jun 2016 14:42:46 +0100 Subject: [PATCH] Make lint clean --- sorttable.js | 109 +++++++++++++++++++++++++++------------------------ 1 file changed, 57 insertions(+), 52 deletions(-) diff --git a/sorttable.js b/sorttable.js index ba17e5f..f571270 100644 --- a/sorttable.js +++ b/sorttable.js @@ -15,6 +15,7 @@ This basically means: do what you want with it. */ +/* jshint -W051, -W083, -W027 */ var stIsIE = /*@cc_on!@*/false; @@ -40,7 +41,7 @@ sorttable = { }, makeSortable: function(table) { - if (table.getElementsByTagName('thead').length == 0) { + if (table.getElementsByTagName('thead').length === 0) { // table doesn't have a tHead. Since it should have, create one and // put the first table row in it. the = document.createElement('thead'); @@ -48,7 +49,7 @@ sorttable = { table.insertBefore(the,table.firstChild); } // Safari doesn't support table.tHead, sigh - if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; + if (table.tHead === null) table.tHead = table.getElementsByTagName('thead')[0]; if (table.tHead.rows.length != 1) return; // can't cope with two header rows @@ -63,12 +64,12 @@ sorttable = { } } if (sortbottomrows) { - if (table.tFoot == null) { + if (table.tFoot === null) { // table doesn't have a tfoot. Create one. tfo = document.createElement('tfoot'); table.appendChild(tfo); } - for (var i=0; i6' : ' ▾'; this.appendChild(sortfwdind); - // build an array to sort. This is a Schwartzian transform thing, - // i.e., we "decorate" each row with the actual sort key, - // sort based on the sort keys, and then put the rows back in order - // which is a lot faster because you only do getInnerText once per row - row_array = []; - col = this.sorttable_columnindex; - rows = this.sorttable_tbody.rows; - for (var j=0; j 12) { // definitely dd/mm return sorttable.sort_ddmm; @@ -208,7 +209,7 @@ sorttable = { hasInputs = (typeof node.getElementsByTagName == 'function') && node.getElementsByTagName('input').length; - if (node.nodeType == 1 && node.getAttribute("sorttable_customkey") != null) { + if (node.nodeType == 1 && node.getAttribute("sorttable_customkey") !== null) { return node.getAttribute("sorttable_customkey"); } else if (typeof node.textContent != 'undefined' && !hasInputs) { @@ -226,6 +227,7 @@ sorttable = { if (node.nodeName.toLowerCase() == 'input') { return node.value.replace(/^\s+|\s+$/g, ''); } + break; case 4: return node.nodeValue.replace(/^\s+|\s+$/g, ''); break; @@ -249,7 +251,7 @@ sorttable = { for (var i=0; i=0; i--) { + for (i=newrows.length-1; i>=0; i--) { tbody.appendChild(newrows[i]); } delete newrows; @@ -267,9 +269,11 @@ sorttable = { }, sort_alpha: function(a,b) { return a[0].localeCompare(b[0]); + /* if (a[0]==b[0]) return 0; if (a[0] 0 ) { - var q = list[i]; list[i] = list[i+1]; list[i+1] = q; + q = list[i]; list[i] = list[i+1]; list[i+1] = q; swap = true; } } // for @@ -322,9 +327,9 @@ sorttable = { if (!swap) break; - for(var i = t; i > b; --i) { + for(i = t; i > b; --i) { if ( comp_func(list[i], list[i-1]) < 0 ) { - var q = list[i]; list[i] = list[i-1]; list[i-1] = q; + q = list[i]; list[i] = list[i-1]; list[i-1] = q; swap = true; } } // for @@ -332,7 +337,7 @@ sorttable = { } // while(swap) } -} +}; /* ****************************************************************** Supporting functions: bundled here to avoid depending on a library @@ -396,7 +401,7 @@ function dean_addEvent(element, type, handler) { // assign a global event handler to do all the work element["on" + type] = handleEvent; } -}; +} // a counter used to create unique IDs dean_addEvent.guid = 1; @@ -409,7 +414,7 @@ function removeEvent(element, type, handler) { delete element.events[type][handler.$$guid]; } } -}; +} function handleEvent(event) { var returnValue = true; @@ -425,20 +430,20 @@ function handleEvent(event) { } } return returnValue; -}; +} function fixEvent(event) { // add W3C standard event methods event.preventDefault = fixEvent.preventDefault; event.stopPropagation = fixEvent.stopPropagation; return event; -}; +} fixEvent.preventDefault = function() { this.returnValue = false; }; fixEvent.stopPropagation = function() { this.cancelBubble = true; -} +}; // Dean's forEach: http://dean.edwards.name/base/forEach.js /*