]> matita.cs.unibo.it Git - helm.git/blob - helm/searchEngine/html/index.html
ported to ocaml 3.08
[helm.git] / helm / searchEngine / html / index.html
1 <HTML>
2 <HEAD>
3 <SCRIPT language="Javascript">
4 var query="*"; // stringa che contiene la query nel suo stato attuale.
5 var storeps=1;
6 var storepv=1;
7 var storepb=1; // queste tre variabili contengono il numero da assegnare al prossimo simbolo set, val o boole per creare il link nel frame in alto a sinistra.
8 var stadd; // contiene la stringa da aggiungere alla query.
9 var fb; // contiene la stringa da aggiungere alla query prima che i set,val e boole siano convertiti in link.
10 var ltr="*"; // qui viene memorizzato qual è l' ultimo link su cui si è cliccato.
11 var norvars=0;
12 var nosvars=0;
13 var novvars1=0;
14 var novvars2=0; // queste tre variabili servono per sapere dove memorizzare i nomi delle rvar,svar e vvar inserite dall' utente. 
15 var wrong=0;
16 var ricordaliaslist=0;
17 var actinput=0;
18 var numeroazioniannullate=0;
19 var terminecic="";var listaliases="";var choices="";var interpretation_choices="";var vlds=new Array();//contengono i parametri per dialogare col server in caso di ambiguità nella Match Conclusion.
20 aliasglob=new Array();//per conservare la lista degli alias
21 function initialize()
22         {
23         rvars=new Array(100);
24         svars=new Array(100);
25         vvars1=new Array(100);
26         vvars2=new Array(100); // contengono le rvar,svar e vvar inserite dall' utente. 
27         storia=new Array();
28         storia[0]="*";
29         norvars=0;
30         nosvars=0;
31         novvars1=0;
32         novvars2=0;
33         ltr="*";
34         query="*";
35         storeps=1;
36         storepv=1;
37         storepb=1;
38         ricordaliaslist=0;
39         vlds=new Array();
40         aliasglob=new Array();
41         actinput=0;
42         numeroazioniannullate=0;
43         }
44
45 // @variable@ will be substituted by the searchEngine with the param.variable
46 // argument value
47 var processorURL="@processorURL@";
48 var thkeys="@thkeys@";
49 var keys="@keys@";
50 var thkeys="@thkeys@";
51 var embedkeys="@embedkeys@";
52 var doctype_public="@doctype-public@";
53 var encoding="@encoding@";
54 var thencoding="@thencoding@";
55 var media_type="@media-type@";
56 var thmedia_type="@thmedia-type@";
57 var CICURI="@CICURI@";
58 var naturalLanguage="@naturalLanguage@";
59 var annotations="@annotations@";
60
61 function ask_uwobo(url)
62        {
63          return (top.topurl+"/ask_uwobo?url="+
64                  encodeURIComponent(processorURL + "apply?" +
65                          "xmluri=" + encodeURIComponent(url) +
66                          "&profile=default" +
67                          "&param.profile=default" +
68                          "&keys=" + encodeURIComponent(thkeys) +
69                          "&param.keys=" + encodeURIComponent(keys) +
70                          "&param.thkeys=" + encodeURIComponent(thkeys) +
71                          "&param.embedkeys=" + encodeURIComponent(embedkeys) +
72                          "&param.doctype-public=" + encodeURIComponent(doctype_public) +
73                          "&param.encoding=" + encodeURIComponent(encoding) +
74                          "&param.thencoding=" + encodeURIComponent(thencoding) +
75                          "&param.media-type=" + encodeURIComponent(media_type) +
76                          "&param.thmedia-type=" + encodeURIComponent(thmedia_type) +
77                          "&param.CICURI=" + encodeURIComponent(CICURI) +
78                          "&param.naturalLanguage=" + encodeURIComponent(naturalLanguage) +
79                          "&param.annotations=" + encodeURIComponent(annotations) +
80                          "&prop.method=html" +
81                          "&param.expandasking=" + encodeURIComponent(top.topurl)));
82        }
83 function help(w) // quando invocata, visualizza l' help relativo ad un oggetto. Di solito è legata ad un evento onFocus o onMouseOver.  
84         {
85         hw.document.close();
86         switch (w)      {
87                         case -10: hw.document.write("Insert an <a href="+top.topurl+top.action+"grammarpdq.html#Id target=gw>Id</a> or an <a href="+top.topurl+top.action+"grammarpdq.html#Uri target=gw>Uri</a> here.")
88                                 break;
89                         case -9: hw.document.write("By clicking this you may add or remove aliases as you wish.")
90                                 break;
91                         case -81: hw.document.write("Allows you to recover your last input")
92                                 break;
93                         case -8: hw.document.write("Allows you to delete your last input")
94                                 break;
95                         case -7: hw.document.write("Erases your query and starts a new pre-defined query, you will keep your list of aliases.")
96                                 break;
97                         case -6: hw.document.write("Puts this string in the current cursor position. This button works only with Internet Explorer.")
98                                 break;
99                         case -5: hw.document.write("Erases your query and starts a new one.")
100                                 break;
101                         case -4: hw.document.write("If you click this your query will be processed and the results will appear in the frame above.")
102                                 break;
103                         case -3: hw.document.write("Substitutes your query with the text written in the area above. Unless you have a good knowledge of MathQL, it's recommended that you use this only to recover errors.")
104                                 break;
105                         case -2: hw.document.write("This is the edit/submit window. You can modify your query here, but be aware that no syntax check will be performed and that if you enter a <a href="+top.topurl+top.action+"grammar.html#rvar target=gw>variable</a> it won't be available for quick composition later. You may also want to add a <a href="+top.topurl+top.action+"grammar.html#set target=gw>set</a>, a <a href="+top.topurl+top.action+"grammar.html#val target=gw>val</a> or a <a href="+top.topurl+top.action+"grammar.html#boole target=gw>boole</a> somewhere in the query. If you do, write '&lt;set&gt;','&lt;val&gt;' or '&lt;bol&gt;' in the point you'd like it to appear, or use the buttons on the right if you are using IE. When you're done with the query, click the Submit button.")
106                                 break;
107                         case -1: hw.document.write("You may see the grammar here.")
108                                 break;
109                         case 0: hw.document.write("")
110                                 break;
111                         case 1: hw.document.write("You may enter an arbitrary statement here; be careful since syntax errors won't be detected.");                              
112                                 break;  
113                         case 2: hw.document.write("Enter an <a href="+top.topurl+top.action+"grammar.html#attr_list target=gw>attr_list</a> here.");
114                                 break;
115                         case 3: hw.document.write("Enter an <a href="+top.topurl+top.action+"grammar.html#id target=gw>id</a> here.");
116                                 break;
117                         case 4: hw.document.write("You must select one previously entered <a href="+top.topurl+top.action+"grammar.html#rvar target=gw>rvar</a>. If you haven't already entered at least one, you can't choose this. ");
118                                 break;
119                         case 5: hw.document.write("Enter a <a href="+top.topurl+top.action+"grammar.html#path target=gw>path</a> here.");
120                                 break;
121                         case 6: hw.document.write("You must select one previously entered <a href="+top.topurl+top.action+"grammar.html#svar target=gw>svar</a>. If you haven't already entered at least one, you can't choose this. ");
122                                 break;
123                         case 7: hw.document.write("Enter a <a href="+top.topurl+top.action+"grammar.html#string_list target=gw>string_list</a> here.");
124                                 break;
125                         case 8: hw.document.write("You must select one <a href="+top.topurl+top.action+"grammar.html#vvar target=gw>vvar</a> previously entered as an 'attr'. If you haven't already entered at least one, you can't choose this. ");
126                                 break;
127                         case 81: hw.document.write("You must select one <a href="+top.topurl+top.action+"grammar.html#vvar target=gw>vvar</a> previously entered in a 'let' statement. If you haven't already entered at least one, you can't choose this. ");
128                                 break;
129                         case 9: hw.document.write("Enter a single <a href="+top.topurl+top.action+"grammar.html#quoted_string target=gw>quoted_string</a> here.");
130                                 break;
131                         }       
132         }
133 function tpa(quotpath)
134         {
135         while (quotpath.indexOf("<")>-1)
136                 {quotpath=quotpath.replace("<","&lt;");}
137         while (quotpath.indexOf(">")>-1)
138                 {quotpath=quotpath.replace(">","&gt;");}
139         return (quotpath);
140         }
141 function idcheck(ident)
142         {
143         lettera=/[a-zA-Z]/;
144         partediid=/[a-zA-Z0-9_\-\']/;
145         if (!lettera.test(ident.charAt(0))){alert("an Id must begin with a letter.");return(0)}
146         while (ident.length>0)
147                 {
148                 ident=ident.substring(1,(ident.length));
149                 if (ident.length>0){
150                 if (!partediid.test(ident.charAt(0))){alert(ident.charAt(0)+" is not a valid character for an Id.");return(0);}
151                 }}
152         return(1)
153         }
154 function uricheck(ident)
155         {
156         cifra=/[0-9]/
157         cic=ident.substring(0,5);//alert(cic);
158         if (cic!="cic:/"){alert("an Uri must begin with the string 'cic:/'");return(0);}
159         ident=ident.substring(5,ident.length);//alert(ident);
160         if (ident.indexOf(".")<0){alert("an Uri must contain a '.'");return(0);}
161         ident1=ident.substring(0,ident.indexOf("."));//alert(ident1);
162         ident2=ident.substring(ident.indexOf(".")+1,ident.length);//alert(ident2);
163         while (ident1.length>0)
164                 {       
165                 if (ident1.indexOf("/")>-1)             
166                         {
167                         if (idcheck(ident1.substring(0,ident1.indexOf("/")))==0){return (0)}
168                         ident1=ident1.substring(ident1.indexOf("/")+1,ident1.length);//alert(ident1);
169                         }
170                 else {if (idcheck(ident1)==0){return (0)}       
171                         ident1="";}
172                 }
173         if (ident2=="con"||ident2=="var"){return(1)}
174         if (ident2.substring(0,6)!="ind#1/"){alert ("syntax error in the Uri.");return(0);}
175         ident2=ident2.substring(6,ident2.length);//alert(ident2);
176         if (!cifra.test(ident2.charAt(0))){alert ("syntax error in the Uri.");return(0);}
177         if (ident2.indexOf("/")>-1)
178                 {
179                 while (ident2.charAt(0)!="/")
180                         {
181                         //alert(ident2);
182                         if (!cifra.test(ident2.charAt(0))){alert ("syntax error in the Uri.");return(0);}
183                         ident2=ident2.substring(1,ident2.length);
184                         }
185                 }
186         while (ident2.length>0)
187                 {
188                 //alert(ident2);
189                 ident2=ident2.substring(1,ident2.length);
190                 if (ident2.length>0){
191                 if (!cifra.test(ident2.charAt(0))){alert ("syntax error in the Uri.");return(0);}
192                 }}
193         
194         return(1)
195         }
196 function gramcheck(how,what) // esegue il controllo sintattico sulla stringa "what", controllando che rispetti i requisiti indicati dalla clausola "how". Se qualcosa non è ok, la variabile "wrong" viene posta ad 1 e la stringa da aggiungere viene ignorata, mentre viene visualizzato un apposito messaggio di errore.              
197         {
198         var slash=0;
199         var alpha=/[A-Za-z:_]/
200         var numero=/[0-9]/
201         switch (how)    {               
202                         case "qsl": // lista di quoted string
203                                 if (what.charAt(0)!="{") {gramcheck("qs",what);break;}
204                                 if (what.charAt(what.length-1)!="}") {alert ("The list must end with a '}'.");wrong=1;break;}
205                                 what=what.substring(1,what.length-1);//alert (what);
206                                 while (what.indexOf("\",\"")>-1)
207                                         {
208                                         as=what.substring(0,what.indexOf("\",\"")+1);//alert(as);
209                                         what=what.substring(what.indexOf("\",\"")+2,what.length);//alert(what);
210                                         gramcheck("qs",as);
211                                         }
212                                 gramcheck("qs",what);
213                                 break;
214                         case "qp": // quoted path
215                                 if (what.charAt(0)!="\"") {alert ("A quoted string must be included between quotes."); wrong=1; break;}
216                                 if (what.charAt(what.length-1)!="\"") {alert ("A quoted string must be included between quotes."); wrong=1; break;}
217                                 while (what.indexOf("\"/\"")>-1)
218                                         {
219                                         as=what.substring(0,what.indexOf("\"/\"")+1);//alert(as);
220                                         what=what.substring(what.indexOf("\"/\"")+2,what.length);//alert(what);
221                                         gramcheck("qs",as);
222                                         }
223                                 gramcheck("qs",what);
224                                 break;
225                         case "qs": // quoted string
226                                 if (what.charAt(0)!="\"") {alert ("A quoted string must be included between quotes."); wrong=1; break;}
227                                 if (what.charAt(what.length-1)!="\"") {alert ("A quoted string must be included between quotes."); wrong=1; break;}
228                                 what=what.substring(0,what.length-1);//alert (what);
229                                 if (wrong==1) break;
230                                 else while (what.length>0)
231                                         {
232                                         what=what.substring(1,what.length);
233                                         if (what.charAt(0)=="\"" && slash==0) {alert ("A \" in a quoted string must be preceded by a \\.");wrong=1;break;} 
234                                         if (what.charAt(0)=="\\") {slash=1} else {slash=0} 
235                                         if (slash==1 && what.length==1) {alert ("A \\ in a quoted string must be followed by something.");wrong=1;}
236                                         }
237                                 break;
238                         case "vlist": // lista di vvar (tutto ciò che si trova dopo "attr")
239                                 //alert(what.substring(0,4));                           
240                                 if ((what.substring(0,4))!="attr"){wrong=1;alert("A vvar_list must begin with the word 'attr'")}
241                                 what=what.substring(5,(what.length));vl=what;
242                                 //alert(what+"what");
243                                 while (what.length>0)
244                                                         {
245                                                         if (what.indexOf(",")>0) {vv=(what.substring(0,what.indexOf(",")));}
246                                                         else {vv=what}                                  
247                                 //alert(vv+"vv");
248                                                         if (vv.charAt(0)!="$"){wrong=1;alert("A vvar must begin with a '$'");}
249                                                         if (vv.indexOf("<-")>0)
250                                                                         {
251                                                                         what=what.substring(vv.length+1,what.length);
252                                 //alert(what+" nuovowhat "+wrong);
253                                                                         path=vv.substring(vv.indexOf("<-")+2,vv.length);
254                                 //alert(path+" path "+wrong);
255                                                                         gramcheck("qp",path); 
256                                                                         vv=vv.substring(1,(vv.indexOf("<-")));
257                                 //alert(vv+" vv "+wrong);
258                                                                         gramcheck("id",vv);
259                                                                         }
260                                                         else {wrong=1;alert("An Assign must contain a '<-'.");what="";}
261                                 //alert (what+"what");  
262                                                         }
263                                 break;
264                         case "id":
265                                 //alert (what.charAt(0));
266                                 if (!alpha.test(what.charAt(0))) {wrong=1;alert("An ID must begin with a letter , ':' , or '_' .");}
267                                 while (what.length>1)   {
268                                         what=what.substring(1,(what.length));
269                                         if (!alpha.test(what.charAt(0)) && !numero.test(what.charAt(0)))
270                                         {wrong=1;alert(what.charAt(0)+" is not a valid character for an id.");}
271                                         //document.write(what+"<BR>");
272                                                         }       
273                                 break;
274                         }
275         
276         if (how=="vlist" && wrong==0) // nel caso in cui sia stato eseguito il controllo su una lista di vvar e non siano stati riscontrati errori, tutte le variabili inserite vengono memorizzate.
277                 {
278                 while (vl.length>0)
279                         {
280                         if (vl.indexOf(",")>-1)
281                                 {
282                                 vvars2[novvars2++]=vl.substring(0,vl.indexOf("<"));
283                                 vl=vl.substring(vl.indexOf(",")+1,vl.length);
284                                 }
285                         else    
286                                 {
287                                 vvars2[novvars2++]=vl.substring(0,vl.indexOf("<"));;
288                                 vl="";
289                                 }                                               
290                         }
291                 //alert ("esco dal loop");
292                 }
293         if (wrong==0) {cw.inputok=1} else stadd="";
294         }
295 function savelink(n,t) // invocata quando si clicca su un link, memorizza quale di questi debba poi essere sostituito. 
296         {
297         if (t=='s') { top.ltr="[?set"+String(n)+"]";}
298         if (t=='v') { top.ltr="[?val"+String(n)+"]";}
299         if (t=='b') { top.ltr="[?bol"+String(n)+"]";}
300 //      alert(ltr);
301         }
302 function aggcw() // invocata automaticamente ad ogni modifica della variabile "query", fa apparire nel frame in alto a destra il menu di composizione relativo al primo link della query. Consente quindi di comporre tutta la query senza mai cliccare su alcun link. 
303         {
304         pq=query;
305         while (pq.length>0)
306                 {
307                 if (pq.indexOf("[?")>-1)        
308                         {
309                         ltr=pq.slice(pq.indexOf("[?"));
310                         ltr=ltr.substring(ltr.indexOf("[?"),(ltr.length-ltr.indexOf("[?"))-(ltr.length-ltr.indexOf("]")-1));
311                         wto=ltr.substring(2,5);
312                         if (wto=="set") {window.open(top.topurl+action+"set.html","cw");pq="";}
313                         else if (wto=="val") {window.open(top.topurl+action+"val.html","cw");pq="";}
314                         else if (wto=="bol") {window.open(top.topurl+action+"boole.html","cw");pq="";}
315                         else pq=pq.substring(pq.indexOf("[?")+2,pq.length);
316                         }
317                 else {window.open(top.topurl+action+"blank.html","cw");pq="";}
318                 } 
319         }
320 function aggform() // aggiorna il form nel frame centrale. Invocata ad ogni cambio della variabile "query".
321         {
322         cquery=query;
323         while (cquery.indexOf("<")>-1)
324                 {
325                 cquery=cquery.replace(cquery.substring(cquery.indexOf("<"),cquery.indexOf(">")+1),"");
326                 //alert(cquery);
327                 }
328         while (cquery.indexOf("[?")>-1)
329                 {
330                 //alert(cquery);
331                 if (cquery.indexOf("]")>-1)
332                         {
333                         while (cquery.indexOf("]")<cquery.indexOf("[?") && cquery.indexOf("]")>-1)
334                         {cquery=cquery.replace("]","q+u+a+d+r+a+c+h+i+u+s+a");}//alert("loop"+cquery.indexOf("]")+cquery.indexOf("[?"))}
335                         ag1=cquery.slice(cquery.indexOf("[?"));//alert(ag1);
336                         ag1=ag1.substring(ag1.indexOf("[?"),(ag1.length-ag1.indexOf("[?"))-(ag1.length-ag1.indexOf("]")));//alert(ag1);
337                         ag2=ag1.substring(2,5);//alert(ag2);
338                         if (ag2=="set") cquery=cquery.replace(cquery.substring(cquery.indexOf("[?"),cquery.indexOf("]")+1),"<set>");
339                         else if (ag2=="val") cquery=cquery.replace(cquery.substring(cquery.indexOf("[?"),cquery.indexOf("]")+1),"<val>");
340                         else if (ag2=="bol") cquery=cquery.replace(cquery.substring(cquery.indexOf("[?"),cquery.indexOf("]")+1),"<boole>");
341                         else cquery=cquery.replace(cquery.substring(cquery.indexOf("[?"),cquery.indexOf("[?")+1),"q+u+a+d+r+a");
342                         //alert(cquery);
343                         }
344                 else {cquery=cquery.replace("[?","q+u+a+d+r+a?")}
345                 //alert(cquery);        
346                 }
347         while (cquery.indexOf("q+u+a+d+r+a+c+h+i+u+s+a")>-1)
348                 {
349                 cquery=cquery.replace("q+u+a+d+r+a+c+h+i+u+s+a","]");
350                 }
351         while (cquery.indexOf("q+u+a+d+r+a")>-1)
352                 {
353                 cquery=cquery.replace("q+u+a+d+r+a","[");
354                 }
355         while (cquery.indexOf("&lt;")>-1)
356                 {
357                 cquery=cquery.replace("&lt;","<");
358                 }
359         while (cquery.indexOf("&gt;")>-1)
360                 {
361                 cquery=cquery.replace("&gt;",">");
362                 }
363         top.sw.agg();
364         }
365 function ripristina()
366         {
367         //alert (actinput+" "+storia.length);
368         if (numeroazioniannullate>0)
369                 {
370                 numeroazioniannullate--;
371                 query=storia[actinput+1];actinput++;
372                 qw.document.close();
373                 qw.document.write(query);
374                 aggform();
375                 sw.apply();
376                 aggcw();
377                 cw.focus();
378                 }
379         }
380 function annulla()
381         {
382         //alert (actinput+" "+storia.length);
383         if (actinput>0)
384                 {
385                 numeroazioniannullate++;
386                 query=storia[actinput-1];actinput--;
387                 qw.document.close();
388                 qw.document.write(query);
389                 aggform();
390                 sw.apply();
391                 if (query=="*"){cw.location=top.topurl+action+"set.html";ltr="*";} else {aggcw();}
392                 cw.focus();
393                 }
394         }
395 function parse() // prende la stringa che si sta tentando di inserire nella query, aggiunge i link dove necessario e mette il risultato nella variabile "fb"
396         {
397         while (fb.indexOf("[set]")>-1){
398         if (fb.indexOf("set")>0)
399                 {
400       fb=fb.replace("[set]","<A HREF="+top.topurl+action+"set.html target=cw onclick=top.savelink("+top.storeps+",'s')>[?set"+top.storeps+"]</A>");
401                 top.storeps++;
402                 }
403                                          }
404         while (fb.indexOf("[val]")>-1){
405         if (fb.indexOf("val")>0)
406                 {
407       fb=fb.replace("[val]","<A HREF="+top.topurl+action+"val.html target=cw onclick=top.savelink("+top.storepv+",'v')>[?val"+top.storepv+"]</A>");
408                 top.storepv++;
409                 }
410                                          }
411         while (fb.indexOf("[boole]")>-1){
412         if (fb.indexOf("boole")>0)
413                 {
414                 fb=fb.replace("[boole]","<A HREF="+top.topurl+action+"boole.html target=cw onclick=top.savelink("+top.storepb+",'b')>[?bol"+top.storepb+"]</A>");
415                 top.storepb++;
416                 }
417                                          }
418         }
419 function aggq() // aggiorna la query sostituendo l' ultimo link editato con la stringa inserita, poi aggiorna tutti i frame.
420         {
421         //window.open(top.topurl+action+"summary.html","cw");
422         qw.document.close();
423         fb=stadd;       
424         nst=ltr.substring(5,(ltr.length-1));// alert(nst+" "+ltr);
425         query=query.replace("<A HREF="+top.topurl+action+"set.html target=cw onclick=top.savelink("+nst+",'s')>"+ltr+"</A>",ltr);
426         query=query.replace("<A HREF="+top.topurl+action+"val.html target=cw onclick=top.savelink("+nst+",'v')>"+ltr+"</A>",ltr);
427         query=query.replace("<A HREF="+top.topurl+action+"boole.html target=cw onclick=top.savelink("+nst+",'b')>"+ltr+"</A>",ltr);
428         parse();
429         query=query.replace(ltr,fb);
430         actinput++;storia[actinput]=query;numeroazioniannullate=0;//alert (actinput+" "+storia.length);
431         qw.document.write(query);aggform();
432         aggcw();
433         cw.focus();
434         }
435 var re1 = /(.*)\?.*/;
436 var re2 = /(.*)\/.*/;
437 var topurl=document.location+"";
438 topurl = topurl.replace(re1,"$1");
439 topurl = topurl.replace(re2,"$1");
440 //var topurl=document.location.protocol+'//'+document.location.host;
441 var action="/getpage?url=";
442 //var action="";
443
444
445 // UTILITY FUNCTIONS FOR templateambigpdq1.html
446 function templateambigpdq1_armageddon()
447         {
448         top.initialize();
449         top.window.open(top.topurl+top.action+"start.html","qw");
450         top.window.open(top.topurl+top.action+"blank.html","cw");
451         top.window.open(top.topurl+top.action+"blank.html","hw");
452         top.window.open(top.topurl+top.action+"blank.html","gw");
453         top.window.open(top.topurl+top.action+"blank.html","sw");
454         }
455
456 function templateambigpdq1_resetta()
457         {
458         if (confirm("This will erase your query and start a new one. Are you sure you want to do this?"))
459                 {templateambigpdq1_armageddon();}
460         }
461
462 function templateambigpdq1_listauri(document,elenco)
463         {
464         for (i=0;i<elenco.length;i++)
465                 {
466                 document.write("<input type=checkbox name=uricheck value="+elenco[i]+"> "+elenco[i]+"<br>"); 
467                 }
468         }
469
470 function templateambigpdq1_invia(document,top,elenco,ident)
471         {
472         vecchiavlds=top.vlds.length;
473         stringa=top.topurl+"/"+top.current_query+"?term="+top.terminecic;
474         stringa=stringa+"&aliases="+top.listaliases;
475         stringa=stringa+"&choices=";
476   var choices = "";
477         top.vlds[top.vlds.length]=ident;
478         for (j=0;j<elenco.length;j++)
479                 {
480                 if (document.disamb.uricheck[j].checked)
481                         {
482                         top.vlds[top.vlds.length]=document.disamb.uricheck[j].value;
483                         }
484                 }
485         top.vlds[top.vlds.length]=";";
486         for (j=0;j<top.vlds.length;j++)
487         {
488            choices=choices+(top.vlds[j]==";"?";":encodeURIComponent(top.vlds[j]))+" ";
489         }
490         choices=choices.substring(0,choices.length-2);
491   top.choices = choices;
492   stringa=stringa+encodeURIComponent(choices);
493         if (top.vlds.length==vecchiavlds){alert("You must select at least one of the options.");}
494         else
495         {
496            window.open(ask_uwobo(stringa),"cw");
497         }
498         } 
499
500   function templateambigpdq1_selezionaCostanti(document,elenco) {
501     for (i=0; i<elenco.length; i++) {
502       if (elenco[i].substring(elenco[i].length-4, elenco[i].length) != ".var") {
503         document.disamb.uricheck[i].checked = true;
504       } else {
505         document.disamb.uricheck[i].checked = false;
506       }
507     }
508   }
509
510
511
512 // UTILITY FUNCTIONS FOR templateambigpdq2.html
513 function templateambigpdq2_armageddon()
514         {
515         top.initialize();
516         top.window.open(top.topurl+top.action+"start.html","qw");
517         top.window.open(top.topurl+top.action+"blank.html","cw");
518         top.window.open(top.topurl+top.action+"blank.html","hw");
519         top.window.open(top.topurl+top.action+"blank.html","gw");
520         top.window.open(top.topurl+top.action+"blank.html","sw");
521         }
522
523 function templateambigpdq2_resetta()
524         {
525         if (confirm("This will erase your query and start a new one. Are you sure you want to do this?"))
526                 {templateambigpdq2_armageddon();}
527         }
528
529 function templateambigpdq2_listainterpretazioni(document,elenco,labels)
530         {
531         for (i=0;i<elenco.length;i++)
532                 {
533                       document.write("<input type=radio name=interp value="+elenco[i]+"> "+labels[i]+"<br />"); 
534                 }
535         }
536
537 function templateambigpdq2_invia(document,elenco)
538         {
539         stringa=top.topurl+"/"+top.current_query+"?term="+top.terminecic;
540         stringa=stringa+"&aliases="+encodeURIComponent(top.listaliases)+"&choices="+encodeURIComponent(top.choices)+"&interpretation_choices=";
541   var parsa = "";
542         controllo=parsa.length;
543         for (j=0;j<elenco.length;j++)
544                 {
545                 if (document.disamb.interp[j].checked)
546                         {
547                         parsa=parsa+encodeURIComponent(elenco[j]);
548
549       // TODO da implementare nella terza fase
550                         //top.aliasglob[top.aliasglob.length]=document.disamb.interp[j].value;
551
552                         //for (k=0;k<top.aliasglob.length;k++){alert(top.aliasglob[k])}
553                         //top.listaliases=top.listaliases+document.disamb.interp[j].value;//in caso di query ulteriori con la stessa lista di alias
554                         }
555                         
556                 }
557   top.interpretation_choices = parsa;
558   stringa=stringa+parsa;
559         if (parsa.length!=controllo) 
560                 {
561                 window.open(ask_uwobo(stringa),"cw");
562                 }
563                 else {alert("You must choose one option.");}
564         } 
565
566
567
568 // UTILITY FUNCTIONS FOR templateambigpdq3.html
569 function templateambigpdq3_init(aliases)
570 {
571    top.aliasglob = new Array();
572    for (i=0; i<aliases.length; i++) {
573       top.aliasglob[i] = aliases[i];
574    }
575    top.vlds=new Array();
576    top.window.open(top.topurl+top.action+"editorpdq.html", "sw");
577 }
578
579 // UTILITY FUNCTIONS FOR constraints_choice_template.html
580 function get_value_of_checkbox(checkbox)
581   {
582     return (checkbox.checked ? "1" : "0");
583   }
584
585 function constraints_choice_template_invia(document,aliases,constr_obj_len,constr_rel_len,constr_sort_len)
586         {
587         stringa=top.topurl+"/"+top.current_query+"?term="+top.terminecic;
588         stringa=stringa+"&aliases="+encodeURIComponent(aliases);
589         stringa=stringa+"&choices="+encodeURIComponent(top.choices);
590         stringa=stringa+"&interpretation_choices="+encodeURIComponent(top.interpretation_choices);
591         stringa=stringa+"&constraints=";
592         for (j=0;j<constr_obj_len;j++)
593          {
594           stringa += document.constraints.constr_obj[j].checked ? "1" : "0";
595       stringa += !document.constraints.obj_depth[j] ||
596                  document.constraints.obj_depth[j].value == "" ? "_" :
597                  document.constraints.obj_depth[j].value;
598       if (j < constr_obj_len - 1) { stringa += "," }
599          }
600   stringa += ":";
601         for (j=0;j<constr_rel_len;j++)
602          {
603           stringa += document.constraints.constr_rel[j].checked ? "1" : "0";
604       stringa += document.constraints.rel_depth[j].value == "" ? "_" :
605                  document.constraints.rel_depth[j].value;
606         if (j < constr_rel_len - 1) { stringa += "," }
607          }
608   stringa += ":";
609         for (j=0;j<constr_sort_len;j++)
610          {
611           stringa += document.constraints.constr_sort[j].checked ? "1" : "0";
612       stringa += document.constraints.sort_depth[j].value == "" ? "_" :
613                  document.constraints.sort_depth[j].value;
614       if (j < constr_sort_len - 1) { stringa += "," }
615          }
616   stringa += ":"+get_value_of_checkbox(document.constraints.only_obj)+
617              ":"+get_value_of_checkbox(document.constraints.only_rel)+
618              ":"+get_value_of_checkbox(document.constraints.only_sort);
619         window.open(ask_uwobo(stringa),"cw");
620         } 
621 </SCRIPT>
622 </HEAD>
623   <SCRIPT>
624     document.write(' <FRAMESET ROWS="69%,31%"> <FRAMESET COLS="40%,60%"> <FRAMESET ROWS="46%,54%"> <FRAME NAME="qw" SRC="'+topurl+action+'start.html"> <FRAME NAME="sw" SRC="'+topurl+action+'blank.html"> </FRAMESET> <FRAME NAME="cw" SRC="'+topurl+action+'blank.html"> </FRAMESET> <FRAMESET COLS="49%,51%"> <FRAME NAME="gw" SRC="'+topurl+action+'blank.html" onFocus="help(-1)";> <FRAME NAME="hw" SRC="'+topurl+action+'blank.html"> </FRAMESET> </FRAMESET>');
625   </SCRIPT>
626 </HTML>