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