|
// LimitedXML class
/**
* Class for storing and accessing shared data in XML.
* @param applicationIdentifier identifier for Application object to share data.
* @param nMax maximum quantity of items to store.
*/
function LimitedXML(xmlNode, nMax) {
this.add = LimitedXML_add;
//this.getXMLDocument = LimitedXML_getXMLDocument;
// replaced with getWorkingNode()
this.getWorkingNode = LimitedXML_getWorkingNode;
this.getItems = LimitedXML_getItems;
this.removeSuperfluous = LimitedXML_removeSuperfluous;
this.xmlNode = xmlNode;
this.xmlSection = "ITEM";
this.nMax = nMax;
}
/**
* Add new item.
* @param value value to add.
*/
function LimitedXML_add(value) {
var workingNode = this.getWorkingNode();
var xmlDoc = workingNode.ownerDocument;
var element = xmlDoc.createElement(this.xmlSection);
var elementText = xmlDoc.createTextNode(value);
workingNode.appendChild(element);
element.appendChild(elementText);
this.removeSuperfluous(workingNode);
}
/**
* Removes superfluous items.
* @param parentNode XML node for the root.
*/
function LimitedXML_removeSuperfluous(parentNode) {
var items = this.getItems();
if(this.nMax < items.length) {
parentNode.removeChild(items.item(0));
}
}
/**
* Queries list of data items.
* @return XMLNodesList of managed items.
*/
function LimitedXML_getItems() {
var workingNode = this.getWorkingNode();
var itemsList = workingNode.childNodes;
return itemsList;
}
/**
* Provides access to managed xml node.
*/
function LimitedXML_getWorkingNode() {
return this.xmlNode;
}
/**
* Provides access and first time creation of shared XML Document.
* @return Shared FreeThreadedDOMDocument object.
*/
/*function LimitedXML_getXMLDocument() {
var xmlDoc = Application(this.applicationIdentifier);
if(typeof(xmlDoc) == "undefined") {
xmlDoc = Server.CreateObject("MSXML.FreeThreadedDOMDocument");
var rootElement=xmlDoc.createElement("ROOT");
xmlDoc.appendChild(rootElement);
Application(this.applicationIdentifier) = xmlDoc;
}
return xmlDoc;
}*/
// LimitedXML class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here