Browse Source

Update JS get_size function

spaghetti 8 years ago
parent
commit
89a536497f
2 changed files with 6 additions and 27 deletions
  1. 1
    1
      sections/torrents/takeedit.php
  2. 5
    26
      static/functions/script_start.js

+ 1
- 1
sections/torrents/takeedit.php View File

@@ -254,7 +254,7 @@ $DB->query("
254 254
   WHERE ID = $TorrentID");
255 255
   */
256 256
 $DB->query("
257
-  SELECT Media, Container, Codec, Resolution, AudioFormat, Subbing, Language, Description, MediaInfo,  Censored, Archive, Subber
257
+  SELECT Media, Container, Codec, Resolution, AudioFormat, Subbing, Language, Description, MediaInfo, Censored, Archive, Subber
258 258
   FROM torrents
259 259
   WHERE ID = $TorrentID");
260 260
 $DBTorVals = $DB->to_array(false, MYSQLI_ASSOC);

+ 5
- 26
static/functions/script_start.js View File

@@ -83,34 +83,13 @@ function html_entity_decode(str) {
83 83
 }
84 84
 
85 85
 function get_size(size) {
86
-  var steps = 0;
86
+  var steps = 0
87 87
   while (size >= 1024) {
88
-    steps++;
89
-    size = size / 1024;
88
+    steps++
89
+    size = size / 1024
90 90
   }
91
-  var ext;
92
-  switch (steps) {
93
-    case 1: ext = ' B';
94
-        break;
95
-    case 1: ext = ' KB';
96
-        break;
97
-    case 2: ext = ' MB';
98
-        break;
99
-    case 3: ext = ' GB';
100
-        break;
101
-    case 4: ext = ' TB';
102
-        break;
103
-    case 5: ext = ' PB';
104
-        break;
105
-    case 6: ext = ' EB';
106
-        break;
107
-    case 7: ext = ' ZB';
108
-        break;
109
-    case 8: ext = ' EB';
110
-        break;
111
-    default: "0.00 MB";
112
-  }
113
-  return (size.toFixed(2) + ext);
91
+  var exts = ['B','KiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB']
92
+  return (size.toFixed(2) + (exts[steps]||''))
114 93
 }
115 94
 
116 95
 function get_ratio_color(ratio) {

Loading…
Cancel
Save