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

Diff of /trunk2/eurovoc/js/usage.js

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 526 by dpavlin, Mon Oct 18 17:59:37 2004 UTC revision 527 by dpavlin, Tue Oct 19 16:15:13 2004 UTC
# Line 27  Line 27 
27    
28  function go(f)  function go(f)
29  {  {
30    var form = document.getElementById('search');          var form = document.getElementById('search');
31    var query = null;          var query = null;
32    if (document.form.elements['query']) query = document.form.elements['query'].value;          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;          var index_name = document.form.elements['index_name'].options[document.form.elements['index_name'].selectedIndex].value;
34    
35    if(!query)          if(!query)
36    {          {
37      return false;                  return false;
38    }          }
39    
40    if(query == null || query == "")          if(query == null || query == "")
41    {          {
42      alert("No search terms entered!");                  alert("No search terms entered!");
43      return false;                  return false;
44    }          }
45    
46    var parsed_string = query.replace(/\s/gi,"+");          var parsed_string = query.replace(/\s/gi,"+");
47    //var url=location.host+location.pathname+"?search="+parsed_string;          //var url=location.host+location.pathname+"?search="+parsed_string;
48    var url=location.pathname+"?";          var url=location.pathname+"?";
49    if (index_name) url += "index_name="+index_name+"&";          if (index_name) url += "index_name="+index_name+"&";
50    url += "query="+parsed_string;          url += "query="+parsed_string;
51    location = url;          location = url;
52    
53    return false;          return false;
 }  
   
 // Function to help find a "DIV" element  
 function findDivHelper(n, id)  
 {  
   for(var m=n.firstChild; m != null; m=m.nextSibling)  
   {  
     if((m.nodeType == 1) &&  
        (m.tagName.toLowerCase() == "div") &&  
        m.getAttribute("id") &&  
        (m.getAttribute("id").toLowerCase() == id.toLowerCase() ))  
     {  
       return m;  
     }  
     else  
     {  
       var r=findDivHelper(m, id);  
       if(r) return r;  
     }  
   }  
   return null;  
54  }  }
55    
56  // Function to find a specified "DIV" element by id  // Function to find a specified "DIV" element by id
57  function findDiv(id)  function findDiv(id)
58  {  {
59    return findDivHelper(document.body,id);          return document.getElementById(id);
60  }  }
61    
62  // Print results to page  // Print results to page
63  function printResults(result)  function printResults(result)
64  {  {
65    //clearTimeout(watchdog_id);          //clearTimeout(watchdog_id);
66    //debug("clearTimeout = "+watchdog_id);          //debug("clearTimeout = "+watchdog_id);
67    debug("printResults("+result.length+")");          debug("printResults("+result.length+")");
68    
69    var d = findDiv("results");          var d = findDiv("results");
70    var header;          var status = findDiv("status");
71    
72    // Null result output          // Null result output
73    if(result.length < 1)          if(result.length < 1)
74    {          {
75      header = (d.getElementsByTagName("h2"))[0].firstChild;                  if (status) status.innerHTML = "Nije pronašen niti jedan rezultat.";
76      try {  
77        header.replaceData(0, 14, "Nothing Found ");                  if(search_err != "")
78      } catch(e) {}                  {
79                            e = document.createElement("font");
80      if(search_err != "")                          e.setAttribute("color","red");
81      {                          e.setAttribute("size","+1");
82        e = document.createElement("font");                          e.appendChild(document.createTextNode(search_err));
83        e.setAttribute("color","red");                          d.appendChild(e);
84        e.setAttribute("size","+1");                          d.appendChild(document.createElement("br"));
85        e.appendChild(document.createTextNode(search_err));                  }
86        d.appendChild(e);  
87        d.appendChild(document.createElement("br"));                  return;
88      }          }
89    
90      return;          debug("sort results by title");
91    }          results.sort(sortResults_title);
92    
93    debug("sort results by title");          // Add results to main document
94    results.sort(sortResults_title);          for(var i=result.length-1; i>=0; i--)
95            {
96    // Add results to main document                  var li = document.createElement("li");
97    for(var i=result.length-1; i>=0; i--)  
98    {                  var e = document.createElement("a");
99      var e = document.createElement("font");                  e.setAttribute("href","hijerarhija.html?o="+result[i].link);
100                    var regex = new RegExp(/ *\* */);
101      e = document.createElement("a");                  if (results[i].title.match(regex)) {
102      e.setAttribute("href","hijerarhija.html?o="+result[i].link);                          e.appendChild(self.document.createTextNode(results[i].title.replace(regex,' ')));
103      e.appendChild(document.createTextNode(result[i].title));                          var pic = self.document.createElement("img");
104      d.appendChild(e);                          pic.src = 'img/crovoc.png';
105      d.appendChild(document.createTextNode(" "));                          pic.border = 0;
106                            e.appendChild(pic);
107      e = document.createElement("a");                  } else {
108      e.setAttribute("href","thes/"+result[i].link+".html"+location.search);                          e.appendChild(document.createTextNode(result[i].title));
109      //e.setAttribute("target","popup");                  }
110      //e.onclick = function() { return popup(); };                  li.appendChild(e);
111      e.onclick = popup;                  li.appendChild(document.createTextNode(" "));
112      e.appendChild(document.createTextNode("\u00bb"));  
113      d.appendChild(e);                  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  /*  /*
124      e = document.createElement("font");                  e = document.createElement("font");
125      e.setAttribute("color","gray");                  e.setAttribute("color","gray");
126      e.appendChild(document.createTextNode("["+result[i].frequency+"]"));                  e.appendChild(document.createTextNode("["+result[i].frequency+"]"));
127      d.appendChild(e);                  li.appendChild(e);
128  */  */
129      d.appendChild(document.createElement("br"));                  li.appendChild(document.createElement("br"));
130    }                  d.appendChild(li);
131            }
132    // Change header  
133    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) {}  
134    
135  }  }
136    
137  // override default sort by frequency and sort by headline  // override default sort by frequency and sort by headline
138  function sortResults_title(a, b)  function sortResults_title(a, b)
139  {  {
140    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);
141  }  }

Legend:
Removed from v.526  
changed lines
  Added in v.527

  ViewVC Help
Powered by ViewVC 1.1.26