UltraRonin commited on
Commit
f372a24
·
1 Parent(s): 3af41a1
Files changed (1) hide show
  1. index.html +25 -23
index.html CHANGED
@@ -268,34 +268,35 @@ tr:hover a {
268
  arrowSpan.textContent = dir === "asc" ? " ▲" : " ▼";
269
 
270
  while (switching) {
271
- switching = false;
272
- const rows = table.rows;
273
- for (let i = 1; i < rows.length - 1; i++) {
274
- let shouldSwitch = false;
275
- let x = rows[i].cells[n].innerHTML;
276
- let y = rows[i + 1].cells[n].innerHTML;
277
 
278
- // 判断是否为数字
279
- let xVal = isNaN(parseFloat(x)) ? x : parseFloat(x);
280
- let yVal = isNaN(parseFloat(y)) ? y : parseFloat(y);
281
 
282
- // 比较逻辑
283
- if (dir === "asc" && xVal > yVal) {
284
- shouldSwitch = true;
285
- } else if (dir === "desc" && xVal < yVal) {
286
- shouldSwitch = true;
287
- }
288
 
289
- if (shouldSwitch) {
290
- rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
291
- switching = true;
292
- switchcount++;
 
293
  }
294
- }
295
 
296
- // 当一次都没有切换时,反转排序方向
297
- if (switchcount === 0) {
298
- dir = dir === "asc" ? "desc" : "asc";
 
299
  }
300
  }
301
 
@@ -350,6 +351,7 @@ tr:hover a {
350
  // }
351
  // }
352
 
 
353
  Object.keys(urls).forEach(key => {
354
  fetch(urls[key])
355
  .then(response => response.json())
 
268
  arrowSpan.textContent = dir === "asc" ? " ▲" : " ▼";
269
 
270
  while (switching) {
271
+ switching = false;
272
+ const rows = table.rows;
273
+ for (let i = 1; i < rows.length - 1; i++) {
274
+ let shouldSwitch = false;
275
+ let x = rows[i].cells[n].innerHTML;
276
+ let y = rows[i + 1].cells[n].innerHTML;
277
 
278
+ // 判断是否为数字
279
+ let xVal = isNaN(parseFloat(x)) ? x : parseFloat(x);
280
+ let yVal = isNaN(parseFloat(y)) ? y : parseFloat(y);
281
 
282
+ // 比较逻辑
283
+ if (dir === "asc" && xVal > yVal) {
284
+ shouldSwitch = true;
285
+ } else if (dir === "desc" && xVal < yVal) {
286
+ shouldSwitch = true;
287
+ }
288
 
289
+ if (shouldSwitch) {
290
+ rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
291
+ switching = true;
292
+ switchcount++;
293
+ }
294
  }
 
295
 
296
+ // 当一次都没有切换时,反转排序方向
297
+ if (switchcount === 0) {
298
+ dir = dir === "asc" ? "desc" : "asc";
299
+ }
300
  }
301
  }
302
 
 
351
  // }
352
  // }
353
 
354
+
355
  Object.keys(urls).forEach(key => {
356
  fetch(urls[key])
357
  .then(response => response.json())