Files
fnx_web/res/static/script/history.js

53 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-11-10 12:39:55 +01:00
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",
2017-11-10 12:39:55 +01:00
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) {
2019-12-10 14:47:11 +01:00
if(!json.success){return;}
var date = new Date(json.date_upload);
2017-11-10 12:39:55 +01:00
var uploadItem = '<a href="/u/'+ json.id +'" target="_blank" class="file_button">'
2019-12-10 14:47:11 +01:00
+ '<img src="'+ apiEndpoint + json.thumbnail_href + '?width=80&height=80"'
2018-10-04 23:36:34 +02:00
+ "alt=\"" + json.name + "\" />"
+ '<span style="color: var(--highlight_color);">'+json.name+'</span>'
2017-11-10 12:39:55 +01:00
+ "<br/>"
+ date.getFullYear() + "-"
+ ("00" + (date.getMonth() + 1)).slice(-2) + "-"
+ ("00" + date.getDate()).slice(-2)
+ "</a>";
2017-11-10 12:39:55 +01:00
2019-09-17 23:38:40 +02:00
$("#uploadedFiles").append($(uploadItem).hide().fadeIn(500));
}