/[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 527 - (hide annotations)
Tue Oct 19 16:15:13 2004 UTC (19 years, 7 months ago) by dpavlin
File MIME type: application/javascript
File size: 4028 byte(s)
localisation and images

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

  ViewVC Help
Powered by ViewVC 1.1.26