commit 34f239498bc743349ecd555a7e64fe711b66552a
parent ed08874f6c44e345cdf475bfa46a9444f980935e
Author: Eli Barzilay <eli@racket-lang.org>
Date: Fri, 30 May 2008 04:12:21 +0000
* A little better JS event handler code
* Re-add search box, now appearing on all pages
svn: r10030
original commit: 66cb57f46d68e2dffb00983484fbd51743032872
Diffstat:
2 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/collects/scribble/html-render.ss b/collects/scribble/html-render.ss
@@ -186,17 +186,16 @@
[onchange "delayed_search(this.value,event);"]
[onkeyup "delayed_search(this.value,event);"]))})
-(define (search-index-box index-url) ; appears on every page
+)
+
+(define (search-index-box) ; appears on every page
(let ([sa string-append])
`(input
([style ,(sa "font-size: 75%; margin: 0px; padding: 0px; border: 1px;"
" background-color: #eee; color: #888;")]
[type "text"]
[value "...search..."]
- [onkeypress ,(sa "if (event && event.keyCode==13"
- " && this.value.indexOf(\"...search...\")<0) {"
- " location=\"doc-index.html?q=\"+escape(this.value);"
- " };")]
+ [onkeypress ,(format "return DoSearchKey(event, this, ~s);" (version))]
[onfocus ,(sa "this.style.color=\"black\";"
" if (this.value.indexOf(\"...search...\")>=0)"
" this.value=\"\";")]
@@ -204,8 +203,6 @@
" this.style.color=\"#888\";"
" this.value=\"...search...\"; }")]))))
-)
-
;; ----------------------------------------
;; main mixin
@@ -611,9 +608,9 @@
#; ; no need for these index-local searches
,@(if (eq? d index)
null
- `((small nbsp
- ,(search-index-box (derive-filename index))))))
- null))
+ `((small nbsp ,(search-index-box)))))
+ null)
+ ,@(if up-path `(nbsp (small ,(search-index-box))) null))
(div ([class "navright"])
,@(render
(make-element
diff --git a/collects/scribble/scribble-common.js b/collects/scribble/scribble-common.js
@@ -44,14 +44,15 @@ function NormalizePath(path) {
return path;
}
-function DoSearchKey(event, field) {
+function DoSearchKey(event, field, ver) {
var val = field.value;
if (event && event.keyCode == 13 && val.indexOf("...search...") < 0) {
- var u = GetCookie("PLT_Root");
+ var u = GetCookie("PLT_Root."+ver);
if (u == null) u = "../"; // default: go up
- u = u.replace(/[^\/\\]*$/, "") + "plt-search.html";
- location = u + "?q=" + escape(val);
+ location = u + "search/index.html" + "?q=" + escape(val);
+ return false;
}
+ return true;
}
// `noscript' is problematic in some browsers (always renders as a