diff options
| author | jules <jules@okfoc.us> | 2014-01-26 01:05:04 -0500 |
|---|---|---|
| committer | jules <jules@okfoc.us> | 2014-01-26 01:05:04 -0500 |
| commit | c0815501d532c9f18cc0941839295ad193cde87a (patch) | |
| tree | 032d4ac92563ae297deb316b680dd31f6688b33f /js | |
| parent | 9f1b5a177eee98f64e7581756cd5fdc7635691ca (diff) | |
make_thumbnail
Diffstat (limited to 'js')
| -rw-r--r-- | js/api/gallery.js | 1 | ||||
| -rw-r--r-- | js/api/set.js | 47 |
2 files changed, 29 insertions, 19 deletions
diff --git a/js/api/gallery.js b/js/api/gallery.js index 92764c6..c1a779d 100644 --- a/js/api/gallery.js +++ b/js/api/gallery.js @@ -40,6 +40,7 @@ shader_gallery.bind = function(){ } function new_shader(){ + shader_id_root = null run_shader({ id: "", shader_id: "", diff --git a/js/api/set.js b/js/api/set.js index 8732c87..3ce0c3a 100644 --- a/js/api/set.js +++ b/js/api/set.js @@ -8,7 +8,7 @@ function save_shader(){ name: $("#shader-name").val() || "", shader_id: shader_id_root } - var blob = dataUriToBlob(cc.clone().resize(200,200).canvas.toDataURL("image/png")) + var thumb = make_thumbnail() status('saving..') console.log(params) @@ -31,24 +31,33 @@ function save_shader(){ $shader = display_shader(params) $("#shader-gallery").prepend($shader) - var form = new FormData(); + save_thumbnail(data.id, thumb) + }) +} - form.append("id", data.id); - form.append("qqfile", blob); - $.ajax({ - url: "http://asdf.us/cgi-bin/im/shader/thumbnail_upload", - type: "POST", - data: form, - processData: false, - contentType: false, - }).done(function(resp){ - console.log(resp); - status('') - var data = JSON.parse(resp) - if (data.success) { - $shader.find("img").attr("src", data.url) - } - }); +function make_thumbnail(){ + return dataUriToBlob(cc.clone().resize(200,200).canvas.toDataURL("image/png")) +} - }) +function save_thumbnail(id, thumb){ + thumb = thumb || make_thumbnail() + + var form = new FormData(); + + form.append("id", data.id); + form.append("qqfile", thumb); + $.ajax({ + url: "http://asdf.us/cgi-bin/im/shader/thumbnail_upload", + type: "POST", + data: form, + processData: false, + contentType: false, + }).done(function(resp){ + console.log(resp); + status('') + var data = JSON.parse(resp) + if (data.success) { + $shader.find("img").attr("src", data.url) + } + }); } |
