// Copyright 2006-2021 The MathWorks, Inc. // Class RTW_Hash ------------------------------------------------------------ // Internal web browser doesn't change window.location.hash if the link points // to the same page. // RTW_Hash remembers the hash value when the page is loaded in the first time // or a link is clicked. // removeHiliteByHash cleans the high lighted elements according to the stored // hash value function RTW_Hash(aHash) { if (aHash == null) { this.fHash = ""; } else { this.fHash = aHash; }; this.getHash = function() { return this.fHash; } this.setHash = function(aHash) { this.fHash = aHash; } } RTW_Hash.instance = null; // Class RTW_TraceInfo -------------------------------------------------------- function RTW_TraceInfo(aFileLinks) { this.fFileLinks = aFileLinks; this.fLines = new Array(); this.fTotalLines = 0; // total number of highlighted lines this.fNumLines = new Array(); this.fFileIdxCache = new Array(); this.fDisablePanel = false; this.fCurrFileIdx = -1; this.fCurrLineIdx = -1; this.fCurrCodeNode = null; this.getHtmlFileName = function(aIndex) { if (aIndex < this.fFileLinks.length) { var href = this.fFileLinks[aIndex].href; return href.substring(href.lastIndexOf('/')+1); } } this.getSrcFileName = function(aIndex) { var name = this.getHtmlFileName(aIndex); if (name) name = RTW_TraceInfo.toSrcFileName(name); return name; } this.getNumFileLinks = function() { return this.fFileLinks.length; } this.setFileLinkColor = function(aIndex, aColor) { var link = this.fFileLinks[aIndex]; if (link && link.parentNode && link.parentNode.style) link.parentNode.style.backgroundColor = aColor; } this.highlightFileLink = function(aIndex, aColor) { for (var i = 0; i < this.fFileLinks.length; ++i) { this.setFileLinkColor(i, i == aIndex ? aColor : ""); } } this.highlightCurrFileLink = function(aColor) { this.highlightFileLink(this.fCurrFileIdx); } this.highlightLines = function(aCodeNode,aColor) { this.fCurrCodeNode = aCodeNode; var lines = this.fLines[this.getHtmlFileName(this.fCurrFileIdx)]; if (lines && aCodeNode) { for (var i = 0; i < lines.length; ++i) { var lineObj = aCodeNode.childNodes[lines[i]-1]; if (lineObj) lineObj.style.backgroundColor=aColor; } } } this.getFileIdx = function(aFile) { if (this.fFileIdxCache[aFile] != null) return this.fFileIdxCache[aFile]; for (var i = 0; i < this.fFileLinks.length; ++i) { if (this.getHtmlFileName(i) == aFile) { this.fFileIdxCache[aFile] = i; return i; } } return null; } this.getCurrFileIdx = function() { return this.fCurrFileIdx; } this.setNumHighlightedLines = function(aFileIdx, aNumLines) { this.fNumLines[aFileIdx] = aNumLines; updateNumHighlightedLines(this.fFileLinks[aFileIdx], aNumLines); } this.getNumLines = function(aFileIdx) { return this.fNumLines[aFileIdx] != null ? this.fNumLines[aFileIdx] : 0; } this.getNumLinesAll = function() { var sum = 0; var len = this.fNumLines.length; for (var i = 0; i < len; ++i) { sum += this.getNumLines(i); } return sum; } this.getPrevButton = function() { var aFrame = getNavFrame(); if (typeof aFrame !== "undefined" && aFrame !== null) return aFrame.document.getElementById("rtwIdButtonPrev"); else return document.getElementById("rtwIdButtonPrev"); } this.getNextButton = function() { var aFrame = getNavFrame(); if (typeof aFrame !== "undefined" && aFrame !== null) return aFrame.document.getElementById("rtwIdButtonNext"); else return document.getElementById("rtwIdButtonNext"); } this.getPanel = function() { var aFrame = getNavFrame(); if (typeof aFrame !== "undefined" && aFrame !== null) return aFrame.document.getElementById("rtwIdTracePanel"); else return document.getElementById("rtwIdTracePanel"); } this.removeHighlighting = function() { for (var i = 0; i < this.fFileLinks.length; ++i) { this.setFileLinkColor(i, ""); this.setNumHighlightedLines(i, 0); } // remove highlight and reset current code node try { if (this.fCurrCodeNode != null) this.highlightLines(getCodeNode(),""); } catch (e) {}; this.fCurrCodeNode = null; if (this.getPrevButton()) { this.getPrevButton().disabled = true; } if (this.getNextButton()) { this.getNextButton().disabled = true; } if (this.getPanel()) { this.getPanel().style.display = "none"; } this.fCurrFileIdx = -1; this.fCurrLineIdx = -1; } this.setCurrLineIdx = function(aLineIdx) { this.fCurrLineIdx = aLineIdx; } this.getCurrLineIdx = function() { return this.fCurrLineIdx; } this.setCurrent = function(aFileIdx, aLineIdx) { this.fCurrFileIdx = aFileIdx; var numLines = this.getNumLines(aFileIdx); if (!numLines || aLineIdx >= numLines) this.fCurrLineIdx = -1; else this.fCurrLineIdx = aLineIdx; var allNumLines = this.getNumLinesAll(); if (this.getPrevButton()) { this.getPrevButton().disabled = (allNumLines <= 1 || !this.hasPrev()); } if (this.getNextButton()) { this.getNextButton().disabled = (allNumLines <= 1 || !this.hasNext()); } if (this.getPanel() && !this.fDisablePanel) { this.getPanel().style.display = 'block'; } } this.setDisablePanel = function(aDisable) { this.fDisablePanel = aDisable; } this.getPrevFileIdx = function() { if (this.fCurrLineIdx > 0) return this.fCurrFileIdx; for (var i = this.fCurrFileIdx - 1; i >= 0; --i) if (this.fNumLines[i] > 0) return i; return null; } // update the navigation bar state this.updateNavState = function() { if (this.getPrevButton()) this.getPrevButton().disabled = !this.hasPrev(); if (this.getNextButton()) this.getNextButton().disabled = !this.hasNext(); setTraceNumber(); } this.hasPrev = function() { return this.getPrevFileIdx() != null; } this.getFirstFileIdx = function() { for (var i = 0; i < this.getNumFileLinks(); ++i) if (this.fNumLines[i] > 0) return i; } this.getLastFileIdx = function() { for (var i = this.getNumFileLinks(); i >= 0; --i) if (this.fNumLines[i] > 0) return i; } this.goFirst = function() { this.fCurrFileIdx = this.getFirstFileIdx(); this.fCurrLineIdx = 0; this.updateNavState(); } this.goLast = function() { this.fCurrFileIdx = this.getLastFileIdx();; this.fCurrLineIdx = this.getNumLines(this.fCurrFileIdx) - 1; this.updateNavState(); } this.goPrev = function() { var fileIdx = this.getPrevFileIdx(); if (fileIdx == null) return; if (fileIdx == this.fCurrFileIdx) --this.fCurrLineIdx; else { this.fCurrFileIdx = fileIdx; this.fCurrLineIdx = this.getNumLines(fileIdx) - 1; } this.updateNavState(); } this.getNextFileIdx = function() { if (this.fCurrLineIdx < this.getNumLines(this.fCurrFileIdx) - 1 && this.getNumLines(this.fCurrFileIdx) > 0) return this.fCurrFileIdx; for (var i = this.fCurrFileIdx + 1; i < this.getNumFileLinks(); ++i) if (this.fNumLines[i] > 0) return i; return null; } this.hasNext = function() { return this.getNextFileIdx() != null; } this.goNext = function() { var fileIdx = this.getNextFileIdx(); if (fileIdx == null) return; if (fileIdx == this.fCurrFileIdx) ++this.fCurrLineIdx; else { this.fCurrFileIdx = fileIdx; this.fCurrLineIdx = 0; } this.updateNavState(); } this.setTotalLines = function(num) { this.fTotalLines = num; } this.getTotalLines = function() { return this.fTotalLines;} this.setLines = function(aFile, aLines) { this.fLines[aFile] = aLines; var index = this.getFileIdx(aFile); if (index != null) this.setNumHighlightedLines(index,aLines.length); } this.getLines = function(aFile) { return this.fLines[aFile]; } // get current on focus line number this.getCurrLine = function() { var file = this.getHtmlFileName(this.getCurrFileIdx()); var lines = this.fLines[file]; var line = null; if (lines) { var line = lines[this.fCurrLineIdx]; } return line; } this.getHRef = function(aFileIdx, aLineIdx, offset) { var file = this.getHtmlFileName(aFileIdx); var lines = this.fLines[file]; if (lines) { var line = lines[aLineIdx]; line = offset_line(line, offset); file = file+"#"+line; } return file; } this.getCurrentHRef = function(offset) { return this.getHRef(this.fCurrFileIdx, this.fCurrLineIdx, offset); } this.setInitLocation = function(aFile, aLine) { var fileIdx = this.getFileIdx(aFile); var lineIdx = null; if (fileIdx != null && aLine) { var lines = this.getLines(aFile); for (var i = 0; i < lines.length; ++i) { if (lines[i] == aLine) { lineIdx = i; break; } } } if (fileIdx == null || lineIdx == null) this.setCurrent(-1,-1); else this.setCurrent(fileIdx,lineIdx); } } // Static methods in RTW_TraceInfo RTW_TraceInfo.getFileLinks = function(docObj) { var links; if (docObj && docObj.getElementsByName) links = docObj.getElementsByName("rtwIdGenFileLinks"); return links ? links : new Array(); } RTW_TraceInfo.toSrcFileName = function(aHtmlFileName) { aHtmlFileName = aHtmlFileName.replace(/_c.html$/,".c"); aHtmlFileName = aHtmlFileName.replace(/_h.html$/,".h"); aHtmlFileName = aHtmlFileName.replace(/_cpp.html$/,".cpp"); aHtmlFileName = aHtmlFileName.replace(/_hpp.html$/,".hpp"); aHtmlFileName = aHtmlFileName.replace(/_cc.html$/,".hpp"); return aHtmlFileName; } RTW_TraceInfo.instance = null; // Class RTW_TraceArgs -------------------------------------------------------- // file.c:10,20,30&file.h:10,20,30[&color=value] or // sid=model:1[&color=value] RTW_TraceArgs = function(aHash) { this.fColor = null; this.fFontSize = null; this.fInitFile = null; this.fInitLine = null; this.fSID = null; this.fFiles = new Array(); this.fLines = new Array(); this.fMessage = null; this.fBlock = null; this.fNumBlocks = 0; this.fUseExternalBrowser = true; this.fInStudio = false; this.fModel2CodeSrc = null; this.fInCodeTrace = false; this.fTraceData = null; this.fFileIdx = []; // filename to fileId this.fRows = []; // highlighted rows indexed by fileId this.fIDs = []; // highlighted IDs indexed by fileId this.hasSid = function() { return !(this.fSID == null); } this.parseCommand = function(aHash) { var args = new Array(); args = aHash.split('&'); for (var i = 0; i < args.length; ++i) { var arg = args[i]; sep = arg.indexOf('='); if (sep != -1) { var cmd = arg.substring(0,sep); var opt = arg.substring(sep+1); switch (cmd.toLowerCase()) { case "color": this.fColor = opt; break; case "fontsize": this.fFontSize = opt; break; case "initfile": this.fInitFile = RTW_TraceArgs.toHtmlFileName(opt); break; case "initline": this.fInitLine = opt; break; case "msg": this.fMessage = opt; break; case "block": this.fBlock = unescape(opt); break; case "numblocks": this.fNumBlocks = parseInt(opt); break; case "sid": this.fSID = opt; // convert sid to code location break; case "model2code_src": // model2code_src from model or webview this.fModel2CodeSrc = opt; break; case "useexternalbrowser": this.fUseExternalBrowser = (opt=="true"); break; case "instudio": this.fInStudio = (opt=="true"); break; case "incodetrace": this.fInCodeTrace = (opt=="true"); break; case "tracedata": this.fTraceData = decodeURI(opt); break; } } } } this.parseUrlHash = function(aHash) { var rows, sep, assignSep; if (aHash) { args = aHash.split('&'); for (var i = 0; i < args.length; ++i) { var arg = args[i]; sep = arg.indexOf(':'); assignSep = arg.indexOf('='); if (sep !== -1 && assignSep === -1) { var fileLines = arg.split(':'); var htmlFileName = RTW_TraceArgs.toHtmlFileName(fileLines[0]); this.fFileIdx[htmlFileName] = i; this.fFiles.push(htmlFileName); if (fileLines[1]) { rows = fileLines[1].split(','); rows = uniqueRows(rows); this.fLines.push(rows); this.fRows[i] = rows; } } } if (this.fInitFile == null && this.fFiles.length > 0) { this.fInitFile = this.fFiles[0]; this.fInitLine = (this.fLines[0] == null ? -1 : this.fLines[0][0]); } } } this.parseUrlHash2 = function(aHash) { aHash = decodeURI(aHash); var rows; var ids; if (aHash && aHash.length > 0 && aHash[0] === "[") { var input = eval(aHash); var i; var j; // set highlight files from url for (i=0; i 0 && top.rtwreport_document_frame.location.href !== "about:blank" && forceReload !== true) { updateHyperlinks(); return; } // modify modelref links update_modelref_report_link(top.reportIFrame.contentWindow.document); try { // ignore browser security error update_modelref_report_link(top.rtwreport_document_frame.document); } catch(e) {}; // redirect the page based on the url var initPage = null; if (RTW_TraceArgs.instance.getNumFiles()) { var fileLinks = RTW_TraceInfo.getFileLinks(tocDocObj); RTW_TraceInfo.instance = new RTW_TraceInfo(fileLinks); RTW_TraceInfo.instance.removeHighlighting() var numFiles = RTW_TraceArgs.instance.getNumFiles(); var tLines = 0; for (var i = 0; i < numFiles; ++i) { RTW_TraceInfo.instance.setLines(RTW_TraceArgs.instance.getFile(i),RTW_TraceArgs.instance.getLines(i)); tLines += RTW_TraceArgs.instance.getLines(i).length; } RTW_TraceInfo.instance.setTotalLines(tLines); if (aPanel == false) { RTW_TraceInfo.instance.setDisablePanel(true); } var initFile = RTW_TraceArgs.instance.getInitFile(); RTW_TraceInfo.instance.setInitLocation(initFile,RTW_TraceArgs.instance.getInitLine()); if (!hasInCodeTrace()) { initPage = RTW_TraceInfo.instance.getCurrentHRef(); } else { initPage = initFile; } } else { // catch error that document frame is in another domain try { var fileDocObj = top.rtwreport_document_frame.document; if (fileDocObj.location && (!fileDocObj.location.href || fileDocObj.location.href == "about:blank")) { var summaryPage = tocDocObj.getElementById("rtwIdSummaryPage"); var tracePage = tocDocObj.getElementById("rtwIdTraceability"); if (summaryPage) { initPage = summaryPage.href; } else if (tracePage) { initPage = tracePage; } } } catch(e) {}; } if (RTW_TraceArgs.instance && RTW_TraceArgs.instance.fMessage) { // display diagnostic message var linkId = "rtwIdMsgFileLink"; var msgFile = tocDocObj.getElementById(linkId); if (msgFile && msgFile.style) { msgFile.style.display = "block"; // Highlight the background of msg link tocHiliteById(linkId); } initPage = "rtwmsg.html"; } if (initPage) { var is_same_page = false; try { var fileDocObj = top.rtwreport_document_frame.document; is_same_page = isSamePage(fileDocObj.location.href, initPage); } catch(e) {}; if (document.getElementById("rtwreport_document_frame")) { document.getElementById("rtwreport_document_frame").setAttribute("src", initPage); } else { top.rtwreport_document_frame.location.href = initPage; } if (is_same_page) { // Goto the same page won't trigger onload function. // Call it manuelly to highligh new code location. rtwFileOnLoad(top.rtwreport_document_frame.document); } } } // Compare if href1(i.e. file:///path/file1.html#222) and href2(i.e.file2.html) are same pages. // isSamePage return true if file1 == file2. function isSamePage(href1, href2) { var page1 = href1.substring(href1.lastIndexOf('/')+1,href1.lastIndexOf('.html')); var page2 = href2.substring(href2.lastIndexOf('/')+1,href2.lastIndexOf('.html')); return (page1 == page2); } // Callback for main document loading function rtwMainOnLoad() { rtwMainOnLoadFcn(document,null,true, false); var newUrl; // modify history state to avoid reload from pressing back if (RTW_TraceArgs.instance && !RTW_TraceArgs.instance.getUseExternalBrowser() && typeof window.history.replaceState === "function") { if (window.location.search.length > 0) { if (window.location.search.indexOf("loaded=true") === -1) { newUrl = document.location.pathname + window.location.search + '&loaded=true'; } else { newUrl = document.location.pathname + window.location.search; } } else { newUrl = document.location.pathname + window.location.search + '?loaded=true'; } window.history.replaceState("","",newUrl); } } // Helper function for traceability report function rtwMainReload(location) { // remove highlight filename and lines before reloading the page if (RTW_TraceInfo.instance) RTW_TraceInfo.instance.removeHighlighting(); rtwMainOnLoadFcn(document,location,true,true); } function rtwMainReloadNoPanel(location) { rtwMainOnLoadFcn(document,location,false,true); } // Callback for hyperlink "Remove Highlighting" function rtwRemoveHighlighting() { if (RTW_TraceInfo.instance) RTW_TraceInfo.instance.removeHighlighting(); if (rtwSrcFrame()) { rtwSrcFrame().focus(); } if (hasInCodeTrace()) { removeInCodeTraceHighlight(); } } // Display diagnostic message in document frame function rtwDisplayMessage() { var docObj = top.rtwreport_document_frame.document; var msg = docObj.getElementById(RTW_TraceArgs.instance.fMessage); if (!msg) { msg = docObj.getElementById("rtwMsg_notTraceable"); } if (msg && msg.style) { msg.style.display = "block"; // make message visible var msgstr = msg.innerHTML; // replace '%s' in message with block name if (top.RTW_TraceArgs.instance) { var sid = top.RTW_TraceArgs.instance.getBlock(); if (sid) { var block = sid; if (top.RTW_rtwnameSIDMap && top.RTW_rtwnameSIDMap.instance && top.RTW_rtwnameSIDMap.instance.getRtwname(sid)) { block = top.RTW_rtwnameSIDMap.instance.getRtwname(sid).rtwname; block = block.replace("<", "<").replace(">", ">"); } else { block = sid; } if (block) { msgstr = msgstr.replace("%s", block); } } } msg.innerHTML = msgstr; } } function updateHyperlinks() { docObj = top.rtwreport_document_frame; if (docObj && docObj.document) { if (RTW_TraceArgs.instance === null || !RTW_TraceArgs.instance.getUseExternalBrowser()) { var plain_link = docObj.document.getElementById("linkToText_plain"); if (plain_link && plain_link.href && plain_link.href.indexOf("matlab:coder.internal.editUrlTextFile") === -1 ) { plain_link.href = "matlab:coder.internal.editUrlTextFile('" + str2StrVar(plain_link.href) + "')"; } var alink = docObj.document.getElementById("linkToCS"); var linkCmd = "matlab:coder.internal.viewCodeConfigsetFromReport"; if (alink && alink.href && alink.href.indexOf(linkCmd) === -1) { alink.href = linkCmd+ "('" + str2StrVar(alink.href) + "');"; if(alink.style) { alink.style.display = ""; hidden_link = docObj.document.getElementById("linkToCS_disabled"); if (hidden_link) { hidden_link.style.display = "none"; } } } } else { var alink = docObj.document.getElementById("linkToCS"); if (alink && alink.style) { alink.style.display = "none"; hidden_link = docObj.document.getElementById("linkToCS_disabled"); if (hidden_link) hidden_link.style.display = ""; } if (typeof docObj.document.getElementsByClassName === "function") { alinks = docObj.document.getElementsByClassName("callMATLAB"); } else if (typeof docObj.document.getElementsByName === "function") { alinks = docObj.document.getElementsByName("callMATLAB"); } else { alinks = []; } alink = docObj.document.getElementById("CodeGenAdvCheck"); if (alink && alink.href && alink.href.indexOf("externalweb=true")===-1) { alink.href = alink.href + "?externalweb=true"; } if (typeof docObj.document.getElementsByName === "function") var objs = docObj.document.getElementsByName("MATLAB_link"); else objs = []; for (var objIndex = 0; objIndex < objs.length; ++objIndex) { objs[objIndex].style.display = "none"; } } } updateCode2ModelLinks(docObj.document); // modify modelref links update_modelref_report_link(top.reportIFrame.contentWindow.document); try { // ignore browser security error update_modelref_report_link(top.rtwreport_document_frame.document); } catch(e) {}; } function update_modelref_report_link(docObj) { if (docObj.getElementsByName) { var arg = ""; if (RTW_TraceArgs.instance && !RTW_TraceArgs.instance.getUseExternalBrowser()) { arg = "?useExternalBrowser=false"; } if (RTW_TraceArgs && RTW_TraceArgs.instance && RTW_TraceArgs.instance.getModel2CodeSrc() != null) { if (arg.length > 0) arg = arg + "&model2code_src=" + RTW_TraceArgs.instance.getModel2CodeSrc(); else arg = "?model2code_src=" + RTW_TraceArgs.instance.getModel2CodeSrc(); } if (arg.length > 0) { links = docObj.getElementsByName('external_link'); for (var link_idx = 0; link_idx < links.length; ++link_idx) { links[link_idx].href = links[link_idx].href + arg; } } } } function rtwResizeFrame(f) { if (f) { f.style.height = f.contentWindow.document.body.scrollHeight + "px"; } } function rtwPageOnLoad(id) { // highlight toc entry tocHiliteById(id); // restore elements state if (top && top.restoreState) { if (top.reportIFrame.contentWindow && top.reportIFrame.contentWindow.document) top.restoreState(top.reportIFrame.contentWindow.document); if (top.rtwreport_document_frame && top.rtwreport_document_frame.document) { top.restoreState(top.rtwreport_document_frame.document); rtwResizeFrame(top.rtwreport_document_frame.document.getElementById("rtwIdContentsIframe")); } } updateHyperlinks(); } // highlight code after changeSys function rtwChangeSysCallback(sid) { if (sid == "" || typeof RTW_Sid2UrlHash == "undefined" || !RTW_Sid2UrlHash.instance) return false; urlHash = RTW_Sid2UrlHash.instance.getUrlHash(sid); if (urlHash != undefined) { if (RTW_TraceArgs && RTW_TraceArgs.instance && !RTW_TraceArgs.instance.getUseExternalBrowser()) urlHash = (urlHash == "")? "?useExternalBrowser=false" : urlHash+"&useExternalBrowser=false"; rtwMainReload(urlHash, true); return true; } else { // remove highlighting from traceinfo rtwRemoveHighlighting(); return false; } } function emlFileOnload(docObj) { var loc = docObj.location; if (loc.hash) { var line = loc.hash.substring(1); hiliteEmlLine(docObj, line); } } function hiliteEmlLine(docObj, line) { var bgColor; if (top.HiliteCodeStatus) bgColor = "#66CCFF"; else bgColor = "#E8D152"; // unhighlight if (typeof docObj.HiliteLine != "undefined") { trObj = docObj.getElementById("LN_"+docObj.HiliteLine); if (trObj != null) { trObj.style.backgroundColor = ""; } } // hilighlight trObj = docObj.getElementById("LN_"+line); if (trObj != null) { trObj.style.backgroundColor = bgColor; docObj.HiliteLine = line; } } function emlLineOnClick(docObj,sid,line) { if (top) { top.HiliteCodeStatus = top.rtwChangeSysCallback(sid); } hiliteEmlLine(docObj, line); } function updateCode2ModelLinks(docObj) { var webviewFrame = top.document.getElementById('rtw_webviewMidFrame'); var link2model = false; var isTestHarness = false; if (top.testHarnessInfo && top.testHarnessInfo.IsTestHarness === "1") { isTestHarness = true; } if (webviewFrame || isTestHarness) { if (webviewFrame && RTW_TraceArgs.instance && (RTW_TraceArgs.instance.getModel2CodeSrc() !== "model" || RTW_TraceArgs.instance.getUseExternalBrowser()) ) { hiliteCmd = "javascript:top.rtwHilite("; } else { hiliteCmd = "matlab:coder.internal.code2model("; link2model = true; } var objs = docObj.getElementsByName('code2model'); var o = null; var str = ''; var sid = ''; var pattern = "'code2model',"; for (var objIndex = 0; objIndex < objs.length; ++objIndex) { o = objs[objIndex]; str = o.href.substring(o.href.indexOf('(')+1); if (str.indexOf(pattern) > -1) { str = str.substring(str.indexOf(pattern) + pattern.length); } o.href = hiliteCmd + str; if (link2model && isTestHarness) { sid = str.substring(0, str.indexOf(")")); o.href = hiliteCmd + sid + ",'" + top.testHarnessInfo.HarnessName+ "','" + top.testHarnessInfo.HarnessOwner+ "','" + top.testHarnessInfo.OwnerFileName + "');"; } } } } function rtwHilite(aBlock,aParentSID) { if (aBlock.indexOf('-') !== -1) { // remove sid range: model:sid:2-10 => model:sid var s; s = aBlock.split(':'); if (s.length > 0) { s = s[s.length-1]; if (s.indexOf('-') != -1) { aBlock = aBlock.substring(0, aBlock.lastIndexOf(':')); } } } if (typeof aParentSID === "undefined") { if (top.RTW_SidParentMap && top.RTW_SidParentMap.instance) aParentSID = top.RTW_SidParentMap.instance.getParentSid(aBlock); else aParentSID = aBlock; } top.HiliteCodeStatus = true; // webview 2 defines an interface api, call slwebview. if (top.slwebview || window.slwebview || document.getElementById("rtw_webview").contentWindow.slwebview) { // webview 2.x if (top.codeToWebView(aBlock, aParentSID) === -1) { alert("Cannot highlight block in model Web view. It may not be exported."); } } else { // webview 1.x if (hiliteBlockForRTWReport(aBlock,aParentSID) === false) { if (hiliteBlockForRTWReport(aBlock, aBlock) === false) { rtwHilite(aParentSID); } } } } function rtwHiliteMultiple(sids, action) { //For new Code Gen report //Highlighting multiple sids if (top.slwebview || window.slwebview || document.getElementById("rtw_webview").contentWindow.slwebview) { // webview 2.x if (top.codeToWebViewArray(sids, action) === -1) { // This could be caused by the fact that we have subsystems to be traced but we can only trace to the top subsystem. In this case we just highlight the first one. rtwHilite(sids[0]); } } } function str2StrVar(str) { return str.replace(/'/g,"''"); } window.onload=rtwMainOnLoad; // handle incode traceability highlighting function inCodeTraceOnload() { var tocDocObj = top.reportIFrame.contentWindow.document; if (!top.RTW_TraceArgs.instance) { var summaryPage = tocDocObj.getElementById("rtwIdSummaryPage"); top.rtwreport_document_frame.location.href = summaryPage.href; return; } var files = top.RTW_TraceArgs.instance.getFile(); if (files.length === 0) { if (top.RTW_TraceArgs.instance) { var block = top.RTW_TraceArgs.instance.getBlock(); block = block.replace("<", "<").replace(">", ">"); } top.rtwreport_document_frame.document.write("
No traceability information for block " + block + ".
"); return; }; var fileLinks = RTW_TraceInfo.getFileLinks(tocDocObj); RTW_TraceInfo.instance = new RTW_TraceInfo(fileLinks); // update filelist with num of highlighted lines var tocDoc = top.reportIFrame.contentWindow.document; var tLines = 0; for (var i=0; i 1) { var spanNodes = parent.getElementsByTagName('span'); var len = spanNodes.length; if (len > 0) { if (aNumLines > 0) { /* display number of matches */ spanNodes.item(len-1).innerHTML = " ("+aNumLines+")"; } else { /* clear number of matches */ spanNodes.item(len-1).innerHTML = ""; } } } } function setupInStudio() { if (top.whole) { var tmp = top.whole.rows.split(","); tmp[0] = "35px"; top.whole.rows = tmp.join(); } if (top.main) { var tmp = top.main.cols.split(","); tmp[0] = "0"; top.main.cols = tmp.join(); } // add file list to source file if (top.Html2SrcLink && top.Html2SrcLink.instance && top.fileSelector) { var myDoc = top.fileSelector.document; var fileSelector = myDoc.createElement("select"); fileSelector.id = "fileSelector"; fileSelector.onchange = top.fileSelectorOnChange; var filename; var filelink; fileSelector.innerHTML += ""; for (var i=0; i < top.fileList.length; i++) { filename = top.fileList[i]; filelink = top.Html2SrcLink.instance.getLink2Src(filename); fileSelector.innerHTML += ""; } var bodyNode = myDoc.body; bodyNode.insertBefore(fileSelector, bodyNode.firstElementChild); var textNode = myDoc.createElement("span"); textNode.innerHTML = "Goto: "; bodyNode.insertBefore(textNode, fileSelector); var myCss = myDoc.createElement("link"); myCss.type = "text/css"; myCss.rel = "stylesheet"; myCss.href = "rtwreport.css"; myDoc.getElementsByTagName("head")[0].appendChild(myCss); } } function toggleNavSideBar(val) { if (top.main) { var tmp = top.main.cols.split(","); if (val === "on") { tmp[tmp.length-1] = "15px"; } else { tmp[tmp.length-1] = "0"; } top.main.cols = tmp.join(); if (top.rtwreport_nav_frame) top.rtwreport_nav_frame.location.href = "nav.html"; } }; function toggleNavToolBar(val) { var midFrame = rtwMidFrame(); if (midFrame) { var tmp1 = midFrame.rows.split(","); var frameIdx = getNavToolbarFrameIdx(); if (val === "on") { tmp1[frameIdx] = "40px"; } else { tmp1[frameIdx] = "0"; } midFrame.rows = tmp1.join(); if (top.rtwreport_navToolbar_frame) { top.rtwreport_navToolbar_frame.location.href = "navToolbar.html"; } } }; var GlobalConfig = { navHiliteColor: "#0000ff", fileLinkHiliteColor: "#ffff99", navToolbarBgcolor: "ivory", offset: 10, hiliteToken: false }; var NavSideBarState = { calLineHeight: 0, overLink: false, linkTarget: null, lastLinkTarget: null, linkTargetIdx: 0 } function drawNavSideBar() { var rectHeight = 1; if (!top || !top.rtwreport_document_frame || !top.rtwreport_nav_frame) return; if (!top.RTW_TraceArgs.instance) return; var fileIdx = top.RTW_TraceArgs.instance.getFileIdx(); if (fileIdx === undefined) return; var rows = top.RTW_TraceArgs.instance.getRows(fileIdx); if (rows.length === 0) return; // no highlighted line var codeTbl = top.rtwreport_document_frame.document.getElementById("codeTbl"); if (!codeTbl) return; // no code table var nRows = codeTbl.rows.length + 1; var canvas = top.rtwreport_nav_frame.document.getElementById("canvas"); canvas.width = top.rtwreport_nav_frame.innerWidth; canvas.height = top.rtwreport_nav_frame.innerHeight-2; NavSideBarState.calLineHeight = canvas.height/nRows; if (canvas.getContext) { var ctx = canvas.getContext("2d"); ctx.clearRect(0, 0, canvas.width, canvas.height); // fill background ctx.fillStyle = GlobalConfig.navToolbarBgcolor; ctx.fillRect(0, 0, canvas.width, canvas.height); ctx.fillStyle = GlobalConfig.navHiliteColor; for (var i=0;i" + anchorObj.text + "
  • "+ size + "
  • "; } propObj.appendChild(ulObj); return propObj; } function getInspectLink(file, pathname, anchorObj) { var model = top.reportModel; var tokenId = anchorObj.id; var navObj = document.createElement("div"); navObj.id = "token_usage_nav"; ulObj = document.createElement("ul"); ulObj.id = "token_nav_links"; ulObj.className="popup_attrib_list"; var srcFileName = RTW_TraceInfo.toSrcFileName(file); var defObj; if (top.CodeDefine.instance.def[srcFileName + ":" + anchorObj.text]) { defObj = top.CodeDefine.instance.def[srcFileName + ":" + anchorObj.text]; } else if (top.CodeDefine.instance.def[anchorObj.text]) { defObj = top.CodeDefine.instance.def[anchorObj.text]; } var line = anchorObj.id.substring(0,anchorObj.id.indexOf("c")); // link to model if (top.TraceInfoFlag && top.TraceInfoFlag.instance && top.TraceInfoFlag.instance.traceFlag[srcFileName+":"+anchorObj.id]) { return null; } // link to def/decl if (defObj) { var filename = defObj.file.split(/\//); filename = filename[filename.length-1]; ulObj.innerHTML += "
  • " + anchorObj.text + " defined at " + RTW_TraceInfo.toSrcFileName(filename) + " line " + defObj.line + "
  • "; } navObj.appendChild(ulObj); return navObj; } var LastHiliteTokenId = null; function rmHiliteClickedToken() { if (LastHiliteTokenId) { var o = top.rtwreport_document_frame.document.getElementById(LastHiliteTokenId); if (o) { o.className = o.className.replace("hiliteToken", ""); } } } function hiliteClickedToken(elem) { rmHiliteClickedToken(); LastHiliteTokenId = elem.id; elem.className += " hiliteToken"; } var initLine = null; function scrollToInitLine() { if (initLine) { var lineElem = top.rtwreport_document_frame.document.getElementById(initLine); if (lineElem) { lineElem.scrollIntoView(); } } } function scrollToLineBasedOnHash(hashValue) { // move to the current highlight line if the hash is not empty if (hashValue === "") { if (top.RTW_TraceInfo.instance && top.RTW_TraceInfo.instance.getCurrLine() !== null) { top.rtwreport_document_frame.document.location.href=top.RTW_TraceInfo.instance.getCurrentHRef(); top.initLine = top.rtwreport_document_frame.document.location.hash.substr(1); } } else { // scroll and hilite line hashValue = hashValue.substr(1); if (isNaN(hashValue)) { // #fcn_name var pattern = "+newPage"; if (hashValue.indexOf(pattern) != -1) { hashValue = hashValue.replace(pattern, ''); var lineElem = top.rtwreport_document_frame.document.getElementById(hashValue); initLine = hashValue; // save initLine in case the dom is updated later by anootation if (lineElem) { lineElem.scrollIntoView(); addTagToCurrentLine(); } } else { var token = null; pattern = ["var_", "fcn_", "type_"]; for (var i =0; i < pattern.length; i++) { if (hashValue.indexOf(pattern[i]) === 0) { token = hashValue.substr(pattern[i].length); break; } } if (token !== null && top.CodeDefine && top.CodeDefine.instance) { var addr; var filename = location.pathname.split(/\//); filename = filename[filename.length-1]; var srcFileName; if (top.RTW_TraceInfo) { srcFileName = top.RTW_TraceInfo.toSrcFileName(filename); } if (top.CodeDefine.instance.def[srcFileName + ":" + token]) { addr = top.CodeDefine.instance.def[srcFileName + ":" + token]; } else { addr = top.CodeDefine.instance.def[token]; } if (addr) { hilite_line(addr.line); } } else { // token id like #line"c"#col if (hashValue.indexOf("c") !== -1) { hilite_line(hashValue.substr(0, hashValue.indexOf("c")), hashValue); } } } } else { // #line hilite_line(hashValue); } } return false; // hilite line number and scroll with an offset function hilite_line(line, tokenId) { if (isNaN(line)) return; if (!tokenId) { tokenId = line; } var elem = top.rtwreport_document_frame.document.getElementById(tokenId); hiliteClickedToken(elem); initLine = offset_line(line); scrollToInitLine(); } } function tokenLinkOnClick(event) { var alink = event.currentTarget; if (alink.pathname === top.rtwreport_document_frame.location.pathname) { event.preventDefault(); scrollToLineBasedOnHash(alink.hash); } return false; } function inspectToken(file, pathname, event) { var height = "70px"; // show inspect data if (top.rtwreport_inspect_frame) { var windowObj = getInspectWindow(); var propObj = getInspectData(file, event.currentTarget); var navObj = getInspectLink(file, pathname, event.currentTarget); if (navObj === null) { closeInspectWindow(); return false; } if (propObj === null) { height = "50px"; } else { windowObj.appendChild(propObj); } windowObj.appendChild(navObj); var data = top.rtwreport_inspect_frame.document.getElementById("popup_window"); if (data) { data.parentNode.replaceChild(windowObj.cloneNode(true), data); } } var offsetHeight = 0; var docHeight = 0; if (typeof(top.rtwInspectFrame().document.body.offsetHeight) === "number") { offsetHeight = top.rtwInspectFrame().document.body.offsetHeight; } if (typeof(top.rtwInspectFrame().document.height) === "number") { docHeight = top.rtwInspectFrame().document.height; } if (offsetHeight > 0) { height = ""+offsetHeight+"px"; } else if (docHeight > 0) { height = ""+docHeight+"px"; } setInspectWindow(height); return false; } function setInspectWindow(height) { // show inspect code frame var midFrame = rtwMidFrame(); if (midFrame) { var tmp = midFrame.rows.split(","); tmp[getInspectFrameIdx()] = height; midFrame.rows = tmp.join(); } } function closeInspectWindow() { setInspectWindow(0); return false; } // set the trace number in the navigation toolbar function setTraceNumber() { if (RTW_TraceInfo.instance) { var aFrame = rtwNavToolbarFrame(); if (aFrame) { var node = aFrame.document.getElementById("rtwIdTraceNumber"); // calculate current line index over total highlighted lines var currNum = RTW_TraceInfo.instance.getCurrLineIdx(); for (var idx=0;idx 0) line = (line > GlobalConfig.offset ? line - GlobalConfig.offset : 1); return line; } function load_js(frame, file) { var h = frame.document.getElementsByTagName("head")[0]; var o = h.getElementsByTagName('script'); for (var i=0;i