diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-11-22 23:19:36 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-11-22 23:19:36 -0500 |
| commit | 070b5e6d9d3c7e23c06f0ae0b75026923529c24d (patch) | |
| tree | 89c430dd17ca54ff60f885ecd99cf6cfa0f0b7ff /js/image.js | |
| parent | 04537ed34d443d0610b77420d1dbef64bc05fbfa (diff) | |
| parent | 1631cdf643283fc71bc9d70b5dcbce03ab9c2386 (diff) | |
Merge branch 'master' of lmno:dither
Diffstat (limited to 'js/image.js')
| -rw-r--r-- | js/image.js | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/js/image.js b/js/image.js index 7a5240f..9296300 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 + window.gif = window.img = window.cam = null - if (imageURL.substr(-3) === "gif") { + if (! imageURL) { + window.gif = null + window.img = null + callback() + } + else if (imageURL.substr(-3).toLowerCase() === "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 } @@ -57,9 +67,10 @@ function uploadImage(opt){ form.append("username", opt.username); form.append("filename", opt.filename); form.append("qqfile", opt.blob); + form.append("tag", opt.tag); var req = new XMLHttpRequest(); - req.open("POST", "/cgi-bin/im/upload"); + req.open("POST", "/cgi-bin/im/shader/upload"); req.onload = function(event) { if (req.status == 200) { var res = JSON.parse(req.responseText); |
