/[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

Annotation of /trunk2/eurovoc/js/usage.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 592 - (hide annotations)
Sat Nov 6 23:25:30 2004 UTC (19 years, 5 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 dpavlin 484 /**
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 dpavlin 592 /*
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 dpavlin 484 function go(f)
37     {
38 dpavlin 527 var form = document.getElementById('search');
39     var query = null;
40 dpavlin 531 if (form) query = form.elements['query'].value;
41 dpavlin 484
42 dpavlin 527 if(!query)
43     {
44     return false;
45     }
46 dpavlin 484
47 dpavlin 527 if(query == null || query == "")
48     {
49     alert("No search terms entered!");
50     return false;
51     }
52 dpavlin 484
53 dpavlin 527 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 dpavlin 484
60 dpavlin 527 return false;
61 dpavlin 484 }
62    
63     // Function to find a specified "DIV" element by id
64     function findDiv(id)
65     {
66 dpavlin 527 return document.getElementById(id);
67 dpavlin 484 }
68    
69     // Print results to page
70     function printResults(result)
71     {
72 dpavlin 527 //clearTimeout(watchdog_id);
73     //debug("clearTimeout = "+watchdog_id);
74     debug("printResults("+result.length+")");
75 dpavlin 484
76 dpavlin 527 var d = findDiv("results");
77     var status = findDiv("status");
78 dpavlin 484
79 dpavlin 527 // Null result output
80     if(result.length < 1)
81     {
82 dpavlin 586 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 dpavlin 484
84 dpavlin 527 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 dpavlin 484
94 dpavlin 527 return;
95     }
96 dpavlin 484
97 dpavlin 527 debug("sort results by title");
98     results.sort(sortResults_title);
99 dpavlin 494
100 dpavlin 527 // Add results to main document
101     for(var i=result.length-1; i>=0; i--)
102     {
103     var li = document.createElement("li");
104 dpavlin 484
105 dpavlin 527 var e = document.createElement("a");
106     e.setAttribute("href","hijerarhija.html?o="+result[i].link);
107 dpavlin 560 var regex = new RegExp(/ *#C# */);
108 dpavlin 527 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 dpavlin 484
120 dpavlin 527 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 dpavlin 484 /*
131 dpavlin 527 e = document.createElement("font");
132     e.setAttribute("color","gray");
133     e.appendChild(document.createTextNode("["+result[i].frequency+"]"));
134     li.appendChild(e);
135 dpavlin 484 */
136 dpavlin 527 li.appendChild(document.createElement("br"));
137     d.appendChild(li);
138     }
139 dpavlin 484
140 dpavlin 527 if (status) status.innerHTML = "Pronaðeno je "+results.length+" rezultata.";
141 dpavlin 484
142     }
143 dpavlin 494
144     // override default sort by frequency and sort by headline
145     function sortResults_title(a, b)
146     {
147 dpavlin 527 return a.title.toLowerCase() == b.title.toLowerCase() ? 0 : ( a.title.toLowerCase() > b.title.toLowerCase() ? -1 : 1);
148 dpavlin 494 }

  ViewVC Help
Powered by ViewVC 1.1.26