From: Claudio Sacerdoti Coen Date: Thu, 25 Oct 2001 10:19:53 +0000 (+0000) Subject: Code obtained from the factorization of makeGraphLinks.xsl and metadataLib.xsl X-Git-Tag: v0_1_3~42 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=f05cab6b58d1706d7a9587b7cca4cad4fce7ff49;p=helm.git Code obtained from the factorization of makeGraphLinks.xsl and metadataLib.xsl --- diff --git a/helm/on-line/javascript/graphLinks.js b/helm/on-line/javascript/graphLinks.js new file mode 100644 index 000000000..85e9fbde7 --- /dev/null +++ b/helm/on-line/javascript/graphLinks.js @@ -0,0 +1,70 @@ +function mkRDFURI(uri) +{ + var prefix = "helm:rdf:www.cs.unibo.it/helm/rdf/backward//"; + var re1 = /#xpointer\(1\/(\d+)\/(\d+)\)/; + var re2 = /#xpointer\(1\/(\d+)\)/; + // Just one of the following replace will do something + uri = uri.replace(re1,",$1,$2"); + uri = uri.replace(re2,",$1"); + + return (prefix + uri); +} + +function removeXPointer(uri) +{ + //var re = /#xpointer(\.*)/; + // CSC: Why the r.e.s below work and the one above does not? + var re1 = /#xpointer\(1\/(\d+)\/(\d+)\)/; + var re2 = /#xpointer\(1\/(\d+)\)/; + var res = uri.replace(re1,""); + res = res.replace(re2,""); + + return res; +} + + +// (use_rdf_uri==true) if the stylesheet must be applied to the +// metadata; (use_rdf_uri==false) otherwise +function mkGraphURL(uri,keys,use_rdf_uri,use_default_uri_set_size) +{ + var getterURL = unescape(getParam("param.getterURL")); + var draw_graphURL = unescape(getParam("param.draw_graphURL")); + var url= setParam(location.href,"keys",keys); + var rdfuri = mkRDFURI(uri); + url = setParam(url,"xmluri", getterURL + 'getxml%3Furi%3D' + + (use_rdf_uri ? rdfuri : removeXPointer(uri))); + url = setParam(url,"param.CICURI",escape(uri)); + var uri_set_size = + use_default_uri_set_size ? -1 : document.uri_set_size.elements[0].value; + if (uri_set_size > 0) + url = setParam(url,"param.uri_set_size",uri_set_size); + url = draw_graphURL + 'draw?url=' + escape(url); + var url2 = setParam(location.href,"keys","MGL,RT"); + url2 = setParam(url2,"xmluri",escape(url)); + if (uri_set_size > 0) + url2 = setParam(url2,"param.uri_set_size",uri_set_size); + return url2; +} + +function mkDepURL(uri,use_default_uri_set_size) +{ + return mkGraphURL(uri,"MDG",0,use_default_uri_set_size); +} + + +function mkMetaURL(uri,use_default_uri_set_size) +{ + return mkGraphURL(uri,"MMG",1,use_default_uri_set_size); +} + +function mkCICURL(uri) +{ + var rawuri = removeXPointer(uri); + var getterURL = getParam("param.getterURL"); + var interfaceURL = unescape(getParam("param.interfaceURL")); + var url= setParam(location.href,"keys",getParam("param.keys")); + url = setParam(url,"xmluri", getterURL + 'getxml%3Furi%3D' + rawuri); + url = setParam(url,"param.CICURI",rawuri); + url = interfaceURL + "?url=" + escape(url); + return url; +}