if false { A colleage of mine publishes technical sheets not only on our Intranet but also on CD-ROM. Last friday, she asked me how to realise the search page on CD-ROM. I answered: maybe there's the ASP, but no little dwarf to work out the ASP, so '''no way''' ... But, next day was saturday ... maybe the wheather ... I found a solution in Javascript. It is a single file search.js to be sourced. Here the source: } proc echo args {puts $args} proc cat {file} { # return contents of $file set port [open $file] set contents [read $port] close $port set contents } if {$argv ne ""} then { set startFile [lindex $argv 0] } else { set startFile [lindex [glob *.htm*] 0] } proc relPathFromTo {fromDir toDir} { # return path string relative from $fromDir to $toDir. # $fromDir is assumed to be a directory (not a file). set from [file normalize $fromDir] set to [file normalize $toDir] if {$::tcl_platform(platform) eq "windows"} { set driveMap { a: A: b: B: c: C: d: D: e: E: f: F: g: G: h: H: i: I: j: J: k: K: l: L: m: M: n: N: o: O: p: P: q: Q: r: R: s: S: t: T: u: U: v: V: w: W: x: X: y: Y: z: Z: } regexp {^[a-zA-Z]:} [pwd] drive if {![regexp {^[a-zA-Z]:} $from]} { set from $drive$from } set from [string map $driveMap $from] if {![regexp {^[a-zA-Z]:} $to]} { set to $drive$to } set to [string map $driveMap $to] } set fromList [file split $from] set fromLength [llength $fromList] set toList [file split $to] set toLength [llength $toList] set commonList {} foreach path1 $fromList path2 $toList { if {$path1 ne $path2} { break } else { lappend commonList $path1 } } set commonLength [llength $commonList] set fromList1 [lrange $fromList $commonLength end] set toList1 [lrange $toList $commonLength end] set resultList {} foreach i $fromList1 { lappend resultList .. } eval lappend resultList $toList1 if {$resultList ne {}} { eval file join $resultList } } array set database {} set titles {} proc parseFile file { variable startFile variable links variable database variable titles if {$startFile eq $file} then { set links {} array unset database array set database {} } set startDir [file dirname $startFile] set file [file normalize $file] set myPath [relPathFromTo [file normalize $startDir] $file] if {[lsearch $links $myPath] >= 0} then { return } echo processing $myPath lappend links $myPath set myDir [file dirname $myPath] set contents [cat $file] # title if {[regexp -nocase {
Suchergebnis für ", queryList .toString() .replace(",", ", "), ":
") else document .write ("Search results for ", queryList .toString() .replace(",", ", "), ":
") var resultList = [] for (var i in queryList) { if (i == 0) resultList = database[queryList[i]] else if (queryList[i] != "") resultList = commonElementsOf(resultList, database[queryList[i]]) } if (resultList && resultList .length) { document .write( "Nichts gefunden
") else document .write ("No match
") } } close $out if false { Here the contents of the search page: