diff --git a/pixelapi/file.go b/pixelapi/file.go index 4e27130..2fd7343 100644 --- a/pixelapi/file.go +++ b/pixelapi/file.go @@ -18,6 +18,7 @@ type FileInfo struct { Name string `json:"name"` Size uint64 `json:"size"` Views int64 `json:"views"` + BandwidthUsed uint64 `json:"bandwidth_used"` DateUpload time.Time `json:"date_upload"` DateLastView time.Time `json:"date_last_view"` MimeType string `json:"mime_type"` diff --git a/pixelapi/list.go b/pixelapi/list.go index 4f2af11..3bb40bb 100644 --- a/pixelapi/list.go +++ b/pixelapi/list.go @@ -19,13 +19,14 @@ type List struct { // ListFile information object from the pixeldrain API type ListFile struct { - ID string `json:"id"` - DetailHREF string `json:"detail_href"` - Name string `json:"name"` - Description string `json:"description"` - DateCreated time.Time `json:"date_created"` - DateLastView time.Time `json:"date_last_view"` - Views int64 `json:"views"` + ID string `json:"id"` + DetailHREF string `json:"detail_href"` + Name string `json:"name"` + Description string `json:"description"` + DateCreated time.Time `json:"date_created"` + DateLastView time.Time `json:"date_last_view"` + Views int64 `json:"views"` + BandwidthUsed uint64 `json:"bandwidth_used"` } // GetList get a List from the pixeldrain API. Errors will be available through diff --git a/res/static/script/ListNavigator.js b/res/static/script/ListNavigator.js index ee02360..583ee9d 100644 --- a/res/static/script/ListNavigator.js +++ b/res/static/script/ListNavigator.js @@ -209,12 +209,6 @@ var ListNavigator = { document.getElementById("button-expand-toolbar").style.top = navHeight+"px"; document.getElementById("sharebar").style.top = navHeight+"px"; document.getElementById("info_popup").style.top = (navHeight+20)+"px"; - // $("#listNavigator").animate( {top: 0}, {"duration": 1500, "queue": false}); - // $("#filepreview").animate( {top: navHeight},{"duration": 1500, "queue": false}); - // $("#toolbar").animate( {top: navHeight},{"duration": 1500, "queue": false}); - // $("#button-expand-toolbar").animate({top: navHeight},{"duration": 1500, "queue": false}); - // $("#sharebar").animate( {top: navHeight},{"duration": 1500, "queue": false}); - // $("#info_popup").css("top", "120px"); }, 200); } }; diff --git a/res/static/script/Toolbar.js b/res/static/script/Toolbar.js index ed2f71d..e6c9dda 100644 --- a/res/static/script/Toolbar.js +++ b/res/static/script/Toolbar.js @@ -55,8 +55,9 @@ var Toolbar = { document.getElementById("btnCopy").classList.remove("button_highlight") }, 60000); }, - setViews: function(amount){ - document.getElementById("views").innerText = "Views: "+amount; + setStats: function(views, downloads){ + document.getElementById("stat_views").innerText = views + document.getElementById("stat_downloads").innerText = Math.round(downloads*10)/10; } }; @@ -127,12 +128,14 @@ var DetailsWindow = { + "Name" + escapeHTML(data.name) + "" + "Url/u/" + data.id + "" + "Mime Type" + escapeHTML(data.mime_type) + "" - + "IS" + data.id + "" + + "ID" + data.id + "" + "Size" + data.size + "" + + "Bandwidth" + data.bandwidth_used + "" + "Upload Date" + data.date_upload + "" + "Description" + escapeHTML(file.description) + "" + "" ); + Toolbar.setStats(data.views, data.bandwidth_used/data.size); } }); } else { @@ -142,9 +145,11 @@ var DetailsWindow = { + "Mime Type" + escapeHTML(file.mime_type) + "" + "ID" + file.id + "" + "Size" + file.size + "" + + "Bandwidth" + file.bandwidth_used + "" + "Upload Date" + file.date_upload + "" + "" ); + Toolbar.setStats(file.views, file.bandwidth_used/file.size); } } }; diff --git a/res/static/script/Viewer.js b/res/static/script/Viewer.js index b77c201..10f7444 100644 --- a/res/static/script/Viewer.js +++ b/res/static/script/Viewer.js @@ -40,7 +40,6 @@ var Viewer = { }); DetailsWindow.setDetails(file); - Toolbar.setViews(file.views); } }; diff --git a/res/static/style/viewer.css b/res/static/style/viewer.css index af30858..ba2fba1 100644 --- a/res/static/style/viewer.css +++ b/res/static/style/viewer.css @@ -148,6 +148,13 @@ body{ vertical-align: 6px; } +.toolbar_label { + text-align: left; + padding-left: 10px; + font-size: 0.8em; + line-height: 0.7em; +} + #sponsors{ position: relative; height: 600px; diff --git a/res/template/file_viewer.html b/res/template/file_viewer.html index 3a6b162..99e1ea1 100644 --- a/res/template/file_viewer.html +++ b/res/template/file_viewer.html @@ -45,7 +45,10 @@
-
Views: No
+
Views
+
N/A
+
Downloads
+
N/A
Back to the Home page diff --git a/res/template/fragments/api/file.html b/res/template/fragments/api/file.html index fb01f68..44435fd 100644 --- a/res/template/fragments/api/file.html +++ b/res/template/fragments/api/file.html @@ -158,6 +158,7 @@ "date_last_view": 1485894987, // Timestamp "size": 5694837, // Bytes "views" 1234, // Amount of unique file views + "bandwidth_used": 1234567890, // Bytes "mime_type" "image/png", "description": "File description", "mime_image": "http://pixeldra.in/res/img/mime/image-png.png", // Image associated with the mime type diff --git a/res/template/fragments/api/list.html b/res/template/fragments/api/list.html index 4156599..ef79f3a 100644 --- a/res/template/fragments/api/list.html +++ b/res/template/fragments/api/list.html @@ -130,7 +130,8 @@ "description": "", "date_created": 1513033304, "date_last_view": 1513033304, - "views": 1 + "views": 1, + "bandwidth_used": 1234567890 }, { "detail_href": "/file/RKwgZb/info", @@ -139,7 +140,8 @@ "description": "", "date_created": 1513033304, "date_last_view": 1513033304, - "views": 2 + "views": 2, + "bandwidth_used": 1234567890 }, { "detail_href": "/file/DRaL_e/info", @@ -148,7 +150,8 @@ "description": "", "date_created": 1513033304, "date_last_view": 1513033304, - "views": 3 + "views": 3, + "bandwidth_used": 1234567890 } ] } diff --git a/webcontroller/file_viewer.go b/webcontroller/file_viewer.go index e4fdd8b..887816e 100644 --- a/webcontroller/file_viewer.go +++ b/webcontroller/file_viewer.go @@ -82,16 +82,17 @@ func (wc *WebController) serveFileViewerDemo(w http.ResponseWriter, r *http.Requ templateData.Other = viewerData{ Type: "file", APIResponse: map[string]interface{}{ - "id": "demo", - "name": "Demo file", - "date_upload": "2017-01-01 12:34:56", - "date_lastview": "2017-01-01 12:34:56", - "size": 123456789, - "views": 1, - "mime_type": "text/demo", - "description": "A file to demonstrate the viewer page", - "mime_image": "/res/img/mime/text.png", - "thumbnail": "/res/img/mime/text.png", + "id": "demo", + "name": "Demo file", + "date_upload": "2017-01-01 12:34:56", + "date_lastview": "2017-01-01 12:34:56", + "size": 123456789, + "views": 1, + "bandwidth_used": 123456789, + "mime_type": "text/demo", + "description": "A file to demonstrate the viewer page", + "mime_image": "/res/img/mime/text.png", + "thumbnail": "/res/img/mime/text.png", }, } err := wc.templates.Get().ExecuteTemplate(w, "file_viewer", templateData)