From 8829a743db3ec88182f3034d077971ba5c2a5cbf Mon Sep 17 00:00:00 2001 From: jules Date: Sun, 29 Dec 2013 18:26:12 -0500 Subject: dither picker --- js/gallery.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 js/gallery.js (limited to 'js/gallery.js') diff --git a/js/gallery.js b/js/gallery.js new file mode 100644 index 0000000..9b2372d --- /dev/null +++ b/js/gallery.js @@ -0,0 +1,33 @@ +// +// gallery .. the most basic image picker + +var gallery = {} + +gallery.init = function(){ + gallery.bind() +} + +gallery.bind = function(){ + $("#gallery-random").click(asdf.random) + $("#gallery-search").submit(dumpfm.search) + $(document).on("click", "#gallery-images img", gallery.choose) + status("ready") +} + +gallery.load = function(ims){ + status("loading " + ims.length + " images"); + $("#gallery-images").empty(); + for (var i = 0; i < ims.length; i++) { + gallery.image(ims[i]); + } +} + +gallery.image = function(im){ + var img = new Image (); + img.onload = function(){ + $("#gallery-images").append(img); + } + try { img.src = im.url; } + catch(e){ return; } + if (img.complete) img.onload(); +} -- cgit v1.2.3-70-g09d2