remove typescript

This commit is contained in:
2020-01-20 12:43:43 +01:00
parent 47b8a4c900
commit 129d6915d2
32 changed files with 751 additions and 15929 deletions

View File

@@ -1,52 +1,55 @@
var uploads;
$(document).ready(function () {
var uploadString = $.cookie("pduploads");
uploadString = uploadString.slice(0, -1);
uploads = uploadString.split(".");
uploads.reverse();
var timeout = 250;
var itemcount = 0;
$.each(uploads, function (nr, id) {
setTimeout(function () {
$.ajax({
type: "GET",
dataType: "json",
url: apiEndpoint + "/file/" + id + "/info",
async: true,
success: function(data) {
historyAddItem(data);
},
error: function(data) {
historyAddItem(data.responseJSON);
}
});
}, timeout);
timeout = timeout + 100;
itemcount++;
if (itemcount > 1000) {
return false;
}
});
});
function historyAddItem(json) {
if(!json.success){return;}
var date = new Date(json.date_upload);
var uploadItem = '<a href="/u/'+ json.id +'" target="_blank" class="file_button">'
+ '<img src="'+ apiEndpoint + json.thumbnail_href + '?width=80&height=80"'
+ "alt=\"" + json.name + "\" />"
+ '<span style="color: var(--highlight_color);">'+json.name+'</span>'
+ "<br/>"
+ date.getFullYear() + "-"
+ ("00" + (date.getMonth() + 1)).slice(-2) + "-"
+ ("00" + date.getDate()).slice(-2)
+ "</a>";
$("#uploadedFiles").append($(uploadItem).hide().fadeIn(500));
function getCookie(name) {
var result = new RegExp('(?:^|; )' + encodeURIComponent(name) + '=([^;]*)').exec(document.cookie);
return result ? result[1] : null;
}
// Get the uploads from localstorage
let uploadsStr = localStorage.getItem("uploaded_files");
if (uploadsStr === null) { uploadsStr = ""; }
let uploads = Array();
if (uploadsStr != "") {
uploadsStr = uploadsStr.slice(0, -1); // Strip the trailing comma
uploads = uploadsStr.split(",");
}
// Get the uploads from a cookie
uploadsStr = getCookie("pduploads");
if (uploadsStr === null) { uploadsStr = ""; }
if (uploadsStr != "") {
uploadsStr = uploadsStr.slice(0, -1); // Strip the trailing dot
uploads.push(uploadsStr.split(".").reverse());
}
// Render all the items
function getHistoryItem() {
let item = uploads.shift();
if (item === undefined || item === "") { return; }
fetch(
apiEndpoint+"/file/"+item+"/info"
).then(resp => {
if (!resp.ok) {
return Promise.reject();
}
return resp.json();
}).then(resp => {
let date = new Date(resp.date_upload);
document.getElementById("uploaded_files").appendChild(
renderFileButton(
apiEndpoint,
resp.id,
resp.name,
date.getFullYear()+"-"+("00"+(date.getMonth()+1)).slice(-2)+"-"+("00"+date.getDate()).slice(-2)
)
);
getHistoryItem();
}).catch(err => {
console.log("Fetch failed: "+err)
getHistoryItem();
})
}
getHistoryItem();