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