﻿//***********************************************************
// ThePortServiceReply Decoder Object.  
// Author: Steve Soares
// Copyright ThePort Inc.
//***********************************************************
//***********************************************************
//***********************************************************
// D E P R I C A T E D !!!  See ThePortXSLUtilities.js!!!
// D E P R I C A T E D !!!  See ThePortXSLUtilities.js!!!
// D E P R I C A T E D !!!  See ThePortXSLUtilities.js!!!
// D E P R I C A T E D !!!  See ThePortXSLUtilities.js!!!
// D E P R I C A T E D !!!  See ThePortXSLUtilities.js!!!
// D E P R I C A T E D !!!  See ThePortXSLUtilities.js!!!
//***********************************************************
//***********************************************************
//***********************************************************
function ServiceReply(oXmlDoc)
{	
	this.m_bResponse    = false
    this.m_sResponse    = "";
    this.m_sData        = "";
    this.m_sStyle       = "";
	this.loadReply(oXmlDoc);
}


// Two older routines needing to be updated in SMUserLogin.xslt
ServiceReply.prototype.getResponse = function() {return this.m_bResponse;}
ServiceReply.prototype.getMessage = function() {return this.m_sData; }


// Newer functions...
ServiceReply.prototype.getResponseText = function() {return this.m_sResponse;}
ServiceReply.prototype.getDataText = function() {return this.m_sData;}
ServiceReply.prototype.getStyleText = function() {return this.m_sStyle;}


//******************************************************************
//
//******************************************************************
ServiceReply.prototype.getProcessedXML = function() {
    try {
        oProcessor = new ThePortXMLProcessor();
        oProcessor.loadXMLText(this.getDataText());
        oProcessor.loadXSLText(this.getStyleText());
        return (oProcessor.transform())
        } 
    catch (e) { return "Error in XSL transform."}
}


//****************************************************************
// By default the tags processed are always:
// Title, description, link & pubdate
// The caller may add any number of extra tags/attrs to this call.
// For example:
// myRssFeed.loadFeed(xmlDoc,'content:encoded','enclosure//@url')) 
//****************************************************************
ServiceReply.prototype.loadReply = function(oXmlDoc) {	
  this.m_bResponse = false;
  try {
      var sResponse	= new String(ThePortUtilities.GetTagValue(oXmlDoc,"Response")).toLowerCase();
      if ((sResponse=="true")||(sResponse=="yes")||(sResponse=="1"))
        this.m_bResponse = true;
      this.m_sResponse	= ThePortUtilities.GetTagValue(oXmlDoc,"Response");
      this.m_sData	= ThePortUtilities.GetTagValue(oXmlDoc,"Data");
      this.m_sStyle	= ThePortUtilities.GetTagValue(oXmlDoc,"Style");
      }
  catch (e) { return false; }
  return true;
}
//**********************************************
// End of ServiceReply Decoder.
//**********************************************

