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