-echo $Mainmenu->res;
+echo $Mainmenu->getRes();
?>
diff -bBu3 -r /root/tmp/wikipedia-suggest/wikipedia-suggest-0.2/extra/object.php ./object.php
--- /root/tmp/wikipedia-suggest/wikipedia-suggest-0.2/extra/object.php 2006-08-06 23:42:55.000000000 +1000
+++ ./object.php 2006-08-08 10:31:35.000000000 +1000
@@ -3,13 +3,17 @@
class Rectangle
{
// class variables
- var $title;
- var $width;
- var $content;
- var $colorBack;
- var $colorBack2;
- var $state;
- var $res;
+ private $title;
+ private $width;
+ private $content;
+ private $colorBack;
+ private $colorBack2;
+ private $state;
+ private $res;
+
+ function getRes() {
+ return $this->res;
+ }
function Rectangle()
{
@@ -65,12 +69,12 @@
{
$this->res = " \n" .
"colorBack . "; width: 4px; \" >" .
- "\n | \n" .
+ "\n\n" .
"colorBack ."; text-align: center; width: " . $this->width . "; \">\n" .
"" . $this->title .
"\n | \n" .
"colorBack ."; width: 4px; \" >\n" .
- "\n" .
+ "\n" .
" | \n \n" . $this->content .
"\ncolorBack ."; height: 2px; width: 4px; \" > | \n" .
"colorBack ."; height: 2px; width: 4px; \" > | \n" .
diff -bBu3 -r /root/tmp/wikipedia-suggest/wikipedia-suggest-0.2/extra/query.php ./query.php
--- /root/tmp/wikipedia-suggest/wikipedia-suggest-0.2/extra/query.php 2006-08-06 23:45:01.000000000 +1000
+++ ./query.php 2006-08-08 17:00:21.000000000 +1000
@@ -2,7 +2,10 @@
header('Content-Type: text/html; charset=utf-8');
-$content = $_GET['query'];
+$content = stripslashes ( $_GET['query'] );
+
+//# Debugging: append search to search log
+//file_put_contents("search-log.txt", $content . "\n", FILE_APPEND);
/* Create a TCP/IP socket. */
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
diff -bBu3 -r /root/tmp/wikipedia-suggest/wikipedia-suggest-0.2/extra/WSuggest.js ./WSuggest.js
--- /root/tmp/wikipedia-suggest/wikipedia-suggest-0.2/extra/WSuggest.js 2006-08-06 23:44:13.000000000 +1000
+++ ./WSuggest.js 2006-08-08 16:57:54.000000000 +1000
@@ -93,13 +93,13 @@
var s = '';
s += ' ';
- for (i = 1; i < 11; ++i)
+ for (var i = 1; i < 11; ++i)
if (i <= res[0].length && i <= res[1].length && i <= res[2].length)
{
if (i == selection)
- { s += ''; }
+ { s += ' '; }
else
- { s += ' '; }
+ { s += ' '; }
s += '';
s += '' + res[0][i - 1] + '';
s += ' | ' + res[1][i - 1] + ' | ';
@@ -111,6 +111,17 @@
else { hide(0); }
}
+function changeHighlight(oldId, newId)
+{
+ var res = answers[query];
+ if (newId > res[0].length) { newId = selection = res[0].length; }
+ if (newId == oldId) return; // nothing to do.
+ var oldRow = document.getElementById('suggest-' + oldId);
+ if (oldRow) oldRow.style.backgroundColor = _bgColor;
+ var newRow = document.getElementById('suggest-' + newId);
+ if (newRow) newRow.style.backgroundColor = _highLightColor;
+}
+
function encodeQuery(value)
{
if (encodeURIComponent)
@@ -119,18 +130,39 @@
return escape(value);
}
+function webQuery(value)
+{
+ var xmlhttp = getHttp();
+ if (xmlhttp) {
+ xmlhttp.open("GET", "query.php?query=" + encodeQuery(value),true);
+ xmlhttp.onreadystatechange=function()
+ {
+ if (xmlhttp.readyState==4) {
+ eval(xmlhttp.responseText);
+ }
+ }
+ xmlhttp.send(null);
+ }
+}
+
function keyDown(e)
{
var intKey = (window.Event) ? e.which : e.keyCode;
+ var value = objInput.value;
- if (intKey == 40) // PageDown
+ if (intKey == 40) // Arrow Down
{
+ if (value != "") {
selection = selection + 1;
- display(selection);
+ changeHighlight(selection - 1, selection);
+ }
}
- else if (intKey == 38) // PageUp
+ else if (intKey == 38) // Arrow Up
{
- if (selection > 1) { selection = selection - 1; display (selection); }
+ if (selection > 1 && value != "") {
+ selection = selection - 1;
+ changeHighlight(selection + 1, selection);
+ }
}
else if (intKey == 13) // enter
{
@@ -138,25 +170,12 @@
if (res && res[2].length > 0) { window.location.href=res[2][selection - 1]; }
}
else {
- var value = objInput.value;
if (value == "") { hide(0); }
else {
selection = 1;
query = value;
if (answers[query]) { display(selection); }
- else {
- var xmlhttp = getHttp();
- if (xmlhttp) {
- xmlhttp.open("GET", "/query.php?query=" + encodeQuery(value),true);
- xmlhttp.onreadystatechange=function()
- {
- if (xmlhttp.readyState==4) {
- eval(xmlhttp.responseText);
- }
- }
- xmlhttp.send(null);
- }
- }
+ else { webQuery(value); }
}
}
}
|