From 403fefe38b9bb8da6ed2410c7c2ec0ed7a9d7c1b Mon Sep 17 00:00:00 2001 From: KasperRT Date: Wed, 18 Mar 2015 00:47:07 +0100 Subject: [PATCH] Added so you can press enter to go to the next in find --- index.php | 1 + js/searchlist.js | 63 ++++++++++++++++++++++++++++++++---------------- static/style.css | 6 ++++- 3 files changed, 48 insertions(+), 22 deletions(-) diff --git a/index.php b/index.php index 3bf3ad92..960dd135 100755 --- a/index.php +++ b/index.php @@ -44,6 +44,7 @@
+
diff --git a/js/searchlist.js b/js/searchlist.js index 534df344..b262fd30 100644 --- a/js/searchlist.js +++ b/js/searchlist.js @@ -61,33 +61,54 @@ $(document).ready(function() } }); $("body").keyup(function(event) { + var x = event.keyCode; if(find) { - if(found != null) + if(x == 13) { - last = found[0]; - if(!(typeof last === "undefined")) - $(".lresult").removeClass("fullbrightness"); - } - found = $("#wrapper").find(".lresult:contains('"+$("#findform-input").val()+"')"); - if(found != "" && $("#findform-input").val() != "") - { - elems.length = 0; - bright.length = 0; - for(i = 0; i < found.length; i++) + if(found != "" && $("#findform-input").val() != "") { - found[i].className = found[i].className + " fullbrightness"; - bright.push(found[i].className.split(" ")[0]); - elems.push(found[i]); + znum+=1; + if(znum >= elems.length) znum = 1; + document.getElementById("numfound").innerHTML = znum + " av " + bright.length; + $("#numfound").css("margin-left", "-"+($("#numfound").width()+8)); + $("#numfound").css("padding-right", 4); + $("#findform-input").css("padding", "0 "+($("#numfound").width()+8)+"px 0 5px"); + myScroll.scrollToElement(elems[znum-1], 10, 0, 0); } - myScroll.scrollToElement(found[0], 10, 0, 0); }else - { - $(".lresult").removeClass("fullbrightness"); - bright.length = 0; - elems.length = 0; - znum = 1; - } + { + if(found != null) + { + last = found[0]; + if(!(typeof last === "undefined")) + $(".lresult").removeClass("fullbrightness"); + } + found = $("#wrapper").find(".lresult:contains('"+$("#findform-input").val()+"')"); + if(found != "" && $("#findform-input").val() != "") + { + elems.length = 0; + bright.length = 0; + znum = 1; + for(i = 0; i < found.length; i++) + { + found[i].className = found[i].className + " fullbrightness"; + bright.push(found[i].className.split(" ")[0]); + elems.push(found[i]); + } + document.getElementById("numfound").innerHTML = znum + " av " + bright.length; + $("#numfound").css("margin-left", "-"+($("#numfound").width()+8)); + $("#numfound").css("padding-right", 4); + $("#findform-input").css("padding", "0 "+($("#numfound").width()+8)+"px 0 5px"); + myScroll.scrollToElement(found[0], 10, 0, 0); + }else + { + $(".lresult").removeClass("fullbrightness"); + bright.length = 0; + elems.length = 0; + znum = 1; + } + } //console.log($("#wrapper").find(".result:contains('"+$("#findform-input").val()+"')")); } }); diff --git a/static/style.css b/static/style.css index a54d9ae6..30e7ec30 100755 --- a/static/style.css +++ b/static/style.css @@ -32,12 +32,16 @@ body { -webkit-transition:height 0.5s; } +#numfound { + color:white; +} + #findform-input { color:#fff; height:24px; font-size:15px; width:60%; - padding:5px; + /*padding:0 50px 0 5px;*/ margin:5px 0; border-radius:2px; border:none;