blob: fc2716665640e77434d0dcacc6ba410fce1e0e22 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
$.fn.int = function(){ return parseInt($(this).val(),10) }
$.fn.float = function(){ return parseFloat($(this).val()) }
function clamp(n,a,b){ return n<a?a:n<b?n:b }
function loadImage(imageURL, callback) {
document.getElementById("save").style.display = "none"
document.getElementById("encode").style.display = "none"
status("loading")
var imageURL = proxify( imageURL );
window.gif = window.img = null
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 {
window.img = new Image();
// img.addEventListener("error", tryToLoadNextImage);
img.addEventListener("load", callback);
img.crossOrigin = "anonymous";
return img.src = imageURL;
}
}
function giveImage() {
if (imageURL.substr(-3) === "gif") {
return gif.frames[gif.currentFrame()].ctx.canvas;
} else {
return img;
}
}
function proxify (url) {
if (url.indexOf("http") == 0)
return "/cgi-bin/proxy?" + url // .replace(/^https?:\/\//, "");
else
return url
};
|