X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fon-line%2Fjavascript%2Fcontrol.js;fp=helm%2Fon-line%2Fjavascript%2Fcontrol.js;h=66412aa9c6af06441b07913a71567e36ed21d553;hb=d70d5de1ec9ccc86c9df45036245af34c37575ea;hp=0000000000000000000000000000000000000000;hpb=99d60351f793983bb7633334ea59e95feb36c72c;p=helm.git diff --git a/helm/on-line/javascript/control.js b/helm/on-line/javascript/control.js new file mode 100644 index 000000000..66412aa9c --- /dev/null +++ b/helm/on-line/javascript/control.js @@ -0,0 +1,138 @@ + +function updateMode(i, s) +{ + var mode = top.mode; + var mode_list = mode.split(","); + var res = ""; + var j; + + for (j = 0; j < mode_list.length; j++) { + if (j == i) res += s; + else res += mode_list[j]; + if (j < mode_list.length - 1) res += ","; + } + + top.mode = res; +} + +function updateOutput(output,format) +{ + var theoryuri = top.theoryuri; + var cicuri = top.cicuri; + var mode = top.mode; + var topurl = top.topurl; + var processorURL = top.processorURL; + var getterURL = top.getterURL; + var mode_list = mode.split(","); + var new_mode = output.options[output.selectedIndex].value; + var dest = "?theoryuri=" + theoryuri + "&cicuri=" + cicuri + "&topurl=" + topurl + "&processorURL=" + processorURL + "&getterURL=" + getterURL + "&mode="; + + if (new_mode != mode_list[0]) { + updateMode(0, new_mode); + if (new_mode == "raw") updateMode(2, format.options[format.selectedIndex].value); + else updateMode(1, format.options[format.selectedIndex].value); + location.search = dest + top.mode; + } +} + +function updateFormat(format) +{ + var mode = top.mode; + var mode_list = mode.split(","); + + if (mode_list[0] == "raw") { + updateMode(1, format.options[format.selectedIndex].value); + } else { + updateMode(2, format.options[format.selectedIndex].value); + } + + refreshReload(); +} + +function updateNatural(checkbox) +{ + if (checkbox.checked) updateMode(3, "yes"); + else updateMode(3, "no"); + refreshReload(); +} + +function updateAnnotations(checkbox) +{ + if (checkbox.checked) updateMode(4, "yes"); + else updateMode(4, "no"); + refreshReload(); +} + +function refreshReload() +{ + var search = + "?mode=" + top.mode + + "&cicuri=" + top.cicuri + + "&theoryuri=" + top.theoryuri + + "&processorURL=" + top.processorURL + + "&getterURL=" + top.getterURL; + + top.frames[0].document.links[0].search = search; + top.frames[0].document.links[1].search = search; + + return true; +} + +function refreshcicHeader(headerURL) +{ + top.cicheader.location.search = "?keys=GP&xmluri=" + headerURL + "¶m.uri=" + top.cicuri; + return true; +} + +function refreshtheoryHeader(headerURL) +{ + top.theoryheader.location.search = "?keys=GP&xmluri=" + headerURL + "¶m.uri=" + top.theoryuri; + return true; +} + +function makeURL(type,uri,cicflags,typesflags) +{ + var mode = top.mode; + var processorURL = top.processorURL; + var getterURL = top.getterURL; + var mode_list = mode.split(","); + + var keys = ""; + var url = ""; + + var output = mode_list[0]; + var format; + if (output == "raw") format = mode_list[1]; + else format = mode_list[2]; + + if (output == "raw") { + url = getterURL + "get?uri=" + uri; + } else { + if (format == "html" && type == "cic") { + keys = "C1,HC2¶m.processorURL=" + escape(processorURL) + + "¶m.getterURL=" + escape(getterURL) + + "¶m.keys=" + escape("C1,HC2"); + } else if (format == "html" && type == "theory") { + keys = "T1,T2,E¶m.processorURL=" + escape(processorURL) + + "¶m.getterURL=" + escape(getterURL) + + "¶m.keys=" + escape("C1,HC2"); + } else if (format == "mml_cont" && type == "cic") { + keys = "C1"; + } else if (format == "mml_cont" && type == "theory") { + keys = "T1,E¶m.keys=C1"; + } else if (format == "mml_pres" && type == "cic") { + keys = "C1,C2"; + } else if (format == "mml_pres" && type == "theory") { + keys = "T1,T2,E¶m.keys=C1,C2"; + } + + var naturalLanguage = typesflags; + if (typesflags != "NO" || type == "theory") { + naturalLanguage = mode_list[3]; + } + url = processorURL + "apply?xmluri=" + escape(getterURL + "get?uri=" + uri) + "&keys=" + keys + "¶m.CICURI=" + uri + "¶m.naturalLanguage=" + naturalLanguage; + } + + return url; +} +