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