Browse code

do not use 'for-in' construct for enumerating arrays

https://stackoverflow.com/questions/3010840/loop-through-an-array-in-javascript

fixes #1

rwa authored on 05.03.2019 20:56:08
Showing 1 changed files

... ...
@@ -291,7 +291,7 @@ if (document.title != '') {
291 291
 var show_cmt = '';
292 292
 
293 293
 function parse_template(object, sort, method) {
294
-	var indent = (sort == false || method == 'ascending') ? object['indent'] : '16px 0px 12px 0px';
294
+	var indent = (sort == false || method == 'ascending' || method == 'descending' ) ? object['indent'] : '16px 0px 12px 0px';
295 295
 
296 296
 	if (!object['deletion_notice']) {
297 297
 		var 
... ...
@@ -338,7 +338,7 @@ function parse_template(object, sort, method) {
338 338
 function sort_comments(method) {
339 339
 	var methods = {
340 340
 		ascending: function() {
341
-			for (var comment in comments) {
341
+			for (var comment = 0; comment <= (comments.length - 1); comment++) {
342 342
 				parse_template(comments[comment], true, method);
343 343
 			}
344 344
 		},
... ...
@@ -355,7 +355,7 @@ function sort_comments(method) {
355 355
 				if(a.sort_name > b.sort_name) return 1;
356 356
 			})
357 357
 
358
-			for (var comment in tmpSortArray) {
358
+			for (var comment = 0; comment <= (tmpSortArray.length - 1); comment++) {
359 359
 				parse_template(tmpSortArray[comment], true, method);
360 360
 			}
361 361
 		},
... ...
@@ -365,7 +365,7 @@ function sort_comments(method) {
365 365
 				return b.sort_date - a.sort_date;
366 366
 			})
367 367
 
368
-			for (var comment in tmpSortArray) {
368
+			for (var comment = 0; comment <= (tmpSortArray.length - 1); comment++) {
369 369
 				parse_template(tmpSortArray[comment], true, method);
370 370
 			}
371 371
 		},
... ...
@@ -375,7 +375,7 @@ function sort_comments(method) {
375 375
 				return b.sort_likes - a.sort_likes;
376 376
 			})
377 377
 
378
-			for (var comment in tmpSortArray) {
378
+			for (var comment = 0; comment <= (tmpSortArray.length - 1); comment++) {
379 379
 				parse_template(tmpSortArray[comment], true, method);
380 380
 			}
381 381
 		}