diff options
Diffstat (limited to 'gallery/js/main.js')
| -rw-r--r-- | gallery/js/main.js | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/gallery/js/main.js b/gallery/js/main.js new file mode 100644 index 0000000..953e346 --- /dev/null +++ b/gallery/js/main.js @@ -0,0 +1,157 @@ +var title_choices = [ + +ZeroClipboard.setMoviePath( 'http://asdf.us/swf/ZeroClipboard10.swf' ); +var clip = new ZeroClipboard.Client(); +clip.glue( 'd_clip_button' ); +var Dump = + { + pick: function () + { + Dump.pickUrl( $(this).attr("src") ) + }, + pickUrl: function (url) + { + $("#rebus").append ($ ("<img>").attr ("src", url)) + $("#rebus").show() + var theDump = $("#urlz").val() + " " + url + $("#urlz").val( theDump ) + clip.setText( theDump ) + return false + }, + clear: function () + { + $("#rebus").html("") + $("#urlz").val("") + clip.setText("") + }, + backspace: function () + { + $("#rebus img:last").remove() + var urllist = $("#urlz").val().split(" ") + urllist.pop() + $("#urlz").val( urllist.join(" ") ) + }, + reverse: function () + { + urllist = $("#urlz").val().split(" ") + Dump.clear() + for (i in urllist.reverse()) + if (urllist[i]) + Dump.pickUrl(urllist[i]) + }, + showNewer: function() + { + window.location.href = '?"""+newer_QS+"""' + }, + showOlder: function() + { + window.location.href = '?"""+back_QS+"""' + } + } +function applyTag(tagname){ + tag_regex = /&tag=[^&]*/; + if (document.URL.match(tag_regex)){ + return document.URL.replace(tag_regex, "&tag="+tagname); + }else if(document.URL.match(/\/$/)){ + return document.URL.replace(/\/$/, "?tag="+tagname); + } + else{ + return document.URL+"&tag="+tagname; + } +} +var Main = + { + editing: false, + kp: function (event) + { + console.log(event.keyCode); + switch (event.keyCode) + { + // BS + case 8: + if (! Main.editing) + 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 + } + return true + }, + poll: function () + { + }, + pollCallback: function () + { + }, + init: function () + { + $(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.href= applyTag(this.id)}); + $(".tag-clear").click(function(){ document.location.href = document.URL.replace(/&?tag=[^&]*/ ,"").replace(/\?$/,"")}); + $("div img").live("click", Dump.pick) + Dump.clear() + } + } + 'Keep on pickin\' on..', + 'Pickolaus Pickleby by Charles Pickens!', + 'You pick potato and I pick potahto...', + 'Take your piq!', + 'Show em what you got', + 'I sure know how to pick \'em', + 'Jus pick somethin already!', + 'You can\'t pick your friends...', + 'Select your image my liege', + 'There\'s a time to choose...', + 'gimme a choice! gimme lil\' choice-a-that...', + 'You choose you lose', + 'novels by James CHOICE...', + 'Choose away, chooser-man...', +] +document.title = title_choices[Math.floor(Math.random() * title_choices.length)] +$(function(){ +var imagedata = [ """ //needs a synchronous call here + for (var i=0; i< (imagedata.length - 1); i++){ + var newDiv = document.createElement("div"); + var newImage = document.createElement("img"); + newImage.src = imagedata[i][0]; + 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(){ +// console.log("like a true playa"); +// }) + $("#images").append(newDiv); + } +}); +Main.init() |
