Embed resources into templates
This commit is contained in:
52
res/include/script/history.js
Normal file
52
res/include/script/history.js
Normal file
@@ -0,0 +1,52 @@
|
||||
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));
|
||||
}
|
Reference in New Issue
Block a user