]> matita.cs.unibo.it Git - helm.git/blob - helm/on-line/javascript/control.js
Added URL quoting to quote also "," (required by Netscape for plug-outs)
[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 makeURL(type,uri,cicflags,typesflags)
107 {
108   var mode = top.mode;
109   var processorURL = top.processorURL;
110   var getterURL = top.getterURL;
111   var mode_list = mode.split(",");
112   
113   var keys = "";
114   var url = "";
115
116   var output = mode_list[0];
117   var format;
118   if (output == "raw") format = mode_list[1];
119   else format = mode_list[2];
120   
121   if (output == "raw") {
122     var ext = "";
123     if (format == "types") ext = ".types"
124     else if (format == "ann") ext = ".ann";
125     url = getterURL + "getxml?uri=" + uri + ext + "&format=" + mode_list[5] +
126      "&patch_dtd=" + mode_list[6];
127   } else {
128     if (format == "html" && type == "cic") {
129       keys = escape("C1,HC2,L")+"&param.processorURL=" + escape(processorURL) +
130        "&param.getterURL=" + escape(getterURL) +
131        "&prop.doctype-public="+escape("-//W3C//DTD XHTML 1.0 Transitional//EN")+
132        "&prop.encoding=iso-8859-1" +
133        "&prop.media-type=text/html" +
134        "&param.doctype-public="+escape("-//W3C//DTD XHTML 1.0 Transitional//EN")+
135        "&param.encoding=iso-8859-1" +
136        "&param.media-type=text/html" +
137        "&param.keys=" + escape("C1,HC2,L");
138     } else if (format == "html" && type == "theory") {
139       keys = escape("T1,T2,L,E")+"&param.processorURL=" + escape(processorURL) +
140        "&param.getterURL=" + escape(getterURL) +
141        "&param.thkeys=" + escape("TC1,HC2,L") +
142        "&param.doctype-public="+escape("-//W3C//DTD XHTML 1.0 Transitional//EN")+
143        "&param.encoding=iso-8859-1" +
144        "&param.media-type=text/html" +
145        "&param.keys=" + escape("C1,HC2,L");
146     } else if (format == "mml_cont" && type == "cic") {
147       keys = "C1";
148     } else if (format == "mml_cont" && type == "theory") {
149       keys = escape("T1,E")+"&param.keys=C1&param.thkeys=TC1";
150     } else if (format == "mml_pres" && type == "cic") {
151       keys = escape("C1,C2,L")+"&param.processorURL=" + escape(processorURL) +
152        "&param.getterURL=" + escape(getterURL) +
153        "&prop.doctype-public="+
154        "&prop.encoding=" +
155        "&prop.media-type=text/xml" +
156        "&param.doctype-public=" +
157        "&param.encoding=" +
158        "&param.media-type=text/xml" +
159        "&param.keys=" + escape("C1,C2,L");
160     } else if (format == "mml_pres" && type == "theory") {
161       keys = escape("T1,T2,L,E")+"&param.keys=C1,C2&param.thkeys=TC1,C2,L" +
162        "&param.processorURL=" + escape(processorURL) +
163        "&param.getterURL=" + escape(getterURL) +
164        "&param.doctype-public=" +
165        "&param.encoding=" +
166        "&param.media-type=text/xml";
167     }
168
169     var naturalLanguage = typesflags;
170     if (typesflags != "NO" || type == "theory") {
171        naturalLanguage = mode_list[3];
172     }
173     var annotations = cicflags;
174     if (cicflags != "NO" || type == "theory") {
175        annotations = mode_list[4];
176     }
177     url = processorURL + "apply?xmluri=" + escape(getterURL + "getxml?uri=" + uri) + "&keys=" + keys + "&param.CICURI=" + uri + "&param.naturalLanguage=" + naturalLanguage + "&param.annotations=" + annotations;
178   }
179
180   return url;
181 }
182