Commit 0b3357f8 authored by Jonny Bradley's avatar Jonny Bradley

[FIX] JSLint: Part 2 of JSLint* corrections: tiki-js.js & tiki-js-sortable.js...

[FIX] JSLint: Part 2 of JSLint* corrections: tiki-js.js & tiki-js-sortable.js - mostly missing line terminations and var declarations (*actually phpStorm code inspections)
parent cc347a84
......@@ -37,7 +37,7 @@ function ts_makeSortable(table) {
function ts_getInnerText(el) {
if (typeof el == "string") return el;
if (typeof el == "undefined") { return el };
if (typeof el == "undefined") { return el }
if (el.innerText) return el.innerText; //Not needed but it is faster
var str = "";
......@@ -70,16 +70,16 @@ function ts_resortTable(lnk) {
// Work out a type for the column
if (table.rows.length <= 1) return;
var itm = ts_getInnerText(table.rows[1].cells[column]);
sortfn = ts_sort_caseinsensitive;
var sortfn = ts_sort_caseinsensitive;
if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d\d\d$/)) sortfn = ts_sort_date;
if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d$/)) sortfn = ts_sort_date;
if (itm.match(/^[$]/)) sortfn = ts_sort_currency;
if (itm.match(/^[\d\.]+$/)) sortfn = ts_sort_numeric;
SORT_COLUMN_INDEX = column;
var firstRow = new Array();
var newRows = new Array();
for (i=0;i<table.rows[0].length;i++) { firstRow[i] = table.rows[0][i]; }
for (j=1;j<table.rows.length;j++) { newRows[j-1] = table.rows[j]; }
var firstRow = [];
var newRows = [], ARROW;
for (var i=0;i<table.rows[0].length;i++) { firstRow[i] = table.rows[0][i]; }
for (var j=1;j<table.rows.length;j++) { newRows[j-1] = table.rows[j]; }
newRows.sort(sortfn);
......@@ -100,7 +100,7 @@ function ts_resortTable(lnk) {
// Delete any other arrows there may be showing
var allspans = document.getElementsByTagName("span");
for (var ci=0;ci<allspans.length;ci++) {
for (ci=0;ci<allspans.length;ci++) {
if (allspans[ci].className == 'sortarrow') {
if (getParent(allspans[ci],"table") == getParent(lnk,"table")) { // in the same table as us?
allspans[ci].innerHTML = '&nbsp;&nbsp;&nbsp;';
......@@ -120,8 +120,8 @@ function getParent(el, pTagName) {
}
function ts_sort_date(a,b) {
// y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX
aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
var aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
var bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]), dt1, dt2, yr;
if (aa.length == 10) {
dt1 = aa.substr(6,4)+aa.substr(3,2)+aa.substr(0,2);
} else {
......@@ -142,30 +142,30 @@ function ts_sort_date(a,b) {
}
function ts_sort_currency(a,b) {
aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,'');
bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,'');
var aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g, '');
var bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g, '');
return parseFloat(aa) - parseFloat(bb);
}
function ts_sort_numeric(a,b) {
aa = parseFloat(ts_getInnerText(a.cells[SORT_COLUMN_INDEX]));
var aa = parseFloat(ts_getInnerText(a.cells[SORT_COLUMN_INDEX]));
if (isNaN(aa)) aa = 0;
bb = parseFloat(ts_getInnerText(b.cells[SORT_COLUMN_INDEX]));
var bb = parseFloat(ts_getInnerText(b.cells[SORT_COLUMN_INDEX]));
if (isNaN(bb)) bb = 0;
return aa-bb;
}
function ts_sort_caseinsensitive(a,b) {
aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase();
bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase();
var aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase();
var bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase();
if (aa==bb) return 0;
if (aa<bb) return -1;
return 1;
}
function ts_sort_default(a,b) {
aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
var aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
var bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
if (aa==bb) return 0;
if (aa<bb) return -1;
return 1;
......
......@@ -693,7 +693,7 @@ function setheadingstate(foo) {
collapseSign("flipper" + foo);
} else /* if (status == "c") */ {
if (document.getElementById(foo) !== null) {
if (!document.getElementById(foo).style.display == "none") {
if (document.getElementById(foo).style.display != "none") {
hide(foo);
expandSign("flipper" + foo);
}
......@@ -1968,7 +1968,7 @@ function adjustRating(element, data) {
var $sibs, $help;
if ($(element).text() == "x") { // unvote
$sibs = $("span > a", $(element).parent())
$sibs = $("span > a", $(element).parent());
$help = $(element).prev().prev();
} else {
$sibs = $(element).siblings().addBack();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment