Size in toolbar
This commit is contained in:
@@ -56,13 +56,12 @@ class DetailsWindow {
|
||||
+ "<tr><td>URL<td><td><a href=\"/u/" + file.id + "\">"+domainURL()+"/u/" + file.id + "</a></td></tr>"
|
||||
+ "<tr><td>Mime Type<td><td>" + escapeHTML(file.mime_type) + "</td></tr>"
|
||||
+ "<tr><td>ID<td><td>" + file.id + "</td></tr>"
|
||||
+ "<tr><td>Size<td><td>" + formatDataVolume(file.size) + "</td></tr>"
|
||||
+ "<tr><td>Bandwidth<td><td>" + formatDataVolume(file.bandwidth_used) + "</td></tr>"
|
||||
+ "<tr><td>Size<td><td>" + formatDataVolume(file.size, 4) + "</td></tr>"
|
||||
+ "<tr><td>Bandwidth<td><td>" + formatDataVolume(file.bandwidth_used, 4) + "</td></tr>"
|
||||
+ "<tr><td>Upload Date<td><td>" + file.date_upload + "</td></tr>"
|
||||
+ "<tr><td>Description<td><td>" + escapeHTML(desc) + "</td></tr>"
|
||||
+ "</table>";
|
||||
|
||||
dw.viewer.toolbar.setStats(file.views, file.bandwidth_used/file.size);
|
||||
if(dw.visible) {
|
||||
dw.updateGraph(file.id);
|
||||
}
|
||||
|
@@ -7,10 +7,11 @@ class Toolbar {
|
||||
// Elements
|
||||
divToolbar = null;
|
||||
divFilePreview = null;
|
||||
downloadFrame = null
|
||||
downloadFrame = null;
|
||||
|
||||
spanViews = null;
|
||||
spanDownloads = null;
|
||||
spanSize = null;
|
||||
|
||||
btnToggleToolbar = null;
|
||||
btnDownload = null;
|
||||
@@ -27,6 +28,7 @@ class Toolbar {
|
||||
t.downloadFrame = document.getElementById("download_frame");
|
||||
t.spanViews = document.getElementById("stat_views");
|
||||
t.spanDownloads = document.getElementById("stat_downloads");
|
||||
t.spanSize = document.getElementById("stat_size");
|
||||
|
||||
t.btnToggleToolbar = document.getElementById("btn_toggle_toolbar");
|
||||
t.btnDownload = document.getElementById("btn_download");
|
||||
@@ -148,9 +150,10 @@ class Toolbar {
|
||||
}, 60000);
|
||||
}
|
||||
|
||||
setStats(views, downloads) {let t = this;
|
||||
t.spanViews.innerText = views
|
||||
t.spanDownloads.innerText = Math.round(downloads*10)/10;
|
||||
setStats(file) {let t = this;
|
||||
t.spanViews.innerText = file.views
|
||||
t.spanDownloads.innerText = Math.round((file.bandwidth_used/file.size)*10)/10;
|
||||
t.spanSize.innerText = formatDataVolume(file.size, 3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,16 +174,3 @@ function loadCaptcha(){
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function formatDataVolume(amt) {
|
||||
if (amt > 1e12) {
|
||||
return Math.round(amt/1e9)/1e3 + " TB";
|
||||
} else if (amt > 1e9) {
|
||||
return Math.round(amt/1e6)/1e3 + " GB";
|
||||
} else if (amt > 1e6) {
|
||||
return Math.round(amt/1e3)/1e3 + " MB";
|
||||
} else if (amt > 1e3) {
|
||||
return Math.round(amt)/1e3 + " kB";
|
||||
}
|
||||
return amt + " B"
|
||||
}
|
||||
|
@@ -73,6 +73,7 @@ class Viewer {
|
||||
|
||||
// Update the file details
|
||||
v.detailsWindow.setDetails(file);
|
||||
v.toolbar.setStats(file);
|
||||
|
||||
// Register a new view. We don't care what this returns becasue we can't
|
||||
// do anything about it anyway
|
||||
|
Reference in New Issue
Block a user