Added so you can press enter to go to the next in find

This commit is contained in:
KasperRT
2015-03-18 00:47:07 +01:00
parent cece1a9452
commit 403fefe38b
3 changed files with 48 additions and 22 deletions

View File

@@ -44,6 +44,7 @@
<div class="result hiddenAdmin" id="adminPanel"><?php include("php/panel.php");?> </div>
<form id="findform" onsubmit="return false;">
<input id="findform-input" type="text" onsubmit="null;" placeholder="Search list..">
<label id="numfound"></label>
</form>
<div id="playlist">
<div id="wrapper">

View File

@@ -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()+"')"));
}
});

View File

@@ -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;