/* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| BI and PM: prmt *| (C) Copyright IBM Corp. 2002, 2022 *| *| US Government Users Restricted Rights - Use, duplication or *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *| *+------------------------------------------------------------------------+ */ //////////////////////////////////////////////////////////////////// // TextBox HTML generation functions //////////////////////////////////////////////////////////////////// // Function to create a textBox prompt control // sPromptId: The id of the prompt control (String) // sFormName: Name of form control to submit selections to the server (String) // sParameterName: Name of control element to be submitted to report server (String) // sDataType: ['number'|'currency'|'integer'|'natural'|'whole'|'percentage'] (String) // Default value is regular text. // sSubmitType: 'default' will submit as a standard form (String) // 'XML' will convert the submission to XML and submit // sDefaultValue: Default value for prompt control. If prompt control is a range, this represents the start value of the range. (String) // iInitialState: Range controls only. Controls whether to check radio buttons (Integer) // RANGE_NO_VALUE will select lowest to highest // RANGE_START_VALUE will select from a particular value to highest // RANGE_END_VALUE will select from lowest to a particular value // RANGE_BOUND_VALUE will select a range // RANGE_EQUAL_VALUE will select a single value // bRequired: If the control is a required field. (Boolean) // bShowThousandSeparator: If a thousand separator is used. (Boolean) // bMultiLine: If prompt control can accomodate multiple lines (e.g. simple text field vs textarea) (Boolean) // bAllowZero: If zeroes are to be allowed. (Boolean) // bHideAdornments: Hide icons (e.g. star icon for required controls) (Boolean) // bHideText: If text box is a password field. (Boolean) // bSuppressExtraPromptNames: Force report server to handle multiple prompt controls as a single entity (Boolean) // e.g. treat datetime control as a single date time, as opposed to treating date and time independntly // bMulti: If control can accomodate more than one value. (Boolean) // bRange: If control is a range. (Boolean) // bReadOnly: If control is read only. (Boolean) // bShowCondition: If the condition drop down is to be shown in the UI (Boolean) // sStyle: Style of prompt control. (String) // sMaxLength: Maximum length for text box. (String) // sEndValue: Optional. Only used for range controls. The end value of the range. (String) function genTextBoxHTML(sPromptId, sFormName, sParameterName, sDataType, sSubmitType, sDefaultValue, iInitialState, bRequired, bShowThousandSeparator, bMultiLine, bAllowZero, bHideAdornments, bHideText, bSuppressExtraPromptNames, bMulti, bRange, bReadOnly, bShowCondition, sStyle, sMaxLength, sEndValue) { var oProperties = sPromptId; if (arguments.length > 1 || typeof oProperties != K_PRMT_sOBJECT) { oProperties = { id: sPromptId, formName: sFormName, parameterName: sParameterName, allowZero: bAllowZero, dataType: sDataType, defaultValue: sDefaultValue, endValue: sEndValue, initialState: iInitialState, hideAdornments: bHideAdornments, hideText: bHideText, maxLength: sMaxLength, multiLine: bMultiLine, multi: bMulti, range: bRange, readOnly: bReadOnly, required: bRequired, showCondition: bShowCondition, showThousandSeparator: bShowThousandSeparator, style: sStyle, submitType: sSubmitType, supressExtraPromptNames: bSuppressExtraPromptNames }; } if (oProperties.multi) { if (!oProperties.range) { genTextBoxMultipleHTML(oProperties); } else { oProperties.startValue = oProperties.defaultValue; genTextBoxRangeMultipleHTML(oProperties); } } else { if (oProperties.range) { oProperties.startValue = oProperties.defaultValue; genTextBoxRangeHTML(oProperties); } else { genTextBoxSingleHTML(oProperties); } } } function genTextBoxSingleHTML(s_PromptId, s_FormName, s_ParameterName, s_DataType, s_SubmitType, s_DefaultValue, b_Required, b_ShowThousandSeparator, b_MultiLine, b_AllowZero, b_HideAdornments, b_HideText, b_SuppressExtraPromptNames, s_Style, s_MaxLength, b_ReadOnly) { var oProperties = s_PromptId; if (arguments.length > 1 || typeof oProperties != K_PRMT_sOBJECT) { oProperties = { id: s_PromptId, formName: s_FormName, parameterName: s_ParameterName, allowZero: b_AllowZero, dataType: s_DataType, defaultValue: s_DefaultValue, hideAdornments: b_HideAdornments, hideText: b_HideText, maxLength: s_MaxLength, multiLine: b_MultiLine, readOnly: b_ReadOnly, required: b_Required, showThousandSeparator: b_ShowThousandSeparator, style: s_Style, submitType: s_SubmitType, supressExtraPromptNames: b_SuppressExtraPromptNames }; } var sPromptId = oProperties.id; if (!verifyPromptId(sPromptId)) { return; } //skin folder var sSkin = (typeof getPromptSkin != K_PRMT_sUNDEFINED ? getPromptSkin() : K_PRMT_sDEFAULTSKIN); var sFormName = oProperties.formName; if (!sFormName) { sFormName = "forms[0]"; } var sParamName = "p_" + oProperties.parameterName; if (oProperties.suppressExtraPromptNames) { sParamName = sParamName.substring(1); } var oErrorImg = "document." + sFormName + ".imgTest" + sPromptId; if (oProperties.hideAdornments) { oErrorImg = null; } var sFormElementName = "_textEditBox" + sPromptId; var sStyle = oProperties.style; if (sStyle.match(/margin/i) === null) { sStyle += ";margin:0px;"; } var sWidth=K_PRMT_sEMPTY; if( cssParser( oProperties.style, 'width') != K_PRMT_sEMPTY ) { sWidth = 'width:100%;'; } var HTMLOut = genHiddenInputHTML(sFormName, jsEncodeStr(sParamName), K_PRMT_sEMPTY) + "
" + "" + ""; if (!oProperties.hideAdornments) { HTMLOut += ""; } HTMLOut += "" + "" + "
" + ""; if (oProperties.required) { HTMLOut += "" + "" + ""; } HTMLOut += "" + "" + "" + "
" + "
"; var sMaxLength = ( oProperties.maxLength !== K_PRMT_sEMPTY && !isNaN(oProperties.maxLength) ? " maxlength='" + oProperties.maxLength + "'" : K_PRMT_sEMPTY ); var sCommonProperties = " class='clsTextWidget pt'" + " style='" + sWidth + cssParser(sStyle, 'color,font,text') + "'" + " onkeyup='textBox" + sPromptId + ".checkData();preventSubmitEvent(event)'" + " onKeyPress='return textBox" + sPromptId + ".keyPress(event)'" + " onblur='textBox" + sPromptId + ".lostFocus(); textBox" + sPromptId + ".endCheckDataInterval()'" + " oncontextmenu='textBox" + sPromptId + ".startCheckDataInterval(100)'"; // Password field if (oProperties.hideText) { HTMLOut += ""; } // Single line edit box else if (!oProperties.multiLine) { HTMLOut += ""; } // Multi line edit box else { HTMLOut += ""; } HTMLOut += "
" + "
"; renderPromptControlHTML("textBox" + sPromptId, HTMLOut); var sCVObj = getCVInstance(oProperties); var JSOut = "this.textBox" + sPromptId + " = new CText(document.forms[\"" + sFormName + "\"].elements[\""+ alterDoubleQuote(sParamName) + "\"], document.forms[\"" + sFormName + "\"].elements[\"" + sFormElementName + "\"]," + oErrorImg + ", '" + oProperties.dataType + "', " + '"' + oProperties.defaultValue.replace(/\\/g, "\\\\") + '"' + ", " + oProperties.required + ", '" + oProperties.submitType + "', " + oProperties.multiLine + ", " + oProperties.showThousandSeparator + ", " + oProperties.allowZero + ", document.getElementById('textEditBox" + sPromptId + "'), 'textBox" + sPromptId + "', " + oProperties.readOnly + ", '" + getCVId(oProperties) + "');" + sCVObj + "preProcessControlArray = " + sCVObj + "preProcessControlArray.concat('textBox" + sPromptId + "');"; executePromptControlJS(JSOut); } function genTextBoxMultipleHTML(s_PromptId, s_FormName, s_ParameterName, s_DataType, s_SubmitType, s_DefaultValue, b_Required, b_ShowThousandSeparator, b_MultiLine, b_AllowZero, b_HideAdornments, b_HideText, b_SuppressExtraPromptNames, b_ShowCondition, s_Style, s_MaxLength) { var oProperties = s_PromptId; if (arguments.length > 1 || typeof oProperties != K_PRMT_sOBJECT) { oProperties = { id: s_PromptId, formName: s_FormName, parameterName: s_ParameterName, allowZero: b_AllowZero, dataType: s_DataType, defaultValue: s_DefaultValue, hideAdornments: b_HideAdornments, hideText: b_HideText, maxLength: s_MaxLength, multiLine: b_MultiLine, required: b_Required, showCondition: b_ShowCondition, showThousandSeparator: b_ShowThousandSeparator, style: s_Style, submitType: s_SubmitType, supressExtraPromptNames: b_SuppressExtraPromptNames }; } var sPromptId = oProperties.id; if (!verifyPromptId(sPromptId)) { return; } //skin folder var sSkin = (typeof getPromptSkin != K_PRMT_sUNDEFINED ? getPromptSkin() : K_PRMT_sDEFAULTSKIN); var sFormName = oProperties.formName; if (!sFormName) { sFormName = "forms[0]"; } var sParamName = "p_" + oProperties.parameterName; if (oProperties.suppressExtraPromptNames) { sParamName = sParamName.substring(1); } var sFormElementName = sParamName; if (oProperties.submitType == K_PRMT_sXML) { sFormElementName = "_oLstChoices" + sPromptId; } var sWidth = K_PRMT_sEMPTY; var sFixedLayout = K_PRMT_sEMPTY; if( cssParser( oProperties.style, "width" ) != K_PRMT_sEMPTY ) { sWidth = 'width:100%;'; sFixedLayout = 'table-layout:fixed;'; } var HTMLOut = K_PRMT_sEMPTY; if (oProperties.submitType == K_PRMT_sXML) { HTMLOut += genHiddenInputHTML(sFormName, jsEncodeStr(sParamName), K_PRMT_sEMPTY); } HTMLOut += "
" + "" + "" + "" + "" + "" + "
"; } else { HTMLOut += ""; } if (!oProperties.hideAdornments && oProperties.required) { HTMLOut += ""; } if (oProperties.showCondition) { HTMLOut += PMT_UIM_CONDITION + "
" + ""; } else { HTMLOut += PMT_UIM_CHOICES; } HTMLOut += "
" + "" + "" + "
" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "
" + "
" + "" + "" + "" + "" + "" + "" + "" + "" + "
" + "" + PMT_UIM_SELECTALL + "" + " " + "" + PMT_UIM_DESELECTALL + "" + "
" + "
" + "
"; renderPromptControlHTML("textBox" + sPromptId, HTMLOut); var sCVObj = getCVInstance(oProperties); var JSOut = "genTextBoxSingleHTML(" + generatePromptProperties(oProperties, { id:"Single" + sPromptId, formName: sFormName, parameterName:"T_" + oProperties.parameterName, submitType: ( oProperties.submitType == K_PRMT_sNO_SUBMIT ? oProperties.submitType : K_PRMT_sEMPTY), defaultValue: K_PRMT_sEMPTY, required: false, style: cssParser(oProperties.style, "background,color,font-weight,font-style,font-family,text-decoration,font-size") + sWidth, suppressExtraPromptNames: true}) + ");" + "genInsertButtonHTML('" + sPromptId + "', 'multipleText" + sPromptId + ".insert()', 'insertButton" + sPromptId + "');" + "genRemoveButtonHTML('" + sPromptId + "', 'multipleText" + sPromptId + ".remove()', 'removeButton" + sPromptId + "');" + "this.multipleText" + sPromptId + " = new CMultipleTextPicker(textBoxSingle" + sPromptId + ", document.forms['" + sFormName + "'].elements['" + sFormElementName + "'], document.forms['" + sFormName + "'].elements['" + sParamName + "'], " + oProperties.required + ", '" + oProperties.submitType + "', document.getElementById('feedback" + sPromptId + "'), document.sizer" + sPromptId + ", document.getElementById('insertButton" + sPromptId + "'), document.getElementById('removeButton" + sPromptId + "'), '" + getCVId(oProperties) + "');" + sCVObj + "preProcessControlArray = " + sCVObj + "preProcessControlArray.concat('multipleText" + sPromptId + "');" + sCVObj + "multipleObserverArray = " + sCVObj + "multipleObserverArray.concat('multipleText" + sPromptId + "');"; executePromptControlJS(JSOut); } function genTextBoxRangeHTML(s_PromptId, s_FormName, s_ParameterName, s_DataType, s_SubmitType, s_StartValue, s_EndValue, i_InitialState, b_Required, b_ShowThousandSeparator, b_MultiLine, b_AllowZero, b_HideAdornments, b_HideText, b_SuppressExtraPromptNames, s_Style, s_MaxLength) { var oProperties = s_PromptId; if (arguments.length > 1 || typeof oProperties != K_PRMT_sOBJECT) { oProperties = { id: s_PromptId, formName: s_FormName, parameterName: s_ParameterName, allowZero: b_AllowZero, dataType: s_DataType, endValue: s_EndValue, initialState: i_InitialState, hideAdornments: b_HideAdornments, hideText: b_HideText, maxLength: s_MaxLength, multiLine: b_MultiLine, required: b_Required, showThousandSeparator: b_ShowThousandSeparator, startValue: s_StartValue, style: s_Style, submitType: s_SubmitType, supressExtraPromptNames: b_SuppressExtraPromptNames }; } var sPromptId = oProperties.id; if (!verifyPromptId(sPromptId)) { return; } //skin folder var sSkin = (typeof getPromptSkin != K_PRMT_sUNDEFINED ? getPromptSkin() : K_PRMT_sDEFAULTSKIN); var sFormName = oProperties.formName; if (!sFormName) { sFormName = "forms[0]"; } var sParamName = "p_" + oProperties.parameterName; if (oProperties.suppressExtraPromptNames) { sParamName = sParamName.substring(1); } var HTMLOut = K_PRMT_sEMPTY; var sWidth = K_PRMT_sEMPTY; if( cssParser( oProperties.style, "width" ) != K_PRMT_sEMPTY ) { sWidth = 'width:100%;'; } if (oProperties.submitType == K_PRMT_sXML) { HTMLOut += genHiddenInputHTML(sFormName, jsEncodeStr(sParamName), K_PRMT_sEMPTY); } HTMLOut += "
" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "
" + PMT_RNG_FROM + "
 " + "" + "" + "" + "" + ""; if (!oProperties.required) { HTMLOut += "" + "" + "" + ""; } HTMLOut += "
"; if (!oProperties.required) { HTMLOut += "" + ""; } // textBoxSingle prompt control for start range HTMLOut += "
" + "
" + "" + "" + PMT_RNG_LOWEST_VALUE + "
" + "
 
" + PMT_RNG_TO + "
 " + "" + "" + "" + "" + ""; if (!oProperties.required) { HTMLOut += "" + "" + "" + ""; } HTMLOut += "
"; if (!oProperties.required) { HTMLOut += "" + ""; } // textBoxSingle prompt control for end range HTMLOut += "
" + "
" + "" + "" + PMT_RNG_HIGHEST_VALUE + "
" + "
" + "
"; renderPromptControlHTML("textBox" + sPromptId, HTMLOut); var JSOut = "genTextBoxSingleHTML(" + generatePromptProperties(oProperties, { id:"range_from" + sPromptId, formName: sFormName, parameterName:"range_from" + oProperties.parameterName, submitType: ( oProperties.submitType == K_PRMT_sNO_SUBMIT ? oProperties.submitType : K_PRMT_sEMPTY), defaultValue: oProperties.startValue, multiLine: false, allowZero: true, hideText: false, hideAdornments:true, style: cssParser(oProperties.style, 'background,color,font,text') + sWidth, suppressExtraPromptNames: true}) + ");" + "genTextBoxSingleHTML(" + generatePromptProperties(oProperties, { id:"range_to" + sPromptId, formName: sFormName, parameterName:"range_to" + oProperties.parameterName, submitType: ( oProperties.submitType == K_PRMT_sNO_SUBMIT ? oProperties.submitType : K_PRMT_sEMPTY), defaultValue: oProperties.endValue, multiLine: false, hideAdornments:true, allowZero: true, hideText: false, style: cssParser(oProperties.style, 'background,color,font,text') + sWidth, suppressExtraPromptNames: true}) + ");"; if (oProperties.required) { JSOut += "this.range" + sPromptId + " = new CRange(document.forms['" + sFormName + "'].elements['" + alterDoubleQuote(sParamName) + "'], null, textBoxrange_from" + sPromptId + ", null, null, textBoxrange_to" + sPromptId + ", null, '" + oProperties.dataType + "', true, '" + oProperties.submitType + "', null, '" + getCVId(oProperties) + "');"; } else { JSOut += "this.range" + sPromptId + " = new CRange(document.forms['" + sFormName + "'].elements['" + alterDoubleQuote(sParamName) + "'], document.forms['" + sFormName + "'].elements['fromValue" + sPromptId + "'][0], textBoxrange_from" + sPromptId + ", null, document.forms['" + sFormName + "'].elements['toValue" + sPromptId + "'][0], textBoxrange_to" + sPromptId + ", null, '" + oProperties.dataType + "', false, '" + oProperties.submitType + "', " + oProperties.initialState + ", '" + getCVId(oProperties) + "');"; } var sCVObj = getCVInstance(oProperties); JSOut += sCVObj + "preProcessControlArray = " + sCVObj + "preProcessControlArray.concat('range" + sPromptId + "');" + sCVObj + "rangeObserverArray = " + sCVObj + "rangeObserverArray.concat('range" + sPromptId + "');"; executePromptControlJS(JSOut); } function genTextBoxRangeMultipleHTML(s_PromptId, s_FormName, s_ParameterName, s_DataType, s_SubmitType, s_StartValue, s_EndValue, i_InitialState, b_Required, b_ShowThousandSeparator, b_MultiLine, b_AllowZero, b_HideAdornments, b_HideText, b_SuppressExtraPromptNames, s_Style, s_MaxLength) { var oProperties = s_PromptId; if (arguments.length > 1 || typeof oProperties != K_PRMT_sOBJECT) { oProperties = { id: s_PromptId, formName: s_FormName, parameterName: s_ParameterName, allowZero: b_AllowZero, dataType: s_DataType, endValue: s_EndValue, initialState: i_InitialState, hideAdornments: b_HideAdornments, hideText: b_HideText, maxLength: s_MaxLength, multiLine: b_MultiLine, required: b_Required, showThousandSeparator: b_ShowThousandSeparator, startValue: s_StartValue, style: s_Style, submitType: s_SubmitType, supressExtraPromptNames: b_SuppressExtraPromptNames }; } var sPromptId = oProperties.id; if (!verifyPromptId(sPromptId)) { return; } //skin folder var sSkin = (typeof getPromptSkin != K_PRMT_sUNDEFINED ? getPromptSkin() : K_PRMT_sDEFAULTSKIN); var sFormName = oProperties.formName; if (!sFormName) { sFormName = "forms[0]"; } var sParamName = "p_" + oProperties.parameterName; if (oProperties.suppressExtraPromptNames) { sParamName = sParamName.substring(1); } var sFixedLayout = K_PRMT_sEMPTY; var sWidth = K_PRMT_sEMPTY; if( cssParser( oProperties.style, "width" ) != K_PRMT_sEMPTY ) { sWidth = 'width:100%;'; sFixedLayout = "table-layout:fixed;"; } var HTMLOut = K_PRMT_sEMPTY; if (oProperties.submitType == K_PRMT_sXML) { HTMLOut += genHiddenInputHTML(sFormName, jsEncodeStr(sParamName), K_PRMT_sEMPTY); } HTMLOut += "
"; HTMLOut += "" + "" + // textBoxRange prompt control "" + "" + "" + "" + "
" + "" + "" + "" + "" + "
" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "
" + "
" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "
"; if (oProperties.required) { HTMLOut += ""; } HTMLOut += PMT_UIM_CHOICES + "
" + "" + "
" + "
" + "" + "
" + "
" + "" + PMT_UIM_SELECTALL + "" + " " + "" + PMT_UIM_DESELECTALL + "" + "
" + "
"; renderPromptControlHTML("textBox" + sPromptId, HTMLOut); var sCVObj = getCVInstance(oProperties); var JSOut = "genTextBoxRangeHTML(" + generatePromptProperties(oProperties, { id: "r_" + sPromptId, formName: sFormName, parameterName: "r_" + oProperties.parameterName, startValue: K_PRMT_sEMPTY, endValue: K_PRMT_sEMPTY, style: cssParser(oProperties.style, 'background,color,font,text') + sWidth, required: false, suppressExtraPromptNames: false}) + ");" + "genInsertButtonHTML('" + sPromptId + "', 'multipleRange" + sPromptId + ".insertChoiceList()', 'insertButton" + sPromptId + "');" + "genRemoveButtonHTML('" + sPromptId + "', 'multipleRange" + sPromptId + ".removeChoiceList()', 'removeButton" + sPromptId + "');" + "this.multipleRange" + sPromptId + " = new CMultipleRange(ranger_" + sPromptId + ", document.forms['" + sFormName + "'].elements['_oLstChoices" + sPromptId + "'], document.forms['" + sFormName + "'].elements['" + sParamName + "'], " + oProperties.required + ", '" + oProperties.submitType + "', document.getElementById('multipleRangeFeedback" + sPromptId + "'), document.sizer" + sPromptId + ", '" + sPromptId + "', document.getElementById('insertButton" + sPromptId + "'), document.getElementById('removeButton" + sPromptId + "'), '" + getCVId(oProperties) + "');" + sCVObj + "preProcessControlArray = " + sCVObj + "preProcessControlArray.concat('multipleRange" + sPromptId + "');" + sCVObj + "multipleObserverArray = " + sCVObj + "multipleObserverArray.concat('multipleRange" + sPromptId + "');" + "multipleRange" + sPromptId + ".initChoiceList();"; executePromptControlJS(JSOut); }