mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
122 lines
3.6 KiB
JavaScript
122 lines
3.6 KiB
JavaScript
$(document).ready(function()
|
|
{
|
|
found = null;
|
|
znum = 1;
|
|
elem = [];
|
|
bright = [];
|
|
$.expr[":"].contains = $.expr.createPseudo(function(arg) {
|
|
return function( elem ) {
|
|
return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
|
|
};
|
|
});
|
|
find = false;
|
|
$("html").keydown(function(event) {
|
|
if ((event.keyCode == 27 && find) || (event.ctrlKey && event.keyCode === 70))
|
|
{
|
|
find = !find;
|
|
znum = 1;
|
|
if(find)
|
|
$(".lresult").addClass("brightness");
|
|
else
|
|
{
|
|
$(".lresult").removeClass("brightness");
|
|
$(".lresult").removeClass("fullbrightness");
|
|
bright.length = 0;
|
|
}
|
|
event.preventDefault();
|
|
$("#findform").toggleClass("display");
|
|
$("#adminPanel").toggleClass("brightness");
|
|
$("#findform-input").val("");
|
|
$("#findform-input").focus();
|
|
/*
|
|
if(find) $("#playlist").height($("#player").height()-30+30);
|
|
if(!find)$("#playlist").height($("#player").height()+30);; //closing
|
|
*/
|
|
/*if(adminTogg) extraHeight = -300;
|
|
else extraHeight = -30;*/
|
|
|
|
if(find)
|
|
{
|
|
if($("#adminPanel").height() != 0)
|
|
{
|
|
extraHeight = $("#adminPanel").height()+30;
|
|
}else
|
|
{
|
|
extraHeight = 10;
|
|
}
|
|
$("#playlist").height($("#player").height()-extraHeight); //opening
|
|
}else if(!find)
|
|
{
|
|
if($("#adminPanel").height() != 0)
|
|
{
|
|
extraHeight = $("#adminPanel").height()-10;
|
|
}else
|
|
{
|
|
extraHeight = -30;
|
|
}
|
|
$("#playlist").height($("#player").height()-extraHeight);; //closing
|
|
}
|
|
|
|
myScroll.refresh();
|
|
setTimeout(function(){myScroll.refresh();}, 505);
|
|
}
|
|
});
|
|
$("body").keyup(function(event) {
|
|
var x = event.keyCode;
|
|
if(find)
|
|
{
|
|
if(x == 13)
|
|
{
|
|
if(found != "" && $("#findform-input").val() != "")
|
|
{
|
|
znum+=1;
|
|
if(znum > elem.length)
|
|
{
|
|
znum = 1;
|
|
myScroll.scrollToElement(elem[0], 10, 0, 0);
|
|
}
|
|
console.log(znum);
|
|
console.log(elem[znum]);
|
|
myScroll.scrollToElement(elem[znum-1], 10, 0, 0);
|
|
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");
|
|
}
|
|
}else
|
|
{
|
|
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() != "")
|
|
{
|
|
elem.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]);
|
|
elem.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;
|
|
elem.length = 0;
|
|
znum = 1;
|
|
}
|
|
}
|
|
//console.log($("#wrapper").find(".result:contains('"+$("#findform-input").val()+"')"));
|
|
}
|
|
});
|
|
}); |