Commit: 0337e3e25e089f357372d618d776319941fcc50c Author: Hannes Magnusson <[email protected]> Sat, 28 Dec 2013 21:08:53 -0800 Parents: 344352530401219533a0e20e2a994da9639175a7 Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=0337e3e25e089f357372d618d776319941fcc50c Log: Add a 'g a' full site search (based on doc indexes) Changed paths: M js/common.js M styles/theme-base.css Diff: diff --git a/js/common.js b/js/common.js index 4378a5e..b817556 100755 --- a/js/common.js +++ b/js/common.js @@ -166,15 +166,20 @@ $.expr[":"].icontains = $.expr.createPseudo(function(arg) { }); function lookfor(txt) { var retval = $("#layout a:icontains('" + txt + "')"); - $("#goto .results ul").empty(); $(retval).each(function(k, val) { $("#goto .results ul").append("<li><a href='" + $(val).attr("href") + "'>" + $(val).text() +"</a></li>"); }); - $("#goto .results a:first").focus(); +} +function localpage(text) { + lookfor(text); } Mousetrap.bind("g s", function(e) { + boogie(e, localpage); +}); +function boogie(e, cb) { + cb($("#goto .text").text()); + $("#goto .results a:first").focus(); $("#goto").slideToggle(); - lookfor($("#goto .text").text()); $("html").on("keydown", function(e) { switch(e.which || e.keyCode) { @@ -183,7 +188,9 @@ Mousetrap.bind("g s", function(e) { var txt = $("#goto .text").text(); txt = txt.substring(0, txt.length - 1); $("#goto .text").text(txt); - lookfor(txt); + $("#goto .results ul").empty(); + cb(txt); + $("#goto .results a:first").focus(); e.preventDefault(); break; @@ -210,11 +217,45 @@ Mousetrap.bind("g s", function(e) { var letter = String.fromCharCode(e.which || e.keyCode); $("#goto .text").append(letter); var txt = $("#goto .text").text().trim(); - lookfor(txt); + $("#goto .results ul").empty(); + cb(txt); + $("#goto .results a:first").focus(); }); Mousetrap.pause(); +} +if (!('contains' in String.prototype)) { + String.prototype.contains = function(str, startIndex) { + return -1 !== String.prototype.indexOf.call(this, str, startIndex); + }; +} +Mousetrap.bind("g a", function(e) { + boogie(e, globalsearch); }); +function globalsearch(txt) { + var key = "search-en"; + var cache = window.localStorage.getItem(key); + cache = JSON.parse(cache); + + var term = txt.toLowerCase(); + if (term.length < 3) { + return; + } + if (cache) { + for (var type in cache.data) { + console.log(type); + var elms = cache.data[type].elements; + for (var node in elms) { + if (elms[node].description.toLowerCase().contains(term) || elms[node].name.toLowerCase().contains(term)) { + $("#goto .results ul").append("<li><a href='/manual/en/" + elms[node].id + ".php'>" + elms[node].name + ": " + elms[node].description +"</a></li>"); + if ($("#goto .results ul li") > 30) { + return; + } + } + } + } + } +} Mousetrap.bind("/", function(e) { if (e.preventDefault) { e.preventDefault(); diff --git a/styles/theme-base.css b/styles/theme-base.css index b3ff549..3d93d10 100755 --- a/styles/theme-base.css +++ b/styles/theme-base.css @@ -1744,13 +1744,14 @@ div.soft-deprecation-notice blockquote.sidebar { line-height: 1; } #goto .search .results :focus { - font-size: 2.5em; - line-height: 1.5; + font-size: 2em; + line-height: 1.2; } #goto .search .text { color: #222; text-shadow: 0px 2px 3px #555; font-size: 10em; + line-height: .7; } #trick { display: none; -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
