Book a Demo

Author Topic: Linking to HTML pages  (Read 3568 times)

andersd7

  • EA User
  • **
  • Posts: 26
  • Karma: +1/-0
    • View Profile
Linking to HTML pages
« on: March 25, 2008, 03:13:10 pm »
I am hoping to be able to reliably link into the HTML using a guid.  The HTML generation appears to build/assign pages based on the relative position in the project.

There is a collection of guid.xml files under the js/data folder. Before I hack into JavaScript, has anyone written a routine which can resolve the url..


thanks David.

andersd7

  • EA User
  • **
  • Posts: 26
  • Karma: +1/-0
    • View Profile
Re: Linking to HTML pages
« Reply #1 on: April 10, 2008, 12:09:56 pm »
The following changes have been made to the default javascript within EA 7.1 to supports linking directly to a html page specified by a guid.

This change was prompted to ensure that a reliable URL into the HTML version of the EA model can be stored externally in either our service registry/repository and other specification documents.  The issue being addressed is the dynamic nature in which the HTML output is produced, whereby links and htm pages are assigned based on the relative position within the EA project.

Example URL string:
http://......./Models/Current/index.htm?guid=AD5D83E7-BAF5-44a4-AB7F-1272CA15C2C0

A word of caution..
  • I am not a javascript programmer and therefore these changes are considered a hack and should be reviewed
  • There is an outstanding issue in that the LinkByGuid value

is not yet set because of the asynchronous nature of the XMLHlhttpRequest onreadystatechange.  This has been tactically resolved by adding an alert statement to prompt the user of continue..
[/list]

Summary of changes

When a page is loaded, search for the “guid” string.
If found,
  • Open the ..js/data/guid.xml file using the XMLHlhttpRequest
  • Extract the first HTM page reference

sample guid.xml file
tocTab[tocTab.length] = new Array("6.2.5.1:1", "", "Customer Relationship Conceptual Business Service Diagram", "EARoot/EA6/EA2/EA5/EA1/EA1395.htm", "176.png", "-1693416310", "0", "", "Package diagram0","{CDACE0A8-AAD7-4981-B210-56C7BF8F67AF}");

I will post updated javascript separately.

andersd7

  • EA User
  • **
  • Posts: 26
  • Karma: +1/-0
    • View Profile
Re: Linking to HTML pages
« Reply #2 on: April 10, 2008, 12:14:04 pm »
DisplayToc.js modifications
var tocRoot, tocBranch, tocSel, tocLoading, tocLastID, tableSel, tabHead, data, [highlight]xmldata[/highlight], tocTab, tocInitRoot, tocMemToc, rFStatus, oldData, tableSelTable, [highlight]LinkByGuid[/highlight];
var initI;
var icon=new Array();
var preloadIcons=new Array(1,10,101,102,103,104,106,107,108,11,113,116,118,16,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,19,20,21,24,25,26,28,29,31,34,4,5,52,53,56,57,6,60,68,69,7,8,82,9,99);

var browser=browserCheck();

function initLoad(src,toc,home) {

      qs=document.location.search.substring(1);

      if (qs.substring(0,qs.indexOf('='))=='goto') {
            var gotoPage = qs.substring(qs.indexOf('=')+1).split(':');
            var fExt = home.substring(home.lastIndexOf('.'));
            var home = "./EARoot/";
            for (var i=0; i<gotoPage.length; i++) {
                  home += "EA"+gotoPage;
                  if (i!=gotoPage.length-1)
                        home += "/";
                  else
                        home += fExt;
            }
      }

[highlight]      if (qs.substring(0,qs.indexOf('='))=='guid') {
              var home = "./";
               resolveGuid(qs.substring(qs.indexOf('=')+1).split('='));
alert ("Press OK to continue.....");
home += LinkByGuid;
      }      [/highlight]
      src=src.document.location+"";

      src=src.substring(src.lastIndexOf('/')+1);
      if(src.indexOf('index')==-1&&src!="") return;

      var content = document.createElement('div');
      content.className = "IndexBody";
      content.innerHTML="      <iframe src='"+toc+"' name='toc' id='tocIFrame' frameborder='0'></iframe>\n";
      content.innerHTML+="      <iframe src='"+home+"' name='cont' id='contentIFrame' frameborder='0'></iframe>";
      content.innerHTML+="      <div id=\"resizeFrames\"></div>";

      initPreLoad(content);

}

[highlight]function resolveGuid(src) {

      var tmp=document.location+"";
      tmp=tmp.substring(0,tmp.indexOf('index.htm?'));

      src = tmp+"js/data/"+src+".xml";
try {
            xmldata = new XMLHttpRequest();
            xmldata.onreadystatechange = processXML;
            xmldata.open("GET", src, true);
            xmldata.send(null);
      } catch(e) {
            if (browser=="ie6"||browser=="ie7") {
                  xmldata = new ActiveXObject("Microsoft.XMLHTTP");
                  if (xmldata) {
                        xmldata.onreadystatechange = processXML;
                        xmldata.open("GET", src, true);
                        xmldata.send();
                  }
            } else {
                  alert(e);
            }
      }
}

function processXML() {
      if (xmldata.readyState == 4 ) {
            if (xmldata.status == 0 || xmldata.status == 200) {
        splits = xmldata.responseText.split(",",4);
        splitlen = splits[3].length-1;
        LinkByGuid = splits[3].substring(2,splitlen);
    }      else {
                     alert ("guid is is not recognised ") ;
            }
      }
}[/highlight]