summaryrefslogtreecommitdiff
path: root/im/imdither/main.js
diff options
context:
space:
mode:
authoryo mama <pepper@scannerjammer.com>2015-02-13 02:42:02 -0800
committeryo mama <pepper@scannerjammer.com>2015-02-13 02:42:02 -0800
commitfd640b170a64584fd9c295be53c91972ff9f9ec1 (patch)
treec67e95b332e183bbf14065bba55dd77e86a71fbe /im/imdither/main.js
parent64f41d53728a966f10aef6d7ffbc00853d754300 (diff)
fixed some basics
Diffstat (limited to 'im/imdither/main.js')
-rwxr-xr-xim/imdither/main.js114
1 files changed, 114 insertions, 0 deletions
diff --git a/im/imdither/main.js b/im/imdither/main.js
new file mode 100755
index 0000000..5b1990d
--- /dev/null
+++ b/im/imdither/main.js
@@ -0,0 +1,114 @@
+var Main =
+ {
+ firsttime: true,
+ generating: false,
+ thelast: "",
+ enter: function (e)
+ {
+ if (Main.generating)
+ return
+ if (e.keyCode === 13)
+ Main.go()
+ },
+ go: function ()
+ {
+ if (Main.generating)
+ return
+ Main.generating = true
+ var theloader = '<span style="width:100%;margin-right:40%"><img style="width:140px;height:120px;display:inline;" src="generating.gif"></img></span>'
+ $("#output-cmd").html(theloader).show()
+ $('.result').show()
+ $('.results').show()
+ $("#output-img").show()
+ $("#output-url").show()
+ $("#result").show()
+ var data =
+ {
+ breakmode:$('input:radio[name=modeswitch]:checked').val(),
+ breaktype: $('#breaktype :selected').val(),
+ breakangle: $("#breakangle").val(),
+ url: $('#url').val(),
+ username: $('#username').val(),
+ firsttime: Main.firsttime.toString()
+ }
+ if (data["breakmode"] == "gradual")
+ {
+ data["breakmode"] = "subtle"
+ if (Main.lines && Main.thelast == $('#url').val())
+ {
+ Main.firsttime = false
+ data["url"] = Main.lines[1]
+ }
+ }
+ else
+ {
+ Main.firsttime = true
+ }
+ Main.thelast = $('#url').val();
+ thestring = JSON.stringify(data);
+ $('#error').append(thestring);
+ if (data.username.length > 0)
+ document.cookie = "imname="+data.username+";path=/;domain=.asdf.us;max-age=1086400"
+ $.post("/cgi-bin/im/break/breaker", data, Main.callback)
+ },
+ error: function (s)
+ {
+ $("#output-cmd").html("<span class='error'>ERROR: " + s + "</span>").show()
+ $("#output-url").hide()
+ $("#output-img").hide()
+ },
+ filesize: function (size)
+ {
+ if (size < 1024)
+ return size.toString() + " bytes"
+ if (size < 1024 * 1024)
+ return Math.floor (size/1024).toString() + " KB"
+ else
+ return Math.floor (size/(1024*1024)).toString() + " MB"
+ },
+ callback: function (raw)
+ {
+ $('#error').append('called');
+ $("#output-cmd").html('')
+ Main.lines = raw.split('\n')
+ Main.lines = Main.lines.reverse()
+ $('#output-url').val(Main.lines[1])
+ $("#output-img").html("click image to enlarge<br><a target=_blank href='"+Main.lines[1]+"'>"+"<img src='"+Main.lines[1]+"' id='output-image'></img><br>"+"</a>"
+);
+ $("#output-info").html('-ACTUAL SIZE-<br>'+Main.filesize(Main.lines[4])+'<br>'+Main.lines[2]+'<br>'+Main.lines[3]+'<br><br>'+'<span>see more at &rarr;<a href="http://asdf.us/im/gallery">photoblaster gallery</a></span>'+'<br>')
+ Main.generating = false
+ },
+ cookie: function ()
+ {
+ if (document.cookie)
+ {
+ var cookies = document.cookie.split(";")
+ for (i in cookies)
+ {
+ var cookie = cookies[i].split("=")
+ if (cookie[0].indexOf("imname") !== -1)
+ {
+ if (cookie[1] !== 'false' && cookie[1] !== 'undefined' && cookie[1].length)
+ {
+ return cookie[1]
+ }
+ }
+ }
+ }
+ return ""
+ },
+ init: function ()
+ {
+ var name = Main.cookie ()
+ $("#username").val(name)
+ $("#breakbutton").bind("click", Main.go)
+ $(document).bind("keydown", Main.enter)
+ }
+ }
+//$('#theform').each(function(){
+// this.reset();
+// });
+
+
+
+Main.init ()