]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/on-line/javascript/control.js
Major interface improvements.
[helm.git] / helm / on-line / javascript / control.js
index 8ad40ce64ceaa580520e4dd13919c9a28aa1179c..bc52d02b617d6a2948d56b65dcaf4d103528d862 100644 (file)
@@ -14,27 +14,32 @@ function updateMode(i, s)
   top.mode = res;
 }
 
-function updateOutput(output,format)
+function updateOutput(output,format,processorURL,interfaceURL)
 {
   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=";
+  var dest = "?theoryuri=" + theoryuri + "&cicuri=" + cicuri + "&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;
+
+    var href =
+     processorURL + 'apply' +
+     '?keys=RT' +
+     '&param.topurl=' + topurl +
+     '&xmluri=' +
+     escape(interfaceURL + '/html/library/control.html' + dest + top.mode);
+    
+    location.href = href;
   }
 }
 
-function updateFormat(format)
+function updateFormat(format,profile,processorURL,interfaceURL)
 {
   var mode = top.mode;
   var mode_list = mode.split(",");
@@ -45,48 +50,55 @@ function updateFormat(format)
     updateMode(2, format.options[format.selectedIndex].value);
   }
 
-  refreshReload();
+  refreshReload(profile,processorURL,interfaceURL);
 }
 
-function updateNatural(checkbox)
+function updateNatural(checkbox,profile,processorURL,interfaceURL)
 {
   if (checkbox.checked) updateMode(3, "yes");
   else updateMode(3, "no");
-  refreshReload();
+  refreshReload(profile,processorURL,interfaceURL);
 }
 
-function updateAnnotations(checkbox)
+function updateAnnotations(checkbox,profile,processorURL,interfaceURL)
 {
   if (checkbox.checked) updateMode(4, "yes");
   else updateMode(4, "no");
-  refreshReload();
+  refreshReload(profile,processorURL,interfaceURL);
 }
 
-function updateCompressed(checkbox)
+function updateCompressed(checkbox,profile,processorURL,interfaceURL)
 {
   if (checkbox.checked) updateMode(5, "gz");
   else updateMode(5, "normal");
-  refreshReload();
+  refreshReload(profile,processorURL,interfaceURL);
 }
 
-function updateDTDPatched(checkbox)
+function updateDTDPatched(checkbox,profile,processorURL,interfaceURL)
 {
   if (checkbox.checked) updateMode(6, "yes");
   else updateMode(6, "no");
-  refreshReload();
+  refreshReload(profile,processorURL,interfaceURL);
 }
 
-function refreshReload()
+function refreshReload(profile, processorURL, interfaceURL)
 {
    var search = 
       "?mode=" + top.mode +
       "&cicuri=" + top.cicuri +
-      "&theoryuri=" + top.theoryuri +
-      "&processorURL=" + top.processorURL +
-      "&getterURL=" + top.getterURL;
+      "&theoryuri=" + top.theoryuri;
 
-   top.frames[0].document.links[0].search = search;
-   top.frames[0].document.links[1].search = search;
+   var href = processorURL +
+    'apply' +
+    '?keys=RT' +
+    '&profile=' + profile +
+    '&param.profile=' + profile +
+    '&xmluri=' +
+    escape(interfaceURL + '/html/library/index.html' + search);
+    
+   top.frames[0].document.links[0].href = href;
+   top.frames[0].document.links[1].href =
+    interfaceURL + '/html/index.html' + search;
 
    return true;
 }
@@ -103,16 +115,42 @@ function refreshtheoryHeader(headerURL)
    return true;
 }
 
-function makeURL(type,uri,cicflags,typesflags)
+function getCICMathMLKeys()
+{
+  return escape("d_c,C1,G,C2,L");
+}
+
+function getTheoryKeys()
+{
+  return escape("T1,T2,L,E");
+}
+
+function getEmbedKeys()
+{
+  return escape("d_c,TC1,HC2,L");
+}
+
+function getCICHTMLKeys()
+{
+  return escape("d_c,C1,HC2,L");
+}
+
+function getCICProofTreeXHTMLMathMLKeys()
+{
+  return escape("HAT,G,HAO,L");
+}
+
+function makeURL(type,uri,cicflags,typesflags,profile,processorURL,interfaceURL,getterURL)
 {
   var mode = top.mode;
-  var processorURL = top.processorURL;
-  var getterURL = top.getterURL;
   var mode_list = mode.split(",");
   
   var keys = "";
   var url = "";
 
+  var interfaceURLidx = interfaceURL + "/html/cic/index.html";
+  var thinterfaceURLidx = interfaceURL + "/html/theory/index.html";
+
   var output = mode_list[0];
   var format;
   if (output == "raw") format = mode_list[1];
@@ -120,61 +158,103 @@ function makeURL(type,uri,cicflags,typesflags)
   
   if (output == "raw") {
     var ext = "";
+    var rdfprefix = "";
     if (format == "types") ext = ".types"
-    else if (format == "ann") ext = ".ann";
-    url = getterURL + "getxml?uri=" + uri + ext + "&format=" + mode_list[5] +
-     "&patched_dtd=" + mode_list[6];
+    else if (format == "ann") ext = ".ann"
+    else if (format == "fwd") rdfprefix = "helm:rdf:www.cs.unibo.it/helm/rdf/forward//"
+    else if (format == "bwd") rdfprefix = "helm:rdf:www.cs.unibo.it/helm/rdf/backward//";
+    url = getterURL + "getxml?uri=" + rdfprefix + uri + ext + "&format=" +
+          mode_list[5] + "&patch_dtd=" + mode_list[6];
   } else {
-    if (format == "html" && type == "cic") {
-      keys = "C1,HC2,L&param.processorURL=" + escape(processorURL) +
-       "&param.getterURL=" + escape(getterURL) +
+    var uri_len = uri.length;
+    if (format == "html" && type == "cic" && uri.substring(uri.length - 10, uri.length) == "proof_tree") {
+      keys = getCICProofTreeXHTMLMathMLKeys() +
+       "&profile=" + profile +
+       "&default.profile=" + profile +
+       "&prop.doctype-public="+escape("-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN")+
+       "&prop.doctype-system="+escape("http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd")+
+       "&prop.encoding=iso-8859-1" +
+       "&prop.media-type=text/xml" +
+       "&prop.method=xml" +
+       "&param.doctype-public="+escape("-//W3C//DTD XHTML 1.0 Transitional//EN")+
+       "&param.encoding=iso-8859-1" +
+       "&param.media-type=text/html" +
+       "&param.keys=" + getCICHTMLKeys() +
+       "&param.framewidth=150";
+    } else if (format == "html" && type == "cic") {
+      keys = getCICHTMLKeys() +
+       "&profile=" + profile +
+       "&param.profile=" + profile +
        "&prop.doctype-public="+escape("-//W3C//DTD XHTML 1.0 Transitional//EN")+
        "&prop.encoding=iso-8859-1" +
        "&prop.media-type=text/html" +
+       "&prop.method=html" +
        "&param.doctype-public="+escape("-//W3C//DTD XHTML 1.0 Transitional//EN")+
        "&param.encoding=iso-8859-1" +
        "&param.media-type=text/html" +
-       "&param.keys=" + escape("C1,HC2,L");
+       "&param.keys=" + getCICHTMLKeys();
     } else if (format == "html" && type == "theory") {
-      keys = "T1,T2,L,E&param.processorURL=" + escape(processorURL) +
-       "&param.getterURL=" + escape(getterURL) +
-       "&param.thkeys=" + escape("TC1,HC2,L") +
+      keys = getTheoryKeys()+
+       "&profile=" + profile +
+       "&param.profile=" + profile +
+       "&param.keys=" + getCICHTMLKeys() +
+       "&param.thkeys=" + getTheoryKeys() +
+       "&param.embedkeys=" + getEmbedKeys() +
        "&param.doctype-public="+escape("-//W3C//DTD XHTML 1.0 Transitional//EN")+
        "&param.encoding=iso-8859-1" +
+       "&param.thencoding=iso-8859-1" +
        "&param.media-type=text/html" +
-       "&param.keys=" + escape("C1,HC2,L");
+       "&param.thmedia-type=text/html";
     } else if (format == "mml_cont" && type == "cic") {
-      keys = "C1";
+      keys = escape("d_c,C1")+
+       "&profile=" + profile +
+       "&param.profile=" + profile +
+       "&prop.doctype-public="+
+       "&prop.media-type=text/xml" +
+       "&param.doctype-public=" +
+       "&param.encoding=" +
+       "&param.media-type=text/xml";
     } else if (format == "mml_cont" && type == "theory") {
-      keys = "T1,E&param.keys=C1&param.thkeys=TC1";
+      keys = escape("T1,L,E")+
+       "&profile=" + profile +
+       "&param.profile=" + profile +
+       "&param.keys=" + escape("d_c,C1") +
+       "&param.thkeys=T1,L,E" +
+       "&param.embedkeys=" + escape("d_c,TC1") +
+       "&param.doctype-public=" +
+       "&param.encoding=" +
+       "&param.thencoding=iso-8859-1" +
+       "&param.media-type=text/xml" +
+       "&param.thmedia-type=text/html";
     } else if (format == "mml_pres" && type == "cic") {
-      keys = "C1,C2,L&param.processorURL=" + escape(processorURL) +
-       "&param.getterURL=" + escape(getterURL) +
+      keys = getCICMathMLKeys()+
+       "&profile=" + profile +
+       "&param.profile=" + profile +
        "&prop.doctype-public="+
-       "&prop.encoding=" +
        "&prop.media-type=text/xml" +
        "&param.doctype-public=" +
        "&param.encoding=" +
        "&param.media-type=text/xml" +
-       "&param.keys=" + escape("C1,C2,L");
+       "&param.keys=" + getCICMathMLKeys();
     } else if (format == "mml_pres" && type == "theory") {
-      keys = "T1,T2,L,E&param.keys=C1,C2&param.thkeys=TC1,C2,L" +
+      keys = getTheoryKeys()+
+       "&profile=" + profile +
+       "&param.profile=" + profile +
+       "&param.keys=" + getCICMathMLKeys() +
+       "&param.thkeys=" + getTheoryKeys() +
+       "&param.embedkeys=" + escape("d_c,TC1,G,C2,L") +
        "&param.doctype-public=" +
        "&param.encoding=" +
-       "&param.media-type=text/xml";
-    }
-
-    var naturalLanguage = typesflags;
-    if (typesflags != "NO" || type == "theory") {
-       naturalLanguage = mode_list[3];
-    }
-    var annotations = cicflags;
-    if (cicflags != "NO" || type == "theory") {
-       annotations = mode_list[4];
+       "&param.thencoding=iso-8859-1" +
+       "&param.media-type=text/xml" +
+       "&param.thmedia-type=text/html";
     }
-    url = processorURL + "apply?xmluri=" + escape(getterURL + "getxml?uri=" + uri) + "&keys=" + keys + "&param.CICURI=" + uri + "&param.naturalLanguage=" + naturalLanguage + "&param.annotations=" + annotations;
   }
 
-  return url;
+  if (output == "raw")
+   return url;
+  else if (type == "cic")
+   return processorURL + "apply?keys=RT&xmluri=" + escape(interfaceURLidx) + "&param.ignore=" + keys + "&param.CICURI=" + uri;
+  else if (type == "theory")
+   return processorURL + "apply?keys=RT&xmluri=" + escape(thinterfaceURLidx) + "&param.ignore=" + keys + "&param.CICURI=" + uri;
 }
-