summaryrefslogtreecommitdiff
path: root/share/frontend/gallery-static/js/main.js
diff options
context:
space:
mode:
authoryo mama <pepper@scannerjammer.com>2016-09-03 11:56:00 -0700
committeryo mama <pepper@scannerjammer.com>2016-09-03 11:56:00 -0700
commit9b9589a54505e4ec0c2555c53b8e7980b6686daa (patch)
tree70e1dca2fee24f418da2d6e6f49c4e3d9526f5e7 /share/frontend/gallery-static/js/main.js
parent8c02a098b055a158b504b827ccae1ce2db705c34 (diff)
fixed rebus
Diffstat (limited to 'share/frontend/gallery-static/js/main.js')
-rw-r--r--share/frontend/gallery-static/js/main.js41
1 files changed, 25 insertions, 16 deletions
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 ($ ("<img>").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($("<img>").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()
}
}