home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Joystick Magazine 2003 November
/
CD1_JOY_153.iso
/
demos
/
NHL2004Demo.exe
/
fe
/
COMMON
/
js
/
dcr_request.js
< prev
next >
Wrap
Text File
|
2003-08-20
|
5KB
|
153 lines
var dcrXmlNode = null ;
var drcRequest = null ;
var onDcrCompleteFunction = null ;
var needValidateReturns = true ;
function getDcrText(appName, pageName, tagName, onCompleteFun) {
onDcrCompleteFunction = onCompleteFun ;
_doGetNHLDcrText(appName, pageName, tagName, false, false, false);
};
function getPublicDcrText(appName, pageName, tagName, onCompleteFun) {
onDcrCompleteFunction = onCompleteFun ;
needValidateReturns = true ;
_doGetNHLDcrText(appName, pageName, tagName, true, false, false);
};
function getTickerNews(appName, pageName, tagName) {
var newsText = "" ;
var xmlString = _doGetNHLDcrText(appName, pageName, tagName, true, false, true);
var xmlDom = new ActiveXObject("MSXML.DOMDocument");
xmlDom.loadXML(xmlString);
var newsNodes = xmlDom.selectNodes("/item/value") ;
var newsNode = null ;
var titleNode ;
var bodyNode ;
var title ;
var body ;
for (i=0; i<newsNodes.length; i++)
{
newsNode = newsNodes[i] ;
if (newsNode) {
titleNode = newsNode.selectSingleNode("title/value") ;
if (titleNode) {
title = titleNode.text ;
newsText += title + " " ;
};
bodyNode = newsNode.selectSingleNode("body/value") ;
if (bodyNode) {
body = bodyNode.text ;
newsText += body + " ";
};
};
};
return newsText ;
}
function getTickerLines(appName, pageName, tagName, onCompleteFun, isSilence) {
onDcrCompleteFunction = onCompleteFun ;
needValidateReturns = (isSilence) ? false : true;
_doGetNHLDcrText(appName, pageName, tagName, true, true, false);
};
function CommNews() {
this.newsTitle = "" ;
this.newsBody = "" ;
};
var comNewsOnComplete = null ;
function getCommNews(appName, pageName, tagName, commNewsOnComplete) {
comNewsOnComplete = commNewsOnComplete ;
onDcrCompleteFunction = makeCommNewsArray ;
_doGetNHLDcrText(appName, pageName, tagName, true, false, true);
};
function makeCommNewsArray(xmlString) {
var newsArray = null ;
var news = null ;
var xmlDom = new ActiveXObject("MSXML.DOMDocument");
xmlDom.loadXML(xmlString);
var newsNodes = xmlDom.selectNodes("/item/value") ;
var newsNode = null ;
var titleNode ;
var bodyNode ;
if (newsNodes.length>0) newsArray = new Array(newsNodes.length) ;
for (i=0; i<newsNodes.length; i++)
{
newsNode = newsNodes[i] ;
if (newsNode) {
news = new CommNews() ;
titleNode = newsNode.selectSingleNode("title/value") ;
if (titleNode) {
news.newsTitle = titleNode.text ;
};
bodyNode = newsNode.selectSingleNode("body/value") ;
if (bodyNode) {
news.newsBody = _getValueString(bodyNode.xml) ;
};
};
newsArray[i] = news ;
};
comNewsOnComplete(newsArray) ;
};
function _getValueString(xmlValueString) {
var len = xmlValueString.length ;
var newString = xmlValueString ;
if ((len>15) && (xmlValueString.indexOf("<value>")==0)) {
newString = xmlValueString.substring(7, len-8) ;
};
return newString ;
};
function getDcrReturns() {
var dcrText = null ;
if (drcRequest) {
if (drcRequest.isError()) {
if (needValidateReturns) {
System.handleError(drcRequest.isError());
onDcrCompleteFunction = null;
return;
} else {
onDcrCompleteFunction = null;
return;
};
};
var xmlNode = drcRequest.getValue();
if (xmlNode) {
var err = xmlNode.selectSingleNode("error") ;
if (needValidateReturns && err) {
var e = new Error() ;
e.description = "::501::Server not responding";
throw e ;
onDcrCompleteFunction = null;
} else if( needValidateReturns && xmlNode.selectSingleNode("SERVER_ERROR")){
onDcrCompleteFunction = null;
var severError = new Error();
severError.description = "::501::Server not responding";
throw severError;
} else {
var root = xmlNode.selectSingleNode("//dcrRecord/dcrText");
var dcrData = null ;
if (root && root.childNodes) {
dcrData = root.childNodes.item(0) ;
};
if (dcrData) {
dcrText = dcrData.data ;
};
};
};
};
onDcrCompleteFunction(dcrText);
};
function _doGetNHLDcrText(appName, pageName, tagName, isPublic, isTicker, getAllValue) {
var domainName = "easo" ;
var subDomainName = "nhl03" ;
if (pageName.lastIndexOf(".eadcr")!=(pageName.length-6)) {
pageName += ".eadcr" ;
};
var dcrParam = "?site=pogo&dn=" + domainName + "&sdn=" + subDomainName + "&an=" + appName + "&pn=" + pageName + "&tn=" + tagName + "&getall=" + getAllValue;
var hostName = System.getHostURL() ;
if (isTicker) {
drcRequest = new Remote_Request(hostName + "easo/nhl03/dcr/get_tickernews.jsp", dcrParam, true);
} else if (isPublic) {
drcRequest = new Remote_Request(hostName + "easo/nhl03/dcr/get_public_dcr_text.jsp", dcrParam, true);
} else {
drcRequest = new Remote_Request(hostName + "easo/nhl03/dcr/get_dcr_text.jsp", dcrParam, true);
};
drcRequest.setOnComplete(getDcrReturns) ;
drcRequest.setIsPostRequest(true);
drcRequest.setReturnXML_DOM(true);
drcRequest.send();
};