summaryrefslogtreecommitdiff
path: root/share/frontend/imgradient/js/main.js
diff options
context:
space:
mode:
authorPepper <pepper@scannerjammer.com>2016-10-08 04:52:44 -0400
committerPepper <pepper@scannerjammer.com>2016-10-08 04:52:44 -0400
commitbc44ea348c682f7cefcbb5302d1d5f43af80371b (patch)
treee2ad5f7f337dec4bb674f875bba7cda9fc46b055 /share/frontend/imgradient/js/main.js
parent87f62e156572adf0e90b9cce781f581d95998255 (diff)
ok cool
Diffstat (limited to 'share/frontend/imgradient/js/main.js')
-rw-r--r--share/frontend/imgradient/js/main.js33
1 files changed, 31 insertions, 2 deletions
diff --git a/share/frontend/imgradient/js/main.js b/share/frontend/imgradient/js/main.js
index 1862de3..a81c6ac 100644
--- a/share/frontend/imgradient/js/main.js
+++ b/share/frontend/imgradient/js/main.js
@@ -87,20 +87,44 @@ var Main =
if (data.name.length > 0){
document.cookie = "imname="+data.name+";path=/;domain=.asdf.us;max-age=1086400"
}
- $.post("/im/api/imgradient", data, Main.callback)
+ $.ajax({
+ url: '/im/api/imgradient',
+ type: 'post',
+ dataType: 'json',
+ data: data,
+ success: function(data){ Main.callback(data) },
+ error: function(data){
+ switch(data.status){
+ case 500:
+ Main.error("Problem with server")
+ console.log(data)
+ break;
+ case 410:
+ Main.error(JSON.parse(data.responseText).message)
+ break;
+ default:
+ Main.error("Something went wrong")
+ console.log(data)
+ }
+ Main.generating = false
+ }
+ });
$("#controls").css('margin',"")
},
error: function (s)
{
$("#output-cmd").html("<span class='error'>ERROR: " + s + "</span>").show()
+ $("#result-arrow").hide()
$("#output-url").hide()
$("#output-img").hide()
},
callback: function (data)
{
+ console.log(data)
if (data.error){
return Main.error(data.error)
}
+ $("#result-arrow").show()
$("#output-cmd").html("size: "+Main.filesize(data.size)+"<br/>"+data.height + "&nbsp;x&nbsp;" + data.width)
$("#output-url").val(data.url)
$("#output-img").hide().attr("src", data.url).fadeIn(700)
@@ -145,7 +169,12 @@ $(document).ready(function(){
$('form').submit(function() {
return false;
});
- $(document).keydown(Main.enter)
+ $("#colorswitcheroo").click(function() {
+ a = $("#img-color1").val();
+ b = $("#img-color2").val();
+ $("#img-color1").val(b);
+ $("#img-color2").val(a);
+ });
$("#img-generate").click(Main.go)
document.getElementById("reset").reset()
})