]> matita.cs.unibo.it Git - helm.git/blob - helm/on-line/javascript/control.js
Code of metadataLib.xsl to share with makeGraphLinks.xsl extracted to
[helm.git] / helm / on-line / javascript / control.js
1 function updateMode(i, s)
2 {
3   var mode = top.mode;
4   var mode_list = mode.split(",");
5   var res = "";
6   var j;
7
8   for (j = 0; j < mode_list.length; j++) {
9     if (j == i) res += s;
10     else res += mode_list[j];
11     if (j < mode_list.length - 1) res += ",";
12   }
13   
14   top.mode = res;
15 }
16
17 function updateOutput(output,format)
18 {
19   var theoryuri = top.theoryuri;
20   var cicuri = top.cicuri;
21   var mode = top.mode;
22   var topurl = top.topurl;
23   var processorURL = top.processorURL;
24   var getterURL = top.getterURL;
25   var draw_graphURL = top.draw_graphURL;
26   var uri_set_queueURL = top.uri_set_queueURL;
27   var mode_list = mode.split(",");
28   var new_mode = output.options[output.selectedIndex].value;
29   var dest = "?theoryuri=" + theoryuri + "&cicuri=" + cicuri + "&topurl=" + topurl + "&processorURL=" + processorURL + "&getterURL=" + getterURL + "&draw_graphURL=" + draw_graphURL + "&uri_set_queueURL=" + uri_set_queueURL + "&mode=";
30   
31   if (new_mode != mode_list[0]) {
32     updateMode(0, new_mode);
33     if (new_mode == "raw") updateMode(2, format.options[format.selectedIndex].value);
34     else updateMode(1, format.options[format.selectedIndex].value);
35
36     var href =
37      top.processorURL + 'apply' +
38      '?keys=RT' +
39      '&param.topurl=' + topurl +
40      '&xmluri=' +
41      escape(top.topurl + '/html/library/control.html' + dest + top.mode);
42     
43     location.href = href;
44   }
45 }
46
47 function updateFormat(format)
48 {
49   var mode = top.mode;
50   var mode_list = mode.split(",");
51
52   if (mode_list[0] == "raw") {
53     updateMode(1, format.options[format.selectedIndex].value);
54   } else {
55     updateMode(2, format.options[format.selectedIndex].value);
56   }
57
58   refreshReload();
59 }
60
61 function updateNatural(checkbox)
62 {
63   if (checkbox.checked) updateMode(3, "yes");
64   else updateMode(3, "no");
65   refreshReload();
66 }
67
68 function updateAnnotations(checkbox)
69 {
70   if (checkbox.checked) updateMode(4, "yes");
71   else updateMode(4, "no");
72   refreshReload();
73 }
74
75 function updateCompressed(checkbox)
76 {
77   if (checkbox.checked) updateMode(5, "gz");
78   else updateMode(5, "normal");
79   refreshReload();
80 }
81
82 function updateDTDPatched(checkbox)
83 {
84   if (checkbox.checked) updateMode(6, "yes");
85   else updateMode(6, "no");
86   refreshReload();
87 }
88
89 function refreshReload()
90 {
91    var search = 
92       "?mode=" + top.mode +
93       "&cicuri=" + top.cicuri +
94       "&theoryuri=" + top.theoryuri +
95       "&processorURL=" + top.processorURL +
96       "&getterURL=" + top.getterURL +
97       "&draw_graphURL=" + top.draw_graphURL +
98       "&uri_set_queueURL=" + top.uri_set_queueURL +
99       "&UNICODEvsSYMBOL=" + top.UNICODEvsSYMBOL;
100
101    var href =
102     top.processorURL + 'apply' +
103     '?keys=RT' +
104     '&param.topurl=' + top.topurl +
105     '&xmluri=' +
106     escape(top.topurl + '/html/library/index.html' + search);
107     
108    top.frames[0].document.links[0].href = href;
109    top.frames[0].document.links[1].href =
110     top.topurl + '/html/index.html' + search;
111
112    return true;
113 }
114
115 function refreshcicHeader(headerURL)
116 {
117 // Qui e sotto da modificare per usare UWOBO!!!
118    top.cicheader.location.search = "?keys=GP&xmluri=" + headerURL + "&param.uri=" + top.cicuri;
119    return true;
120 }
121
122 function refreshtheoryHeader(headerURL)
123 {
124    top.theoryheader.location.search = "?keys=GP&xmluri=" + headerURL + "&param.uri=" + top.theoryuri;
125    return true;
126 }
127
128 function getCICMathMLKeys()
129 {
130   //Important note: do not modify this function without modifying makeURL
131   return escape("d_c,C1,G,C2,L");
132 }
133
134 function makeURL(type,uri,cicflags,typesflags)
135 {
136   var mode = top.mode;
137   var processorURL = top.processorURL;
138   var getterURL = top.getterURL;
139   var draw_graphURL = top.draw_graphURL;
140   var uri_set_queueURL = top.uri_set_queueURL;
141   var UNICODEvsSYMBOL = top.UNICODEvsSYMBOL;
142   var mode_list = mode.split(",");
143   
144   var keys = "";
145   var url = "";
146
147   var interfaceURL = top.topurl + "/html/cic/index.html";
148   var thinterfaceURL = top.topurl + "/html/theory/index.html";
149
150   var output = mode_list[0];
151   var format;
152   if (output == "raw") format = mode_list[1];
153   else format = mode_list[2];
154   
155   if (output == "raw") {
156     var ext = "";
157     var rdfprefix = "";
158     if (format == "types") ext = ".types"
159     else if (format == "ann") ext = ".ann"
160     else if (format == "fwd") rdfprefix = "helm:rdf:www.cs.unibo.it/helm/rdf/forward//"
161     else if (format == "bwd") rdfprefix = "helm:rdf:www.cs.unibo.it/helm/rdf/backward//";
162     url = getterURL + "getxml?uri=" + rdfprefix + uri + ext + "&format=" +
163           mode_list[5] + "&patch_dtd=" + mode_list[6];
164   } else {
165     if (format == "html" && type == "cic") {
166       //Important note: do not modify this function without modifying
167       //getCICMathMLKeys
168       keys = escape("d_c,C1,HC2,L") +
169        "&param.processorURL=" + escape(processorURL) +
170        "&param.getterURL=" + escape(getterURL) +
171        "&param.draw_graphURL=" + escape(draw_graphURL) +
172        "&param.uri_set_queueURL=" + escape(uri_set_queueURL) +
173        "&param.UNICODEvsSYMBOL=" + escape(UNICODEvsSYMBOL) +
174        "&prop.doctype-public="+escape("-//W3C//DTD XHTML 1.0 Transitional//EN")+
175        "&prop.encoding=iso-8859-1" +
176        "&prop.media-type=text/html" +
177        "&param.doctype-public="+escape("-//W3C//DTD XHTML 1.0 Transitional//EN")+
178        "&param.encoding=iso-8859-1" +
179        "&param.media-type=text/html" +
180        "&param.keys=" + escape("d_c,C1,HC2,L") +
181        "&param.interfaceURL=" + escape(interfaceURL);
182     } else if (format == "html" && type == "theory") {
183       keys = escape("T1,T2,L,E")+
184        "&param.processorURL=" + escape(processorURL) +
185        "&param.getterURL=" + escape(getterURL) +
186        "&param.draw_graphURL=" + escape(draw_graphURL) +
187        "&param.uri_set_queueURL=" + escape(uri_set_queueURL) +
188        "&param.UNICODEvsSYMBOL=" + escape(UNICODEvsSYMBOL) +
189        "&param.keys=" + escape("d_c,C1,HC2,L") +
190        "&param.thkeys=" + escape("T1,T2,L,E") +
191        "&param.embedkeys=" + escape("d_c,TC1,HC2,L") +
192        "&param.doctype-public="+escape("-//W3C//DTD XHTML 1.0 Transitional//EN")+
193        "&param.encoding=iso-8859-1" +
194        "&param.thencoding=iso-8859-1" +
195        "&param.media-type=text/html" +
196        "&param.thmedia-type=text/html" +
197        "&param.interfaceURL=" + escape(interfaceURL) +
198        "&param.thinterfaceURL=" + escape(thinterfaceURL);
199     } else if (format == "mml_cont" && type == "cic") {
200       keys = escape("d_c,C1");
201     } else if (format == "mml_cont" && type == "theory") {
202       keys = escape("T1,L,E")+
203        "&param.keys=" + escape("d_c,C1") +
204        "&param.thkeys=T1,L,E" +
205        "&param.embedkeys=" + escape("d_c,TC1") +
206
207        "&param.processorURL=" + escape(processorURL) +
208        "&param.getterURL=" + escape(getterURL) +
209        "&param.draw_graphURL=" + escape(draw_graphURL) +
210        "&param.uri_set_queueURL=" + escape(uri_set_queueURL) +
211        "&param.doctype-public=" +
212        "&param.encoding=" +
213        "&param.thencoding=iso-8859-1" +
214        "&param.media-type=text/xml" +
215        "&param.thmedia-type=text/html" +
216        "&param.interfaceURL=" + escape(interfaceURL) +
217        "&param.thinterfaceURL=" + escape(thinterfaceURL);
218     } else if (format == "mml_pres" && type == "cic") {
219       keys = escape("d_c,C1,G,C2,L")+
220        "&param.processorURL=" + escape(processorURL) +
221        "&param.getterURL=" + escape(getterURL) +
222        "&param.draw_graphURL=" + escape(draw_graphURL) +
223        "&param.uri_set_queueURL=" + escape(uri_set_queueURL) +
224        "&prop.doctype-public="+
225        "&prop.encoding=" +
226        "&prop.media-type=text/xml" +
227        "&param.doctype-public=" +
228        "&param.encoding=" +
229        "&param.media-type=text/xml" +
230        "&param.keys=" + escape("d_c,C1,G,C2,L") +
231        "&param.interfaceURL=" + escape(interfaceURL);
232     } else if (format == "mml_pres" && type == "theory") {
233       keys = escape("T1,T2,L,E")+
234        "&param.keys=d_c,C1,G,C2,L" +
235        "&param.thkeys=T1,T2,L,E" +
236        "&param.embedkeys=d_c,TC1,G,C2,L" +
237        "&param.processorURL=" + escape(processorURL) +
238        "&param.getterURL=" + escape(getterURL) +
239        "&param.draw_graphURL=" + escape(draw_graphURL) +
240        "&param.uri_set_queueURL=" + escape(uri_set_queueURL) +
241        "&param.doctype-public=" +
242        "&param.encoding=" +
243        "&param.thencoding=iso-8859-1" +
244        "&param.media-type=text/xml" +
245        "&param.thmedia-type=text/html" +
246        "&param.interfaceURL=" + escape(interfaceURL) +
247        "&param.thinterfaceURL=" + escape(thinterfaceURL);
248     }
249
250     var naturalLanguage = typesflags;
251     if (typesflags != "NO" || type == "theory") {
252        naturalLanguage = mode_list[3];
253     }
254     var annotations = cicflags;
255     if (cicflags != "NO" || type == "theory") {
256        annotations = mode_list[4];
257     }
258     url = processorURL + "apply?xmluri=" + escape(getterURL + "getxml?uri=" + uri) + "&keys=" + keys + "&param.CICURI=" + uri + "&param.naturalLanguage=" + naturalLanguage + "&param.annotations=" + annotations + "&param.topurl=" + top.topurl;
259   }
260
261   if (output == "raw")
262    return url;
263   else if (type == "cic")
264    return interfaceURL + "?url=" + escape(url);
265   else if (type == "theory")
266    return thinterfaceURL + "?url=" + escape(url)
267 }
268