]> matita.cs.unibo.it Git - helm.git/blob - helm/on-line/javascript/control.js
New HELM interface almost stable.
[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,processorURL,interfaceURL)
18 {
19   var theoryuri = top.theoryuri;
20   var cicuri = top.cicuri;
21   var mode = top.mode;
22   var mode_list = mode.split(",");
23   var new_mode = output.options[output.selectedIndex].value;
24   var dest = "?theoryuri=" + theoryuri + "&cicuri=" + cicuri + "&mode=";
25   
26   if (new_mode != mode_list[0]) {
27     updateMode(0, new_mode);
28     if (new_mode == "raw") updateMode(2, format.options[format.selectedIndex].value);
29     else updateMode(1, format.options[format.selectedIndex].value);
30
31     var href =
32      processorURL + 'apply' +
33      '?keys=RT' +
34      '&param.topurl=' + topurl +
35      '&xmluri=' +
36      escape(interfaceURL + '/html/library/control.html' + dest + top.mode);
37     
38     location.href = href;
39   }
40 }
41
42 function updateFormat(format,profile,processorURL,interfaceURL)
43 {
44   var mode = top.mode;
45   var mode_list = mode.split(",");
46
47   if (mode_list[0] == "raw") {
48     updateMode(1, format.options[format.selectedIndex].value);
49   } else {
50     updateMode(2, format.options[format.selectedIndex].value);
51   }
52
53   refreshReload(profile,processorURL,interfaceURL);
54 }
55
56 function updateNatural(checkbox,profile,processorURL,interfaceURL)
57 {
58   if (checkbox.checked) updateMode(3, "yes");
59   else updateMode(3, "no");
60   refreshReload(profile,processorURL,interfaceURL);
61 }
62
63 function updateAnnotations(checkbox,profile,processorURL,interfaceURL)
64 {
65   if (checkbox.checked) updateMode(4, "yes");
66   else updateMode(4, "no");
67   refreshReload(profile,processorURL,interfaceURL);
68 }
69
70 function updateCompressed(checkbox,profile,processorURL,interfaceURL)
71 {
72   if (checkbox.checked) updateMode(5, "gz");
73   else updateMode(5, "normal");
74   refreshReload(profile,processorURL,interfaceURL);
75 }
76
77 function updateDTDPatched(checkbox,profile,processorURL,interfaceURL)
78 {
79   if (checkbox.checked) updateMode(6, "yes");
80   else updateMode(6, "no");
81   refreshReload(profile,processorURL,interfaceURL);
82 }
83
84 function refreshReload(profile, processorURL, interfaceURL)
85 {
86    var search = 
87       "?mode=" + top.mode +
88       "&cicuri=" + top.cicuri +
89       "&theoryuri=" + top.theoryuri;
90
91    var href = processorURL +
92     'apply' +
93     '?keys=RT' +
94     '&profile=' + profile +
95     '&param.profile=' + profile +
96     '&xmluri=' +
97     escape(interfaceURL + '/html/library/index.html' + search);
98     
99    top.frames[0].document.links[0].href = href;
100    top.frames[0].document.links[1].href =
101     interfaceURL + '/html/index.html' + search;
102
103    return true;
104 }
105
106 function refreshcicHeader(headerURL)
107 {
108    top.cicheader.location.search = "?keys=GP&xmluri=" + headerURL + "&param.uri=" + top.cicuri;
109    return true;
110 }
111
112 function refreshtheoryHeader(headerURL)
113 {
114    top.theoryheader.location.search = "?keys=GP&xmluri=" + headerURL + "&param.uri=" + top.theoryuri;
115    return true;
116 }
117
118 function getCICMathMLKeys()
119 {
120   return escape("d_c,C1,G,C2,L");
121 }
122
123 function getTheoryKeys()
124 {
125   return escape("T1,T2,L,E");
126 }
127
128 function getEmbedKeys()
129 {
130   return escape("d_c,TC1,HC2,L");
131 }
132
133 function getCICHTMLKeys()
134 {
135   return escape("d_c,C1,HC2,L");
136 }
137
138 function getCICProofTreeXHTMLMathMLKeys()
139 {
140   return escape("HAT,G,HAO,L");
141 }
142
143 function makeURL(type,uri,cicflags,typesflags,profile,processorURL,interfaceURL,getterURL)
144 {
145   var mode = top.mode;
146   var mode_list = mode.split(",");
147   
148   var keys = "";
149   var url = "";
150
151   var interfaceURLidx = interfaceURL + "/html/cic/index.html";
152   var thinterfaceURLidx = interfaceURL + "/html/theory/index.html";
153
154   var output = mode_list[0];
155   var format;
156   if (output == "raw") format = mode_list[1];
157   else format = mode_list[2];
158   
159   if (output == "raw") {
160     var ext = "";
161     var rdfprefix = "";
162     if (format == "types") ext = ".types"
163     else if (format == "ann") ext = ".ann"
164     else if (format == "fwd") rdfprefix = "helm:rdf:www.cs.unibo.it/helm/rdf/forward//"
165     else if (format == "bwd") rdfprefix = "helm:rdf:www.cs.unibo.it/helm/rdf/backward//";
166     url = getterURL + "getxml?uri=" + rdfprefix + uri + ext + "&format=" +
167           mode_list[5] + "&patch_dtd=" + mode_list[6];
168   } else {
169     var uri_len = uri.length;
170     if (format == "html" && type == "cic" && uri.substring(uri.length - 10, uri.length) == "proof_tree") {
171       keys = getCICProofTreeXHTMLMathMLKeys() +
172        "&profile=" + profile +
173        "&default.profile=" + profile +
174        "&prop.doctype-public="+escape("-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN")+
175        "&prop.doctype-system="+escape("http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd")+
176        "&prop.encoding=iso-8859-1" +
177        "&prop.media-type=text/xml" +
178        "&prop.method=xml" +
179        "&param.doctype-public="+escape("-//W3C//DTD XHTML 1.0 Transitional//EN")+
180        "&param.encoding=iso-8859-1" +
181        "&param.media-type=text/html" +
182        "&param.keys=" + getCICHTMLKeys() +
183        "&param.framewidth=150";
184     } else if (format == "html" && type == "cic") {
185       keys = getCICHTMLKeys() +
186        "&profile=" + profile +
187        "&param.profile=" + profile +
188        "&prop.doctype-public="+escape("-//W3C//DTD XHTML 1.0 Transitional//EN")+
189        "&prop.encoding=iso-8859-1" +
190        "&prop.media-type=text/html" +
191        "&prop.method=html" +
192        "&param.doctype-public="+escape("-//W3C//DTD XHTML 1.0 Transitional//EN")+
193        "&param.encoding=iso-8859-1" +
194        "&param.media-type=text/html" +
195        "&param.keys=" + getCICHTMLKeys();
196     } else if (format == "html" && type == "theory") {
197       keys = getTheoryKeys()+
198        "&profile=" + profile +
199        "&param.profile=" + profile +
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     } else if (format == "mml_cont" && type == "cic") {
209       keys = escape("d_c,C1")+
210        "&profile=" + profile +
211        "&param.profile=" + profile +
212        "&prop.doctype-public="+
213        "&prop.media-type=text/xml" +
214        "&param.doctype-public=" +
215        "&param.encoding=" +
216        "&param.media-type=text/xml";
217     } else if (format == "mml_cont" && type == "theory") {
218       keys = escape("T1,L,E")+
219        "&profile=" + profile +
220        "&param.profile=" + profile +
221        "&param.keys=" + escape("d_c,C1") +
222        "&param.thkeys=T1,L,E" +
223        "&param.embedkeys=" + escape("d_c,TC1") +
224        "&param.doctype-public=" +
225        "&param.encoding=" +
226        "&param.thencoding=iso-8859-1" +
227        "&param.media-type=text/xml" +
228        "&param.thmedia-type=text/html";
229     } else if (format == "mml_pres" && type == "cic") {
230       keys = getCICMathMLKeys()+
231        "&profile=" + profile +
232        "&param.profile=" + profile +
233        "&prop.doctype-public="+
234        "&prop.media-type=text/xml" +
235        "&param.doctype-public=" +
236        "&param.encoding=" +
237        "&param.media-type=text/xml" +
238        "&param.keys=" + getCICMathMLKeys();
239     } else if (format == "mml_pres" && type == "theory") {
240       keys = getTheoryKeys()+
241        "&profile=" + profile +
242        "&param.profile=" + profile +
243        "&param.keys=" + getCICMathMLKeys() +
244        "&param.thkeys=" + getTheoryKeys() +
245        "&param.embedkeys=" + escape("d_c,TC1,G,C2,L") +
246        "&param.doctype-public=" +
247        "&param.encoding=" +
248        "&param.thencoding=iso-8859-1" +
249        "&param.media-type=text/xml" +
250        "&param.thmedia-type=text/html";
251     }
252   }
253
254   if (output == "raw")
255    return url;
256   else if (type == "cic")
257    return processorURL + "apply?keys=RT&xmluri=" + escape(interfaceURLidx) + "&param.ignore=" + keys + "&param.CICURI=" + uri;
258   else if (type == "theory")
259    return processorURL + "apply?keys=RT&xmluri=" + escape(thinterfaceURLidx) + "&param.ignore=" + keys + "&param.CICURI=" + uri;
260 }
261