diff options
Diffstat (limited to 'share/frontend/gallery-static')
| -rw-r--r-- | share/frontend/gallery-static/js/main.js | 38 | ||||
| -rw-r--r-- | share/frontend/gallery-static/main.css | 15 |
2 files changed, 40 insertions, 13 deletions
diff --git a/share/frontend/gallery-static/js/main.js b/share/frontend/gallery-static/js/main.js index aadc7e1..b72ee6c 100644 --- a/share/frontend/gallery-static/js/main.js +++ b/share/frontend/gallery-static/js/main.js @@ -82,22 +82,35 @@ var Dump = { } } -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; - } +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 @@ -163,9 +176,10 @@ var Main = $("#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(/\?$/,"")}); + $(".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() } diff --git a/share/frontend/gallery-static/main.css b/share/frontend/gallery-static/main.css index 1201689..56afc1d 100644 --- a/share/frontend/gallery-static/main.css +++ b/share/frontend/gallery-static/main.css @@ -18,6 +18,19 @@ div img { cursor: pointer; // display: none; } +#search { + position: fixed; + left: 300px; + top: 10px; +} +#search input { + padding: 3px; + border: 1px solid #ddd; + font-weight: bold; + background: #f8f4fb; + font-size: 16px; + width: 140px; +} #dump { position: fixed; left: 0; @@ -66,7 +79,7 @@ div img { { position: fixed; top: 10px; - left: 200px; + left: 150px; cursor: pointer; text-align: left; font-family: sans-serif; |
