X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Rakka.git;a=blobdiff_plain;f=js%2Fsearch.js;h=3367804c97d0dd51facad3753446f8be13549b5d;hp=c1a90f84aa493a6c4691091bc3ca8ea293012616;hb=529f792d338c75910079903e143d4dd21bd806c3;hpb=e751af5e3d23d7757f363bf4e86f9d732d90be7f diff --git a/js/search.js b/js/search.js index c1a90f8..3367804 100644 --- a/js/search.js +++ b/js/search.js @@ -1,23 +1,34 @@ (function () { $(document).ready(function () { - $("input.searchField") - .val("Search") - .removeClass("activeField") - .addClass("inactiveField") - .focus(function () { - if ($(this).attr("class").indexOf("inactiveField")) { - $(this) - .val("") - .removeClass("inactiveField") - .addClass("activeField"); - } - }) - .keypress(function (e) { + var $fld = $("input.searchField") + + $fld.keypress(function (e) { if (e.which == 10 || e.which == 13) { window.location = Rakka.baseURI + "search.html?q=" + encodeURI($(this).val()); } }); + + /* 檢索 query が指定されてゐれば、それが最初から入力されてゐる + * 状態にする。 + */ + var form = Rakka.getQueryForm(); + if (form["q"] == null) { + $fld.val("Search") + .removeClass("activeField") + .addClass("inactiveField") + .focus(function () { + if ($(this).attr("class").indexOf("inactiveField")) { + $(this) + .val("") + .removeClass("inactiveField") + .addClass("activeField"); + } + }); + } + else { + $fld.val(form["q"]); + } }); })(); \ No newline at end of file