Skip to content

Commit cacbf43

Browse files
committed
more jslint fixes
1 parent f0fd953 commit cacbf43

38 files changed

+103
-77
lines changed

functions/array/end.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ function end ( arr ) {
1212
// * example 2: end(['Kevin', 'van', 'Zonneveld']);
1313
// * returns 2: 'Zonneveld'
1414

15-
if (!this.php_js) this.php_js = {};
16-
if (!this.php_js.pointers) this.php_js.pointers = [];
15+
if (!this.php_js) {
16+
this.php_js = {};
17+
}
18+
if (!this.php_js.pointers) {
19+
this.php_js.pointers = [];
20+
}
1721
var pointers = this.php_js.pointers;
1822
if (pointers.indexOf(arr) === -1) {
1923
pointers.push(arr, 0);

functions/array/key.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ function key(arr) {
66
// * example 1: key(array);
77
// * returns 1: 'fruit1'
88

9-
if (!this.php_js) this.php_js = {
10-
pointers:[]
11-
};
9+
if (!this.php_js) {
10+
this.php_js = {};
11+
}
12+
if (!this.php_js.pointers) {
13+
this.php_js.pointers = [];
14+
}
1215
var pointers = this.php_js.pointers;
1316
if (pointers.indexOf(arr) === -1) {
1417
pointers.push(arr, 0);

functions/array/krsort.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ function krsort(array, sort_flags) {
99
// * results 1: data == {3: 'Kevin', 2: 'van', 1: 'Zonneveld'}
1010
// * returns 1: true
1111

12-
var tmp_arr={}, keys=[], sorter, i, key;
12+
var tmp_arr={}, keys=[], sorter, i, key, that=this;
1313

1414
switch (sort_flags) {
1515
case 'SORT_STRING': // compare items as strings
1616
sorter = function (a, b) {
17-
return strnatcmp(b, a);
17+
return that.strnatcmp(b, a);
1818
};
1919
break;
2020
case 'SORT_LOCALE_STRING': // compare items as strings, based on the current locale (set with i18n_loc_set_default() as of PHP6)
@@ -30,10 +30,12 @@ function krsort(array, sort_flags) {
3030
case 'SORT_REGULAR': // compare items normally (don't change types)
3131
default:
3232
sorter = function (a, b) {
33-
if (a < b)
33+
if (a < b) {
3434
return 1;
35-
if (a > b)
35+
}
36+
if (a > b) {
3637
return -1;
38+
}
3739
return 0;
3840
};
3941
break;
@@ -53,7 +55,7 @@ function krsort(array, sort_flags) {
5355
delete array[key];
5456
}
5557
for (i in tmp_arr) {
56-
array[i] = tmp_arr[i]
58+
array[i] = tmp_arr[i];
5759
}
5860

5961
return true;

functions/array/ksort.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ function ksort(array, sort_flags) {
99
// * results 1: data == {1: 'Kevin', 2: 'van', 3: 'Zonneveld'}
1010
// * returns 1: true
1111

12-
var tmp_arr={}, keys=[], sorter, i, key;
12+
var tmp_arr={}, keys=[], sorter, i, key, that=this;
1313

1414
switch (sort_flags) {
1515
case 'SORT_STRING': // compare items as strings
1616
sorter = function (a, b) {
17-
return strnatcmp(a, b);
17+
return that.strnatcmp(a, b);
1818
};
1919
break;
2020
case 'SORT_LOCALE_STRING': // compare items as strings, based on the current locale (set with i18n_loc_set_default() as of PHP6)
@@ -30,10 +30,12 @@ function ksort(array, sort_flags) {
3030
case 'SORT_REGULAR': // compare items normally (don't change types)
3131
default:
3232
sorter = function (a, b) {
33-
if (a > b)
33+
if (a > b) {
3434
return 1;
35-
if (a < b)
35+
}
36+
if (a < b) {
3637
return -1;
38+
}
3739
return 0;
3840
};
3941
break;

functions/classobj/get_class.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ function get_class(obj) {
1515
// * example 6: get_class(function MyFunction() {});
1616
// * returns 6: false
1717

18-
if (obj instanceof Object && !(obj instanceof Array)
19-
&& !(obj instanceof Function) && obj.constructor
20-
&& obj != window) {
18+
if (obj instanceof Object && !(obj instanceof Array) &&
19+
!(obj instanceof Function) && obj.constructor &&
20+
obj != window) {
2121
var arr = obj.constructor.toString().match(/function\s*(\w+)/);
2222

2323
if (arr && arr.length == 2) {

functions/classobj/get_declared_classes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ function get_declared_classes() {
1616
for (i in window) {
1717
try {
1818
if (typeof window[i] === 'function') {
19-
if (!already[i] && class_exists(i)) {
19+
if (!already[i] && this.class_exists(i)) {
2020
already[i] = 1;
2121
arr.push(i);
2222
}
2323
} else if (typeof window[i] === 'object') {
2424
for (j in window[i]) {
25-
if (typeof window[j] === 'function' && window[j] && !already[j] && class_exists(j)) {
25+
if (typeof window[j] === 'function' && window[j] && !already[j] && this.class_exists(j)) {
2626
already[j] = 1;
2727
arr.push(j);
2828
}

functions/datetime/getdate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function getdate(timestamp) {
2222
r['yday'] = Math.floor((d - (new Date(y, 0, 1))) / 86400000);
2323
r['weekday'] = _w[w];
2424
r['month'] = _m[m];
25-
r['0'] = parseInt(d.getTime() / 1000);
25+
r['0'] = parseInt(d.getTime() / 1000, 10);
2626

2727
return r;
2828
}

functions/datetime/gmdate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ function gmdate (format, timestamp) {
88
(typeof(timestamp) == 'number') ? new Date(timestamp*1000) : // UNIX timestamp
99
new Date(timestamp));
1010
timestamp = Date.parse(dt.toUTCString().slice(0, -4))/1000;
11-
return date(format, timestamp);
11+
return this.date(format, timestamp);
1212
}

functions/datetime/gmmktime.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function gmmktime() {
1111
0: function(tt){ return d.setUTCHours(tt); },
1212
1: function(tt){ return d.setUTCMinutes(tt); },
1313
2: function(tt){ var set = d.setUTCSeconds(tt); mb = d.getUTCDate() - dn.getUTCDate(); return set;},
14-
3: function(tt){ var set = d.setUTCMonth(parseInt(tt)-1); ma = d.getUTCFullYear() - dn.getUTCFullYear(); return set;},
14+
3: function(tt){ var set = d.setUTCMonth(parseInt(tt, 10)-1); ma = d.getUTCFullYear() - dn.getUTCFullYear(); return set;},
1515
4: function(tt){ return d.setUTCDate(tt+mb);},
1616
5: function(tt){
1717
if (tt >= 0 && tt <= 69) {
@@ -26,7 +26,7 @@ function gmmktime() {
2626
};
2727

2828
for( i = 0; i < argc; i++ ){
29-
no = parseInt(argv[i]*1);
29+
no = parseInt(argv[i]*1, 10);
3030
if (isNaN(no)) {
3131
return false;
3232
} else {

functions/datetime/gmstrftime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ function gmstrftime (format, timestamp) {
88
(typeof(timestamp) == 'number') ? new Date(timestamp*1000) : // UNIX timestamp
99
new Date(timestamp));
1010
timestamp = Date.parse(dt.toUTCString().slice(0, -4))/1000;
11-
return strftime(format, timestamp);
11+
return this.strftime(format, timestamp);
1212
}

0 commit comments

Comments
 (0)