123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435 |
- // 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<d.forms.length;i++) x=d.forms[i][n];
- for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
- if(!x && document.getElementById) x=document.getElementById(n); return x;
- }
- function writeErrorMessage (msg) {
- var err = findObj("ErrorMessage");
- if (err) {
- if (document.getElementById) { //IE 5.5+ , Netscape 6.0+
- err.innerHTML = '<table><tr><td valign="middle"><img src="../ppwb/Graphics/error.gif" height=18 width=18 alt=""></td><td class="CustomExceptionError" valign="middle">' + msg + '</td></tr></table><br><br>';
- } 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('<html><body><table><tr><td><img src="../ppwb/Graphics/error.gif" height=18 width=18 alt=""></td><td class="CustomExceptionError" valign="middle">' + msg + '</td></tr></table></body></html>');
- 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 '<INPUT TYPE="HIDDEN" NAME="CHOP' + chartType + '" VALUE="' + getChartOptions(chartType) + '">' + "\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;
- }
- }
|