]> matita.cs.unibo.it Git - helm.git/blob - helm/on-line/javascript/control.js
This commit was manufactured by cvs2svn to create branch 'start'.
[helm.git] / helm / on-line / javascript / control.js
1
2 function updateMode(i, s)
3 {
4   var mode = top.mode;
5   var mode_list = mode.split(",");
6   var res = "";
7   var j;
8
9   for (j = 0; j < mode_list.length; j++) {
10     if (j == i) res += s;
11     else res += mode_list[j];
12     if (j < mode_list.length - 1) res += ",";
13   }
14   
15   top.mode = res;
16 }
17
18 function updateOutput(output,format)
19 {
20   var theoryuri = top.theoryuri;
21   var cicuri = top.cicuri;
22   var mode = top.mode;
23   var topurl = top.topurl;
24   var processorURL = top.processorURL;
25   var getterURL = top.getterURL;
26   var mode_list = mode.split(",");
27   var new_mode = output.options[output.selectedIndex].value;
28   var dest = "?theoryuri=" + theoryuri + "&cicuri=" + cicuri + "&topurl=" + topurl + "&processorURL=" + processorURL + "&getterURL=" + getterURL + "&mode=";
29   
30   if (new_mode != mode_list[0]) {
31     updateMode(0, new_mode);
32     if (new_mode == "raw") updateMode(2, format.options[format.selectedIndex].value);
33     else updateMode(1, format.options[format.selectedIndex].value);
34     location.search = dest + top.mode;
35   }
36 }
37
38 function updateFormat(format)
39 {
40   var mode = top.mode;
41   var mode_list = mode.split(",");
42
43   if (mode_list[0] == "raw") {
44     updateMode(1, format.options[format.selectedIndex].value);
45   } else {
46     updateMode(2, format.options[format.selectedIndex].value);
47   }
48
49   refreshReload();
50 }
51
52 function updateNatural(checkbox)
53 {
54   if (checkbox.checked) updateMode(3, "yes");
55   else updateMode(3, "no");
56   refreshReload();
57 }
58
59 function updateAnnotations(checkbox)
60 {
61   if (checkbox.checked) updateMode(4, "yes");
62   else updateMode(4, "no");
63   refreshReload();
64 }
65
66 function refreshReload()
67 {
68    var search = 
69       "?mode=" + top.mode +
70       "&cicuri=" + top.cicuri +
71       "&theoryuri=" + top.theoryuri +
72       "&processorURL=" + top.processorURL +
73       "&getterURL=" + top.getterURL;
74
75    top.frames[0].document.links[0].search = search;
76    top.frames[0].document.links[1].search = search;
77
78    return true;
79 }
80
81 function refreshcicHeader(headerURL)
82 {
83    top.cicheader.location.search = "?keys=GP&xmluri=" + headerURL + "&param.uri=" + top.cicuri;
84    return true;
85 }
86
87 function refreshtheoryHeader(headerURL)
88 {
89    top.theoryheader.location.search = "?keys=GP&xmluri=" + headerURL + "&param.uri=" + top.theoryuri;
90    return true;
91 }
92
93 function makeURL(type,uri,cicflags,typesflags)
94 {
95   var mode = top.mode;
96   var processorURL = top.processorURL;
97   var getterURL = top.getterURL;
98   var mode_list = mode.split(",");
99   
100   var keys = "";
101   var url = "";
102
103   var output = mode_list[0];
104   var format;
105   if (output == "raw") format = mode_list[1];
106   else format = mode_list[2];
107   
108   if (output == "raw") {
109     url = getterURL + "get?uri=" + uri;
110   } else {
111     if (format == "html" && type == "cic") {
112       keys = "C1,HC2&param.processorURL=" + escape(processorURL) +
113        "&param.getterURL=" + escape(getterURL) +
114        "&param.keys=" + escape("C1,HC2");
115     } else if (format == "html" && type == "theory") {
116       keys = "T1,T2,E&param.processorURL=" + escape(processorURL) +
117        "&param.getterURL=" + escape(getterURL) +
118        "&param.keys=" + escape("C1,HC2");
119     } else if (format == "mml_cont" && type == "cic") {
120       keys = "C1";
121     } else if (format == "mml_cont" && type == "theory") {
122       keys = "T1,E&param.keys=C1";
123     } else if (format == "mml_pres" && type == "cic") {
124       keys = "C1,C2";
125     } else if (format == "mml_pres" && type == "theory") {
126       keys = "T1,T2,E&param.keys=C1,C2";
127     }
128
129     var naturalLanguage = typesflags;
130     if (typesflags != "NO" || type == "theory") {
131        naturalLanguage = mode_list[3];
132     }
133     url = processorURL + "apply?xmluri=" + escape(getterURL + "get?uri=" + uri) + "&keys=" + keys + "&param.CICURI=" + uri + "&param.naturalLanguage=" + naturalLanguage;
134   }
135
136   return url;
137 }
138