]> matita.cs.unibo.it Git - helm.git/blob - helm/on-line/javascript/control.js
6734d4a133f5e6fc9ab60961b87fae73995bfc3a
[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    top.cicheader.location.search = "?keys=GP&xmluri=" + headerURL + "&param.uri=" + top.cicuri;
118    return true;
119 }
120
121 function refreshtheoryHeader(headerURL)
122 {
123    top.theoryheader.location.search = "?keys=GP&xmluri=" + headerURL + "&param.uri=" + top.theoryuri;
124    return true;
125 }
126
127 function getCICMathMLKeys()
128 {
129   return escape("d_c,C1,G,C2,L");
130 }
131
132 function getTheoryKeys()
133 {
134   return escape("T1,T2,L,E");
135 }
136
137 function getEmbedKeys()
138 {
139   return escape("d_c,TC1,HC2,L");
140 }
141
142 function getCICHTMLKeys()
143 {
144   return escape("d_c,C1,HC2,L");
145 }
146
147 function makeURL(type,uri,cicflags,typesflags)
148 {
149   var mode = top.mode;
150   var processorURL = top.processorURL;
151   var getterURL = top.getterURL;
152   var draw_graphURL = top.draw_graphURL;
153   var uri_set_queueURL = top.uri_set_queueURL;
154   var UNICODEvsSYMBOL = top.UNICODEvsSYMBOL;
155   var mode_list = mode.split(",");
156   
157   var keys = "";
158   var url = "";
159
160   var interfaceURL = top.topurl + "/html/cic/index.html";
161   var thinterfaceURL = top.topurl + "/html/theory/index.html";
162
163   var output = mode_list[0];
164   var format;
165   if (output == "raw") format = mode_list[1];
166   else format = mode_list[2];
167   
168   if (output == "raw") {
169     var ext = "";
170     var rdfprefix = "";
171     if (format == "types") ext = ".types"
172     else if (format == "ann") ext = ".ann"
173     else if (format == "fwd") rdfprefix = "helm:rdf:www.cs.unibo.it/helm/rdf/forward//"
174     else if (format == "bwd") rdfprefix = "helm:rdf:www.cs.unibo.it/helm/rdf/backward//";
175     url = getterURL + "getxml?uri=" + rdfprefix + uri + ext + "&format=" +
176           mode_list[5] + "&patch_dtd=" + mode_list[6];
177   } else {
178     if (format == "html" && type == "cic") {
179       keys = getCICHTMLKeys() +
180        "&param.processorURL=" + escape(processorURL) +
181        "&param.getterURL=" + escape(getterURL) +
182        "&param.draw_graphURL=" + escape(draw_graphURL) +
183        "&param.uri_set_queueURL=" + escape(uri_set_queueURL) +
184        "&param.UNICODEvsSYMBOL=" + escape(UNICODEvsSYMBOL) +
185        "&prop.doctype-public="+escape("-//W3C//DTD XHTML 1.0 Transitional//EN")+
186        "&prop.encoding=iso-8859-1" +
187        "&prop.media-type=text/html" +
188        "&param.doctype-public="+escape("-//W3C//DTD XHTML 1.0 Transitional//EN")+
189        "&param.encoding=iso-8859-1" +
190        "&param.media-type=text/html" +
191        "&param.keys=" + getCICHTMLKeys() +
192        "&param.interfaceURL=" + escape(interfaceURL);
193     } else if (format == "html" && type == "theory") {
194       keys = getTheoryKeys()+
195        "&param.processorURL=" + escape(processorURL) +
196        "&param.getterURL=" + escape(getterURL) +
197        "&param.draw_graphURL=" + escape(draw_graphURL) +
198        "&param.uri_set_queueURL=" + escape(uri_set_queueURL) +
199        "&param.UNICODEvsSYMBOL=" + escape(UNICODEvsSYMBOL) +
200        "&param.keys=" + getCICHTMLKeys() +
201        "&param.thkeys=" + getTheoryKeys() +
202        "&param.embedkeys=" + getEmbedKeys() +
203        "&param.doctype-public="+escape("-//W3C//DTD XHTML 1.0 Transitional//EN")+
204        "&param.encoding=iso-8859-1" +
205        "&param.thencoding=iso-8859-1" +
206        "&param.media-type=text/html" +
207        "&param.thmedia-type=text/html" +
208        "&param.interfaceURL=" + escape(interfaceURL) +
209        "&param.thinterfaceURL=" + escape(thinterfaceURL);
210     } else if (format == "mml_cont" && type == "cic") {
211       keys = escape("d_c,C1")+
212        "&prop.doctype-public="+
213        "&prop.encoding=" +
214        "&prop.media-type=text/xml" +
215        "&param.doctype-public=" +
216        "&param.encoding=" +
217        "&param.media-type=text/xml";
218     } else if (format == "mml_cont" && type == "theory") {
219       keys = escape("T1,L,E")+
220        "&param.keys=" + escape("d_c,C1") +
221        "&param.thkeys=T1,L,E" +
222        "&param.embedkeys=" + escape("d_c,TC1") +
223
224        "&param.processorURL=" + escape(processorURL) +
225        "&param.getterURL=" + escape(getterURL) +
226        "&param.draw_graphURL=" + escape(draw_graphURL) +
227        "&param.uri_set_queueURL=" + escape(uri_set_queueURL) +
228        "&param.doctype-public=" +
229        "&param.encoding=" +
230        "&param.thencoding=iso-8859-1" +
231        "&param.media-type=text/xml" +
232        "&param.thmedia-type=text/html" +
233        "&param.interfaceURL=" + escape(interfaceURL) +
234        "&param.thinterfaceURL=" + escape(thinterfaceURL);
235     } else if (format == "mml_pres" && type == "cic") {
236       keys = getCICMathMLKeys()+
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        "&prop.doctype-public="+
242        "&prop.encoding=" +
243        "&prop.media-type=text/xml" +
244        "&param.doctype-public=" +
245        "&param.encoding=" +
246        "&param.media-type=text/xml" +
247        "&param.keys=" + getCICMathMLKeys() +
248        "&param.interfaceURL=" + escape(interfaceURL);
249     } else if (format == "mml_pres" && type == "theory") {
250       keys = getTheoryKeys()+
251        "&param.keys=" + getCICMathMLKeys() +
252        "&param.thkeys=" + getTheoryKeys() +
253        "&param.embedkeys=" + escape("d_c,TC1,G,C2,L") +
254        "&param.processorURL=" + escape(processorURL) +
255        "&param.getterURL=" + escape(getterURL) +
256        "&param.draw_graphURL=" + escape(draw_graphURL) +
257        "&param.uri_set_queueURL=" + escape(uri_set_queueURL) +
258        "&param.doctype-public=" +
259        "&param.encoding=" +
260        "&param.thencoding=iso-8859-1" +
261        "&param.media-type=text/xml" +
262        "&param.thmedia-type=text/html" +
263        "&param.interfaceURL=" + escape(interfaceURL) +
264        "&param.thinterfaceURL=" + escape(thinterfaceURL);
265     }
266
267     var naturalLanguage = typesflags.toLowerCase();
268     if (typesflags != "NO" || type == "theory") {
269        naturalLanguage = mode_list[3];
270     }
271     var annotations = cicflags.toLowerCase();
272     if (cicflags != "NO" || type == "theory") {
273        annotations = mode_list[4];
274     }
275     url = processorURL + "apply?xmluri=" + escape(getterURL + "getxml?uri=" + uri) + "&keys=" + keys + "&param.CICURI=" + uri + "&param.naturalLanguage=" + naturalLanguage + "&param.annotations=" + annotations + "&param.topurl=" + top.topurl;
276   }
277
278   if (output == "raw")
279    return url;
280   else if (type == "cic")
281    return interfaceURL + "?url=" + escape(url);
282   else if (type == "theory")
283    return thinterfaceURL + "?url=" + escape(url)
284 }
285