blob: b9fb56f39172591fa23880e4a3d9faaa419efeaa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
// remote scripting library
// (c) copyright 2005 modernmethod, inc
var started;
var typing;
var memory=null;
var body=null;
var oldbody=null;
// Remove the typing barrier to allow call() to complete
function Search_doneTyping()
{
typing=false;
}
// Wait 500ms to run call()
function Searching_Go()
{
setTimeout("Searching_Call()", 500);
}
// If the user is typing wait until they are done.
function Search_Typing() {
started=true;
typing=true;
setTimeout("Search_doneTyping()", 500);
// I believe these are needed by IE for when the users press return?
if (window.event)
{
if (event.keyCode == 13)
{
event.cancelBubble = true;
event.returnValue = true;
}
}
}
// Set the body div to the results
function Searching_SetResult( request )
{
if ( request.status != 200 ) {
alert("Error: " + request.status + " " + request.statusText + ": " + request.responseText);
return;
}
var result = request.responseText;
//body.innerHTML = result;
t = document.getElementById("searchTarget");
if ( t == null ) {
oldbody=body.innerHTML;
body.innerHTML= '<div id="searchTargetContainer"><div id="searchTarget" ></div></div>' ;
t = document.getElementById("searchTarget");
}
t.innerHTML = result;
t.style.display='block';
}
function Searching_Hide_Results()
{
t = document.getElementById("searchTarget");
t.style.display='none';
body.innerHTML = oldbody;
}
// This will call the php function that will eventually
// return a results table
function Searching_Call()
{
var x;
Searching_Go();
//Don't proceed if user is typing
if (typing)
return;
x = document.getElementById("searchInput").value;
// Don't search again if the query is the same
if (x==memory)
return;
memory=x;
if (started) {
// Don't search for blank or < 3 chars.
if ((x=="") || (x.length < 3))
{
return;
}
sajax_do_call( "wfSajaxSearch", [ x ], Searching_SetResult );
}
}
//Initialize
function sajax_onload() {
x = document.getElementById( 'searchInput' );
x.onkeypress= function() { Search_Typing(); };
Searching_Go();
body = document.getElementById("content");
}
|