]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/lily_search.js
Add '-dcrop' option to ps and svg backends
[lilypond.git] / Documentation / lily_search.js
1 var resObject = null;
2 var useAjax = (document.location.protocol.toLowerCase() == 'http:');
3 var isLocal = !useAjax;
4
5 var previous_search = "";
6
7 function erzXMLHttpRequestObject ()
8 {
9   var resObject = null;
10   try {
11     resObject = new XMLHttpRequest ();
12   }
13   catch (Error) {
14     try {
15       resObject = new ActiveXObject ("Microsoft.XMLHTTP");
16     }
17     catch (Error) {
18       try {
19         resObject = new ActiveXObject ("MSXML2.XMLHTTP");
20       }
21       catch (Error) {
22         alert ("Unable to create XMLHttpRequest object for the search function!");
23         useAjax = false;
24       }
25     }
26   }
27   return resObject;
28 }
29
30 function searchResult (language, manual, bigpage)
31 {
32   search_string = this.document.search_form.q.value;
33   if (useAjax && previous_search != search_string) {
34     if (useAjax && search_string.length >= 3) {
35       var reldir = "";
36       if (bigpage == 0) {
37         reldir = "../"
38       }
39       resObject.open ('get', reldir + 'lily_index_search.php?lang=' + escape(language) + '&manual=' + escape(manual) + '&bigpage=' + bigpage + '&q=' + escape(search_string), true);
40       resObject.onreadystatechange = handleResponse;
41       resObject.send (null);
42     } else {
43       clearResults ();
44     }
45     previous_search = search_string;
46   }
47 }
48
49 function result_field ()
50 {
51   return document.getElementById ('search_results');
52 }
53 function assignResults (results)
54 {
55     field = result_field ();
56     field.innerHTML = resObject.responseText;
57     field.style.display = 'block';
58 }
59
60 function handleResponse ()
61 {
62   if (resObject.readyState == 4 ) {
63     assignResults (resObject.responseText);
64   }
65 }
66
67 function clearResults ()
68 {
69     field = result_field ();
70     field.innerHTML = 0;
71     field.style.display = 'none';
72 }
73
74
75 function print_search_field (language, manual, bigpage)
76 {
77   if (useAjax) {
78     // If the user presses enter and submits the form, also call the search
79     // script to print out the results in a separate page
80     search_call = "searchResult('" + language + "', '" + manual + "', " + bigpage + ")";
81     var reldir = "";
82     if (bigpage == 0) {
83       reldir = "../"
84     }
85     search_script = reldir + 'lily_index_search.php';
86     document.write("<div id=\"search\">");
87     document.write("<form name=\"search_form\" action=\"" + search_script + "\" onsubmit=\"" + search_call + "; return false;\">");
88     document.write("<input type=\"hidden\" name=\"lang\" value=\"" + escape(language) + "\" >");
89     document.write("<input type=\"hidden\" name=\"manual\" value=\"" + escape(manual) + "\" >");
90     document.write("<input type=\"hidden\" name=\"bigpage\" value=\"" + bigpage + "\" >");
91     document.write("<input type=\"hidden\" name=\"form_submitted\" value=\"1\" >");
92     document.write("<p class=\"searchbar\">Search: ");
93     document.write("  <input name=\"q\" onkeyup=\"" + search_call + "\" size=25></input></p>");
94     document.write("  <div id=\"search_results\"></div>");
95     document.write("</form>");
96     document.write("</div>");
97   }
98 }
99 if (useAjax) {
100   resObject = erzXMLHttpRequestObject ();
101 }