add viewer scripts
This commit is contained in:
1 parent
129d6915d2
commit
10cbc809ad
22 files changed
+1064
-934
No files matched your search
+3
-8
@@ -19,14 +19,9 @@ 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"`
|
||||
BandwidthUsed uint64 `json:"bandwidth_used"`
|
||||
DetailHREF string `json:"detail_href"`
|
||||
Description string `json:"description"`
|
||||
FileInfo `json:""`
|
||||
}
|
||||
|
||||
// GetList get a List from the pixeldrain API. Errors will be available through
|
||||
|
||||
@@ -1,182 +0,0 @@
|
||||
/* global Viewer */
|
||||
|
||||
var ListNavigator = {
|
||||
length: 0,
|
||||
position: 0,
|
||||
data: [],
|
||||
history: [],
|
||||
shuffle: false,
|
||||
|
||||
nextItem: function(){
|
||||
if(!Viewer.isList){
|
||||
return;
|
||||
}
|
||||
if(this.shuffle){
|
||||
this.randItem();
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.position >= this.length){
|
||||
this.position = 0;
|
||||
}else{
|
||||
this.position++;
|
||||
}
|
||||
|
||||
this.setItem(this.position);
|
||||
},
|
||||
|
||||
previousItem: function(){
|
||||
if(!Viewer.isList){
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.position === 0){
|
||||
this.position = this.length - 1;
|
||||
}else{
|
||||
this.position--;
|
||||
}
|
||||
|
||||
this.setItem(this.position);
|
||||
},
|
||||
|
||||
randItem: function(){
|
||||
if(!Viewer.isList){
|
||||
return;
|
||||
}
|
||||
|
||||
// Avoid viewing the same file multiple times
|
||||
var rand;
|
||||
do {
|
||||
rand = Math.round(Math.random() * this.length);
|
||||
console.log("rand is " + rand);
|
||||
} while(this.inHistory(rand));
|
||||
|
||||
this.setItem(rand);
|
||||
},
|
||||
|
||||
setItem: function(index){
|
||||
if(index >= this.length){
|
||||
this.position = 0;
|
||||
}else{
|
||||
this.position = index;
|
||||
}
|
||||
|
||||
// Set the URL hash
|
||||
location.hash = "item=" + this.position;
|
||||
Viewer.setFile(this.data[this.position]);
|
||||
|
||||
this.addToHistory(index);
|
||||
|
||||
$("#list_navigator").find("*").removeClass("file_button_selected");
|
||||
var selectedItem = $("#list_navigator div").eq(this.position);
|
||||
selectedItem.addClass("file_button_selected");
|
||||
var itemWidth = selectedItem.outerWidth(true);
|
||||
|
||||
// This centers the scroll bar exactly on the selected item
|
||||
$("#list_navigator").animate(
|
||||
{scrollLeft: ((this.position * itemWidth) + (itemWidth / 2)) - ($("#list_navigator").width() / 2)},
|
||||
{duration: 1000, queue: false}
|
||||
);
|
||||
|
||||
this.loadThumbnails(index);
|
||||
},
|
||||
|
||||
addToHistory: function(index){
|
||||
if(this.history.length >= (this.length - 6)){
|
||||
this.history.shift();
|
||||
}
|
||||
|
||||
this.history.push(index);
|
||||
},
|
||||
|
||||
inHistory: function(index){
|
||||
var i = $.inArray(index, this.history); // Returns -1 when the item is not found
|
||||
|
||||
return (i !== -1); // Return false when it's not in the array
|
||||
},
|
||||
|
||||
toggleShuffle: function(){
|
||||
this.shuffle = !this.shuffle; // :P
|
||||
|
||||
if(this.shuffle){
|
||||
$("#btnShuffle > span").html("Shuffle ☑"); // Check icon
|
||||
$("#btnShuffle").addClass("button_highlight");
|
||||
}else{
|
||||
$("#btnShuffle > span").html("Shuffle ☐"); // Empty checkbox
|
||||
$("#btnShuffle").removeClass("button_highlight");
|
||||
}
|
||||
},
|
||||
|
||||
loadThumbnails: function(index){
|
||||
var startPos = +index - 50;
|
||||
var endPos = +index + 50;
|
||||
// fyi, the + is to let javascript know it's actually a number instead of a string
|
||||
|
||||
if(startPos < 0){
|
||||
startPos = 0;
|
||||
}
|
||||
|
||||
if(endPos >= this.length){
|
||||
endPos = this.length - 1;
|
||||
}
|
||||
console.log(endPos);
|
||||
|
||||
var navigatorItems = document.getElementById("list_navigator").children
|
||||
|
||||
for (i = startPos; i <= endPos; i++){
|
||||
if (navigatorItems[i].innerHTML.includes("list_item_thumbnail")) {
|
||||
continue; // Thumbnail already loaded
|
||||
}
|
||||
|
||||
var thumb = "/api/file/" + this.data[i].id + "/thumbnail?width=48&height=48";
|
||||
var name = this.data[i].name;
|
||||
|
||||
var itemHtml = "<img src=\"" + thumb + "\" "
|
||||
+ "class=\"list_item_thumbnail\" alt=\"" + escapeHTML(name) + "\"/>"
|
||||
+ escapeHTML(name);
|
||||
|
||||
navigatorItems[i].innerHTML = itemHtml;
|
||||
}
|
||||
},
|
||||
|
||||
init: function(data){
|
||||
this.data = data;
|
||||
this.length = data.length;
|
||||
|
||||
var listHTML = "";
|
||||
data.forEach(function(item, i){
|
||||
var filename;
|
||||
if(item.name !== "null"){
|
||||
filename = item.name;
|
||||
}else{
|
||||
filename = "Removed File";
|
||||
}
|
||||
|
||||
listHTML += "<div class=\"file_button list_item\" "
|
||||
+ "onClick=\"ListNavigator.setItem('" + i + "')\">"
|
||||
+ escapeHTML(filename) + "<br>"
|
||||
+ "</div>";
|
||||
});
|
||||
document.getElementById("list_navigator").innerHTML = listHTML;
|
||||
|
||||
document.getElementById("btnDownloadList").style.display = "";
|
||||
document.getElementById("btnShuffle").style.display = "";
|
||||
|
||||
// Make the navigator visible
|
||||
document.getElementById("list_navigator").style.display = "inline-block";
|
||||
|
||||
// Skip to the file defined in the link hash
|
||||
if(Number.isInteger(parseInt(getHashValue("item")))){
|
||||
this.setItem(parseInt(getHashValue("item")));
|
||||
}else{
|
||||
this.setItem(0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Misc function, don't really know where else to put it
|
||||
function getHashValue(key) {
|
||||
var matches = location.hash.match(new RegExp(key + '=([^&]*)'));
|
||||
return matches ? matches[1] : null;
|
||||
}
|
||||
@@ -1,356 +0,0 @@
|
||||
/*
|
||||
* Time for a more Java-like approach.
|
||||
*
|
||||
* Feel free to use this of course
|
||||
*
|
||||
* Made by Fornax
|
||||
*/
|
||||
|
||||
/* global Viewer */
|
||||
|
||||
var Toolbar = {
|
||||
visible: false,
|
||||
toggle: function () {
|
||||
if (this.visible) {
|
||||
if (Sharebar.visible) {
|
||||
Sharebar.toggle();
|
||||
}
|
||||
|
||||
document.getElementById("toolbar").style.left = "-8em";
|
||||
document.getElementById("filepreview").style.left = "0px";
|
||||
document.getElementById("button_toggle_toolbar").classList.remove("button_highlight");
|
||||
|
||||
this.visible = false;
|
||||
} else {
|
||||
document.getElementById("toolbar").style.left = "0px";
|
||||
document.getElementById("filepreview").style.left = "8em";
|
||||
document.getElementById("button_toggle_toolbar").classList.add("button_highlight");
|
||||
|
||||
this.visible = true;
|
||||
}
|
||||
},
|
||||
download: function () {
|
||||
var triggerDL = function(){
|
||||
document.getElementById("download_frame").src = "/api/file/" + Viewer.currentFile + "?download";
|
||||
}
|
||||
|
||||
if (captchaKey === "a"){
|
||||
// If the server doesn't support captcha there's no use in checking
|
||||
// availability
|
||||
triggerDL();
|
||||
return;
|
||||
}
|
||||
|
||||
$.getJSON(
|
||||
apiEndpoint + "/file/" + Viewer.currentFile + "/availability"
|
||||
).done(function(data){
|
||||
if(data.success === true){
|
||||
// Downloading is allowed, start the download
|
||||
triggerDL();
|
||||
}
|
||||
}).fail(function(data){
|
||||
if(data.responseJSON.success === false) {
|
||||
var popupDiv = document.getElementById("captcha_popup");
|
||||
var popupTitle = document.getElementById("captcha_popup_title");
|
||||
var popupContent = document.getElementById("captcha_popup_content");
|
||||
var popupCaptcha = document.getElementById("captcha_popup_captcha");
|
||||
|
||||
if(data.responseJSON.value === "file_rate_limited_captcha_required") {
|
||||
popupTitle.innerText = "Rate limiting enabled!";
|
||||
popupContent.innerText = "This file is using a suspicious "+
|
||||
"amount of bandwidth relative to its popularity. To "+
|
||||
"continue downloading this file you will have to "+
|
||||
"prove that you're a human first.";
|
||||
}else if(data.responseJSON.value === "virus_detected_captcha_required"){
|
||||
popupTitle.innerText = "Malware warning!";
|
||||
popupContent.innerText = "According to our scanning "+
|
||||
"systems this file may contain a virus of type '"+
|
||||
data.responseJSON.extra+"'. You can continue "+
|
||||
"downloading this file at your own risk, but you will "+
|
||||
"have to prove that you're a human first.";
|
||||
}
|
||||
|
||||
// Load the recaptcha script with a load function
|
||||
$.getScript("https://www.google.com/recaptcha/api.js?onload=loadCaptcha&render=explicit");
|
||||
|
||||
popupDiv.style.opacity = "1";
|
||||
popupDiv.style.visibility = "visible";
|
||||
}else{
|
||||
// No JSON, try download anyway
|
||||
triggerDL();
|
||||
}
|
||||
});
|
||||
},
|
||||
downloadList: function(){
|
||||
if(!Viewer.isList){
|
||||
return;
|
||||
}
|
||||
document.getElementById("download_frame").src = "/api/list/" + Viewer.listId + "/zip";
|
||||
},
|
||||
copyUrl: function () {
|
||||
if(copyText(window.location.href)) {
|
||||
console.log('Text copied');
|
||||
$("#btnCopy>span").text("Copied!");
|
||||
document.getElementById("btnCopy").classList.add("button_highlight")
|
||||
} else {
|
||||
console.log('Copying not supported');
|
||||
$("#btnCopy>span").text("Error!");
|
||||
alert("Your browser does not support copying text.");
|
||||
}
|
||||
|
||||
// Return to normal
|
||||
setTimeout(function(){
|
||||
$("#btnCopy>span").text("Copy");
|
||||
document.getElementById("btnCopy").classList.remove("button_highlight")
|
||||
}, 60000);
|
||||
},
|
||||
setStats: function(views, downloads){
|
||||
document.getElementById("stat_views").innerText = views
|
||||
document.getElementById("stat_downloads").innerText = Math.round(downloads*10)/10;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var Sharebar = {
|
||||
visible: false,
|
||||
|
||||
toggle: function(){
|
||||
if (navigator.share) {
|
||||
navigator.share({
|
||||
title: Viewer.title,
|
||||
text: "Download " + Viewer.title + " here",
|
||||
url: window.location.href
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Toolbar.visible){
|
||||
Toolbar.toggle();
|
||||
}
|
||||
|
||||
if(this.visible){
|
||||
document.getElementById("sharebar").style.left = "-8em";
|
||||
document.getElementById("btnShare").classList.remove("button_highlight")
|
||||
this.visible = false;
|
||||
}else{
|
||||
document.getElementById("sharebar").style.left = "8em";
|
||||
document.getElementById("btnShare").classList.add("button_highlight")
|
||||
this.visible = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function copyText(text) {
|
||||
// Create a textarea to copy the text from
|
||||
var ta = document.createElement("textarea");
|
||||
ta.setAttribute("readonly", "readonly")
|
||||
ta.style.position = "absolute";
|
||||
ta.style.left = "-9999px";
|
||||
ta.value = text; // Put the text in the textarea
|
||||
|
||||
// Add the textarea to the DOM so it can be seleted by the user
|
||||
document.body.appendChild(ta);
|
||||
ta.select(); // Select the contents of the textarea
|
||||
var success = document.execCommand("copy"); // Copy the selected text
|
||||
document.body.removeChild(ta); // Remove the textarea
|
||||
return success;
|
||||
}
|
||||
|
||||
function loadCaptcha(){
|
||||
grecaptcha.render("captcha_popup_captcha", {
|
||||
sitekey: captchaKey,
|
||||
theme: "dark",
|
||||
callback: function(token){
|
||||
document.getElementById("download_frame").src = "/api/file/" + Viewer.currentFile +
|
||||
"?download&recaptcha_response="+token;
|
||||
|
||||
setTimeout(function(){
|
||||
var popupDiv = document.getElementById("captcha_popup");
|
||||
popupDiv.style.opacity = "0";
|
||||
popupDiv.style.visibility = "hidden";
|
||||
}, 1000)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
var DetailsWindow = {
|
||||
visible: false,
|
||||
fileID: "",
|
||||
graph: 0,
|
||||
popupDiv: document.getElementById("details_popup"),
|
||||
detailsButton: document.getElementById("btnDetails"),
|
||||
toggle: function () {
|
||||
if (this.visible) {
|
||||
this.popupDiv.style.opacity = "0"
|
||||
this.popupDiv.style.visibility = "hidden"
|
||||
this.detailsButton.classList.remove("button_highlight")
|
||||
this.visible = false;
|
||||
} else {
|
||||
this.popupDiv.style.opacity = "1"
|
||||
this.popupDiv.style.visibility = "visible"
|
||||
this.detailsButton.classList.add("button_highlight")
|
||||
this.visible = true;
|
||||
|
||||
// This is a workaround for a chrome bug which makes it so hidden
|
||||
// windows can't be scrolled after they are shown
|
||||
this.popupDiv.focus();
|
||||
|
||||
if (this.graph === 0) {
|
||||
this.renderGraph();
|
||||
}
|
||||
this.updateGraph(this.fileID);
|
||||
}
|
||||
},
|
||||
setDetails: function (file) {
|
||||
var that = this;
|
||||
if (Viewer.isList) {
|
||||
// Lists give incomplete file information, so we have to request
|
||||
// more details in the background. File descriptions only exist in
|
||||
// lists, so for that we use the data provided in the page source
|
||||
$.ajax({
|
||||
dataType: "json",
|
||||
url: apiEndpoint + "/file/" + file.id + "/info",
|
||||
success: function(data){
|
||||
that.fileID = data.id;
|
||||
$("#info_file_details").html(
|
||||
"<table>"
|
||||
+ "<tr><td>Name<td><td>" + escapeHTML(data.name) + "</td></tr>"
|
||||
+ "<tr><td>URL<td><td><a href=\"/u/" + data.id + "\">/u/" + data.id + "</a></td></tr>"
|
||||
+ "<tr><td>Mime Type<td><td>" + escapeHTML(data.mime_type) + "</td></tr>"
|
||||
+ "<tr><td>ID<td><td>" + data.id + "</td></tr>"
|
||||
+ "<tr><td>Size<td><td>" + formatDataVolume(data.size) + "</td></tr>"
|
||||
+ "<tr><td>Bandwidth<td><td>" + formatDataVolume(data.bandwidth_used) + "</td></tr>"
|
||||
+ "<tr><td>Upload Date<td><td>" + data.date_upload + "</td></tr>"
|
||||
+ "<tr><td>Description<td><td>" + escapeHTML(file.description) + "</td></tr>"
|
||||
+ "</table>"
|
||||
);
|
||||
Toolbar.setStats(data.views, data.bandwidth_used/data.size);
|
||||
if(that.visible) {
|
||||
that.updateGraph(that.fileID);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.fileID = file.id;
|
||||
$("#info_file_details").html(
|
||||
"<table>"
|
||||
+ "<tr><td>Name<td><td>" + escapeHTML(file.name) + "</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>Upload Date<td><td>" + file.date_upload + "</td></tr>"
|
||||
+ "</table>"
|
||||
);
|
||||
Toolbar.setStats(file.views, file.bandwidth_used/file.size);
|
||||
if(this.visible) {
|
||||
this.updateGraph(file.id);
|
||||
}
|
||||
}
|
||||
},
|
||||
updateGraph: function(fileID) {
|
||||
var that = this;
|
||||
console.log("updating graph "+fileID);
|
||||
$.get(apiEndpoint+"/file/" + fileID + "/timeseries?interval=60?days=14", function(response){
|
||||
console.log(response);
|
||||
if (response.success) {
|
||||
that.graph.data.labels = response.labels;
|
||||
that.graph.data.datasets[0].data = response.downloads;
|
||||
that.graph.data.datasets[1].data = response.views;
|
||||
that.graph.update();
|
||||
}
|
||||
});
|
||||
},
|
||||
renderGraph: function() {
|
||||
console.log("rendering graph");
|
||||
Chart.defaults.global.defaultFontColor = "#b3b3b3";
|
||||
Chart.defaults.global.defaultFontSize = 15;
|
||||
Chart.defaults.global.defaultFontFamily = "Ubuntu";
|
||||
Chart.defaults.global.aspectRatio = 2.5;
|
||||
Chart.defaults.global.elements.point.radius = 0;
|
||||
Chart.defaults.global.tooltips.mode = "index";
|
||||
Chart.defaults.global.tooltips.axis = "x";
|
||||
Chart.defaults.global.tooltips.intersect = false;
|
||||
this.graph = new Chart(
|
||||
document.getElementById('bandwidth_chart'),
|
||||
{
|
||||
type: 'line',
|
||||
data: {
|
||||
datasets: [
|
||||
{
|
||||
label: "Downloads",
|
||||
backgroundColor: "rgba(64, 255, 64, .05)",
|
||||
borderColor: "rgba(128, 255, 128, 1)",
|
||||
borderWidth: 1.5,
|
||||
lineTension: 0.1,
|
||||
fill: true,
|
||||
yAxisID: "y_bandwidth",
|
||||
}, {
|
||||
label: "Views",
|
||||
backgroundColor: "rgba(64, 64, 255, .1)",
|
||||
borderColor: "rgba(128, 128, 255, 1)",
|
||||
borderWidth: 1.5,
|
||||
lineTension: 0.1,
|
||||
fill: true,
|
||||
yAxisID: "y_views",
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
yAxes: [
|
||||
{
|
||||
type: "linear",
|
||||
display: true,
|
||||
position: "left",
|
||||
id: "y_bandwidth",
|
||||
scaleLabel: {
|
||||
display: true,
|
||||
labelString: "Downloads"
|
||||
},
|
||||
gridLines: {
|
||||
color: "rgba(100, 255, 100, .1)"
|
||||
}
|
||||
}, {
|
||||
type: "linear",
|
||||
display: true,
|
||||
position: "right",
|
||||
id: "y_views",
|
||||
scaleLabel: {
|
||||
display: true,
|
||||
labelString: "Views"
|
||||
},
|
||||
gridLines: {
|
||||
color: "rgba(128, 128, 255, .2)"
|
||||
}
|
||||
}
|
||||
],
|
||||
xAxes: [
|
||||
{
|
||||
ticks: {
|
||||
maxRotation: 20
|
||||
},
|
||||
gridLines: {
|
||||
display: false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -1,147 +0,0 @@
|
||||
/* global ListNavigator, Toolbar, DetailsWindow */
|
||||
|
||||
var Viewer = {
|
||||
currentFile: "",
|
||||
title: "", // Contains either the file name or list title
|
||||
listId: "",
|
||||
isList: false,
|
||||
isFile: false,
|
||||
initialized: false,
|
||||
|
||||
init: function(type, data){
|
||||
if(this.initialized){
|
||||
return;
|
||||
}
|
||||
|
||||
// On small screens the toolbar takes too much space, so it collapses automatically
|
||||
if($("#filepreview").width() > 600 && !Toolbar.visible){
|
||||
Toolbar.toggle();
|
||||
}
|
||||
|
||||
// The close button only works if the window has an opener. So we hide
|
||||
// the button if it does not
|
||||
if (window.opener === null && window.history.length !== 1) {
|
||||
$("#button_close_file_viewer").remove();
|
||||
}
|
||||
|
||||
if(type === "file"){
|
||||
this.isFile = true;
|
||||
this.currentFile = data.id;
|
||||
this.title = data.name;
|
||||
this.setFile(data);
|
||||
} else if (type === "list") {
|
||||
this.isList = true;
|
||||
this.listId = data.id;
|
||||
this.title = data.title;
|
||||
ListNavigator.init(data.data);
|
||||
}
|
||||
|
||||
renderSponsors();
|
||||
|
||||
this.initialized = true;
|
||||
},
|
||||
setFile: function(file){
|
||||
this.currentFile = file.id;
|
||||
var title = "";
|
||||
if (this.isList) {
|
||||
document.getElementById("file_viewer_headerbar_title").style.lineHeight = "1em";
|
||||
document.getElementById("file_viewer_list_title").innerText = this.title;
|
||||
document.getElementById("file_viewer_file_title").innerText = file.name;
|
||||
document.title = this.title + " ~ " + file.name + " ~ pixeldrain";
|
||||
} else {
|
||||
document.getElementById("file_viewer_file_title").innerText = file.name;
|
||||
document.title = file.name + " ~ pixeldrain";
|
||||
}
|
||||
|
||||
$.get("/u/" + file.id + "/preview", function(response){
|
||||
$("#filepreview").html(response);
|
||||
});
|
||||
|
||||
DetailsWindow.setDetails(file);
|
||||
}
|
||||
};
|
||||
|
||||
// Against XSS attacks
|
||||
function escapeHTML(str) {
|
||||
return String(str)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"');
|
||||
}
|
||||
|
||||
// Register keyboard shortcuts
|
||||
document.addEventListener("keydown", function(event){
|
||||
if (event.ctrlKey || event.altKey) {
|
||||
return // prevent custom shortcuts from interfering with system shortcuts
|
||||
}
|
||||
|
||||
switch (event.which) {
|
||||
case 65: // A or left arrow key go to previous file
|
||||
case 37:
|
||||
ListNavigator.previousItem();
|
||||
break;
|
||||
case 68: // D or right arrow key go to next file
|
||||
case 39:
|
||||
ListNavigator.nextItem();
|
||||
break;
|
||||
case 83:
|
||||
if (event.shiftKey) {
|
||||
Toolbar.downloadList(); // SHIFT + S downloads all files in list
|
||||
} else {
|
||||
Toolbar.download(); // S to download the current file
|
||||
}
|
||||
break;
|
||||
case 82: // R to toggle list shuffle
|
||||
ListNavigator.toggleShuffle();
|
||||
break;
|
||||
case 67: // C to copy to clipboard
|
||||
Toolbar.copyUrl();
|
||||
break;
|
||||
case 73: // I to open the details window
|
||||
DetailsWindow.toggle();
|
||||
break;
|
||||
case 81: // Q to close the window
|
||||
window.close();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
window.addEventListener("resize", renderSponsors);
|
||||
function renderSponsors() {
|
||||
var scale = 1;
|
||||
var scaleWidth = 1;
|
||||
var scaleHeight = 1;
|
||||
var minWidth = 728;
|
||||
var minHeight = 800;
|
||||
|
||||
if (window.innerWidth < minWidth) {
|
||||
scaleWidth = window.innerWidth/minWidth;
|
||||
}
|
||||
if (window.innerHeight < minHeight) {
|
||||
scaleHeight = window.innerHeight/minHeight;
|
||||
}
|
||||
scale = scaleWidth < scaleHeight ? scaleWidth : scaleHeight;
|
||||
|
||||
console.log(scale, scaleWidth, scaleHeight);
|
||||
|
||||
// Because of the scale transformation the automatic margins don't work
|
||||
// anymore. So we have to maunally calculate the margin. Where we take the
|
||||
// width of the viewport - the width of the ad to calculate the amount of
|
||||
// pixels around the ad. We multiply the ad size by the scale we calcualted
|
||||
// to account for the smaller size.
|
||||
var offset = (window.innerWidth - (minWidth*scale)) / 2
|
||||
if (offset < 0) {
|
||||
offset = 0
|
||||
}
|
||||
document.querySelector(".sponsors > iframe").style.marginLeft = offset+"px";
|
||||
|
||||
if (scale == 1) {
|
||||
document.querySelector(".sponsors > iframe").style.transform = "none";
|
||||
document.querySelector(".sponsors").style.height = "90px";
|
||||
} else {
|
||||
document.querySelector(".sponsors > iframe").style.transform = "scale("+scale+")";
|
||||
document.querySelector(".sponsors").style.height = (scale*90)+"px";
|
||||
}
|
||||
}
|
||||
@@ -66,3 +66,19 @@ function addUploadHistory(fileID) {
|
||||
// Save the new ID
|
||||
localStorage.setItem("uploaded_files", fileID + "," + uploads);
|
||||
}
|
||||
|
||||
function copyText(text) {
|
||||
// Create a textarea to copy the text from
|
||||
let ta = document.createElement("textarea");
|
||||
ta.setAttribute("readonly", "readonly")
|
||||
ta.style.position = "absolute";
|
||||
ta.style.left = "-9999px";
|
||||
ta.value = text; // Put the text in the textarea
|
||||
|
||||
// Add the textarea to the DOM so it can be seleted by the user
|
||||
document.body.appendChild(ta);
|
||||
ta.select() // Select the contents of the textarea
|
||||
let success = document.execCommand("copy"); // Copy the selected text
|
||||
document.body.removeChild(ta); // Remove the textarea
|
||||
return success;
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
class DetailsWindow {
|
||||
viewer = null;
|
||||
|
||||
visible = false;
|
||||
fileID = "";
|
||||
graph = 0;
|
||||
|
||||
divPopup = null;
|
||||
btnDetails = null;
|
||||
btnCloseDetails = null;
|
||||
divFileDetails = null;
|
||||
|
||||
constructor(viewer) {let dw = this;
|
||||
dw.viewer = viewer;
|
||||
|
||||
dw.divPopup = document.getElementById("details_popup");
|
||||
dw.btnDetails = document.getElementById("btn_details");
|
||||
dw.btnCloseDetails = document.getElementById("btn_close_details");
|
||||
dw.divFileDetails = document.getElementById("info_file_details");
|
||||
|
||||
dw.btnDetails.addEventListener("click", () => { dw.toggle(); });
|
||||
dw.btnCloseDetails.addEventListener("click", () => { dw.toggle(); });
|
||||
}
|
||||
|
||||
toggle() {let dw = this;
|
||||
if (dw.visible) {
|
||||
dw.divPopup.style.opacity = "0";
|
||||
dw.divPopup.style.visibility = "hidden";
|
||||
dw.btnDetails.classList.remove("button_highlight");
|
||||
dw.visible = false;
|
||||
} else {
|
||||
dw.divPopup.style.opacity = "1";
|
||||
dw.divPopup.style.visibility = "visible";
|
||||
dw.btnDetails.classList.add("button_highlight");
|
||||
dw.visible = true;
|
||||
|
||||
// This is a workaround for a chrome bug which makes it so hidden
|
||||
// windows can't be scrolled after they are shown
|
||||
dw.divPopup.focus();
|
||||
|
||||
if (dw.graph === 0) {
|
||||
dw.renderGraph();
|
||||
}
|
||||
dw.updateGraph(dw.fileID);
|
||||
}
|
||||
}
|
||||
|
||||
setDetails(file) {let dw = this;
|
||||
if (dw.viewer.isList) {
|
||||
// Lists give incomplete file information, so we have to request
|
||||
// more details in the background. File descriptions only exist in
|
||||
// lists, so for that we use the data provided in the page source
|
||||
fetch(apiEndpoint + "/file/" + file.id + "/info").then(resp => {
|
||||
if (!resp.ok) {return;}
|
||||
return resp.json();
|
||||
}).then(resp => {
|
||||
dw.fileID = resp.id;
|
||||
dw.divFileDetails.innerHTML = "<table>"
|
||||
+ "<tr><td>Name<td><td>" + escapeHTML(resp.name) + "</td></tr>"
|
||||
+ "<tr><td>URL<td><td><a href=\"/u/" + resp.id + "\">/u/" + resp.id + "</a></td></tr>"
|
||||
+ "<tr><td>Mime Type<td><td>" + escapeHTML(resp.mime_type) + "</td></tr>"
|
||||
+ "<tr><td>ID<td><td>" + resp.id + "</td></tr>"
|
||||
+ "<tr><td>Size<td><td>" + formatDataVolume(resp.size) + "</td></tr>"
|
||||
+ "<tr><td>Bandwidth<td><td>" + formatDataVolume(resp.bandwidth_used) + "</td></tr>"
|
||||
+ "<tr><td>Upload Date<td><td>" + resp.date_upload + "</td></tr>"
|
||||
+ "<tr><td>Description<td><td>" + escapeHTML(file.description) + "</td></tr>"
|
||||
+ "</table>";
|
||||
|
||||
dw.viewer.toolbar.setStats(resp.views, resp.bandwidth_used/resp.size);
|
||||
if(dw.visible) {
|
||||
dw.updateGraph(dw.fileID);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
dw.fileID = file.id;
|
||||
dw.divFileDetails.innerHTML = "<table>"
|
||||
+ "<tr><td>Name<td><td>" + escapeHTML(file.name) + "</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>Upload Date<td><td>" + file.date_upload + "</td></tr>"
|
||||
+ "</table>";
|
||||
|
||||
dw.viewer.toolbar.setStats(file.views, file.bandwidth_used/file.size);
|
||||
if(dw.visible) {
|
||||
dw.updateGraph(file.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateGraph(fileID) {let dw = this;
|
||||
console.log("updating graph "+fileID);
|
||||
fetch(apiEndpoint+"/file/" + fileID + "/timeseries?interval=60?days=14").then(resp => {
|
||||
if (!resp.ok) {return null;}
|
||||
return resp.json();
|
||||
}).then(resp => {
|
||||
dw.graph.data.labels = resp.labels;
|
||||
dw.graph.data.datasets[0].data = resp.downloads;
|
||||
dw.graph.data.datasets[1].data = resp.views;
|
||||
dw.graph.update();
|
||||
})
|
||||
}
|
||||
|
||||
renderGraph() {let dw = this;
|
||||
console.log("rendering graph");
|
||||
Chart.defaults.global.defaultFontColor = "#b3b3b3";
|
||||
Chart.defaults.global.defaultFontSize = 15;
|
||||
Chart.defaults.global.defaultFontFamily = "Ubuntu";
|
||||
Chart.defaults.global.aspectRatio = 2.5;
|
||||
Chart.defaults.global.elements.point.radius = 0;
|
||||
Chart.defaults.global.tooltips.mode = "index";
|
||||
Chart.defaults.global.tooltips.axis = "x";
|
||||
Chart.defaults.global.tooltips.intersect = false;
|
||||
dw.graph = new Chart(
|
||||
document.getElementById('bandwidth_chart'),
|
||||
{
|
||||
type: 'line',
|
||||
data: {
|
||||
datasets: [
|
||||
{
|
||||
label: "Downloads",
|
||||
backgroundColor: "rgba(64, 255, 64, .05)",
|
||||
borderColor: "rgba(128, 255, 128, 1)",
|
||||
borderWidth: 1.5,
|
||||
lineTension: 0.1,
|
||||
fill: true,
|
||||
yAxisID: "y_bandwidth",
|
||||
}, {
|
||||
label: "Views",
|
||||
backgroundColor: "rgba(64, 64, 255, .1)",
|
||||
borderColor: "rgba(128, 128, 255, 1)",
|
||||
borderWidth: 1.5,
|
||||
lineTension: 0.1,
|
||||
fill: true,
|
||||
yAxisID: "y_views",
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
yAxes: [
|
||||
{
|
||||
type: "linear",
|
||||
display: true,
|
||||
position: "left",
|
||||
id: "y_bandwidth",
|
||||
scaleLabel: {
|
||||
display: true,
|
||||
labelString: "Downloads"
|
||||
},
|
||||
gridLines: {
|
||||
color: "rgba(100, 255, 100, .1)"
|
||||
}
|
||||
}, {
|
||||
type: "linear",
|
||||
display: true,
|
||||
position: "right",
|
||||
id: "y_views",
|
||||
scaleLabel: {
|
||||
display: true,
|
||||
labelString: "Views"
|
||||
},
|
||||
gridLines: {
|
||||
color: "rgba(128, 128, 255, .2)"
|
||||
}
|
||||
}
|
||||
],
|
||||
xAxes: [
|
||||
{
|
||||
ticks: {
|
||||
maxRotation: 20
|
||||
},
|
||||
gridLines: {
|
||||
display: false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
class ListNavigator {
|
||||
viewer = null;
|
||||
length = 0;
|
||||
position = 0;
|
||||
data = [];
|
||||
history = [];
|
||||
shuffle = false;
|
||||
|
||||
divListNavigator = null;
|
||||
btnDownloadList = null;
|
||||
btnShuffle = null;
|
||||
|
||||
constructor(viewer, data){let ln = this;
|
||||
ln.viewer = viewer;
|
||||
ln.data = data;
|
||||
ln.length = data.length;
|
||||
|
||||
ln.divListNavigator = document.getElementById("list_navigator");
|
||||
|
||||
ln.btnDownloadList = document.getElementById("btn_download_list");
|
||||
ln.btnDownloadList.style.display = "";
|
||||
ln.btnDownloadList.addEventListener("click", () => { ln.downloadList(); });
|
||||
|
||||
ln.btnShuffle = document.getElementById("btn_shuffle");
|
||||
ln.btnShuffle.style.display = "";
|
||||
ln.btnShuffle.addEventListener("click", () => { ln.toggleShuffle(); });
|
||||
|
||||
// Render list contents in list navigator div
|
||||
data.forEach((item, i) => {
|
||||
let filename;
|
||||
if(item.name !== "null"){
|
||||
filename = item.name;
|
||||
}else{
|
||||
filename = "Removed File";
|
||||
}
|
||||
|
||||
let d = document.createElement("div");
|
||||
d.classList = "file_button list_item";
|
||||
d.addEventListener("click", () => { ln.setItem(i); });
|
||||
d.innerText = filename;
|
||||
ln.divListNavigator.appendChild(d);
|
||||
});
|
||||
|
||||
// Make the navigator visible
|
||||
ln.divListNavigator.style.display = "inline-block";
|
||||
|
||||
// Skip to the file defined in the link hash
|
||||
if(Number.isInteger(parseInt(getHashValue("item")))){
|
||||
ln.setItem(parseInt(getHashValue("item")));
|
||||
}else{
|
||||
ln.setItem(0);
|
||||
}
|
||||
}
|
||||
|
||||
nextItem(){let ln = this;
|
||||
if(ln.shuffle){
|
||||
ln.randItem();
|
||||
return;
|
||||
}
|
||||
|
||||
if (ln.position >= ln.length) {
|
||||
ln.position = 0;
|
||||
} else {
|
||||
ln.position++;
|
||||
}
|
||||
|
||||
ln.setItem(ln.position);
|
||||
}
|
||||
|
||||
previousItem(){let ln = this;
|
||||
if(ln.position === 0){
|
||||
ln.position = ln.length - 1;
|
||||
}else{
|
||||
ln.position--;
|
||||
}
|
||||
|
||||
ln.setItem(ln.position);
|
||||
}
|
||||
|
||||
randItem(){let ln = this;
|
||||
// Avoid viewing the same file multiple times
|
||||
let rand;
|
||||
do {
|
||||
rand = Math.round(Math.random() * ln.length);
|
||||
console.log("rand is " + rand);
|
||||
} while(ln.history.indexOf(index) > -1);
|
||||
|
||||
ln.setItem(rand);
|
||||
}
|
||||
|
||||
setItem(index){let ln = this;
|
||||
if(index >= ln.length){
|
||||
ln.position = 0;
|
||||
}else{
|
||||
ln.position = index;
|
||||
}
|
||||
|
||||
// Set the URL hash
|
||||
location.hash = "item=" + ln.position;
|
||||
ln.viewer.setFile(ln.data[ln.position]);
|
||||
|
||||
ln.addToHistory(index);
|
||||
ln.loadThumbnails(index);
|
||||
|
||||
document.querySelectorAll("#list_navigator > .file_button_selected").forEach(el => {
|
||||
el.classList.remove("file_button_selected");
|
||||
});
|
||||
|
||||
let selectedItem = ln.divListNavigator.children[ln.position];
|
||||
selectedItem.classList.add("file_button_selected");
|
||||
|
||||
let cst = window.getComputedStyle(selectedItem);
|
||||
let itemWidth = selectedItem.offsetWidth + parseInt(cst.marginLeft) + parseInt(cst.marginRight);
|
||||
|
||||
let start = ln.divListNavigator.scrollLeft;
|
||||
let end = ((ln.position * itemWidth) + (itemWidth / 2)) - (ln.divListNavigator.clientWidth / 2);
|
||||
let steps = 60; // One second
|
||||
let stepSize = (end - start)/steps;
|
||||
|
||||
let animateScroll = (pos, step) => {
|
||||
ln.divListNavigator.scrollLeft = pos;
|
||||
|
||||
if (step < steps) {
|
||||
requestAnimationFrame(() => {
|
||||
animateScroll(pos+stepSize, step+1);
|
||||
});
|
||||
}
|
||||
};
|
||||
animateScroll(start, 0);
|
||||
}
|
||||
|
||||
downloadList(){let ln = this;
|
||||
document.getElementById("download_frame").src = "/api/list/" + ln.viewer.listId + "/zip";
|
||||
}
|
||||
|
||||
addToHistory(index){let ln = this;
|
||||
if(ln.history.length >= (ln.length - 6)){
|
||||
ln.history.shift();
|
||||
}
|
||||
|
||||
ln.history.push(index);
|
||||
}
|
||||
|
||||
toggleShuffle(){let ln = this;
|
||||
ln.shuffle = !ln.shuffle; // :P
|
||||
|
||||
if(ln.shuffle){
|
||||
document.querySelector("#btn_shuffle > span").innerHTML = "Shuffle ☑"; // Check icon
|
||||
ln.btnShuffle.classList.add("button_highlight");
|
||||
}else{
|
||||
document.querySelector("#btn_shuffle > span").innerHTML = "Shuffle ☐"; // Empty checkbox
|
||||
ln.btnShuffle.classList.remove("button_highlight");
|
||||
}
|
||||
}
|
||||
|
||||
loadThumbnails(index){let ln = this;
|
||||
let startPos = +index - 50;
|
||||
let endPos = +index + 50;
|
||||
// fyi, the + is to let javascript know it's actually a number instead of a string
|
||||
|
||||
if(startPos < 0){
|
||||
startPos = 0;
|
||||
}
|
||||
|
||||
if(endPos >= ln.length){
|
||||
endPos = ln.length - 1;
|
||||
}
|
||||
|
||||
let navigatorItems = document.getElementById("list_navigator").children
|
||||
|
||||
for (let i = startPos; i <= endPos; i++){
|
||||
if (navigatorItems[i].innerHTML.includes("list_item_thumbnail")) {
|
||||
continue; // Thumbnail already loaded
|
||||
}
|
||||
|
||||
let thumb = "/api/file/" + ln.data[i].id + "/thumbnail?width=48&height=48";
|
||||
let name = ln.data[i].name;
|
||||
|
||||
let itemHtml = "<img src=\"" + thumb + "\" "
|
||||
+ "class=\"list_item_thumbnail\" alt=\"" + escapeHTML(name) + "\"/>"
|
||||
+ escapeHTML(name);
|
||||
|
||||
navigatorItems[i].innerHTML = itemHtml;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Misc function, don't really know where else to put it
|
||||
function getHashValue(key) {
|
||||
let matches = location.hash.match(new RegExp(key + '=([^&]*)'));
|
||||
return matches ? matches[1] : null;
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
class Toolbar {
|
||||
viewer = null;
|
||||
|
||||
visible = false;
|
||||
sharebarVisible = false;
|
||||
|
||||
// Elements
|
||||
divToolbar = null;
|
||||
divFilePreview = null;
|
||||
downloadFrame = null
|
||||
|
||||
spanViews = null;
|
||||
spanDownloads = null;
|
||||
|
||||
btnToggleToolbar = null;
|
||||
btnDownload = null;
|
||||
btnCopyLink = null;
|
||||
spanCopyLink = null;
|
||||
btnShare = null;
|
||||
divSharebar = null;
|
||||
|
||||
constructor(viewer) {let t = this;
|
||||
this.viewer = viewer;
|
||||
|
||||
t.divToolbar = document.getElementById("toolbar");
|
||||
t.divFilePreview = document.getElementById("filepreview");
|
||||
t.downloadFrame = document.getElementById("download_frame");
|
||||
t.spanViews = document.getElementById("stat_views");
|
||||
t.spanDownloads = document.getElementById("stat_downloads");
|
||||
|
||||
t.btnToggleToolbar = document.getElementById("btn_toggle_toolbar");
|
||||
t.btnDownload = document.getElementById("btn_download");
|
||||
t.btnCopyLink = document.getElementById("btn_copy");
|
||||
t.spanCopyLink = document.querySelector("#btn_copy > span");
|
||||
t.btnShare = document.getElementById("btn_share");
|
||||
t.divSharebar = document.getElementById("sharebar");
|
||||
|
||||
t.btnToggleToolbar.addEventListener("click", () => { t.toggle(); });
|
||||
t.btnDownload.addEventListener("click", () => { t.download(); });
|
||||
t.btnCopyLink.addEventListener("click", () => { t.copyUrl(); });
|
||||
t.btnShare.addEventListener("click", () => { t.toggleSharebar(); });
|
||||
}
|
||||
|
||||
toggle() {let t = this;
|
||||
if (t.visible) {
|
||||
if (t.sharebarVisible) { t.toggleSharebar(); }
|
||||
|
||||
t.divToolbar.style.left = "-8em";
|
||||
t.divFilePreview.style.left = "0px";
|
||||
t.btnToggleToolbar.classList.remove("button_highlight");
|
||||
t.visible = false;
|
||||
} else {
|
||||
t.divToolbar.style.left = "0px";
|
||||
t.divFilePreview.style.left = "8em";
|
||||
t.btnToggleToolbar.classList.add("button_highlight");
|
||||
t.visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
toggleSharebar(){let t = this;
|
||||
if (navigator.share) {
|
||||
navigator.share({
|
||||
title: t.viewer.title,
|
||||
text: "Download " + t.viewer.title + " here",
|
||||
url: window.location.href
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if(t.sharebarVisible){
|
||||
t.divSharebar.style.left = "-8em";
|
||||
t.btnShare.classList.remove("button_highlight")
|
||||
t.sharebarVisible = false;
|
||||
}else{
|
||||
t.divSharebar.style.left = "8em";
|
||||
t.btnShare.classList.add("button_highlight")
|
||||
t.sharebarVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
download() {let t = this;
|
||||
let triggerDL = function(){
|
||||
t.downloadFrame.src = apiEndpoint+"/file/"+t.viewer.currentFile+"?download";
|
||||
}
|
||||
|
||||
if (captchaKey === "a"){
|
||||
// If the server doesn't support captcha there's no use in checking
|
||||
// availability
|
||||
triggerDL();
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(apiEndpoint+"/file/"+t.viewer.currentFile+"/availability").then(resp => {
|
||||
return resp.json();
|
||||
}).then(resp => {
|
||||
let popupDiv = document.getElementById("captcha_popup");
|
||||
let popupTitle = document.getElementById("captcha_popup_title");
|
||||
let popupContent = document.getElementById("captcha_popup_content");
|
||||
|
||||
let showCaptcha = function() {
|
||||
// Load the recaptcha script with a load function
|
||||
var script = document.createElement("script");
|
||||
script.src = "https://www.google.com/recaptcha/api.js?onload=loadCaptcha&render=explicit";
|
||||
document.appendChild(script);
|
||||
// $.getScript("https://www.google.com/recaptcha/api.js?onload=loadCaptcha&render=explicit");
|
||||
popupDiv.style.opacity = "1";
|
||||
popupDiv.style.visibility = "visible";
|
||||
}
|
||||
|
||||
if (resp.value === "file_rate_limited_captcha_required") {
|
||||
popupTitle.innerText = "Rate limiting enabled!";
|
||||
popupContent.innerText = "This file is using a suspicious "+
|
||||
"amount of bandwidth relative to its popularity. To "+
|
||||
"continue downloading this file you will have to "+
|
||||
"prove that you're a human first.";
|
||||
showCaptcha();
|
||||
} else if (resp.value === "virus_detected_captcha_required") {
|
||||
popupTitle.innerText = "Malware warning!";
|
||||
popupContent.innerText = "According to our scanning "+
|
||||
"systems this file may contain a virus of type '"+
|
||||
resp.extra+"'. You can continue downloading this file at "+
|
||||
"your own risk, but you will have to prove that you're a "+
|
||||
"human first.";
|
||||
showCaptcha();
|
||||
} else {
|
||||
triggerDL();
|
||||
}
|
||||
}).catch(e => {
|
||||
triggerDL();
|
||||
});
|
||||
}
|
||||
|
||||
copyUrl() {let t = this;
|
||||
if(copyText(window.location.href)) {
|
||||
console.log('Text copied');
|
||||
t.spanCopyLink.innerText = "Copied!";
|
||||
t.btnCopyLink.classList.add("button_highlight")
|
||||
} else {
|
||||
console.log('Copying not supported');
|
||||
t.spanCopyLink.innerText = "Error!";
|
||||
alert("Your browser does not support copying text.");
|
||||
}
|
||||
|
||||
// Return to normal
|
||||
setTimeout(function(){
|
||||
t.spanCopyLink.innerText = "Copy";
|
||||
t.btnCopyLink.classList.remove("button_highlight")
|
||||
}, 60000);
|
||||
}
|
||||
|
||||
setStats(views, downloads) {let t = this;
|
||||
t.spanViews.innerText = views
|
||||
t.spanDownloads.innerText = Math.round(downloads*10)/10;
|
||||
}
|
||||
}
|
||||
|
||||
// Called by the google recaptcha script
|
||||
function loadCaptcha(){
|
||||
grecaptcha.render("captcha_popup_captcha", {
|
||||
sitekey: captchaKey,
|
||||
theme: "dark",
|
||||
callback: function(token){
|
||||
document.getElementById("download_frame").src = "/api/file/" + Viewer.currentFile +
|
||||
"?download&recaptcha_response="+token;
|
||||
|
||||
setTimeout(function(){
|
||||
let popupDiv = document.getElementById("captcha_popup");
|
||||
popupDiv.style.opacity = "0";
|
||||
popupDiv.style.visibility = "hidden";
|
||||
}, 1000)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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"
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
class Viewer {
|
||||
// Child components
|
||||
toolbar = null;
|
||||
listNavigator = null;
|
||||
detailsWindow = null;
|
||||
|
||||
divFilepreview = null;
|
||||
|
||||
currentFile = "";
|
||||
title = ""; // Contains either the file name or list title
|
||||
listId = "";
|
||||
isList = false;
|
||||
isFile = false;
|
||||
initialized = false;
|
||||
|
||||
constructor(type, data) {let v = this;
|
||||
if(v.initialized){
|
||||
return;
|
||||
}
|
||||
|
||||
v.toolbar = new Toolbar(v);
|
||||
v.detailsWindow = new DetailsWindow(v);
|
||||
|
||||
v.divFilepreview = document.getElementById("filepreview");
|
||||
|
||||
// On small screens the toolbar takes too much space, so it collapses
|
||||
// automatically
|
||||
if(v.divFilepreview.clientWidth > 600 && !v.toolbar.visible){
|
||||
v.toolbar.toggle();
|
||||
}
|
||||
|
||||
// The close button only works if the window has an opener. So we hide
|
||||
// the button if it does not
|
||||
if (window.opener === null && window.history.length !== 1) {
|
||||
document.getElementById("button_close_file_viewer").remove()
|
||||
}
|
||||
|
||||
|
||||
if(type === "file"){
|
||||
v.isFile = true;
|
||||
v.currentFile = data.id;
|
||||
v.title = data.name;
|
||||
v.setFile(data);
|
||||
} else if (type === "list") {
|
||||
v.isList = true;
|
||||
v.listId = data.id;
|
||||
v.title = data.title;
|
||||
v.listNavigator = new ListNavigator(v, data.data);
|
||||
}
|
||||
|
||||
v.renderSponsors();
|
||||
window.addEventListener("resize", e => { v.renderSponsors(e); });
|
||||
|
||||
// Register keyboard shortcuts
|
||||
document.addEventListener("keydown", e => { v.keyboardEvent(e); });
|
||||
|
||||
v.initialized = true;
|
||||
}
|
||||
|
||||
setFile(file) {let v = this;
|
||||
v.currentFile = file.id;
|
||||
if (v.isList) {
|
||||
document.getElementById("file_viewer_headerbar_title").style.lineHeight = "1em";
|
||||
document.getElementById("file_viewer_list_title").innerText = this.title;
|
||||
document.getElementById("file_viewer_file_title").innerText = file.name;
|
||||
document.title = v.title + " ~ " + file.name + " ~ pixeldrain";
|
||||
} else {
|
||||
document.getElementById("file_viewer_file_title").innerText = file.name;
|
||||
document.title = file.name + " ~ pixeldrain";
|
||||
}
|
||||
|
||||
// Update the file details
|
||||
v.detailsWindow.setDetails(file);
|
||||
|
||||
// Clear the canvas
|
||||
v.divFilepreview.innerHTML = "";
|
||||
|
||||
if (file.mime_type.startsWith("image")) {
|
||||
new ImageViewer(v, file).render(v.divFilepreview);
|
||||
} else if (file.mime_type.startsWith("video")) {
|
||||
new VideoViewer(v, file, () => {
|
||||
if (v.listNavigator !== null) {
|
||||
v.listNavigator.nextItem();
|
||||
}
|
||||
}).render(v.divFilepreview);
|
||||
} else if (file.mime_type.startsWith("audio") || file.mime_type === "application/ogg") {
|
||||
new AudioViewer(v, file, () => {
|
||||
if (v.listNavigator !== null) {
|
||||
v.listNavigator.nextItem();
|
||||
}
|
||||
}).render(v.divFilepreview);
|
||||
} else {
|
||||
fetch("/u/"+file.id+"/preview").then(resp => {
|
||||
if (!resp.ok) { return Promise.reject(resp.status); }
|
||||
return resp.text();
|
||||
}).then(resp => {
|
||||
v.divFilepreview.innerHTML = resp;
|
||||
}).catch(err => {
|
||||
v.divFilepreview.innerText = "Error loading file: "+err;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
renderSponsors() {
|
||||
let scale = 1;
|
||||
let scaleWidth = 1;
|
||||
let scaleHeight = 1;
|
||||
let minWidth = 728;
|
||||
let minHeight = 800;
|
||||
|
||||
if (window.innerWidth < minWidth) {
|
||||
scaleWidth = window.innerWidth/minWidth;
|
||||
}
|
||||
if (window.innerHeight < minHeight) {
|
||||
scaleHeight = window.innerHeight/minHeight;
|
||||
}
|
||||
scale = scaleWidth < scaleHeight ? scaleWidth : scaleHeight;
|
||||
|
||||
// Because of the scale transformation the automatic margins don't work
|
||||
// anymore. So we have to maunally calculate the margin. Where we take the
|
||||
// width of the viewport - the width of the ad to calculate the amount of
|
||||
// pixels around the ad. We multiply the ad size by the scale we calcualted
|
||||
// to account for the smaller size.
|
||||
let offset = (window.innerWidth - (minWidth*scale)) / 2
|
||||
if (offset < 0) {
|
||||
offset = 0
|
||||
}
|
||||
document.querySelector(".sponsors > iframe").style.marginLeft = offset+"px";
|
||||
|
||||
if (scale == 1) {
|
||||
document.querySelector(".sponsors > iframe").style.transform = "none";
|
||||
document.querySelector(".sponsors").style.height = "90px";
|
||||
} else {
|
||||
document.querySelector(".sponsors > iframe").style.transform = "scale("+scale+")";
|
||||
document.querySelector(".sponsors").style.height = (scale*90)+"px";
|
||||
}
|
||||
}
|
||||
|
||||
keyboardEvent(evt) {let v = this;
|
||||
if (evt.ctrlKey || evt.altKey) {
|
||||
return // prevent custom shortcuts from interfering with system shortcuts
|
||||
}
|
||||
|
||||
switch (evt.which) {
|
||||
case 65: // A or left arrow key go to previous file
|
||||
case 37:
|
||||
if (v.listNavigator != null) {
|
||||
v.listNavigator.previousItem();
|
||||
}
|
||||
break;
|
||||
case 68: // D or right arrow key go to next file
|
||||
case 39:
|
||||
if (v.listNavigator != null) {
|
||||
v.listNavigator.nextItem();
|
||||
}
|
||||
break;
|
||||
case 83:
|
||||
if (evt.shiftKey) {
|
||||
v.toolbar.downloadList(); // SHIFT + S downloads all files in list
|
||||
} else {
|
||||
v.toolbar.download(); // S to download the current file
|
||||
}
|
||||
break;
|
||||
case 82: // R to toggle list shuffle
|
||||
if (v.listNavigator != null) {
|
||||
v.listNavigator.toggleShuffle();
|
||||
}
|
||||
break;
|
||||
case 67: // C to copy to clipboard
|
||||
v.toolbar.copyUrl();
|
||||
break;
|
||||
case 73: // I to open the details window
|
||||
v.detailsWindow.toggle();
|
||||
break;
|
||||
case 81: // Q to close the window
|
||||
window.close();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Against XSS attacks
|
||||
function escapeHTML(str) {
|
||||
return String(str)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"');
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
class AudioViewer {
|
||||
viewer = null;
|
||||
file = null;
|
||||
next = null;
|
||||
|
||||
container = null;
|
||||
icon = null;
|
||||
element = null;
|
||||
source = null;
|
||||
|
||||
constructor(viewer, file, next) {let av = this;
|
||||
av.viewer = viewer;
|
||||
av.file = file;
|
||||
av.next = next;
|
||||
|
||||
av.container = document.createElement("div");
|
||||
av.container.classList = "image-container";
|
||||
av.container.appendChild(document.createElement("br"));
|
||||
|
||||
av.icon = document.createElement("img");
|
||||
av.icon.src = "/res/img/mime/audio.png";
|
||||
av.container.appendChild(av.icon);
|
||||
|
||||
av.container.appendChild(document.createElement("br"));
|
||||
av.container.appendChild(document.createTextNode(file.name));
|
||||
av.container.appendChild(document.createElement("br"));
|
||||
av.container.appendChild(document.createElement("br"));
|
||||
|
||||
av.element = document.createElement("audio");
|
||||
av.element.autoplay = "autoplay";
|
||||
av.element.controls = "controls";
|
||||
av.element.style.width = "90%";
|
||||
av.element.addEventListener("ended", () => { av.next(); }, false);
|
||||
|
||||
av.source = document.createElement("source");
|
||||
av.source.src = apiEndpoint+"/file/"+av.file.id;
|
||||
av.element.appendChild(av.source);
|
||||
av.container.appendChild(av.element);
|
||||
}
|
||||
|
||||
render(parent) {let av = this;
|
||||
parent.appendChild(av.container);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
class ImageViewer {
|
||||
viewer = null;
|
||||
file = null;
|
||||
|
||||
imgContainer = null;
|
||||
imgElement = null;
|
||||
|
||||
zoomed = false;
|
||||
x = 0;
|
||||
y = 0;
|
||||
dragging = false;
|
||||
|
||||
constructor(viewer, file) {let iv = this;
|
||||
iv.viewer = viewer;
|
||||
iv.file = file;
|
||||
|
||||
iv.imgContainer = document.createElement("div");
|
||||
iv.imgContainer.classList = "image-container";
|
||||
|
||||
iv.imgElement = document.createElement("img");
|
||||
iv.imgElement.classList = "pannable drop-shadow";
|
||||
iv.imgElement.src = apiEndpoint+"/file/"+iv.file.id;
|
||||
iv.imgElement.addEventListener("mousedown", (e) => { return iv.mousedown(e); });
|
||||
iv.imgElement.addEventListener("dblclick", (e) => { return iv.doubleclick(e); });
|
||||
iv.imgElement.addEventListener("doubletap", (e) => { return iv.doubleclick(e); });
|
||||
document.addEventListener("mousemove", (e) => { return iv.mousemove(e); });
|
||||
document.addEventListener("mouseup", (e) => { return iv.mouseup(e); });
|
||||
|
||||
iv.imgContainer.appendChild(iv.imgElement);
|
||||
}
|
||||
|
||||
render(parent) {let iv = this;
|
||||
parent.appendChild(iv.imgContainer);
|
||||
}
|
||||
|
||||
doubleclick(e) {let iv = this;
|
||||
if (iv.zoomed) {
|
||||
iv.imgElement.style.maxWidth = "100%";
|
||||
iv.imgElement.style.maxHeight = "100%";
|
||||
iv.imgElement.style.top = "50%";
|
||||
iv.imgElement.style.left = "auto";
|
||||
iv.imgElement.style.transform = "translateY(-50%)";
|
||||
iv.imgContainer.style.overflow = "hidden";
|
||||
iv.zoomed = false;
|
||||
} else {
|
||||
iv.imgElement.style.maxWidth = "none";
|
||||
iv.imgElement.style.maxHeight = "none";
|
||||
iv.imgElement.style.top = "0";
|
||||
iv.imgElement.style.left = "";
|
||||
iv.imgElement.style.transform = "none";
|
||||
iv.imgContainer.style.overflow = "scroll";
|
||||
iv.zoomed = true;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
|
||||
mousedown(e) {let iv = this;
|
||||
if (!iv.dragging && e.which === 1 && iv.zoomed) {
|
||||
iv.x = e.pageX;
|
||||
iv.y = e.pageY;
|
||||
iv.dragging = true;
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
mousemove(e) {let iv = this;
|
||||
if (iv.dragging) {
|
||||
iv.imgContainer.scrollLeft = iv.imgContainer.scrollLeft - (e.pageX - iv.x);
|
||||
iv.imgContainer.scrollTop = iv.imgContainer.scrollTop - (e.pageY - iv.y);
|
||||
|
||||
iv.x = e.pageX;
|
||||
iv.y = e.pageY;
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
mouseup(e) {let iv = this;
|
||||
if (iv.dragging) {
|
||||
iv.dragging = false;
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// var zoomed = false;
|
||||
// // When a user clicks the image
|
||||
// $("#displayImg").on("dblclick doubletap", function (event) {
|
||||
// if (zoomed) {
|
||||
// $("#displayImg").css("max-width", "100%");
|
||||
// $("#displayImg").css("max-height", "100%");
|
||||
// $("#displayImg").css("top", "50%");
|
||||
// $("#displayImg").css("left", "auto");
|
||||
// $("#displayImg").css("transform", "translateY(-50%)");
|
||||
// $(".image-container").css("overflow", "hidden");
|
||||
// zoomed = false;
|
||||
// } else {
|
||||
// $("#displayImg").css("max-width", "none");
|
||||
// $("#displayImg").css("max-height", "none");
|
||||
// $("#displayImg").css("transform", "none");
|
||||
// $(".pannable").css("top", "0");
|
||||
// $(".image-container").css("overflow", "scroll");
|
||||
// zoomed = true;
|
||||
// }
|
||||
|
||||
|
||||
// return false;
|
||||
// });
|
||||
|
||||
// Image dragging around the screen
|
||||
|
||||
// var drag = {
|
||||
// x: 0,
|
||||
// y: 0,
|
||||
// state: false
|
||||
// };
|
||||
|
||||
// $(".pannable").on("mousedown", function (e) {
|
||||
// if (!drag.state && e.which === 1 && zoomed) {
|
||||
// drag.x = e.pageX;
|
||||
// drag.y = e.pageY;
|
||||
// drag.state = true;
|
||||
|
||||
// return false;
|
||||
// }
|
||||
// });
|
||||
|
||||
// var img = $(".image-container");
|
||||
|
||||
// $(document).on("mousemove", function (e) {
|
||||
// if (drag.state) {
|
||||
// img.scrollLeft(img.scrollLeft() - (e.pageX - drag.x));
|
||||
// img.scrollTop(img.scrollTop() - (e.pageY - drag.y));
|
||||
|
||||
// drag.x = e.pageX;
|
||||
// drag.y = e.pageY;
|
||||
// }
|
||||
// });
|
||||
|
||||
// $(document).on("mouseup", function () {
|
||||
// if (drag.state) {
|
||||
// drag.state = false;
|
||||
// }
|
||||
// });
|
||||
@@ -0,0 +1,34 @@
|
||||
class VideoViewer {
|
||||
viewer = null;
|
||||
file = null;
|
||||
next = null;
|
||||
|
||||
vidContainer = null;
|
||||
vidElement = null;
|
||||
videoSource = null;
|
||||
|
||||
constructor(viewer, file, next) {let vv = this;
|
||||
vv.viewer = viewer;
|
||||
vv.file = file;
|
||||
vv.next = next;
|
||||
|
||||
vv.vidContainer = document.createElement("div");
|
||||
vv.vidContainer.classList = "image-container";
|
||||
|
||||
vv.vidElement = document.createElement("video");
|
||||
vv.vidElement.autoplay = "autoplay";
|
||||
vv.vidElement.controls = "controls";
|
||||
vv.vidElement.classList = "center drop-shadow";
|
||||
vv.vidElement.addEventListener("ended", () => { vv.next(); }, false);
|
||||
|
||||
vv.videoSource = document.createElement("source");
|
||||
vv.videoSource.src = apiEndpoint+"/file/"+vv.file.id;
|
||||
|
||||
vv.vidElement.appendChild(vv.videoSource);
|
||||
vv.vidContainer.appendChild(vv.vidElement);
|
||||
}
|
||||
|
||||
render(parent) {let vv = this;
|
||||
parent.appendChild(vv.vidContainer);
|
||||
}
|
||||
}
|
||||
@@ -178,22 +178,6 @@ function copyLink() {
|
||||
}
|
||||
}
|
||||
|
||||
function copyText(text) {
|
||||
// Create a textarea to copy the text from
|
||||
let ta = document.createElement("textarea");
|
||||
ta.setAttribute("readonly", "readonly")
|
||||
ta.style.position = "absolute";
|
||||
ta.style.left = "-9999px";
|
||||
ta.value = text; // Put the text in the textarea
|
||||
|
||||
// Add the textarea to the DOM so it can be seleted by the user
|
||||
document.body.appendChild(ta);
|
||||
ta.select() // Select the contents of the textarea
|
||||
let success = document.execCommand("copy"); // Copy the selected text
|
||||
document.body.removeChild(ta); // Remove the textarea
|
||||
return success;
|
||||
}
|
||||
|
||||
/*
|
||||
* Upload Handlers
|
||||
*/
|
||||
@@ -344,6 +328,32 @@ btnCopyBBCode.addEventListener("click", function(){
|
||||
}
|
||||
});
|
||||
|
||||
let btnCopyMarkdown = document.getElementById("btn_copy_markdown");
|
||||
btnCopyMarkdown.addEventListener("click", function(){
|
||||
let text = "";
|
||||
let uploads = uploader.finishedUploads();
|
||||
|
||||
// Add the text to the textarea
|
||||
for (let i = 0; i < uploads.length; i++) {
|
||||
// Example: * [Some_file.png](https://pixeldrain.com/u/abcd1234)
|
||||
|
||||
if (uploads.length > 1) { text += " * "; }
|
||||
text += "["+uploads[i].fileName+"]("+domainURL()+"/u/"+uploads[i].fileID+")\n";
|
||||
}
|
||||
if (shareLink.includes("/l/")) {
|
||||
text += " * [All "+uploads.length+" files]("+shareLink+")\n";
|
||||
}
|
||||
|
||||
// Copy the selected text
|
||||
if(copyText(text)){
|
||||
btnCopyMarkdown.classList.add("button_highlight");
|
||||
btnCopyMarkdown.innerHTML = "Markdown copied to clipboard!"
|
||||
}else{
|
||||
btnCopyMarkdown.classList.add("button_red");
|
||||
btnCopyMarkdown.innerHTML = "Copying links failed"
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
* Keyboard shortcuts
|
||||
|
||||
@@ -347,6 +347,7 @@ pre{
|
||||
white-space: normal;
|
||||
text-overflow: ellipsis;
|
||||
vertical-align: top;
|
||||
cursor: pointer;
|
||||
}
|
||||
.file_button:hover,
|
||||
.file_button_selected {
|
||||
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
/*! jQuery v2.1.4 | (c) 2005, 2015 jQuery Foundation, Inc. | jquery.org/license */
|
||||
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.4",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!n.isArray(a)&&a-parseFloat(a)+1>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=l.createElement("script"),b.text=a,l.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:k}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b="length"in a&&a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N=M.replace("w","w#"),O="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+N+"))|)"+L+"*\\]",P=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+O+")*)|.*)\\)|)",Q=new RegExp(L+"+","g"),R=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),S=new RegExp("^"+Line truncated
|
||||
return M.access(a,b,c)},removeData:function(a,b){M.remove(a,b)},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=n.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||n.isArray(c)?d=L.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:n.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?n.queue(this[0],a):void 0===b?this:this.each(function(){var c=n.queue(this,a,b);n._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&n.dequeue(this,a)})},dequeue:function(a){return this.each(function(){n.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=n.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=L.get(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var Q=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,R=["Top","Right","Bottom","Left"],S=function(a,b){return a=b||a,"none"===n.css(a,"display")||!n.contains(a.ownerDocument,a)},T=/^(?:checkbox|radio)$/i;!function(){var a=l.createDocumentFragment(),b=a.appendChild(l.createElement("div")),c=l.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild(c),k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";k.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|pointer|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return l.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,m,o,p=[d||l],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||l,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+n.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3Line truncated
|
||||
void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void n.removeAttr(a,b))},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=n.propFix[c]||c,n.expr.match.bool.test(c)&&(a[d]=!1),a.removeAttribute(c)},attrHooks:{type:{set:function(a,b){if(!k.radioValue&&"radio"===b&&n.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),Za={set:function(a,b,c){return b===!1?n.removeAttr(a,c):a.setAttribute(c,c),c}},n.each(n.expr.match.bool.source.match(/\w+/g),function(a,b){var c=$a[b]||n.find.attr;$a[b]=function(a,b,d){var e,f;return d||(f=$a[b],$a[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,$a[b]=f),e}});var _a=/^(?:input|select|textarea|button)$/i;n.fn.extend({prop:function(a,b){return J(this,n.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[n.propFix[a]||a]})}}),n.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!n.isXMLDoc(a),f&&(b=n.propFix[b]||b,e=n.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){return a.hasAttribute("tabindex")||_a.test(a.nodeName)||a.href?a.tabIndex:-1}}}}),k.optSelected||(n.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null}}),n.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){n.propFix[this.toLowerCase()]=this});var ab=/[\t\r\n\f]/g;n.fn.extend({addClass:function(a){var b,c,d,e,f,g,h="string"==typeof a&&a,i=0,j=this.length;if(n.isFunction(a))return this.each(function(b){n(this).addClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ab," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=n.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0===arguments.length||"string"==typeof a&&a,i=0,j=this.length;if(n.isFunction(a))return this.each(function(b){n(this).removeClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ab," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?n.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(n.isFunction(a)?function(c){n(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=n(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===U||"boolean"===c)&&(this.className&&L.set(this,"__className__",this.className),this.className=this.className||a===!1?"":L.get(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(ab," ").indexOf(b)>=0)return!0;return!1}});var bb=/\r/g;n.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=n.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,n(this).val()):a,null==e?e="":"number"==typeof e?e+="":n.isArray(e)&&(e=n.map(e,function(a){return null==a?"":a+""})),b=n.valHooks[this.type]||n.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=n.valHooks[e.type]||n.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(bb,""):null==c?"":c)}}}),n.extend({valHooks:{option:{get:function(a){var b=n.find.attr(a,"value");return null!=b?b:n.trim(n.text(a))}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(k.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&n.nodeName(c.parentNode,"optgroup"))){if(b=n(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=n.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=n.inArray(d.value,f)>=0)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),n.each(["radio","checkbox"],function(){n.valHooks[this]={set:function(a,b){return n.isArray(b)?a.checked=n.inArray(n(a).val(),b)>=0:void 0}},k.checkOn||(n.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})}),n.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenLine truncated
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
/*! jQuery v3.2.1 | (c) JS Foundation and other contributors | jquery.org/license */
|
||||
!function(a,b){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){"use strict";var c=[],d=a.document,e=Object.getPrototypeOf,f=c.slice,g=c.concat,h=c.push,i=c.indexOf,j={},k=j.toString,l=j.hasOwnProperty,m=l.toString,n=m.call(Object),o={};function p(a,b){b=b||d;var c=b.createElement("script");c.text=a,b.head.appendChild(c).parentNode.removeChild(c)}var q="3.2.1",r=function(a,b){return new r.fn.init(a,b)},s=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,t=/^-ms-/,u=/-([a-z])/g,v=function(a,b){return b.toUpperCase()};r.fn=r.prototype={jquery:q,constructor:r,length:0,toArray:function(){return f.call(this)},get:function(a){return null==a?f.call(this):a<0?this[a+this.length]:this[a]},pushStack:function(a){var b=r.merge(this.constructor(),a);return b.prevObject=this,b},each:function(a){return r.each(this,a)},map:function(a){return this.pushStack(r.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(f.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(a<0?b:0);return this.pushStack(c>=0&&c<b?[this[c]]:[])},end:function(){return this.prevObject||this.constructor()},push:h,sort:c.sort,splice:c.splice},r.extend=r.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||r.isFunction(g)||(g={}),h===i&&(g=this,h--);h<i;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(r.isPlainObject(d)||(e=Array.isArray(d)))?(e?(e=!1,f=c&&Array.isArray(c)?c:[]):f=c&&r.isPlainObject(c)?c:{},g[b]=r.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},r.extend({expando:"jQuery"+(q+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===r.type(a)},isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){var b=r.type(a);return("number"===b||"string"===b)&&!isNaN(a-parseFloat(a))},isPlainObject:function(a){var b,c;return!(!a||"[object Object]"!==k.call(a))&&(!(b=e(a))||(c=l.call(b,"constructor")&&b.constructor,"function"==typeof c&&m.call(c)===n))},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?j[k.call(a)]||"object":typeof a},globalEval:function(a){p(a)},camelCase:function(a){return a.replace(t,"ms-").replace(u,v)},each:function(a,b){var c,d=0;if(w(a)){for(c=a.length;d<c;d++)if(b.call(a[d],d,a[d])===!1)break}else for(d in a)if(b.call(a[d],d,a[d])===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(s,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(w(Object(a))?r.merge(c,"string"==typeof a?[a]:a):h.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:i.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;d<c;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;f<g;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,e,f=0,h=[];if(w(a))for(d=a.length;f<d;f++)e=b(a[f],f,c),null!=e&&h.push(e);else for(f in a)e=b(a[f],f,c),null!=e&&h.push(e);return g.apply([],h)},guid:1,proxy:function(a,b){var c,d,e;if("string"==typeof b&&(c=a[b],b=a,a=c),r.isFunction(a))return d=f.call(arguments,2),e=function(){return a.apply(b||this,d.concat(f.call(arguments)))},e.guid=a.guid=a.guid||r.guid++,e},now:Date.now,support:o}),"function"==typeof Symbol&&(r.fn[Symbol.iterator]=c[Symbol.iterator]),r.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(a,b){j["[object "+b+"]"]=b.toLowerCase()});function w(a){var b=!!a&&"length"in a&&a.length,c=r.type(a);return"function"!==c&&!r.isWindow(a)&&("array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a)}var x=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=function(a,b){for(var c=0,d=a.length;c<d;c++)if(a[c]===b)return c;return-1},J="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",K="[\\x20\\t\\r\\n\\f]",L="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",M="\\["+K+"*("+L+")(?:"+K+"*([*^$|!~]?=)"+K+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+L+"))|)"+K+"*\\]",N=":("+L+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+M+")*)|.*)\\)|)",O=new RegExp(K+"+","g"),P=new RegExp("^"+K+"+|((?:^|[^\\\\])(?:\\\\.)*)"+K+"+$","g"),Q=new RegExp("^"+K+"*,"+K+"*"),R=new RegExp("^"+K+"*([>+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(N),U=new RegExp("^"+L+"$"),V={IDLine truncated
|
||||
a.removeEventListener("load",S),r.ready()}"complete"===d.readyState||"loading"!==d.readyState&&!d.documentElement.doScroll?a.setTimeout(r.ready):(d.addEventListener("DOMContentLoaded",S),a.addEventListener("load",S));var T=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===r.type(c)){e=!0;for(h in c)T(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,r.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(r(a),c)})),b))for(;h<i;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},U=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function V(){this.expando=r.expando+V.uid++}V.uid=1,V.prototype={cache:function(a){var b=a[this.expando];return b||(b={},U(a)&&(a.nodeType?a[this.expando]=b:Object.defineProperty(a,this.expando,{value:b,configurable:!0}))),b},set:function(a,b,c){var d,e=this.cache(a);if("string"==typeof b)e[r.camelCase(b)]=c;else for(d in b)e[r.camelCase(d)]=b[d];return e},get:function(a,b){return void 0===b?this.cache(a):a[this.expando]&&a[this.expando][r.camelCase(b)]},access:function(a,b,c){return void 0===b||b&&"string"==typeof b&&void 0===c?this.get(a,b):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d=a[this.expando];if(void 0!==d){if(void 0!==b){Array.isArray(b)?b=b.map(r.camelCase):(b=r.camelCase(b),b=b in d?[b]:b.match(L)||[]),c=b.length;while(c--)delete d[b[c]]}(void 0===b||r.isEmptyObject(d))&&(a.nodeType?a[this.expando]=void 0:delete a[this.expando])}},hasData:function(a){var b=a[this.expando];return void 0!==b&&!r.isEmptyObject(b)}};var W=new V,X=new V,Y=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Z=/[A-Z]/g;function $(a){return"true"===a||"false"!==a&&("null"===a?null:a===+a+""?+a:Y.test(a)?JSON.parse(a):a)}function _(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(Z,"-$&").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c=$(c)}catch(e){}X.set(a,b,c)}else c=void 0;return c}r.extend({hasData:function(a){return X.hasData(a)||W.hasData(a)},data:function(a,b,c){return X.access(a,b,c)},removeData:function(a,b){X.remove(a,b)},_data:function(a,b,c){return W.access(a,b,c)},_removeData:function(a,b){W.remove(a,b)}}),r.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=X.get(f),1===f.nodeType&&!W.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=r.camelCase(d.slice(5)),_(f,d,e[d])));W.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){X.set(this,a)}):T(this,function(b){var c;if(f&&void 0===b){if(c=X.get(f,a),void 0!==c)return c;if(c=_(f,a),void 0!==c)return c}else this.each(function(){X.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){X.remove(this,a)})}}),r.extend({queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=W.get(a,b),c&&(!d||Array.isArray(c)?d=W.access(a,b,r.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=r.queue(a,b),d=c.length,e=c.shift(),f=r._queueHooks(a,b),g=function(){r.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return W.get(a,c)||W.access(a,c,{empty:r.Callbacks("once memory").add(function(){W.remove(a,[b+"queue",c])})})}}),r.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?r.queue(this[0],a):void 0===b?this:this.each(function(){var c=r.queue(this,a,b);r._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&r.dequeue(this,a)})},dequeue:function(a){return this.each(function(){r.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=r.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=W.get(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var aa=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,ba=new RegExp("^(?:([+-])=|)("+aa+")([a-z%]*)$","i"),ca=["Top","Right","Bottom","Left"],da=function(a,b){return a=b||a,"none"===a.style.display||""===a.style.display&&r.contains(a.ownerDocument,a)&&"none"===r.css(a,"display")},ea=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};function fa(a,b,c,d){var e,f=1,g=20,h=d?function(){return d.cur()}:function(){return r.css(a,b,"")},i=h(),j=c&&c[3]||(r.cssNumber[b]?"":"px"),k=(r.cssNumber[b]||"px"!==j&&+i)&&ba.exec(r.css(a,b));if(k&&k[3]!==j){j=j||k[3],c=c||[],k=+i||1;do f=f||".5",k/=f,r.style(a,b,k+j);while(f!==(f=h()/i)&&1!==f&&--g)}return c&&(k=+k||+i||0,e=c[1]?k+(c[1]+1)*c[2]:+c[2],d&&(d.unit=j,d.start=k,d.end=e)),e}var ga={};function ha(a){var b,c=a.ownerDocument,d=a.nodeName,e=ga[d];return e?e:(b=c.body.appendChild(c.createElement(d)),e=r.css(b,"display"),b.parentNode.removeChild(b),"none"===e&&(e=Line truncated
|
||||
null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"===b&&B(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}},removeAttr:function(a,b){var c,d=0,e=b&&b.match(L);if(e&&1===a.nodeType)while(c=e[d++])a.removeAttribute(c)}}),lb={set:function(a,b,c){return b===!1?r.removeAttr(a,c):a.setAttribute(c,c),c}},r.each(r.expr.match.bool.source.match(/\w+/g),function(a,b){var c=mb[b]||r.find.attr;mb[b]=function(a,b,d){var e,f,g=b.toLowerCase();return d||(f=mb[g],mb[g]=e,e=null!=c(a,b,d)?g:null,mb[g]=f),e}});var nb=/^(?:input|select|textarea|button)$/i,ob=/^(?:a|area)$/i;r.fn.extend({prop:function(a,b){return T(this,r.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[r.propFix[a]||a]})}}),r.extend({prop:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return 1===f&&r.isXMLDoc(a)||(b=r.propFix[b]||b,e=r.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=r.find.attr(a,"tabindex");return b?parseInt(b,10):nb.test(a.nodeName)||ob.test(a.nodeName)&&a.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),o.optSelected||(r.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null},set:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}}),r.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){r.propFix[this.toLowerCase()]=this});function pb(a){var b=a.match(L)||[];return b.join(" ")}function qb(a){return a.getAttribute&&a.getAttribute("class")||""}r.fn.extend({addClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).addClass(a.call(this,b,qb(this)))});if("string"==typeof a&&a){b=a.match(L)||[];while(c=this[i++])if(e=qb(c),d=1===c.nodeType&&" "+pb(e)+" "){g=0;while(f=b[g++])d.indexOf(" "+f+" ")<0&&(d+=f+" ");h=pb(d),e!==h&&c.setAttribute("class",h)}}return this},removeClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).removeClass(a.call(this,b,qb(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof a&&a){b=a.match(L)||[];while(c=this[i++])if(e=qb(c),d=1===c.nodeType&&" "+pb(e)+" "){g=0;while(f=b[g++])while(d.indexOf(" "+f+" ")>-1)d=d.replace(" "+f+" "," ");h=pb(d),e!==h&&c.setAttribute("class",h)}}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):r.isFunction(a)?this.each(function(c){r(this).toggleClass(a.call(this,c,qb(this),b),b)}):this.each(function(){var b,d,e,f;if("string"===c){d=0,e=r(this),f=a.match(L)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else void 0!==a&&"boolean"!==c||(b=qb(this),b&&W.set(this,"__className__",b),this.setAttribute&&this.setAttribute("class",b||a===!1?"":W.get(this,"__className__")||""))})},hasClass:function(a){var b,c,d=0;b=" "+a+" ";while(c=this[d++])if(1===c.nodeType&&(" "+pb(qb(c))+" ").indexOf(b)>-1)return!0;return!1}});var rb=/\r/g;r.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=r.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,r(this).val()):a,null==e?e="":"number"==typeof e?e+="":Array.isArray(e)&&(e=r.map(e,function(a){return null==a?"":a+""})),b=r.valHooks[this.type]||r.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=r.valHooks[e.type]||r.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(rb,""):null==c?"":c)}}}),r.extend({valHooks:{option:{get:function(a){var b=r.find.attr(a,"value");return null!=b?b:pb(r.text(a))}},select:{get:function(a){var b,c,d,e=a.options,f=a.selectedIndex,g="select-one"===a.type,h=g?null:[],i=g?f+1:e.length;for(d=f<0?i:g?f:0;d<i;d++)if(c=e[d],(c.selected||d===f)&&!c.disabled&&(!c.parentNode.disabled||!B(c.parentNode,"optgroup"))){if(b=r(c).val(),g)return b;h.push(b)}return h},set:function(a,b){var c,d,e=a.options,f=r.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=r.inArray(r.valHooks.option.get(d),f)>-1)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),r.each(["radio","checkbox"],function(){r.valHooks[this]={set:function(a,b){if(Array.isArray(b))return a.checked=r.inArray(r(a).val(),b)>-1}},o.checkOn||(r.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var sb=/^(?:focusinfocus|focusoutblur)$/;r.extend(r.event,{trigger:function(b,c,e,f){var g,h,i,j,k,m,n,o=[e||d],p=l.call(b,"type")?b.type:b,q=l.call(b,"namespace")?b.namespace.split("."):[];if(h=i=e=e||d,3!==e.nodeType&&8!==e.nodeType&&!sb.test(p+r.event.triggered)&&(p.indexOf(".")>-1&&(q=p.split("."),p=q.shift(),q.sort()),k=p.indexOf(":")<0&&"on"+p,b=b[r.expando]?bLine truncated
|
||||
Vendored
-114
@@ -1,114 +0,0 @@
|
||||
/*!
|
||||
* jQuery Cookie Plugin v1.4.1
|
||||
* https://github.com/carhartl/jquery-cookie
|
||||
*
|
||||
* Copyright 2006, 2014 Klaus Hartl
|
||||
* Released under the MIT license
|
||||
*/
|
||||
(function (factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD (Register as an anonymous module)
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node/CommonJS
|
||||
module.exports = factory(require('jquery'));
|
||||
} else {
|
||||
// Browser globals
|
||||
factory(jQuery);
|
||||
}
|
||||
}(function ($) {
|
||||
|
||||
var pluses = /\+/g;
|
||||
|
||||
function encode(s) {
|
||||
return config.raw ? s : encodeURIComponent(s);
|
||||
}
|
||||
|
||||
function decode(s) {
|
||||
return config.raw ? s : decodeURIComponent(s);
|
||||
}
|
||||
|
||||
function stringifyCookieValue(value) {
|
||||
return encode(config.json ? JSON.stringify(value) : String(value));
|
||||
}
|
||||
|
||||
function parseCookieValue(s) {
|
||||
if (s.indexOf('"') === 0) {
|
||||
// This is a quoted cookie as according to RFC2068, unescape...
|
||||
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
|
||||
}
|
||||
|
||||
try {
|
||||
// Replace server-side written pluses with spaces.
|
||||
// If we can't decode the cookie, ignore it, it's unusable.
|
||||
// If we can't parse the cookie, ignore it, it's unusable.
|
||||
s = decodeURIComponent(s.replace(pluses, ' '));
|
||||
return config.json ? JSON.parse(s) : s;
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
function read(s, converter) {
|
||||
var value = config.raw ? s : parseCookieValue(s);
|
||||
return $.isFunction(converter) ? converter(value) : value;
|
||||
}
|
||||
|
||||
var config = $.cookie = function (key, value, options) {
|
||||
|
||||
// Write
|
||||
|
||||
if (arguments.length > 1 && !$.isFunction(value)) {
|
||||
options = $.extend({}, config.defaults, options);
|
||||
|
||||
if (typeof options.expires === 'number') {
|
||||
var days = options.expires, t = options.expires = new Date();
|
||||
t.setMilliseconds(t.getMilliseconds() + days * 864e+5);
|
||||
}
|
||||
|
||||
return (document.cookie = [
|
||||
encode(key), '=', stringifyCookieValue(value),
|
||||
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
||||
options.path ? '; path=' + options.path : '',
|
||||
options.domain ? '; domain=' + options.domain : '',
|
||||
options.secure ? '; secure' : ''
|
||||
].join(''));
|
||||
}
|
||||
|
||||
// Read
|
||||
|
||||
var result = key ? undefined : {},
|
||||
// To prevent the for loop in the first place assign an empty array
|
||||
// in case there are no cookies at all. Also prevents odd result when
|
||||
// calling $.cookie().
|
||||
cookies = document.cookie ? document.cookie.split('; ') : [],
|
||||
i = 0,
|
||||
l = cookies.length;
|
||||
|
||||
for (; i < l; i++) {
|
||||
var parts = cookies[i].split('='),
|
||||
name = decode(parts.shift()),
|
||||
cookie = parts.join('=');
|
||||
|
||||
if (key === name) {
|
||||
// If second argument (value) is a function it's a converter...
|
||||
result = read(cookie, value);
|
||||
break;
|
||||
}
|
||||
|
||||
// Prevent storing a cookie that we couldn't decode.
|
||||
if (!key && (cookie = read(cookie)) !== undefined) {
|
||||
result[name] = cookie;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
config.defaults = {};
|
||||
|
||||
$.removeCookie = function (key, options) {
|
||||
// Must not alter options, thus extending a fresh object...
|
||||
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
|
||||
return !$.cookie(key);
|
||||
};
|
||||
|
||||
}));
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
jquery-3.2.1.min.js
|
||||
@@ -1,79 +0,0 @@
|
||||
// Image zoom-in script
|
||||
|
||||
var zoomed = false;
|
||||
// When a user clicks the image
|
||||
$("#displayImg").on("contextmenu", function (event) {
|
||||
// Trigger on a right click
|
||||
if (event.which === 3) {
|
||||
if (zoomed) {
|
||||
$(".pannable").css("max-width", "100%");
|
||||
$(".pannable").css("max-height", "100%");
|
||||
$(".pannable").css("top", "50%");
|
||||
$(".pannable").css("left", "auto");
|
||||
$(".pannable").css("transform", "translateY(-50%)");
|
||||
zoomed = false;
|
||||
} else {
|
||||
$(".pannable").css("max-width", "none");
|
||||
$(".pannable").css("max-height", "none");
|
||||
$(".pannable").css("transform", "none");
|
||||
$(".pannable").css("top", "0");
|
||||
zoomed = true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Image dragging around the screen
|
||||
// Grabbed this script from stackoverflow, thanks Alexander Mistakidis!
|
||||
// http://stackoverflow.com/questions/22187130/panning-div-element-around-using-javascript
|
||||
// Edited to fit my needs
|
||||
var deltaX = 0;
|
||||
var deltaY = 0;
|
||||
var scale = 1.0;
|
||||
|
||||
var drag = {
|
||||
elem: null,
|
||||
x: 0,
|
||||
y: 0,
|
||||
state: false
|
||||
};
|
||||
var delta = {
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
|
||||
$(".pannable").on("mousedown", function (e) {
|
||||
if (!drag.state && e.which === 1) {
|
||||
drag.elem = $('.pannable');
|
||||
drag.x = e.pageX;
|
||||
drag.y = e.pageY;
|
||||
drag.state = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$(document).on("mousemove", function (e) {
|
||||
if (drag.state) {
|
||||
delta.x = e.pageX - drag.x;
|
||||
delta.y = e.pageY - drag.y;
|
||||
|
||||
var cur_offset = $(drag.elem).offset();
|
||||
|
||||
$(drag.elem).offset({
|
||||
left: (cur_offset.left + delta.x),
|
||||
top: (cur_offset.top + delta.y)
|
||||
});
|
||||
|
||||
drag.x = e.pageX;
|
||||
drag.y = e.pageY;
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("mouseup", function () {
|
||||
if (drag.state) {
|
||||
drag.state = false;
|
||||
}
|
||||
});
|
||||
+14
-11
@@ -26,7 +26,6 @@
|
||||
</div>
|
||||
|
||||
<script src="/res/script/Chart.min.js"></script>
|
||||
<script src="/res/script/jquery.js"></script>
|
||||
<script>
|
||||
var apiEndpoint = '{{.APIEndpoint}}';
|
||||
|
||||
@@ -80,11 +79,11 @@
|
||||
},
|
||||
ticks: {
|
||||
callback: function(value, index, values) {
|
||||
if (value > 1e12) {
|
||||
if (value >= 1e12) {
|
||||
return Math.round(value/1e9)/1e3 + " TB";
|
||||
} else if (value > 1e9) {
|
||||
} else if (value >= 1e9) {
|
||||
return Math.round(value/1e6)/1e3 + " GB";
|
||||
} else if (value > 1e6) {
|
||||
} else if (value >= 1e6) {
|
||||
return Math.round(value/1e3)/1e3 + " MB";
|
||||
}
|
||||
return value/1e3 + " kB";
|
||||
@@ -123,15 +122,19 @@
|
||||
);
|
||||
|
||||
function setData(){
|
||||
$.get(apiEndpoint+"/admin/files/timeseries?days="+days+"&interval="+interval, function(response){
|
||||
console.log(response);
|
||||
if (response.success) {
|
||||
window.graph.data.labels = response.labels;
|
||||
window.graph.data.datasets[0].data = response.downloads;
|
||||
window.graph.data.datasets[1].data = response.views;
|
||||
fetch(apiEndpoint+"/admin/files/timeseries?days="+days+"&interval="+interval).then(resp => {
|
||||
if (!resp.ok) { return Promise.reject("Error: "+resp.status);}
|
||||
return resp.json();
|
||||
}).then(resp => {
|
||||
if (resp.success) {
|
||||
window.graph.data.labels = resp.labels;
|
||||
window.graph.data.datasets[0].data = resp.downloads;
|
||||
window.graph.data.datasets[1].data = resp.views;
|
||||
window.graph.update();
|
||||
}
|
||||
});
|
||||
}).catch(e => {
|
||||
alert("Error requesting time series: "+e);
|
||||
})
|
||||
}
|
||||
|
||||
setData();
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<body>
|
||||
<div id="file_viewer" class="file_viewer">
|
||||
<div id="file_viewer_headerbar" class="highlight_1 file_viewer_headerbar">
|
||||
<button id="button_toggle_toolbar" class="button_toggle_toolbar" onClick="Toolbar.toggle();">☰</button>
|
||||
<button id="btn_toggle_toolbar" class="button_toggle_toolbar">☰</button>
|
||||
<a href="/" id="button_home" class="button button_home">
|
||||
<img src="{{template `pixeldrain_icon.png`}}"
|
||||
alt="Back to the Home page"
|
||||
@@ -32,7 +32,7 @@
|
||||
<div id="file_viewer_list_title"></div>
|
||||
<div id="file_viewer_file_title">{{.Title}}</div>
|
||||
</div>
|
||||
<button id="button_close_file_viewer" class="button_close_file_viewer button_red" onClick="window.close();">{{template `close.svg` .}}</button>
|
||||
<button id="button_close_file_viewer" class="button_close_file_viewer button_red" onclick="window.close();">{{template `close.svg` .}}</button>
|
||||
</div>
|
||||
<div id="list_navigator" class="list_navigator"></div>
|
||||
<div id="file_viewer_window" class="file_viewer_window">
|
||||
@@ -42,27 +42,27 @@
|
||||
<div id="stat_downloads_label" class="toolbar_label">Downloads</div>
|
||||
<div id="stat_downloads" style="text-align: center;">N/A</div>
|
||||
|
||||
<button id="btnDownload" class="toolbar_button button_full_width" onClick="Toolbar.download();">
|
||||
<button id="btn_download" class="toolbar_button button_full_width">
|
||||
{{template `save.svg` .}}
|
||||
<span>Download</span>
|
||||
</button>
|
||||
<button id="btnDownloadList" class="toolbar_button button_full_width" style="display: none" onClick="Toolbar.downloadList()">
|
||||
<button id="btn_download_list" class="toolbar_button button_full_width" style="display: none">
|
||||
{{template `save.svg` .}}
|
||||
<span>DL all files</span>
|
||||
</button>
|
||||
<button id="btnCopy" class="toolbar_button button_full_width" onClick="Toolbar.copyUrl();">
|
||||
<button id="btn_copy" class="toolbar_button button_full_width">
|
||||
{{template `copy.svg` .}}
|
||||
<span><u>C</u>opy Link</span>
|
||||
</button>
|
||||
<button id="btnShare" class="toolbar_button button_full_width" onClick="Sharebar.toggle();">
|
||||
<button id="btn_share" class="toolbar_button button_full_width">
|
||||
{{template `share.svg` .}}
|
||||
<span>Share</span>
|
||||
</button>
|
||||
<button id="btnShuffle" class="toolbar_button button_full_width" style="display: none" onClick="ListNavigator.toggleShuffle();">
|
||||
<button id="btn_shuffle" class="toolbar_button button_full_width" style="display: none">
|
||||
{{template `shuffle.svg` .}}
|
||||
<span>Shuffle ☐</span>
|
||||
</button>
|
||||
<button id="btnDetails" class="toolbar_button button_full_width" onClick="DetailsWindow.toggle();">
|
||||
<button id="btn_details" class="toolbar_button button_full_width">
|
||||
{{template `help.svg` .}}
|
||||
<span>Deta<u>i</u>ls</span>
|
||||
</button>
|
||||
@@ -109,7 +109,7 @@
|
||||
<div id="details_popup" class="popup details_popup">
|
||||
<div id="details_popup_title" class="highlight_1">
|
||||
File Info
|
||||
<button style="position: absolute; top: 3px; right: 3px;" class="button_red" onclick="DetailsWindow.toggle();">{{template `close.svg` .}}</button>
|
||||
<button id="btn_close_details" style="position: absolute; top: 3px; right: 3px;" class="button_red">{{template `close.svg` .}}</button>
|
||||
</div>
|
||||
<div class="content_area">
|
||||
<div id="info_file_details"></div>
|
||||
@@ -150,19 +150,24 @@
|
||||
</div>
|
||||
|
||||
<script src="/res/script/Chart.min.js"></script>
|
||||
<script src="/res/script/jquery.js"></script>
|
||||
<script>
|
||||
var apiEndpoint = '{{.APIEndpoint}}';
|
||||
var captchaKey = '{{.Other.CaptchaKey}}';
|
||||
|
||||
{{template `util.js`}}
|
||||
{{template `Toolbar.js`}}
|
||||
{{template `Viewer.js`}}
|
||||
{{template `DetailsWindow.js`}}
|
||||
{{template `ListNavigator.js`}}
|
||||
{{template `Viewer.js`}}
|
||||
|
||||
{{template `ImageViewer.js`}}
|
||||
{{template `VideoViewer.js`}}
|
||||
{{template `AudioViewer.js`}}
|
||||
|
||||
// This info gets filled in on the server side to prevent having to make an API call right after the page loads.
|
||||
// Just to slice another few milliseconds from the load time :)
|
||||
window.addEventListener("load", function(){
|
||||
Viewer.init('{{.Other.Type}}', {{.Other.APIResponse}});
|
||||
new Viewer('{{.Other.Type}}', {{.Other.APIResponse}});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -106,6 +106,7 @@
|
||||
<br/>
|
||||
<button id="btn_create_list">Create list with uploaded files</button>
|
||||
<button id="btn_copy_links">Copy all links to clipboard</button>
|
||||
<button id="btn_copy_markdown">Copy markdown to clipboard</button>
|
||||
<button id="btn_copy_bbcode">Copy BBCode to clipboard</button>
|
||||
<br/>
|
||||
<div id="created_lists"></div>
|
||||
|
||||
Reference in new issue
Block a user