123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- /********************************************************************************************************************************
- * Licensed Materials - Property of IBM *
- * *
- * IBM Cognos Products: AGS *
- * *
- * (C) Copyright IBM Corp. 2005, 2008 *
- * *
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *
- *********************************************************************************************************************************/
- //***************************************************
- //start NonDuplicationItems object
- //***************************************************
- function NonDuplicationItems(sItems)
- {
- //This list should not be displayed really.
- var uiStyle = new CUIStyle("CList_li", "CList_over", "CList_selected", "", null);
- this.cList = new CList('NonDupList',true, "CList_ul",uiStyle);
- this.DELIM=';';
- this.parseFromString(sItems);
- this.cList.setEqualityFunc(
- function listEqualityCheck(list,node) {
- var result = false;
- var items = list.getAllItems();
- for (var i=0; items && i < items.length;i++) {
- result = result || items[i].nodeValue.localeCompare(node.nodeValue) == 0;
- }
- return result;
- }
- );
- }
- /**
- * remove a non dupe item from this if there is one
- */
- NonDuplicationItems.prototype.getList = function()
- {
- return this.cList;
- }
- /**
- * remove a non dupe item from this if there is one
- */
- NonDuplicationItems.prototype.removeItem = function(sItem)
- {
- var nodes = this.cList.getAllNodes();
- for (var i=0; i < nodes.length; i++) {
- if(nodes[i].firstChild.nodeValue.localeCompare(sItem)== 0){
- var index = this.cList.indexById(nodes[i].id);
- this.cList.remove(index);
- }
- }
- }
- /**
- * remove a non dupe item from this if there is one
- */
- NonDuplicationItems.prototype.items = function()
- {
- var result = new Array();
- var items = this.cList.getAllItems();
- for (var i=0; i < items.length; i++) {
- result.push(items[i].nodeValue);
- }
- return result;
- }
- NonDuplicationItems.prototype.containsItem = function(sItem)
- {
- var textNode = document.createTextNode(sItem);
- return this.cList.containsItem(textNode);
- }
- //load all the query items into the textarea
- NonDuplicationItems.prototype.toString = function()
- {
- var theStr = "";
- var textNodes = this.cList.getAllItems();
- for (var i=0;i<textNodes.length;i++) {
- theStr = theStr + textNodes[i].nodeValue;
- }
- return theStr;
- }
- /*
- Parse the content of the textarea for valid query items
- */
- NonDuplicationItems.prototype.parseFromString = function(stringValue)
- {
- if (stringValue && stringValue != 'undefined' && stringValue.localeCompare("") != 0) {
- var items = stringValue.split(this.DELIM);
- for(var i=0;i < items.length;i++) {
- if (items[i].localeCompare("") != 0) {
- var textNode = document.createTextNode(items[i] + this.DELIM);
- this.cList.add(textNode);
- }
- }
- }
- }
- NonDuplicationItems.prototype.size = function()
- {
- return this.cList.size();
- }
- NonDuplicationItems.prototype.clear = function()
- {
- this.cList.removeAllNodes();
- }
- //***************************************************
- //end NonDuplicationItems object
- //***************************************************
|