* Avoid redundant hard-wiring of main path in JS code

* Fix `<<' and `>>' events
* No "provided from" for ids without modules

svn: r10032
This commit is contained in:
Eli Barzilay 2008-05-30 08:06:36 +00:00
parent 73f4a8dc74
commit 65e3a0d0ee
3 changed files with 42 additions and 34 deletions

View File

@ -25,7 +25,7 @@
(string<? (car a) (car b)))] (string<? (car a) (car b)))]
[else (string-ci<? (car a) (car b))]))) [else (string-ci<? (car a) (car b))])))
(define (make-script renderer sec ri) (define (make-script user-dir? renderer sec ri)
(define l null) (define l null)
(define span-classes null) (define span-classes null)
;; To make the index smaller, html contents is represented as one of these: ;; To make the index smaller, html contents is represented as one of these:
@ -36,7 +36,9 @@
;; In addition, a "file:/main-doc.../path..." url is saved as ">path..." ;; In addition, a "file:/main-doc.../path..." url is saved as ">path..."
;; This function does the url compacting. ;; This function does the url compacting.
(define main-url ; (make sure that it teminates with a slash) (define main-url ; (make sure that it teminates with a slash)
(regexp-replace #rx"/*$" (url->string (path->url (find-doc-dir))) "/")) (if user-dir?
(regexp-replace #rx"/*$" (url->string (path->url (find-doc-dir))) "/")
"../"))
(define compact-url (define compact-url
(let ([rx (regexp (string-append "^" (regexp-quote main-url)))]) (let ([rx (regexp (string-append "^" (regexp-quote main-url)))])
(lambda (url) (regexp-replace rx url ">")))) (lambda (url) (regexp-replace rx url ">"))))
@ -159,7 +161,7 @@
+'</td></tr>' +'</td></tr>'
+'<tr><td align="left">' +'<tr><td align="left">'
+'<a href="#" title="Previous Page"' +'<a href="#" title="Previous Page"'
+'onclick="key_handler(\"PgUp\"); return false;"' +' onclick="key_handler(\'PgUp\'); return false;"'
+'><tt><b>&lt;&lt;</b></tt></a>' +'><tt><b>&lt;&lt;</b></tt></a>'
+'</td><td align="center">' +'</td><td align="center">'
+'<span id="search_status" style="color: #601515; font-weight: bold;">' +'<span id="search_status" style="color: #601515; font-weight: bold;">'
@ -167,7 +169,7 @@
+'</span>' +'</span>'
+'</td><td align="right">' +'</td><td align="right">'
+'<a href="#" title="Next Page"' +'<a href="#" title="Next Page"'
+'onclick="key_handler(\"PgDn\"); return false;"' +' onclick="key_handler(\'PgDn\'); return false;"'
+'><tt><b>&gt;&gt;</b></tt></a>' +'><tt><b>&gt;&gt;</b></tt></a>'
+'</td></tr>' +'</td></tr>'
+'<tr><td colspan="3">' +'<tr><td colspan="3">'
@ -276,13 +278,11 @@
for (var i=0@";" i<result_links.length@";" i++) { for (var i=0@";" i<result_links.length@";" i++) {
var n = i + first_search_result; var n = i + first_search_result;
if (n < search_results.length) { if (n < search_results.length) {
var desc = ""; var desc = "", libs = search_results[n][3];
if (search_results[n][3]) { if (libs && (libs.length > 0)) {
for (var j=0@";" j<search_results[n][3].length@";" j++) for (var j=0@";" j<libs.length@";" j++)
desc += (j==0 ? "" : ", " ) desc += (j==0 ? "" : ", " )
+ '<span class="schememod">' + '<span class="schememod">' + libs[j] + '</span>';
+ search_results[n][3][j]
+ '</span>';
desc = '&nbsp;&nbsp;' desc = '&nbsp;&nbsp;'
+ '<span style="font-size: 80%;">' + '<span style="font-size: 80%;">'
+ '<span style="font-size: 80%;">provided from</span> ' + '<span style="font-size: 80%;">provided from</span> '
@ -317,16 +317,24 @@
search_timer = null; search_timer = null;
clearTimeout(t); clearTimeout(t);
} }
var key = event && event.keyCode; var key = event;
if (key == 13) { if (typeof event != "string") {
switch (event.keyCode) {
case 13: key = "Enter"; break;
case 33: key = "PgUp"; break;
case 34: key = "PgDn"; break;
}
}
switch (key) {
case "Enter":
DoSearch(); DoSearch();
return false; return false;
} else if (key == 33) { case "PgUp":
DoSearch(); // in case we didn't update it yet DoSearch(); // in case we didn't update it yet
first_search_result -= results_num; first_search_result -= results_num;
UpdateResults(); UpdateResults();
return false; return false;
} else if (key == 34) { case "PgDn":
DoSearch(); // in case we didn't update it yet DoSearch(); // in case we didn't update it yet
if (first_search_result + results_num < search_results.length) { if (first_search_result + results_num < search_results.length) {
first_search_result += results_num; first_search_result += results_num;
@ -345,10 +353,10 @@
})(); })();
}) })
(define (make-search) (define (make-search user-dir?)
(make-splice (make-splice
(list (list
(make-delayed-block (make-delayed-block
(lambda (r s i) (make-paragraph (list (make-script r s i))))) (lambda (r s i) (make-paragraph (list (make-script user-dir? r s i)))))
(make-element (make-with-attributes #f '((id . "plt_search_container"))) (make-element (make-with-attributes #f '((id . "plt_search_container")))
null)))) null))))

View File

@ -4,4 +4,4 @@
@main-page['search #t] @main-page['search #t]
@make-search[] @make-search[#f]

View File

@ -4,4 +4,4 @@
@main-page['search #f] @main-page['search #f]
@make-search[] @make-search[#t]