$(function(){ for (var i=0; i < imagedata.length; i++){ var newDiv = document.createElement("div"); var newImage = document.createElement("img"); newImage.src = imagedata[i]; newImage.className = "pb"; newDiv.appendChild(newImage); // consider calling something like isotope add here...and ONLY APPENDING the image to the parent div once it has loaded // $(newImage).load(function(){ // }) $("#images").append(newDiv); } }); $(function(){ $("b").addClass("pulsate_and_grow"); $(".sorting-options").click(function(){ $(".sorting-options").click(function(){ if ($(this).hasClass("pulsate_opacity")){ $(this).removeClass("pulsate_opacity"); } $(this).addClass("pulsate_opacity"); }); }); }); //ZeroClipboard.setMoviePath( 'http://asdf.us/swf/ZeroClipboard10.swf' ); //var clip = new ZeroClipboard.Client(); //clip.glue( 'd_clip_button' ); var Dump = { current_urls: [], pick: function () { Dump.pickUrl( $(this).attr("src") ) }, pickUrl: function (url) { Dump.current_urls.push(url) Dump.load_rebus() }, clear: function () { $("#rebus").html("") $("#urlz").val("") Dump.current_urls = [] window.localStorage.setItem('urls', "") // clip.setText("") }, load_rebus: function(){ var as_str = Dump.current_urls.join(" ") window.localStorage.setItem('urls', as_str) // $("#rebus").html("") $("#rebus").html( Dump.current_urls.map( function(url){ return $("").attr("src", url)[0].outerHTML} ).join(" ") ) $("#rebus").show() console.log(as_str) $("#urlz").val( as_str ) }, backspace: function () { Dump.current_urls.pop() Dump.load_rebus() }, reverse: function () { Dump.current_urls.reverse() Dump.load_rebus() }, showNewer: function() { }, showOlder: function() { } } function applyTag(tagname) { var qs = $.QueryString qs.tag = tagname return serializeQS(qs) } function serializeQS (obj) { let str = []; for (let p in obj) if (obj.hasOwnProperty(p)) { str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); } return str.join("&"); } var Main = { editing: false, kp: function (event) { if (document.activeElement && document.activeElement.getAttribute('id') === 'search-q') { if (event.keyCode === 13) { var qs = $.QueryString qs.text = document.activeElement.value delete qs.start window.location.search = serializeQS(qs) } return } switch (event.keyCode) { // BS case 8: if (! Main.editing) { event.stopPropagation() Dump.backspace() } return false // C case 67: if (! Main.editing) Dump.clear() break // R case 82: if (! Main.editing) Dump.reverse() break // ESC case 27: // H case 72: if (! Main.editing) $("#rebus").toggle() break // LEFT ARROW case 37: if (! Main.editing) Dump.showNewer() break // RIGHT ARROW case 39: if (! Main.editing) Dump.showOlder() break case 83: if (! Main.editing) window.sorter.shuffle() break } // S key return true }, poll: function () { }, pollCallback: function () { }, init: function () { //the rebus needs to preload dumps that are stored from localstorage if (window.localStorage.getItem('urls')){ Dump.current_urls = window.localStorage.getItem('urls').split(" ") }else{ Dump.current_urls = [] } $(document).keydown(Main.kp) $("#urlz").focus(function(){ Main.editing = true }) $("#urlz").blur(function(){ Main.editing = false }) $("#clear").live("click", Dump.clear) $("#help").click(function(){ $("#keys").slideToggle() }) $("#actions b").click(function(){ $("#sorting-optionsContainer").slideToggle() }) $("#tags b").click(function(){ $("#tag-optionsContainer").slideToggle() }) $(".tag-options").click(function(){document.location.search = applyTag(this.id)}); $(".tag-clear").click(function(){ document.location.search = '' }); $("div img").live("click", Dump.pick) $("#search-q").val($.QueryString.text || "") Dump.load_rebus() // Dump.clear() } } $(function(){ //get params from the query string, and create //the back and newer buttons //taking into account name, tag and random var params = { name } Main.init() })