/[webpac]/trunk2/out/js/usage.js
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk2/out/js/usage.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 506 - (hide annotations)
Sun Oct 10 18:55:27 2004 UTC (19 years, 6 months ago) by dpavlin
File MIME type: application/javascript
File size: 3946 byte(s)
fix another warning

1 dpavlin 391 /**
2     usage.js an example usage of the search engine
3    
4     A part of the jsfind project (http://projects.elucidsoft.net/jsfind)
5     Copyright (C) 2003 Shawn Garbett
6    
7     This program is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License
9     as published by the Free Software Foundation; either version 2
10     of the License, or (at your option) any later version.
11    
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     GNU General Public License for more details.
16    
17     You should have received a copy of the GNU General Public License
18     along with this program; if not, write to the Free Software
19     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20    
21     Contact Info:
22     Shawn Garbett <Shawn@eLucidSoft.net>
23     http://www.elucidsoft.net
24     4037 General Bate Drive
25     Nashville, TN 37204
26     */
27    
28     function go(f)
29     {
30 dpavlin 462 var form = document.getElementById('search');
31 dpavlin 506 var query = document.form.elements['query'].value;
32     var index_name = document.form.elements['index_name'].options[document.form.elements['index_name'].selectedIndex].value;
33 dpavlin 462
34     if(!query)
35 dpavlin 391 {
36     return false;
37     }
38    
39     if(query == null || query == "")
40     {
41     alert("No search terms entered!");
42     return false;
43     }
44    
45     var parsed_string = query.replace(/\s/gi,"+");
46     //var url=location.host+location.pathname+"?search="+parsed_string;
47     var url=location.pathname+"?";
48     if (index_name) url += "index_name="+index_name+"&";
49     url += "query="+parsed_string;
50     location = url;
51    
52     return false;
53     }
54    
55     // Function to help find a "DIV" element
56     function findDivHelper(n, id)
57     {
58     for(var m=n.firstChild; m != null; m=m.nextSibling)
59     {
60     if((m.nodeType == 1) &&
61     (m.tagName.toLowerCase() == "div") &&
62 dpavlin 451 m.getAttribute("id") &&
63 dpavlin 391 (m.getAttribute("id").toLowerCase() == id.toLowerCase() ))
64     {
65     return m;
66     }
67     else
68     {
69     var r=findDivHelper(m, id);
70     if(r) return r;
71     }
72     }
73     return null;
74     }
75    
76     // Function to find a specified "DIV" element by id
77     function findDiv(id)
78     {
79     return findDivHelper(document.body,id);
80     }
81    
82     // Print results to page
83     function printResults(result)
84     {
85     //clearTimeout(watchdog_id);
86     //debug("clearTimeout = "+watchdog_id);
87     debug("printResults("+result.length+")");
88    
89     var d = findDiv("results");
90 dpavlin 451 var header;
91 dpavlin 391
92     // Null result output
93     if(result.length < 1)
94     {
95 dpavlin 451 header = (d.getElementsByTagName("h2"))[0].firstChild;
96 dpavlin 461 try {
97     header.replaceData(0, 14, "Nothing Found ");
98     } catch(e) {}
99 dpavlin 391
100     if(search_err != "")
101     {
102     e = document.createElement("font");
103     e.setAttribute("color","red");
104     e.setAttribute("size","+1");
105     e.appendChild(document.createTextNode(search_err));
106     d.appendChild(e);
107     d.appendChild(document.createElement("br"));
108     }
109    
110     return;
111     }
112    
113     // Add results to main document
114     for(var i=result.length-1; i>=0; i--)
115     {
116     var e = document.createElement("font");
117    
118     e = document.createElement("a");
119 dpavlin 499 e.setAttribute("href","browse.html?o="+result[i].link);
120 dpavlin 396 e.appendChild(document.createTextNode(result[i].title));
121 dpavlin 391 d.appendChild(e);
122     d.appendChild(document.createTextNode(" "));
123    
124 dpavlin 467 e = document.createElement("a");
125     e.setAttribute("href","thes/"+result[i].link+".html"+location.search);
126 dpavlin 470 e.setAttribute("target","popup");
127 dpavlin 473 //e.onclick = function() { return popup(); };
128     e.onclick = popup;
129 dpavlin 470 e.appendChild(document.createTextNode("\u00bb"));
130 dpavlin 467 d.appendChild(e);
131     /*
132 dpavlin 391 e = document.createElement("font");
133 dpavlin 396 e.setAttribute("color","gray");
134 dpavlin 391 e.appendChild(document.createTextNode("["+result[i].frequency+"]"));
135     d.appendChild(e);
136 dpavlin 467 */
137 dpavlin 391 d.appendChild(document.createElement("br"));
138     }
139    
140     // Change header
141 dpavlin 451 header = (d.getElementsByTagName("h2"))[0].firstChild;
142 dpavlin 391
143 dpavlin 461 try {
144     header.replaceData(0, 14, "Search Results");
145     } catch(e) {}
146 dpavlin 391
147     }

  ViewVC Help
Powered by ViewVC 1.1.26