mirror of
https://github.com/byReqz/blue-searchpage.git
synced 2024-11-21 21:13:15 +00:00
replaced Google with DuckDuckGo and beautified some code
This commit is contained in:
parent
69876e43ef
commit
0a12bc1da5
@ -1,4 +1,5 @@
|
|||||||
# blue-searchpage
|
# blue-searchpage
|
||||||
another old project ive found in some folder <br>
|
another old project ive found in some folder <br>
|
||||||
pretty sure i havent made all of it, if the original creator wants this removed, please message me <br>
|
pretty sure i havent made all of it, if the original creator wants this removed, please message me <br>
|
||||||
|
duckduckgo search uses my custom settings, they can be changed by removing the attributes from the link in engines/base.js <br>
|
||||||
you can see it live here https://byreqz.github.io/blue-searchpage
|
you can see it live here https://byreqz.github.io/blue-searchpage
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
var apiUrl = "http://go.infinise.com/api/2.5/";
|
var apiUrl = "http://go.infinise.com/api/2.5/";
|
||||||
|
|
||||||
|
|
||||||
/* GOOGLE
|
/* DUCKDUCKGO
|
||||||
----------------------------------------------------- */
|
----------------------------------------------------- */
|
||||||
|
|
||||||
eng.google = {
|
eng.google = {
|
||||||
pageTitle: "Google",
|
pageTitle: "DuckDuckGo",
|
||||||
logo: "google.png",
|
logo: "duckduckgo.png",
|
||||||
places: {
|
places: {
|
||||||
'Web' : ["http://www.google.com/search?q=%query%&hl=en", apiUrl+"?eng=google×tamp=%time%&q=%query%"],
|
'Web' : ["https://duckduckgo.com/?q=%query%&kp=-2&kae=t&kam=osm&kay=b&kau=-1&kap=-1&kaq=-1&kak=-1&kax=-1"],
|
||||||
'Images' : ["http://images.google.com/images?q=%query%&hl=en", apiUrl+"?eng=google×tamp=%time%&q=%query%"],
|
'Images' : ["https://duckduckgo.com/?q=%query%&kp=-2&kae=t&kam=osm&kay=b&kau=-1&kap=-1&kaq=-1&kak=-1&kax=-1&iax=images&ia=images"],
|
||||||
'Maps' : ["http://maps.google.com/maps?q=%query%", false]
|
'Maps' : ["https://duckduckgo.com/?q=%query%&kp=-2&kae=t&kam=osm&kay=b&kau=-1&kap=-1&kaq=-1&kak=-1&kax=-1&iaxm=maps", false]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BIN
engines/duckduckgo.png
Normal file
BIN
engines/duckduckgo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 154 KiB |
Binary file not shown.
Before Width: | Height: | Size: 5.8 KiB |
23
index.html
23
index.html
@ -1 +1,22 @@
|
|||||||
<head><link href='https://fonts.googleapis.com/css?family=Roboto:100&subset=latin,cyrillic-ext,greek-ext,greek,vietnamese,cyrillic,latin-ext' rel='stylesheet' type='text/css'><meta http-equiv="Content-type" content="text/html;charset=UTF-8"><title id="title">Start</title><link rel="stylesheet" href="style.css" type="text/css"><script src="scripts/jquery-1.4.2.min.js" type="text/javascript"></script> <script src="scripts/tools.js" type="text/javascript"></script> <script src="scripts/scripts.js" type="text/javascript"></script> <script src="engines/base.js" type="text/javascript"></script> <script type="text/javascript" src="scripts/jquery.js"></script> </head><body><div id="engines"></div><div id="container"><form id="form" onsubmit="return doSearch()"><div id="input"><input id="i" type="text" autocomplete="off" spellcheck="false" placeholder="Who the fuck is byReqz?" results="0" /></div> <a onclick="nextLanguage()" id="lang"></a><ul id="sugs"></ul></form><p id="method"></p></div></body>
|
<head>
|
||||||
|
<link href='https://fonts.googleapis.com/css?family=Roboto:100&subset=latin,cyrillic-ext,greek-ext,greek,vietnamese,cyrillic,latin-ext' rel='stylesheet' type='text/css'>
|
||||||
|
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
|
||||||
|
<title id="title">Start</title>
|
||||||
|
<link rel="stylesheet" href="style.css" type="text/css">
|
||||||
|
<script src="scripts/jquery-1.4.2.min.js" type="text/javascript"></script>
|
||||||
|
<script src="scripts/tools.js" type="text/javascript"></script>
|
||||||
|
<script src="scripts/scripts.js" type="text/javascript"></script>
|
||||||
|
<script src="engines/base.js" type="text/javascript"></script>
|
||||||
|
<script type="text/javascript" src="scripts/jquery.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="engines"></div>
|
||||||
|
<div id="container">
|
||||||
|
<form id="form" onsubmit="return doSearch()">
|
||||||
|
<div id="input"><input id="i" type="text" autocomplete="off" spellcheck="false" placeholder="Who the fuck is byReqz?" results="0" /></div> <a onclick="nextLanguage()" id="lang"></a>
|
||||||
|
<ul id="sugs"></ul>
|
||||||
|
</form>
|
||||||
|
<p id="method"></p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
3624
scripts/jquery-1.4.2.min.js
vendored
3624
scripts/jquery-1.4.2.min.js
vendored
File diff suppressed because it is too large
Load Diff
3213
scripts/jquery.js
vendored
3213
scripts/jquery.js
vendored
File diff suppressed because one or more lines are too long
@ -1,144 +1,151 @@
|
|||||||
|
|
||||||
var eng = {},
|
var eng = {},
|
||||||
current = {},
|
current = {},
|
||||||
fadeDur = 200,
|
fadeDur = 200,
|
||||||
titlePrefix = "Search ",
|
titlePrefix = "Search ",
|
||||||
|
|
||||||
idxWidth = 700,
|
idxWidth = 700,
|
||||||
idxLogoFull = [225,80],
|
idxLogoFull = [225, 80],
|
||||||
idxLogoSmall = [157,56],
|
idxLogoSmall = [157, 56],
|
||||||
idxMargin = 24,
|
idxMargin = 24,
|
||||||
idxFadedOpacity = 0.3,
|
idxFadedOpacity = 0.3,
|
||||||
|
|
||||||
idxHeight = 0;
|
idxHeight = 0;
|
||||||
|
|
||||||
|
|
||||||
$(function()
|
$(function() {
|
||||||
{
|
// Create Engine Index
|
||||||
// Create Engine Index
|
|
||||||
|
|
||||||
indexCreate();
|
indexCreate();
|
||||||
|
|
||||||
// Behavior
|
// Behavior
|
||||||
|
|
||||||
$("#i").keyup(function(ev) { fetchSuggestions(ev.which); });
|
$("#i").keyup(function(ev) {
|
||||||
$(document).click(function(ev) { closeSugBox(ev.srcElement) });
|
fetchSuggestions(ev.which);
|
||||||
|
});
|
||||||
|
$(document).click(function(ev) {
|
||||||
|
closeSugBox(ev.srcElement)
|
||||||
|
});
|
||||||
|
|
||||||
$("#toggleInfo").click(function(){
|
$("#toggleInfo").click(function() {
|
||||||
$("#infoBox").toggle(400);
|
$("#infoBox").toggle(400);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set up first engine
|
// Set up first engine
|
||||||
|
|
||||||
build(firstProp(eng), false);
|
build(firstProp(eng), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
function doSearch()
|
function doSearch() {
|
||||||
{
|
var url = eng[current.engine].places[current.place][0];
|
||||||
var url = eng[current.engine].places[current.place][0];
|
url = url.replace("%query%", encodeURIComponent($("#i").val()));
|
||||||
url = url.replace("%query%", encodeURIComponent($("#i").val()));
|
if (typeof eng[current.engine].languages == "object")
|
||||||
if (typeof eng[current.engine].languages == "object")
|
url = url.replace("%lang%", eng[current.engine].languages[current.language]);
|
||||||
url = url.replace("%lang%", eng[current.engine].languages[current.language]);
|
|
||||||
|
|
||||||
window.location.href = url;
|
window.location.href = url;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ENGINE INDEX
|
/* ENGINE INDEX
|
||||||
----------------------------------------------------- */
|
----------------------------------------------------- */
|
||||||
|
|
||||||
function indexCreate()
|
function indexCreate() {
|
||||||
{
|
var row = 0,
|
||||||
var row = 0,
|
i = 0, // Reset every row
|
||||||
i = 0, // Reset every row
|
j = 0, // Total
|
||||||
j = 0, // Total
|
offset = 0,
|
||||||
offset = 0,
|
cols = Math.floor(idxWidth / idxLogoSmall[0]);
|
||||||
cols = Math.floor(idxWidth/idxLogoSmall[0]);
|
|
||||||
|
|
||||||
for (e in eng)
|
for (e in eng) {
|
||||||
{
|
// If the offset hasn't been set yet
|
||||||
// If the offset hasn't been set yet
|
// And the number of engines left to draw is <= items in the final row
|
||||||
// And the number of engines left to draw is <= items in the final row
|
if (
|
||||||
if (
|
offset == 0 &&
|
||||||
offset == 0 &&
|
(numKeys(eng) - j) <= (numKeys(eng) % cols)
|
||||||
(numKeys(eng) - j) <= (numKeys(eng) % cols)
|
) {
|
||||||
) {
|
offset = cols - numKeys(eng) % cols;
|
||||||
offset = cols - numKeys(eng) % cols;
|
offset = offset * (idxLogoSmall[0] + idxMargin) / 2;
|
||||||
offset = offset * (idxLogoSmall[0]+idxMargin) / 2;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$("#engines").prepend("<a id='"+e+"_logo' ref='"+e+"'><img src='engines/"+eng[e].logo+"'></a>");
|
$("#engines").prepend("<a id='" + e + "_logo' ref='" + e + "'><img src='engines/" + eng[e].logo + "'></a>");
|
||||||
|
|
||||||
if (i == cols) { i=0; row++; };
|
if (i == cols) {
|
||||||
eng[e].idxPos = [
|
i = 0;
|
||||||
(idxLogoSmall[0]+idxMargin)*i - idxWidth/2 + offset,
|
row++;
|
||||||
(idxLogoSmall[1]+idxMargin)*row
|
};
|
||||||
];
|
eng[e].idxPos = [
|
||||||
i++; j++;
|
(idxLogoSmall[0] + idxMargin) * i - idxWidth / 2 + offset,
|
||||||
}
|
(idxLogoSmall[1] + idxMargin) * row
|
||||||
idxHeight = (row+1)*(idxLogoSmall[1]+idxMargin)-idxMargin;
|
];
|
||||||
idxHeight = Math.max(idxHeight, idxLogoFull[1]);
|
i++;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
idxHeight = (row + 1) * (idxLogoSmall[1] + idxMargin) - idxMargin;
|
||||||
|
idxHeight = Math.max(idxHeight, idxLogoFull[1]);
|
||||||
|
|
||||||
$("#engines a").click(function(){ build($(this).attr("ref"), true); })
|
$("#engines a").click(function() {
|
||||||
|
build($(this).attr("ref"), true);
|
||||||
|
})
|
||||||
|
|
||||||
$("#engines a").css({
|
$("#engines a").css({
|
||||||
"left": "50%",
|
"left": "50%",
|
||||||
"bottom": "0",
|
"bottom": "0",
|
||||||
"marginLeft": -idxLogoFull[0]/2+"px"
|
"marginLeft": -idxLogoFull[0] / 2 + "px"
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#engines").mouseenter(function(){ indexOpen(); });
|
$("#engines").mouseenter(function() {
|
||||||
$("#engines").mouseleave(function(){ indexClose(); });
|
indexOpen();
|
||||||
|
});
|
||||||
|
$("#engines").mouseleave(function() {
|
||||||
|
indexClose();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var idxState = false,
|
var idxState = false,
|
||||||
idxClear = undefined;
|
idxClear = undefined;
|
||||||
|
|
||||||
function indexOpen()
|
function indexOpen() {
|
||||||
{
|
idxState = true;
|
||||||
idxState = true;
|
clearTimeout(idxClear);
|
||||||
clearTimeout(idxClear);
|
|
||||||
|
|
||||||
$("#engines").css({
|
$("#engines").css({
|
||||||
"height": idxHeight
|
"height": idxHeight
|
||||||
});
|
});
|
||||||
|
|
||||||
for (e in eng)
|
for (e in eng) {
|
||||||
{
|
var op = $("#" + e + "_logo").hasClass("active");
|
||||||
var op = $("#"+e+"_logo").hasClass("active");
|
$("#" + e + "_logo").stop().queue("fx", []).animate({
|
||||||
$("#"+e+"_logo").stop().queue("fx",[]).animate({
|
"marginLeft": eng[e].idxPos[0] + "px",
|
||||||
"marginLeft": eng[e].idxPos[0]+"px",
|
"marginBottom": eng[e].idxPos[1] + "px",
|
||||||
"marginBottom": eng[e].idxPos[1]+"px",
|
"opacity": (op) ? 1 : idxFadedOpacity,
|
||||||
"opacity": (op) ? 1 : idxFadedOpacity,
|
"width": idxLogoSmall[0],
|
||||||
"width": idxLogoSmall[0],
|
"height": idxLogoSmall[1],
|
||||||
"height": idxLogoSmall[1],
|
}, fadeDur);
|
||||||
}, fadeDur);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function indexClose()
|
function indexClose() {
|
||||||
{
|
idxState = false;
|
||||||
idxState = false;
|
|
||||||
|
|
||||||
$("#engines").css({
|
$("#engines").css({
|
||||||
"height": idxLogoFull[1]
|
"height": idxLogoFull[1]
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#engines a").each(function()
|
$("#engines a").each(function() {
|
||||||
{
|
var op = $(this).hasClass("active");
|
||||||
var op = $(this).hasClass("active");
|
$(this).stop().queue("fx", []).animate({
|
||||||
$(this).stop().queue("fx",[]).animate({
|
"marginLeft": -idxLogoFull[0] / 2 + "px",
|
||||||
"marginLeft": -idxLogoFull[0]/2+"px",
|
"marginBottom": 0,
|
||||||
"marginBottom": 0,
|
"opacity": (op) ? 1 : 0,
|
||||||
"opacity": (op) ? 1 : 0,
|
"width": idxLogoFull[0],
|
||||||
"width": idxLogoFull[0],
|
"height": idxLogoFull[1]
|
||||||
"height": idxLogoFull[1]
|
}, fadeDur);
|
||||||
}, fadeDur);
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// Because jQuery doesn't like me
|
// Because jQuery doesn't like me
|
||||||
idxClear = setTimeout(function(){ $("#engines a:not(.active)").css("opacity",0) }, fadeDur);
|
idxClear = setTimeout(function() {
|
||||||
|
$("#engines a:not(.active)").css("opacity", 0)
|
||||||
|
}, fadeDur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -146,67 +153,68 @@ function indexClose()
|
|||||||
/* GENERATING THE SEARCH ENGINE PAGE
|
/* GENERATING THE SEARCH ENGINE PAGE
|
||||||
----------------------------------------------------- */
|
----------------------------------------------------- */
|
||||||
|
|
||||||
function build(e, animate)
|
function build(e, animate) {
|
||||||
{
|
var methodFade = (animate) ? fadeDur : 0;
|
||||||
var methodFade = (animate) ? fadeDur : 0;
|
|
||||||
|
|
||||||
current.engine = e; // Just the engine's ID for reference
|
current.engine = e; // Just the engine's ID for reference
|
||||||
e = eng[e]; // Engine object
|
e = eng[e]; // Engine object
|
||||||
|
|
||||||
$("#title").html(titlePrefix+e.pageTitle);
|
$("#title").html(titlePrefix + e.pageTitle);
|
||||||
|
|
||||||
$("#method").stop().queue("fx",[]).animate({"opacity": 0}, methodFade);
|
$("#method").stop().queue("fx", []).animate({
|
||||||
|
"opacity": 0
|
||||||
|
}, methodFade);
|
||||||
|
|
||||||
op = (idxState) ? idxFadedOpacity : 0;
|
op = (idxState) ? idxFadedOpacity : 0;
|
||||||
$("#engines a").stop().queue("fx",[]).removeClass("active");
|
$("#engines a").stop().queue("fx", []).removeClass("active");
|
||||||
$("#"+current.engine+"_logo").addClass("active").animate({"opacity": 1}, fadeDur);
|
$("#" + current.engine + "_logo").addClass("active").animate({
|
||||||
$("#engines a:not(.active)").animate({"opacity": op}, fadeDur);
|
"opacity": 1
|
||||||
|
}, fadeDur);
|
||||||
|
$("#engines a:not(.active)").animate({
|
||||||
|
"opacity": op
|
||||||
|
}, fadeDur);
|
||||||
|
|
||||||
if (typeof e.languages == "object") setLang(firstProp(e.languages));
|
if (typeof e.languages == "object") setLang(firstProp(e.languages));
|
||||||
else $("#lang").fadeOut(fadeDur);
|
else $("#lang").fadeOut(fadeDur);
|
||||||
|
|
||||||
closeSugBox(false);
|
closeSugBox(false);
|
||||||
|
|
||||||
$("#i").attr("autosave", "com.infinise.go."+current.engine);
|
$("#i").attr("autosave", "com.infinise.go." + current.engine);
|
||||||
$("#input input").focus();
|
$("#input input").focus();
|
||||||
|
|
||||||
setTimeout(function()
|
setTimeout(function() {
|
||||||
{
|
$("#method").html("");
|
||||||
$("#method").html("");
|
for (place in e.places) $("#method").append("<a onclick='setPlace(this)'>" + place + "</a>");
|
||||||
for (place in e.places) $("#method").append("<a onclick='setPlace(this)'>"+place+"</a>");
|
|
||||||
|
|
||||||
setPlace("#method a:first");
|
setPlace("#method a:first");
|
||||||
|
|
||||||
$("#method").animate({"opacity": 1}, fadeDur);
|
$("#method").animate({
|
||||||
}, methodFade);
|
"opacity": 1
|
||||||
|
}, fadeDur);
|
||||||
|
}, methodFade);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPlace(place)
|
function setPlace(place) {
|
||||||
{
|
current.place = $(place).html();
|
||||||
current.place = $(place).html();
|
|
||||||
|
|
||||||
$("#method a").removeClass("active");
|
$("#method a").removeClass("active");
|
||||||
$(place).addClass("active");
|
$(place).addClass("active");
|
||||||
$("#input input").focus();
|
$("#input input").focus();
|
||||||
|
|
||||||
if (eng[current.engine].places[current.place][1] !== false)
|
if (eng[current.engine].places[current.place][1] !== false) {
|
||||||
{
|
fetchSuggestions();
|
||||||
fetchSuggestions();
|
$("#i").attr("autocomplete", "off");
|
||||||
$("#i").attr("autocomplete", "off");
|
} else {
|
||||||
}
|
closeSugBox(false);
|
||||||
else
|
$("#i").attr("autocomplete", "on");
|
||||||
{
|
}
|
||||||
closeSugBox(false);
|
|
||||||
$("#i").attr("autocomplete", "on");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLang(language)
|
function setLang(language) {
|
||||||
{
|
current.language = language;
|
||||||
current.language = language;
|
|
||||||
|
|
||||||
$("#lang").fadeIn(fadeDur).html(language);
|
$("#lang").fadeIn(fadeDur).html(language);
|
||||||
$("#input input").focus();
|
$("#input input").focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -216,159 +224,157 @@ function setLang(language)
|
|||||||
var isCtrl = false;
|
var isCtrl = false;
|
||||||
var isCmd = false;
|
var isCmd = false;
|
||||||
|
|
||||||
$(document).keyup(function(e)
|
$(document).keyup(function(e) {
|
||||||
{
|
if (e.which == 17) isCtrl = false;
|
||||||
if (e.which == 17) isCtrl=false;
|
if (e.which == 91) isCmd = false;
|
||||||
if (e.which == 91) isCmd=false;
|
}).keydown(function(e) {
|
||||||
}
|
if (e.which == 17) isCtrl = true;
|
||||||
).keydown(function(e)
|
if (e.which == 91) isCmd = true;
|
||||||
{
|
|
||||||
if (e.which == 17) isCtrl=true;
|
|
||||||
if (e.which == 91) isCmd=true;
|
|
||||||
|
|
||||||
if (e.which == 49 && isCtrl == true) { /* Key "1" */ nextEngine(); return false; }
|
if (e.which == 49 && isCtrl == true) {
|
||||||
if (e.which == 50 && isCtrl == true) { /* Key "2" */ nextPlace(); return false; }
|
/* Key "1" */
|
||||||
if (e.which == 51 && isCtrl == true) { /* Key "3" */ nextLanguage(); return false; }
|
nextEngine();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (e.which == 50 && isCtrl == true) {
|
||||||
|
/* Key "2" */
|
||||||
|
nextPlace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (e.which == 51 && isCtrl == true) {
|
||||||
|
/* Key "3" */
|
||||||
|
nextLanguage();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (e.which == 38) { /* Arrow Up */ prevSugResult(); }
|
if (e.which == 38) {
|
||||||
if (e.which == 40) { /* Arrow Down */ nextSugResult(); }
|
/* Arrow Up */
|
||||||
if (e.which == 27) { /* ESC */ closeSugBox(false); }
|
prevSugResult();
|
||||||
if (e.which == 13) { /* Enter */ applySugResult(); }
|
}
|
||||||
|
if (e.which == 40) {
|
||||||
|
/* Arrow Down */
|
||||||
|
nextSugResult();
|
||||||
|
}
|
||||||
|
if (e.which == 27) {
|
||||||
|
/* ESC */
|
||||||
|
closeSugBox(false);
|
||||||
|
}
|
||||||
|
if (e.which == 13) {
|
||||||
|
/* Enter */
|
||||||
|
applySugResult();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function nextEngine()
|
function nextEngine() {
|
||||||
{
|
build(findNext(eng, current.engine), true);
|
||||||
build(findNext(eng, current.engine), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function nextPlace()
|
function nextPlace() {
|
||||||
{
|
var nextPlace = findNext(eng[current.engine].places, current.place);
|
||||||
var nextPlace = findNext(eng[current.engine].places, current.place);
|
$("#method a").each(function() {
|
||||||
$("#method a").each(function()
|
if ($(this).html() == nextPlace) setPlace($(this));
|
||||||
{
|
})
|
||||||
if ($(this).html() == nextPlace) setPlace($(this));
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function nextLanguage()
|
function nextLanguage() {
|
||||||
{
|
setLang(findNext(eng[current.engine].languages, current.language));
|
||||||
setLang(findNext(eng[current.engine].languages, current.language));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* SUGGESTIONS
|
/* SUGGESTIONS
|
||||||
----------------------------------------------------- */
|
----------------------------------------------------- */
|
||||||
|
|
||||||
function fetchSuggestions(key)
|
function fetchSuggestions(key) {
|
||||||
{
|
if (key == undefined || (!inArray(key, new Array(13, 16, 20, 27, 37, 38, 39, 40)) && !isCtrl && !isCmd)) {
|
||||||
if (key == undefined || (!inArray(key, new Array(13,16,20,27,37,38,39,40)) && !isCtrl && !isCmd))
|
if ($("#i").val() != "" && eng[current.engine].places[current.place][1] !== false) {
|
||||||
{
|
current.suggestionsTimestamp = new Date().getTime();
|
||||||
if ( $("#i").val() != "" && eng[current.engine].places[current.place][1] !== false )
|
|
||||||
{
|
|
||||||
current.suggestionsTimestamp = new Date().getTime();
|
|
||||||
|
|
||||||
var url = eng[current.engine].places[current.place][1];
|
var url = eng[current.engine].places[current.place][1];
|
||||||
url = url.replace("%query%", encodeURIComponent($("#i").val()));
|
url = url.replace("%query%", encodeURIComponent($("#i").val()));
|
||||||
url = url.replace("%time%", current.suggestionsTimestamp);
|
url = url.replace("%time%", current.suggestionsTimestamp);
|
||||||
if (typeof eng[current.engine].languages == "object")
|
if (typeof eng[current.engine].languages == "object")
|
||||||
url = url.replace("%lang%", eng[current.engine].languages[current.language]);
|
url = url.replace("%lang%", eng[current.engine].languages[current.language]);
|
||||||
|
|
||||||
$.getJSON(url, function(data) { buildSuggestions(data); })
|
$.getJSON(url, function(data) {
|
||||||
}
|
buildSuggestions(data);
|
||||||
else closeSugBox(false);
|
})
|
||||||
}
|
} else closeSugBox(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildSuggestions(list)
|
function buildSuggestions(list) {
|
||||||
{
|
if (list.empty) {
|
||||||
if (list.empty)
|
if (console) console.log("(1) Suggestions for '" + list.query + "' empty.");
|
||||||
{
|
closeSugBox(false);
|
||||||
if(console)console.log("(1) Suggestions for '"+list.query+"' empty.");
|
} else if (
|
||||||
closeSugBox(false);
|
list.engine == current.engine &&
|
||||||
}
|
list.timestamp == current.suggestionsTimestamp &&
|
||||||
else if (
|
list.query == $("#i").val()
|
||||||
list.engine == current.engine &&
|
) {
|
||||||
list.timestamp == current.suggestionsTimestamp &&
|
if (console) console.log("(2) Suggestions for '" + list.query + "' accepted.");
|
||||||
list.query == $("#i").val()
|
|
||||||
) {
|
|
||||||
if(console)console.log("(2) Suggestions for '"+list.query+"' accepted.");
|
|
||||||
|
|
||||||
$("#sugs").html("");
|
$("#sugs").html("");
|
||||||
for (sug in list.results)
|
for (sug in list.results) {
|
||||||
{
|
sug = list.results[sug];
|
||||||
sug = list.results[sug];
|
$("#sugs").append("<li><a href='" + sug[1] + "'>" + sug[0] + "</a></li>");
|
||||||
$("#sugs").append("<li><a href='"+sug[1]+"'>"+sug[0]+"</a></li>");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$("#sugs").css({"display": "block"});
|
$("#sugs").css({
|
||||||
$("#sugs li").mousemove(function()
|
"display": "block"
|
||||||
{
|
});
|
||||||
$("#sugs .active").removeClass("active");
|
$("#sugs li").mousemove(function() {
|
||||||
$(this).addClass("active");
|
$("#sugs .active").removeClass("active");
|
||||||
}
|
$(this).addClass("active");
|
||||||
).click(function()
|
}).click(function() {
|
||||||
{
|
applySugResult();
|
||||||
applySugResult();
|
});
|
||||||
});
|
} else {
|
||||||
}
|
if (console) console.log("(3) Suggestions for '" + list.query + "' discarded.");
|
||||||
else
|
}
|
||||||
{
|
|
||||||
if(console)console.log("(3) Suggestions for '"+list.query+"' discarded.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function prevSugResult()
|
function prevSugResult() {
|
||||||
{
|
if ($("#sugs").css("display") == "none") return;
|
||||||
if ($("#sugs").css("display") == "none") return;
|
if ($("#sugs .active").length == 0) {
|
||||||
if ($("#sugs .active").length == 0) {
|
$("#sugs li:last-child").addClass("active");
|
||||||
$("#sugs li:last-child").addClass("active");
|
} else {
|
||||||
} else {
|
$("#sugs .active").removeClass("active").prev().addClass("active");
|
||||||
$("#sugs .active").removeClass("active").prev().addClass("active");
|
}
|
||||||
}
|
backupQuery();
|
||||||
backupQuery();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function nextSugResult()
|
function nextSugResult() {
|
||||||
{
|
if ($("#sugs").css("display") == "none") return;
|
||||||
if ($("#sugs").css("display") == "none") return;
|
if ($("#sugs .active").length == 0) {
|
||||||
if ($("#sugs .active").length == 0) {
|
$("#sugs li:first-child").addClass("active");
|
||||||
$("#sugs li:first-child").addClass("active");
|
} else {
|
||||||
} else {
|
$("#sugs .active").removeClass("active").next().addClass("active");
|
||||||
$("#sugs .active").removeClass("active").next().addClass("active");
|
}
|
||||||
}
|
backupQuery();
|
||||||
backupQuery();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var originalQuery = false;
|
var originalQuery = false;
|
||||||
|
|
||||||
function backupQuery()
|
function backupQuery() {
|
||||||
{
|
if ($("#sugs .active").length > 0) {
|
||||||
if ($("#sugs .active").length > 0) {
|
if (!originalQuery) originalQuery = $("#i").val();
|
||||||
if (!originalQuery) originalQuery = $("#i").val();
|
$("#i").val($("#sugs .active a").html());
|
||||||
$("#i").val($("#sugs .active a").html());
|
} else {
|
||||||
} else {
|
$("#i").val(originalQuery);
|
||||||
$("#i").val(originalQuery);
|
originalQuery = false;
|
||||||
originalQuery = false;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeSugBox(src)
|
function closeSugBox(src) {
|
||||||
{
|
if (src == false || src == undefined || (src.id != "i" && src.id != "sugs"))
|
||||||
if (src == false || src == undefined || (src.id != "i" && src.id != "sugs"))
|
$("#sugs").html("").css({
|
||||||
$("#sugs").html("").css({"display": "none"});
|
"display": "none"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function applySugResult()
|
function applySugResult() {
|
||||||
{
|
if ($("#sugs .active").length > 0) {
|
||||||
if ($("#sugs .active").length > 0) {
|
$("#i").val($("#sugs .active a").html());
|
||||||
$("#i").val($("#sugs .active a").html());
|
closeSugBox(false);
|
||||||
closeSugBox(false);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user