123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- // Licensed Materials - Property of IBM
- //
- // IBM Cognos Products: cpscrn
- //
- // (C) Copyright IBM Corp. 2005, 2018
- //
- // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- //
- //
- // Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
- // Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
- function getPickerForm(formName)
- {
- var forms = document.getElementsByTagName("form");
- var currentPicker = null;
- var i = 0;
-
- //while ((currentPicker == null) && (i < forms.length))
- while ((i < forms.length))
- {
- if (forms[i].name == formName){
- currentPicker = forms[i];
- }
- i++;
- }
- return currentPicker;
- }
- function recreatePickerForm(formName, action)
- {
- var forms = document.getElementsByTagName("form");
- var currentPicker = getPickerForm(formName);
- if (currentPicker != null)
- {
- //remove all elements from the form just in case it was used previously
- currentPicker.parentNode.removeChild(currentPicker);
- }
- //recreate the picker form
- currentPicker = document.createElement("form");
- currentPicker.name = formName;
- currentPicker.action = action;
- currentPicker.target = "UI_MODAL_DIALOG_IFRAME";
- document.body.appendChild(currentPicker);
-
- }
- function createPickerInput(form, id, name, value)
- {
- var anInput = document.createElement('input');
- anInput.setAttribute("type","hidden");
- anInput.setAttribute("name",name);
- anInput.setAttribute("value",value);
- anInput.setAttribute("id",id);
- form.appendChild(anInput);
- }
- function isInRemoveLang(locale)
- {
- var inputs = document.getElementsByTagName("input");
- var removeLangEl = null;
- var count = 0;
- while ((removeLangEl == null) && (count < inputs.length))
- {
- var currEl = inputs[count];
- if ((currEl.type == "hidden") && (currEl.name == 'removeLang'))
- {
- removeLangEl = currEl;
- }
- count++;
- }
- return (removeLangEl.value.indexOf(locale) != -1)
- }
- function getMultiLingualElements(pickParamName, propertyName, form, selector, control)
- {
- var currentLocale = selector.options[selector.selectedIndex].value;
- var inputs = document.getElementsByTagName("input");
- var langValueIndex = 1;
- for (var ind = 0; ind < inputs.length; ind++)
- {
- if (inputs[ind].type == "hidden")
- {
- if (inputs[ind].name.indexOf(propertyName + "-") == 0)
- {
- var indexOfLocale = (propertyName + "-").length;
- var locale = inputs[ind].name.substr(indexOfLocale);
- if (!isInRemoveLang(locale))
- {
- if (locale == currentLocale)
- {
- inputs[ind].value = control.value;
- }
- createPickerInput(form, pickParamName + "-" + locale, pickParamName + "-" + locale, inputs[ind].value);
- langValueIndex++;
- }
- }
- }
- }
- return (langValueIndex > 1);
- }
- function getRadiobuttonSelectElements(pickParamName, propertyName, form)
- {
- var radiobuttons = document.getElementsByTagName("input");
- var radioIndex = 1;
- var checkedRadioButton = null;
- var count = 0;
- while ((checkedRadioButton == null) && (count < radiobuttons.length) )
- {
- var currentEl = radiobuttons[count];
- if ((currentEl.type == 'radio') && (currentEl.name == ("p_" + propertyName)) && (currentEl.checked) )
- {
- checkedRadioButton = currentEl;
- }
- count++;
- }
- if (checkedRadioButton == null)
- {
- return false;
- }
- else
- {
- createPickerInput(form, pickParamName + "_" + radiobuttons, pickParamName, checkedRadioButton.value);
- return true;
- }
- }
- function getCheckboxSelectElements(pickParamName, propertyName, form)
- {
- var checkboxes = document.getElementsByTagName("input");
- var checkIndex = 1;
- for (var ind = 0; ind < checkboxes.length; ind++)
- {
- if (checkboxes[ind].type == "checkbox")
- {
- if (checkboxes[ind].name.indexOf("p_" + propertyName + "_option") == 0)
- {
- if (checkboxes[ind].checked)
- {
- createPickerInput(form, pickParamName + "_" + checkIndex, pickParamName + "_" + checkIndex, checkboxes[ind].value);
- checkIndex++;
- }
- }
- }
- }
- return (checkIndex > 1);
- }
- function getOptionSelectElements(pickParamName, propertyName, form)
- {
- var selections = document.getElementsByTagName("select");
- var optionIndex = 1;
- for (var ind = 0; ind < selections.length; ind++)
- {
- if (selections[ind].name == ("p_" + propertyName))
- {
- var theOptions = selections[ind].options;
- for (var optind=0;optind < theOptions.length;optind++)
- {
- if (theOptions[optind].selected)
- {
- //if it is a select-one list then treat the result as a
- //simple element otherwise assume that you will be creating multiple inputs for this
- //for this property
- if (selections[ind].type == "select-one")
- {
- createPickerInput(form, pickParamName, pickParamName, theOptions[optind].value);
- }
- else
- {
- createPickerInput(form, pickParamName + "_" + optionIndex, pickParamName + "_" + optionIndex, theOptions[optind].value);
- }
- optionIndex++;
- }
- }
- }
- }
- return (optionIndex > 1);
- }
- function getSelectElements(pickParamName, propertyName, form)
- {
- //first see if we have a bunch of check boxes
- if (getCheckboxSelectElements(pickParamName, propertyName, form))
- {
- return true;
- }
- //next see if we have a bunch of option tags
- if (getOptionSelectElements(pickParamName, propertyName, form))
- {
- return true;
- }
- return false;
- }
- function getSelect1Elements(pickParamName, propertyName, form)
- {
- //first see if we have a bunch of check boxes
- if (getRadiobuttonSelectElements(pickParamName, propertyName, form))
- {
- return true;
- }
-
- //next see if we have a bunch of option tags
- if (getOptionSelectElements(pickParamName, propertyName, form))
- {
- return true;
- }
- return false;
- }
- function getValueFromSimpleElement(element)
- {
- if ((element.type == "text") || (element.type == "textarea"))
- {
- return element.value;
- }
- if ((element.type == "radio") || (element.type == "checkbox"))
- {
- return element.checked;
- }
- if (element.type == "hidden")
- {
- return element.value;
- }
- }
- //****xml functions
- function XMLBuilderLoadXMLFromString(markup)
- {
- var xmlDocument = null;
- // Try to activeX first. In IE10, if we use the DOMParser, the selectSingleNode will not longer work and IE still does not support the xpath evaluate method
- try
- {
- // If we do not hit an exception while creating ActiveXObject object, it means that we use Internet Explorer browser
- xmlDocument = new ActiveXObject('Microsoft.XMLDOM');
- xmlDocument.loadXML(markup);
- }
- catch (e)
- {
- // If we get in here, it means that we use other then Internet Explorer browser
- if (typeof DOMParser != 'undefined')
- {
- xmlDocument = new DOMParser().parseFromString(markup, 'application/xml');
- }
- }
-
- return xmlDocument;
- }
- function xmldecode(text)
- {
- var amp_re = /&/g;
- var lt_re = /</g;
- var gt_re = />/g;
- var apos_re = /'/g;
- // Decode stuff which has been encoded/escaped out.
- // ORDER IS IMPORTANT - amp_re must be the last value to replace!
- text = text.replace(lt_re, "<");
- text = text.replace(gt_re, ">");
- text = text.replace(apos_re, "'");
- text = text.replace(amp_re, "&");
- return text;
- }
|