/[webpac]/trunk2/eurovoc/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

Contents of /trunk2/eurovoc/js/usage.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 531 - (show annotations)
Tue Oct 19 18:15:53 2004 UTC (19 years, 6 months ago) by dpavlin
File MIME type: application/javascript
File size: 3870 byte(s)
fix few more warnings and cosmetic changes

1 /**
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 var form = document.getElementById('search');
31 var query = null;
32 if (form) query = form.elements['query'].value;
33
34 if(!query)
35 {
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 find a specified "DIV" element by id
56 function findDiv(id)
57 {
58 return document.getElementById(id);
59 }
60
61 // Print results to page
62 function printResults(result)
63 {
64 //clearTimeout(watchdog_id);
65 //debug("clearTimeout = "+watchdog_id);
66 debug("printResults("+result.length+")");
67
68 var d = findDiv("results");
69 var status = findDiv("status");
70
71 // Null result output
72 if(result.length < 1)
73 {
74 if (status) status.innerHTML = "Nije pronaĆ°en niti jedan rezultat.";
75
76 if(search_err != "")
77 {
78 e = document.createElement("font");
79 e.setAttribute("color","red");
80 e.setAttribute("size","+1");
81 e.appendChild(document.createTextNode(search_err));
82 d.appendChild(e);
83 d.appendChild(document.createElement("br"));
84 }
85
86 return;
87 }
88
89 debug("sort results by title");
90 results.sort(sortResults_title);
91
92 // Add results to main document
93 for(var i=result.length-1; i>=0; i--)
94 {
95 var li = document.createElement("li");
96
97 var e = document.createElement("a");
98 e.setAttribute("href","hijerarhija.html?o="+result[i].link);
99 var regex = new RegExp(/ *\* */);
100 if (results[i].title.match(regex)) {
101 e.appendChild(self.document.createTextNode(results[i].title.replace(regex,' ')));
102 var pic = self.document.createElement("img");
103 pic.src = 'img/crovoc.png';
104 pic.border = 0;
105 e.appendChild(pic);
106 } else {
107 e.appendChild(document.createTextNode(result[i].title));
108 }
109 li.appendChild(e);
110 li.appendChild(document.createTextNode(" "));
111
112 e = document.createElement("a");
113 e.setAttribute("href","thes/"+result[i].link+".html"+location.search);
114 //e.setAttribute("target","popup");
115 //e.onclick = function() { return popup(); };
116 e.onclick = popup;
117 var pic = self.document.createElement("img");
118 pic.src = 'img/listic.png';
119 pic.border = 0;
120 e.appendChild(pic);
121 li.appendChild(e);
122 /*
123 e = document.createElement("font");
124 e.setAttribute("color","gray");
125 e.appendChild(document.createTextNode("["+result[i].frequency+"]"));
126 li.appendChild(e);
127 */
128 li.appendChild(document.createElement("br"));
129 d.appendChild(li);
130 }
131
132 if (status) status.innerHTML = "PronaĆ°eno je "+results.length+" rezultata.";
133
134 }
135
136 // override default sort by frequency and sort by headline
137 function sortResults_title(a, b)
138 {
139 return a.title.toLowerCase() == b.title.toLowerCase() ? 0 : ( a.title.toLowerCase() > b.title.toLowerCase() ? -1 : 1);
140 }

  ViewVC Help
Powered by ViewVC 1.1.26