* 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)))]
[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 span-classes null)
;; 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..."
;; This function does the url compacting.
(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
(let ([rx (regexp (string-append "^" (regexp-quote main-url)))])
(lambda (url) (regexp-replace rx url ">"))))
@ -159,7 +161,7 @@
+'</td></tr>'
+'<tr><td align="left">'
+'<a href="#" title="Previous Page"'
+'onclick="key_handler(\"PgUp\"); return false;"'
+' onclick="key_handler(\'PgUp\'); return false;"'
+'><tt><b>&lt;&lt;</b></tt></a>'
+'</td><td align="center">'
+'<span id="search_status" style="color: #601515; font-weight: bold;">'
@ -167,7 +169,7 @@
+'</span>'
+'</td><td align="right">'
+'<a href="#" title="Next Page"'
+'onclick="key_handler(\"PgDn\"); return false;"'
+' onclick="key_handler(\'PgDn\'); return false;"'
+'><tt><b>&gt;&gt;</b></tt></a>'
+'</td></tr>'
+'<tr><td colspan="3">'
@ -276,13 +278,11 @@
for (var i=0@";" i<result_links.length@";" i++) {
var n = i + first_search_result;
if (n < search_results.length) {
var desc = "";
if (search_results[n][3]) {
for (var j=0@";" j<search_results[n][3].length@";" j++)
var desc = "", libs = search_results[n][3];
if (libs && (libs.length > 0)) {
for (var j=0@";" j<libs.length@";" j++)
desc += (j==0 ? "" : ", " )
+ '<span class="schememod">'
+ search_results[n][3][j]
+ '</span>';
+ '<span class="schememod">' + libs[j] + '</span>';
desc = '&nbsp;&nbsp;'
+ '<span style="font-size: 80%;">'
+ '<span style="font-size: 80%;">provided from</span> '
@ -317,16 +317,24 @@
search_timer = null;
clearTimeout(t);
}
var key = event && event.keyCode;
if (key == 13) {
var key = event;
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();
return false;
} else if (key == 33) {
case "PgUp":
DoSearch(); // in case we didn't update it yet
first_search_result -= results_num;
UpdateResults();
return false;
} else if (key == 34) {
case "PgDn":
DoSearch(); // in case we didn't update it yet
if (first_search_result + results_num < search_results.length) {
first_search_result += results_num;
@ -345,10 +353,10 @@
})();
})
(define (make-search)
(define (make-search user-dir?)
(make-splice
(list
(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")))
null))))

View File

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

View File

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