summaryrefslogtreecommitdiff
path: root/js/image.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/image.js')
-rw-r--r--js/image.js20
1 files changed, 15 insertions, 5 deletions
diff --git a/js/image.js b/js/image.js
index 7a5240f..9ac1290 100644
--- a/js/image.js
+++ b/js/image.js
@@ -1,20 +1,30 @@
+var gif, img
+var imageURL = null
+
function loadImage(imageURL, callback) {
var imageURL = proxify( imageURL );
+ window.imageURL = imageURL
window.gif = window.img = null
- if (imageURL.substr(-3) === "gif") {
+ if (! imageURL) {
+ window.gif = null
+ window.img = null
+ callback()
+ }
+ else if (imageURL.substr(-3) === "gif") {
window.gif = GIF(imageURL);
// gif.on("error", tryToLoadNextImage);
// gif.on("rendered", trackLoadTime);
gif.on("rendered", callback);
- return gif.render();
- } else {
+ gif.render();
+ }
+ else {
window.img = new Image();
// img.addEventListener("error", tryToLoadNextImage);
img.addEventListener("load", callback);
img.crossOrigin = "anonymous";
- return img.src = imageURL;
+ img.src = imageURL;
}
}
@@ -28,7 +38,7 @@ function giveImage(t) {
function proxify (url) {
if (url.indexOf("http") == 0)
- return "/cgi-bin/proxy?" + url // .replace(/^https?:\/\//, "");
+ return "/cgi-bin/proxy?" + url.replace(/^https/, "http");
else
return url
}