📄 converter.js
字号:
{
var pattern = sParam + "=[^&]*&?";
var regExp = new RegExp(pattern, "i");
var resultArray = regExp.exec(sObjURL);
var listArray = sObjURL.split(regExp);
var sRetURL = null;
// Check if the parameter is existing in the url
if (resultArray != null)
{
// Remove the the parameter
if( listArray.length == 1 || listArray[1] == "")
{
sRetURL = sObjURL.substring(0 , (listArray[0].length-1));
}
else
{
sRetURL = sObjURL.replace(regExp, "");
}
}
else
{
sRetURL = sObjURL;
}
return sRetURL;
}
/**
*
*/
function isROIFile(sFQFileName)
{
if (sFQFileName == null) return null;
iDot = sFQFileName.lastIndexOf(".");
if (iDot == -1) return "";
iSemiColon = sFQFileName.lastIndexOf(";");
if (iSemiColon == -1) iSemiColon = iDot+4;
var sFileExt = sFQFileName.substring(iDot + 1, iSemiColon);
return (sFileExt.toLowerCase() == "roi");
}
/**
*
*/
function isStandardProtocol(link)
{
var bProtocolExists = false;
if( (link.indexOf( "http:" ) == 0) ||
(link.indexOf( "https:") == 0) ||
(link.indexOf( "mailto:") == 0) ||
(link.indexOf( "file:") == 0) ||
(link.indexOf( "rotp:") == 0) ||
(link.indexOf( "ftp:") == 0) )
{
bProtocolExists = true;
}
return bProtocolExists;
}
// different types of RC directives, which can be a part of hyperlinks.
// There can be many more directives which should be added if not found in this list.
var NONE = 0;
var VIEWPAGE = 1;
var SEARCH = 2;
var SUBMIT = 3;
var REQUEST = 4;
var GETREPORTDATA = 5;
var GETSTYLESHEET = 6;
var GETDYNAMICDATA = 7;
var GETSTATICDATA = 8;
var DROP = 9;
var VIEWDEFAULT = 10;
var VIEWFRAMESET = 11;
var VIEWTOC = 12;
var VIEWNAVIGATION = 13;
var SAVEAS = 14;
/**
* This function will return an integer array of length 2.
* The 1st element will be directive constant and 2nd will be its index in the link
*/
function getDirectiveFromLink(link)
{
var iArrReutrnValue = new Array(2);
var iDirectiveIndex = -1;
iArrReutrnValue [0] = NONE;
if ((iDirectiveIndex = link.toLowerCase().indexOf('?viewpage', 0)) != -1)
{
iArrReutrnValue [0] = VIEWPAGE;
}
else if ((iDirectiveIndex = link.toLowerCase().indexOf('?search')) != -1)
{
iArrReutrnValue [0] = SEARCH;
}
else if ((iDirectiveIndex = link.toLowerCase().indexOf('?submit')) != -1)
{
iArrReutrnValue [0] = SUBMIT;
}
else if ((iDirectiveIndex = link.toLowerCase().indexOf('?request')) != -1)
{
iArrReutrnValue [0] = REQUEST;
}
else if ((iDirectiveIndex = link.toLowerCase().indexOf('?getreportdata')) != -1)
{
iArrReutrnValue [0] = GETREPORTDATA;
}
else if ((iDirectiveIndex = link.toLowerCase().indexOf('?getstylesheet')) != -1)
{
iArrReutrnValue [0] = GETSTYLESHEET;
}
else if ((iDirectiveIndex = link.toLowerCase().indexOf('?getdynamicdata')) != -1)
{
iArrReutrnValue [0] = GETDYNAMICDATA;
}
else if ((iDirectiveIndex = link.toLowerCase().indexOf('?getstaticdata')) != -1)
{
iArrReutrnValue [0] = GETSTATICDATA;
}
else if ((iDirectiveIndex = link.toLowerCase().indexOf('?drop')) != -1)
{
iArrReutrnValue [0] = DROP;
}
else if ((iDirectiveIndex = link.toLowerCase().indexOf('?viewdefault')) != -1)
{
iArrReutrnValue [0] = VIEWDEFAULT;
}
else if ((iDirectiveIndex = link.toLowerCase().indexOf('?viewframeset')) != -1)
{
iArrReutrnValue [0] = VIEWFRAMESET;
}
else if ((iDirectiveIndex = link.toLowerCase().indexOf('?viewtoc')) != -1)
{
iArrReutrnValue [0] = VIEWTOC;
}
else if ((iDirectiveIndex = link.toLowerCase().indexOf('?viewnavigation')) != -1)
{
iArrReutrnValue [0] = VIEWNAVIGATION;
}
else if ((iDirectiveIndex = link.toLowerCase().indexOf('?saveas')) != -1)
{
iArrReutrnValue [0] = SAVEAS;
}
iArrReutrnValue [1] = iDirectiveIndex;
return iArrReutrnValue;
}
/**
* resolveNestedLinkUrl method resolves the url for nested search condition
*/
function resolveNestedLinkUrl(link)
{
var resolvedURL = link;
var doesNestedExist = true;
var iSearchStart = link.toLowerCase().indexOf('&search&');
if(iSearchStart != -1)
{
var iEndSearch = link.toLowerCase().indexOf('&endsearch', iSearchStart);
if (iEndSearch != -1)
{
//DECODES THE VALUE TO AVOID DOUBLE ENCODING
var decodedValue = decode(link.substring(iSearchStart+8, iEndSearch));
var newString = "&searchcriteria="+encode(decodedValue);
var oldString = link.substring(iSearchStart, iEndSearch+10);
resolvedURL = resolvedURL.replace(oldString, newString);
}
}
// IF OTHER DIRECTIVES ALSO NEED TO BE RESOLVED IF BLOCK SHOULD BE ADDED OVER HERE
return resolvedURL;
}
function resolveLinkUrl(link)
{
var sSearchCriteria = "";
var sResolvedLink = "";
var sReportName = "";
var sRemainingLink = "";
var sOrgLink = link;
if (!(ns4 && g_browserVersion == 4.08)) // DO NOT DECODE FOR NS 4.08
link = decode(link);
link = resolveNestedLinkUrl(link);
var iLinkDirectiveAndIndex = getDirectiveFromLink(link);
switch (iLinkDirectiveAndIndex[0])
{
case 1://VIEWPAGE
{
sReportName = link.substring(0, iLinkDirectiveAndIndex[1]);
var sSearchStart = link.toLowerCase().indexOf('search&');
var sEndSearch = link.toLowerCase().indexOf('&endsearch');
var sOtherViewOptions = "";
if (sSearchStart != -1 && sEndSearch != -1)
{
// 7 is length of "search&"
sSearchCriteria = "&searchcriteria=" + encode(link.substring((sSearchStart + 7), sEndSearch));
// 9 is length of "?viewpage"
sOtherViewOptions = link.substring((iLinkDirectiveAndIndex[1] + 9) , (sSearchStart - 1));
}
else
{
sSearchCriteria = "";
// 9 is length of "?viewpage"
sOtherViewOptions = link.substring((iLinkDirectiveAndIndex[1] + 9));
}
sResolvedLink = "../servlet/ViewPage?name=" + encode(sReportName) + sOtherViewOptions + sSearchCriteria;
break;
}
case 2://SEARCH
{
sReportName = link.substring(0, iLinkDirectiveAndIndex[1]);
// 8 is length of "?search&"
var iEndSearchIndex = link.toLowerCase().indexOf('&endsearch', (iLinkDirectiveAndIndex[1] + 8));
sSearchCriteria = link.substring((iLinkDirectiveAndIndex[1] + 8), iEndSearchIndex);
sResolvedLink = "../viewer/viewframeset.jsp?name=" + encode(sReportName) + "&searchcriteria=" + encode(sSearchCriteria);
break;
}
case 3://SUBMIT
{
sReportName = link.substring(0, iLinkDirectiveAndIndex[1]);
// 7 is length of "?submit"
sRemainingLink = link.substring(iLinkDirectiveAndIndex[1] + 7);
if (sRemainingLink.toLowerCase().indexOf("__scheduletype=immediate") != -1)
{
sResolvedLink = "../newrequest/do_executereport.jsp?__executableName=" + encode(sReportName) + sRemainingLink;
}
else
{
sResolvedLink = "../newrequest/do_submitjob.jsp?__executableName=" + encode(sReportName) + sRemainingLink;
}
break;
}
//CLEANUP: DO NOT REMOVE THE FOLLOWING CASE
/*case REQUEST:
{
sReportName = link.substring(0, iLinkDirectiveAndIndex[1]);
// 8 is length of "?request"
sRemainingLink = link.substring(iLinkDirectiveAndIndex[1] + 8);
sResolvedLink = "../newrequest/index.jsp?__executableName=" + encode(sReportName) + sRemainingLink;
break;
}*/
case 5://GETREPORTDATA
{
sReportName = link.substring(0, iLinkDirectiveAndIndex[1]);
// 14 is length of "?getreportdata"
sRemainingLink = link.substring(iLinkDirectiveAndIndex[1] + 14);
sResolvedLink = "../servlet/GetReportData?name=" + encode(sReportName) + sRemainingLink;
break;
}
case 6://GETSTYLESHEET
{
break;
}
case 7://GETDYNAMICDATA
{
break;
}
case 8://GETSTATICDATA:
{
break;
}
case 9://DROP:
{
break;
}
case 10://VIEWDEFAULT:
{
break;
}
case 11://VIEWFRAMESET:
{
break;
}
case 12://VIEWTOC:
{
break;
}
case 13://VIEWNAVIGATION:
{
break;
}
case 14://SAVEAS:
{
break;
}
case 0://NONE:
default:
{
if (isROIFile(sOrgLink))
{
sReportName = sOrgLink.substring(0, sOrgLink.toLowerCase().lastIndexOf(".roi") + 4);// 4 is length of ".roi"
//ENCODING # BECAUSE IT IS NOT ENCODED BY SERVER
sReportName = sReportName.replace(/#/g, encode("#"));
sRemainingLink = sOrgLink.substring(sOrgLink.toLowerCase().lastIndexOf(".roi") + 4);// 4 is length of ".roi"
if (sRemainingLink.length > 0)
{
if (sRemainingLink.charAt(0) == '?')
{
sRemainingLink = "&"+sRemainingLink.substring(1);
}
else if(sRemainingLink.charAt(0) != '&')
{
sRemainingLink = "&"+sRemainingLink;
}
}
sResolvedLink = "../viewer/viewframeset.jsp?name=" + sReportName + sRemainingLink;
}
else
{
sResolvedLink = "../servlet/DownloadFile?name=" + sOrgLink;
}
}
}
return sResolvedLink;
}
/**
* Decodes special characters ", ' and & that arrive from the view server
*/
function decodeSpecialCharacters(sText)
{
sDecoded = "";
nLen = sText.length;
for (i = 0; i < nLen; i++)
{
c = sText.charAt(i);
if (c == '%')
{
sCode = sText.substring(i + 1, i + 3);
if (sCode == "22") // DBLQUOTE "
sDecoded += "\"";
else
if (sCode == "25") // PERCENT %
sDecoded += "%";
else
if (sCode == "27") // QUOTE '
sDecoded += "'";
else
if (sCode == "26") // AMPERSTAND &
sDecoded += "&";
else
alert("Unhandled link character %" + sCode);
i += 2;
continue;
}
else
sDecoded += c;
}
return sDecoded;
}
/**
*
*/
function debugDataValue(sText)
{
iSDV = sText.indexOf("DataValue=");
if (iSDV == -1)
{
iSDV = sText.indexOf("DataValue%3d");
if (iSDV != -1) iSDV += 12;
}
else
iSDV += 10;
iEDV = sText.indexOf("&EndSearch");
if (iEDV == -1) iEDV = sText.indexOf("&serverURL");
if (iSDV == -1 || iEDV == -1)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -