/[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 592 - (show annotations)
Sat Nov 6 23:25:30 2004 UTC (19 years, 4 months ago) by dpavlin
File MIME type: application/javascript
File size: 4179 byte(s)
cludge to prevenet operation aborted message from Internet Explorer if there
is no div with id debug on page.

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 /*
29 Internet Explorer returns operation aborted if no debug div is present on
30 page, so we'll override default debug function from jsFind with dummy one.
31 */
32 function debug(foo) {
33 return;
34 }
35
36 function go(f)
37 {
38 var form = document.getElementById('search');
39 var query = null;
40 if (form) query = form.elements['query'].value;
41
42 if(!query)
43 {
44 return false;
45 }
46
47 if(query == null || query == "")
48 {
49 alert("No search terms entered!");
50 return false;
51 }
52
53 var parsed_string = query.replace(/\s/gi,"+");
54 //var url=location.host+location.pathname+"?search="+parsed_string;
55 var url=location.pathname+"?";
56 if (index_name) url += "index_name="+index_name+"&";
57 url += "query="+parsed_string;
58 location = url;
59
60 return false;
61 }
62
63 // Function to find a specified "DIV" element by id
64 function findDiv(id)
65 {
66 return document.getElementById(id);
67 }
68
69 // Print results to page
70 function printResults(result)
71 {
72 //clearTimeout(watchdog_id);
73 //debug("clearTimeout = "+watchdog_id);
74 debug("printResults("+result.length+")");
75
76 var d = findDiv("results");
77 var status = findDiv("status");
78
79 // Null result output
80 if(result.length < 1)
81 {
82 if (status) status.innerHTML = "Nije pronaðen niti jedan rezultat. Poku¹ajte s upisom rijeèi u drugom rodu, broju i pade¾u (carina &ne; carine, carinska &ne; carinski &ne; carinskog).";
83
84 if(search_err != "")
85 {
86 e = document.createElement("font");
87 e.setAttribute("color","red");
88 e.setAttribute("size","+1");
89 e.appendChild(document.createTextNode(search_err));
90 d.appendChild(e);
91 d.appendChild(document.createElement("br"));
92 }
93
94 return;
95 }
96
97 debug("sort results by title");
98 results.sort(sortResults_title);
99
100 // Add results to main document
101 for(var i=result.length-1; i>=0; i--)
102 {
103 var li = document.createElement("li");
104
105 var e = document.createElement("a");
106 e.setAttribute("href","hijerarhija.html?o="+result[i].link);
107 var regex = new RegExp(/ *#C# */);
108 if (results[i].title.match(regex)) {
109 e.appendChild(self.document.createTextNode(results[i].title.replace(regex,' ')));
110 var pic = self.document.createElement("img");
111 pic.src = 'img/crovoc.png';
112 pic.border = 0;
113 e.appendChild(pic);
114 } else {
115 e.appendChild(document.createTextNode(result[i].title));
116 }
117 li.appendChild(e);
118 li.appendChild(document.createTextNode(" "));
119
120 e = document.createElement("a");
121 e.setAttribute("href","thes/"+result[i].link+".html"+location.search);
122 //e.setAttribute("target","popup");
123 //e.onclick = function() { return popup(); };
124 e.onclick = popup;
125 var pic = self.document.createElement("img");
126 pic.src = 'img/listic.png';
127 pic.border = 0;
128 e.appendChild(pic);
129 li.appendChild(e);
130 /*
131 e = document.createElement("font");
132 e.setAttribute("color","gray");
133 e.appendChild(document.createTextNode("["+result[i].frequency+"]"));
134 li.appendChild(e);
135 */
136 li.appendChild(document.createElement("br"));
137 d.appendChild(li);
138 }
139
140 if (status) status.innerHTML = "Pronaðeno je "+results.length+" rezultata.";
141
142 }
143
144 // override default sort by frequency and sort by headline
145 function sortResults_title(a, b)
146 {
147 return a.title.toLowerCase() == b.title.toLowerCase() ? 0 : ( a.title.toLowerCase() > b.title.toLowerCase() ? -1 : 1);
148 }

  ViewVC Help
Powered by ViewVC 1.1.26