summaryrefslogtreecommitdiff
path: root/js/image.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-11-22 23:19:36 -0500
committerJules Laplace <jules@okfoc.us>2014-11-22 23:19:36 -0500
commit070b5e6d9d3c7e23c06f0ae0b75026923529c24d (patch)
tree89c430dd17ca54ff60f885ecd99cf6cfa0f0b7ff /js/image.js
parent04537ed34d443d0610b77420d1dbef64bc05fbfa (diff)
parent1631cdf643283fc71bc9d70b5dcbce03ab9c2386 (diff)
Merge branch 'master' of lmno:dither
Diffstat (limited to 'js/image.js')
-rw-r--r--js/image.js25
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);