Previus/next scan buttons in scan.
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 3 Jan 1996 08:59:41 +0000 (08:59 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 3 Jan 1996 08:59:41 +0000 (08:59 +0000)
www/query.egw
www/search.egw
www/z39util.tcl

index 16856a1..618955e 100644 (file)
@@ -4,7 +4,7 @@
 </head>
 <body>
 {
-# $Id: query.egw,v 1.22 1996/01/02 15:34:08 adam Exp $
+# $Id: query.egw,v 1.23 1996/01/03 08:59:41 adam Exp $
 
     if {[info commands saveState] == ""} {
         source z39util.tcl
@@ -25,6 +25,9 @@ proc ok-response {} {
     global hist
 
     set host [lindex $sessionParms 0]
+    set initSet [lindex $sessionParms 1]
+    set scanLine [lindex $sessionParms 2]
+    set scanTerm [lindex $sessionParms 3]
 
     if {[catch {set setNo $nextSetNo}]} {
         set nextSetNo 1
@@ -95,13 +98,21 @@ proc ok-response {} {
     }
     set databases [lindex $targets($host) 1]
 
-    if {[catch {set prevHost $hist([expr $setNo - 1],host)}]} {
+#    if {[catch {set prevHost $hist([expr $setNo - 1],host)}]} {
+#        set databaseDefault [lindex $databases 0]
+#        set oSetNo 0
+#    } else {
+#        set oSetNo [expr $setNo - 1]
+#        set databaseDefault $hist($oSetNo,database)
+#    }
+    if {$initSet == ""} {
         set databaseDefault [lindex $databases 0]
         set oSetNo 0
     } else {
-        set oSetNo [expr $setNo - 1]
+        set oSetNo $initSet
         set databaseDefault $hist($oSetNo,database)
     }
+    
     html {<form action="http:} $env(SCRIPT_NAME)
     html / $sessionId {/search.egw/} $setNo {" method=post>} \n
     set nodb [llength $databases]
@@ -142,8 +153,11 @@ proc ok-response {} {
         }
         html "</select>\n"
         html {<input type="text" name="entry} $no {"}
+        if {$scanLine == $no} {
+            html { value="} $scanTerm {" }
+        }
         html { size=35>} \n
-        html {<input type="checkbox" name="scan" value="} $no {" scan>}
+        html {<input type="checkbox" name="scan} $no {" value="1" scan>}
         if {$no < 3} {
             html {<select name="logic} $no {">} \n
             if {$oSetNo > 0} {
@@ -204,6 +218,9 @@ and will continue to be so until the end of December 1995.</em>
     html "databases: " $databases " <br>\n"
     html "setNo: " $setNo " <br>\n"
     html "nextSetNo: " $nextSetNo " <br>\n"
+    html "initSet: " $initSet " <br>\n"
+    html "scanLine: " $scanLine " <br>\n"
+    html "scanTerm: " $scanTerm " <br>\n"
 }
 </body></html>
 
index 0feff70..daaf3b7 100644 (file)
@@ -1,8 +1,8 @@
 <html>
 {
-# $Id: search.egw,v 1.21 1996/01/02 10:52:28 adam Exp $
+# $Id: search.egw,v 1.22 1996/01/03 08:59:43 adam Exp $
 
-proc perform-scan {} {
+proc start-scan {scanNo cache dir} {
     global sessionId
     global sessionParms
     global sessionWait
@@ -12,30 +12,49 @@ proc perform-scan {} {
     global nextSetNo
     global env
 
-    set scanNo 1000
-
-    set termPlusAttr [build-scan $hist($setNo,host) 3]
+    set host $hist($setNo,host)
 
-    if {"$termPlusAttr" == ""} {
-        html "<head><title> WWW/Z39.50 Gateway Scan</title>\n<body>\n"
+    html "<head><title> WWW/Z39.50 Gateway Scan " $host " </title>\n"
+    html "</head><body>\n"
+                
+    if {$hist($setNo,$scanNo,scanTerm) == ""} {
         displayError "Empty query" \
-            "You must specify at least one search word"
+                     "You must specify at least one search word"
         html "</body></html>\n"
         wabort
+        return
     }
-    set hist($setNo,scanAttr) [lindex $termPlusAttr 1]
-    set hist($setNo,$scanNo,scanTerm) [lindex $termPlusAttr 0]
-    
-    set host $hist($setNo,host)
-
-    html "<head><title> WWW/Z39.50 Gateway Scan " $host " </title>\n"
-    html "</head><body>\n"
-
-    if {[z39scan $setNo $scanNo 0 20 10] != "1"} {
+    if {$dir == "b"} {
+        set lines 20
+        set pos 20
+    } elseif {$dir == "f"} {
+        set lines 20
+        set pos 1
+    } else {
+        set lines 20
+        set pos 10
+    }
+    if {[z39scan $setNo $scanNo 0 $lines $pos $cache] != "1"} {
         return
     }
+    html {<a href="http:} $env(SCRIPT_NAME)
+    html / $sessionId {/search.egw/} $setNo + [expr $scanNo - 1] + b
+    html {">Backward</a>} "\n"
+
+    html {<a href="http:} $env(SCRIPT_NAME)
+    html / $sessionId {/search.egw/} $setNo + [expr $scanNo + 1] + f
+    html {">Forward</a><br>}
+
     display-scan $setNo $scanNo 0
 
+    html {<a href="http:} $env(SCRIPT_NAME)
+    html / $sessionId {/search.egw/} $setNo + [expr $scanNo - 1] + b
+    html {">Backward</a>} "\n"
+
+    html {<a href="http:} $env(SCRIPT_NAME)
+    html / $sessionId {/search.egw/} $setNo + [expr $scanNo + 1] + f
+    html {">Forward</a><br>}
+
     html "<hr>\n"
     html "<h3>Debug information</h3>\n"
     html "sessionId: $sessionId <br>\n"
@@ -136,7 +155,7 @@ proc buttons {setNo setMax startPos after} {
 
     set setNo [lindex $sessionParms 0]
 
-    if {[wform menu1] != ""} {
+    if {[wform] != ""} {
         set hist($nextSetNo,idAuthentication) $hist($setNo,idAuthentication)
         set hist($nextSetNo,host) $hist($setNo,host)
 
@@ -172,11 +191,19 @@ proc buttons {setNo setMax startPos after} {
         if {$hist($setNo,maxPresent) == ""} {
             set hist($setNo,maxPresent) 30
         }
-
-        if {[wform submit] == "Scan"} {
-            perform-scan
-            wabort
+        for {set i 1} {$i <= 3} {incr i} {
+            if {[wform scan$i] != ""} {
+                set scanNo 1000
+                set hist($setNo,scan) $i
+                set termPlusAttr [build-scan $hist($setNo,host) $i]
+                set hist($setNo,$scanNo,scanTerm) [lindex $termPlusAttr 0]
+                set hist($setNo,scanAttr) [lindex $termPlusAttr 1]
+                start-scan $scanNo 0 {}
+                wabort
+                return
+            }
         }
+        set hist($setNo,scan) 0
         set query [build-query $hist($setNo,host) 3]
         if {"x$query" == "x"} {
             html "<head><title> WWW/Z39.50 Gateway Search</title>\n<body>\n"
@@ -186,6 +213,16 @@ proc buttons {setNo setMax startPos after} {
             wabort
         }
         set hist($setNo,query) $query
+    } else {
+        if {$hist($setNo,scan) > 0} {
+            set scanNo [lindex $sessionParms 1]
+            set dir [lindex $sessionParms 2]
+            if {$scanNo == ""} {
+                set scanNo 1000
+            }
+            start-scan $scanNo 1 $dir
+            wabort
+        }
     }
     set host $hist($setNo,host)
 
index 3a2c694..9413385 100644 (file)
@@ -1,5 +1,5 @@
 #
-# $Id: z39util.tcl,v 1.15 1996/01/02 10:52:32 adam Exp $
+# $Id: z39util.tcl,v 1.16 1996/01/03 08:59:45 adam Exp $
 #
 proc saveState {} {
     uplevel #0 {
@@ -361,20 +361,18 @@ proc display-rec {from to dfunc tno} {
     }
 }
 
-proc build-scan {t ilines} {
+proc build-scan {t i} {
     global targets
 
-    for {set i 1} {$i <= $ilines} {incr i} {
-        set term [wform entry$i]
-        if {$term != ""} {
-            set field [wform menu$i]
-            foreach x [lindex $targets($t) 2] {
-                if {[lindex $x 0] == $field} {
-                    set attr [lindex $x 1]
-                }
+    set term [wform entry$i]
+    if {$term != ""} {
+        set field [wform menu$i]
+        foreach x [lindex $targets($t) 2] {
+            if {[lindex $x 0] == $field} {
+                set attr [lindex $x 1]
             }
-            return [list $term $attr]
         }
+        return [list $term $attr]
     }
     return ""
 }
@@ -409,7 +407,7 @@ proc build-query {t ilines} {
     return $q
 }
 
-proc z39scan {setNo scanNo tno scanLines scanPos} {
+proc z39scan {setNo scanNo tno scanLines scanPos cache} {
     global hist
     global sessionWait
     global targets
@@ -480,7 +478,7 @@ proc z39scan {setNo scanNo tno scanLines scanPos} {
             return 0
         }
     } else {
-        if {![catch [list $zs numberOfTermsRequested 5]]} {
+        if {$cache && ![catch [list $zs numberOfTermsRequested 5]]} {
             return 1
         }
     }
@@ -517,6 +515,8 @@ proc z39scan {setNo scanNo tno scanLines scanPos} {
 proc display-scan {setNo scanNo tno} {
     global hist
     global targets
+    global env
+    global sessionId
 
     if {$tno > 0} {
         set zz z39$tno
@@ -525,16 +525,30 @@ proc display-scan {setNo scanNo tno} {
     }
     set zs $zz.s$scanNo.$setNo
     set m [$zs numberOfEntriesReturned]
-
-    html "<dl>\n"
+        
+    if {$m > 0} {
+        set t [lindex [$zs scanLine 0] 1]
+        if {$tno > 0} {
+            set hist($setNo,$tno,[expr $scanNo - 1],scanTerm) $t
+        } else {
+            set hist($setNo,[expr $scanNo - 1],scanTerm) $t
+        }
+        set t [lindex [$zs scanLine [expr $m - 1]] 1]
+        if {$tno > 0} {
+            set hist($setNo,$tno,[expr $scanNo + 1],scanTerm) $t
+        } else {
+            set hist($setNo,[expr $scanNo + 1],scanTerm) $t
+        }
+    }
     for {set i 0} {$i < $m} {incr i} {
-        html "<dt>"
+        html {<a href="http:} $env(SCRIPT_NAME)
+        html / $sessionId {/query.egw/} $hist($setNo,host) + $setNo +
+        html $hist($setNo,scan) + [lindex [$zs scanLine $i] 1] {">}
         html [lindex [$zs scanLine $i] 1]
-        html ": "
+        html {</a>: <em>}
         html [lindex [$zs scanLine $i] 2]
-        html "\n"
+        html "</em><br>\n"
     }
-    html "</dl>\n"
 }
 
 proc z39search {setNo piggy tno elements} {