summaryrefslogtreecommitdiff
path: root/js/gallery.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/gallery.js')
-rw-r--r--js/gallery.js33
1 files changed, 33 insertions, 0 deletions
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();
+}