From 9b9589a54505e4ec0c2555c53b8e7980b6686daa Mon Sep 17 00:00:00 2001 From: yo mama Date: Sat, 3 Sep 2016 11:56:00 -0700 Subject: fixed rebus --- share/frontend/gallery-static/js/main.js | 41 +++++++++++++++++++------------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'share/frontend/gallery-static/js/main.js') diff --git a/share/frontend/gallery-static/js/main.js b/share/frontend/gallery-static/js/main.js index 7d92b93..742a1df 100644 --- a/share/frontend/gallery-static/js/main.js +++ b/share/frontend/gallery-static/js/main.js @@ -31,40 +31,43 @@ $(function(){ //var clip = new ZeroClipboard.Client(); //clip.glue( 'd_clip_button' ); + var Dump = { + current_urls: [], pick: function () { Dump.pickUrl( $(this).attr("src") ) }, pickUrl: function (url) { - $("#rebus").append ($ ("").attr ("src", url)) - $("#rebus").show() - var theDump = $("#urlz").val() + " " + url - $("#urlz").val( theDump ) -// clip.setText( theDump ) - return false + Dump.current_urls.push(url) + Dump.load_rebus() }, clear: function () { $("#rebus").html("") $("#urlz").val("") + Dump.current_urls = [] // clip.setText("") }, + load_rebus: function(){ + var as_str = Dump.current_urls.join(" ") + window.localStorage.setItem('urls', as_str) + $("#rebus").html("") + Dump.current_urls.map(function(url){ $("#rebus").append($("").attr("src", url))}) + $("#rebus").show() + console.log(as_str) + $("#urlz").val( as_str ) + }, backspace: function () { - $("#rebus img:last").remove() - var urllist = $("#urlz").val().split(" ") - urllist.pop() - $("#urlz").val( urllist.join(" ") ) + Dump.current_urls.pop() + Dump.load_rebus() }, reverse: function () { - urllist = $("#urlz").val().split(" ") - Dump.clear() - for (i in urllist.reverse()) - if (urllist[i]) - Dump.pickUrl(urllist[i]) + Dump.current_urls.reverse() + Dump.load_rebus() }, showNewer: function() { @@ -140,6 +143,12 @@ var Main = }, 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 }) @@ -150,7 +159,7 @@ var Main = $(".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() +// Dump.clear() } } -- cgit v1.2.3-70-g09d2