// Licensed Materials - Property of IBM // // IBM Cognos Products: pps // // (C) Copyright IBM Corp. 2005, 2017 // // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. // This forms the javascript functions used for the display options // action pane for PowerPlay Studio. // The functions handle any minor browser differences. var DISPLAY_CROSSTAB = 0; var DISPLAY_PIECHART = 1; var DISPLAY_BARCHART = 2; var DISPLAY_CLUSTERCHART = 3; var DISPLAY_LINECHART = 4; var DISPLAY_STACKEDCHART = 5; var DISPLAY_THREEDCHART = 6; var DISPLAY_FINANCIAL_CROSSTAB = 9; var isNSBrowser = navigator.appName.indexOf("Netscape")>=0; if( navigator.appVersion == "" ) isNSBrowser = false; var isNSMac = isNSBrowser && navigator.platform.indexOf("Mac") >= 0; var isSplitPane = parent.parent.getWindow().name == "FX1"; function findObj(n, d) { var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i

'; } else if (isNSBrowser) { // Other Netscape browsers err.visibility = "visible"; err.moveTo(11, document.layers["referenceLayer"].top + document.layers["referenceLayer"].clip.bottom); err.resizeTo(parent.FE.innerWidth - 25, 50); err.document.open(); err.document.write('
' + msg + '
'); err.document.close(); } else alert (msg); } } function getHiddenFormChart () { if (isSplitPane) { return parent.FX2.document.fhidden; } else { return parent.FX.document.fhidden; } } function getHiddenFormXtab () { if (isSplitPane) { return parent.FX1.document.fhidden; } else { return parent.FX.document.fhidden; } } function getDisplayType () { if (isSplitPane) { return parseInt(getHiddenFormChart().YS.value); } else { if (getHiddenFormChart().Y) return parseInt(getHiddenFormChart().Y.value); else return DISPLAY_CROSSTAB; } } function isChartDisplay() { var displayType = getDisplayType(); return (displayType != DISPLAY_CROSSTAB && displayType != DISPLAY_FINANCIAL_CROSSTAB); } function applyDisplayOptions (forceClose) { if (parent.isXtabStillLoading()) { setTimeout("applyDisplayOptions()", 50); return; } var hiddenForm = getHiddenFormChart(); if(!hiddenForm) return; var htmlToAppend = ""; var command = ""; if (isChartDisplay()) { var chartType = getDisplayType(); command += "T:"; command += getChartOptions(chartType); command += '"'; } if (forceClose) { command += "\t\t"; command += "MT"; } var shortNames = 0; if(document.optionsForm.ShortNames.checked) shortNames = 1; if((!hiddenForm.SHN && shortNames) || (hiddenForm.SHN && shortNames != hiddenForm.SHN.value)) { command += "\t\t"; command += "OSHN"; } var fitChartsForm = hiddenForm.F; var fitChartsElem = document.optionsForm.fitcharts; if (!fitChartsForm && fitChartsElem && fitChartsElem.checked) { command += "\t\t"; command += "OF"; } else if (fitChartsForm && fitChartsElem && (fitChartsForm.value != fitChartsElem.checked)) { command += "\t\t"; command += "OF"; } if (!validateFields()) writeErrorMessage(strInvalidMinMaxMsg); else if (!validateAndSetScaling(hiddenForm)) writeErrorMessage(strInvalidHeightWidthMsg); else { hiddenForm.CNCT.value = 4; if (isSplitPane) parent.FX2.doit(command); else parent.FX.doit(command); } } function closeit() { if (isSplitPane) { parent.FX2.doit('MT'); } else { parent.FX.doit('MT'); } } function onOK() { applyDisplayOptions(true); } function getChartInputStr() { var chartType = getDisplayType(); if (isChartDisplay()) return '' + "\n"; else return ""; } function getChartOptions(n) { var opts; switch (n) { case 1: opts = getPieOptions(); break; case 2: opts = getBarOptions(); break; case 3: opts = getClusterOptions(); break; case 4: opts = getLineOptions(); break; case 5: opts = getStackedOptions(); break; case 6: opts = getThreedOptions(); break; } return opts; } function getPieOptions() { var opt; if(document.optionsForm.slicelabels[0].checked) opt = '"COP_VP;2;0"\t"COP_LP;2;2"'; else opt = '"COP_VP;2;2"\t"COP_LP;2;0"'; return opt; } function getBarOptions() { var opt; if (document.optionsForm.ManualScale.checked) { opt = '"COA_MS;1;1"\t"COA_MSI;3;' + document.optionsForm.MinValue.value + '"\t"COA_MSA;3;' + document.optionsForm.MaxValue.value + '"'; } else { opt = '"COA_MS;1;0"'; } if (document.optionsForm.ShowGrid.checked) opt += '\t"COA_SG;1;1"'; else opt += '\t"COA_SG;1;0"'; if (document.optionsForm.BarValues.checked) opt += '\t"COGCB_LP;2;1"'; else opt += '\t"COGCB_LP;2;0"'; return opt; } function getClusterOptions() { var opt; if (document.optionsForm.ManualScale.checked) { opt = '"COA_MS;1;1"\t"COA_MSI;3;' + document.optionsForm.MinValue.value + '"\t"COA_MSA;3;' + document.optionsForm.MaxValue.value + '"'; } else { opt = '"COA_MS;1;0"'; } if (document.optionsForm.ShowGrid.checked) opt += '\t"COA_SG;1;1"'; else opt += '\t"COA_SG;1;0"'; if (document.optionsForm.BarValues.checked) opt += '\t"COGCB_LP;2;1"'; else opt += '\t"COGCB_LP;2;0"'; return opt; } function getLineOptions() { var opt; if (document.optionsForm.ManualScale.checked) { opt = '"COA_MS;1;1"\t"COA_MSI;3;' + document.optionsForm.MinValue.value + '"\t"COA_MSA;3;' + document.optionsForm.MaxValue.value + '"'; } else { opt = '"COA_MS;1;0"'; } if (document.optionsForm.ShowGrid.checked) opt += '\t"COA_SG;1;1"'; else opt += '\t"COA_SG;1;0"'; if (document.optionsForm.Markers.checked) opt += '\t"COGCL_SM;1;1"'; else opt += '\t"COGCL_SM;1;0"'; return opt; } function getStackedOptions() { var opt; if (document.optionsForm.ManualScale.checked) { opt = '"COA_MS;1;1"\t"COA_MSI;3;' + document.optionsForm.MinValue.value + '"\t"COA_MSA;3;' + document.optionsForm.MaxValue.value + '"'; } else { opt = '"COA_MS;1;0"'; } if (document.optionsForm.ShowGrid.checked) opt += '\t"COA_SG;1;1"'; else opt += '\t"COA_SG;1;0"'; return opt; } function getThreedOptions() { var opt; if (document.optionsForm.ManualScale.checked) { opt = '"COA_MS;1;1"\t"COA_MSI;3;' + document.optionsForm.MinValue.value + '"\t"COA_MSA;3;' + document.optionsForm.MaxValue.value + '"'; } else { opt = '"COA_MS;1;0"'; } if (document.optionsForm.ShowGrid.checked) opt += '\t"COA3_SGL;1;1"\t"COA3_SGR;1;1"\t"COA3_SGB;1;1"'; else opt += '\t"COA3_SGL;1;0"\t"COA3_SGR;1;0"\t"COA3_SGB;1;0"'; return opt; } function validateFields() { if (document.optionsForm.ManualScale && document.optionsForm.ManualScale.checked) { if (document.optionsForm.MaxValue && (!document.optionsForm.MaxValue.value.length || !validateField(document.optionsForm.MaxValue))) return false; if (document.optionsForm.MinValue && (!document.optionsForm.MinValue.value.length || !validateField(document.optionsForm.MinValue))) return false; if (document.optionsForm.MaxValue && document.optionsForm.MinValue && (parseFloat(getNonLocalizedDecimalVal(document.optionsForm.MaxValue.value)) <= parseFloat(getNonLocalizedDecimalVal(document.optionsForm.MinValue.value)))) return false; } return true; } function validateAndSetScaling(hf) { if (chartType == 0 || chartType == 9) return true; if (document.optionsForm.fitcharts && document.optionsForm.fitcharts.checked) { var chartType = getDisplayType(); if ((chartType == DISPLAY_PIECHART) || (chartType == DISPLAY_THREEDCHART)) { if (!validateAndSetValue(document.optionsForm.HeightScaling, hf.POS)) return false; } else { if (!validateAndSetValue(document.optionsForm.HeightScaling, hf.PHS)) return false; if (!validateAndSetValue(document.optionsForm.WidthScaling, hf.PWS)) return false; } } return true; } function validateAndSetValue(elem, formElem) { if (elem) { if (!validateField(elem)) return false; var elemValue = elem.value; if ((elemValue < minScalingValue) || (elemValue > maxScalingValue)) return false; formElem.value = elemValue; } return true; } function switchOnOffTextFields() { if (!document.optionsForm.ManualScale.checked) { document.optionsForm.MaxValue.value = ""; document.optionsForm.MinValue.value = ""; } } function getNonLocalizedDecimalVal(val) { return val.replace(decimalpt,'.'); } function switchOnManualScale() { if (!document.optionsForm.ManualScale.checked) { document.optionsForm.ManualScale.checked = true; } } function validateField(FormObj) { var userInput = FormObj.value; var reducedInput = ""; var len = userInput.length; var negative = false; for ( var i = 0; i < len; i++ ) { //Strip out the thousand Separators. if ((i==0) && userInput.charAt(i) == '-') { negative = true; } else if (userInput.charAt(i) != thousandsep) { reducedInput += userInput.charAt(i); } } var acceptableChars = "/[^0-9" + decimalpt + "]/"; var pos = reducedInput.search(eval(acceptableChars)); if (pos != -1) return false; //Ensure that we only have 1 decimal if (reducedInput.indexOf(decimalpt) != reducedInput.lastIndexOf(decimalpt)) return false; if ( negative ) reducedInput = "-" + reducedInput; FormObj.value = reducedInput; return true; } function sliceLabelsButtonNames() { document.optionsForm.slicelabels[0].checked = true; document.optionsForm.slicelabels[1].checked = false; } function sliceLabelsButtonValues() { document.optionsForm.slicelabels[0].checked = false; document.optionsForm.slicelabels[1].checked = true; } function processInput(hw) { var chartType = getDisplayType(); if ((chartType == DISPLAY_PIECHART) || (chartType == DISPLAY_THREEDCHART)) { if (hw == "h") document.optionsForm.WidthScaling.value = document.optionsForm.HeightScaling.value; else document.optionsForm.HeightScaling.value = document.optionsForm.WidthScaling.value; } } function switchOnScaling() { if (!document.optionsForm.fitcharts.checked) { document.optionsForm.fitcharts.checked = true; } }