mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-22 16:06:18 +08:00
22 lines
532 B
JavaScript
22 lines
532 B
JavaScript
// By adding unique attribute to image's src,
|
|
// we force browser to reload/update cached image
|
|
function reloadImage(img) {
|
|
var src = $(img).attr("src");
|
|
src = src.split("?", 1);
|
|
src += "?timestamp=" + new Date().getTime();
|
|
$(img).attr("src", src);
|
|
}
|
|
|
|
// Hack for image retrieval after upload (403 is
|
|
// thrown, mostly Chrome issue, and hence image
|
|
// isn't retrieved)
|
|
function reloadImagesHack(imgs) {
|
|
setTimeout(function() {
|
|
if(imgs.length) {
|
|
imgs.each(function() {
|
|
reloadImage($(this));
|
|
});
|
|
}
|
|
}, 1000);
|
|
}
|