123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357 |
- // 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 Find pane of
- // PowerPlay Studio.
- // The functions handle any minor browser differences.
- var visBox;
- var invisBox;
- var rc;
- var xtabgroup;
- var catarr;
- var sumarr;
- var selectedGroup;
- var categories = new Array();
- categories["R"] = new Array();
- categories["C"] = new Array();
- var hiddenSummaries = new Array();
- hiddenSummaries["R"] = new Array();
- hiddenSummaries["C"] = new Array();
- var selections;
- function addToArray(rc, group, name, code, vis, level) {
-
- if (!categories[rc][group])
- categories[rc][group] = new Array();
- categories[rc][group][categories[rc][group].length] = new categoryRecord(name, code, vis, level, categories[rc][group].length);
- }
- function addHiddenSummary (rc, group) {
- hiddenSummaries[rc][group] = new summaryRec(true,true);
- }
- function isHiddenSummary () {
- //If it doesent yet exist in the array, it isn't hidden
- if (typeof hiddenSummaries[rc][parseInt(xtabgroup)-1] == "undefined") {
- hiddenSummaries[rc][parseInt(xtabgroup)-1] = new summaryRec(false,false);
- }
- return hiddenSummaries[rc][parseInt(xtabgroup)-1]._present;
- }
- function setHiddenSummary (hidden) {
- if (typeof hiddenSummaries[rc][parseInt(xtabgroup)-1] == "undefined") {
- hiddenSummaries[rc][parseInt(xtabgroup)-1] = new summaryRec(false,false);
- }
- hiddenSummaries[rc][parseInt(xtabgroup)-1]._present = hidden;
- }
- function summaryRec(original,present) {
- this._original = original;
- this._present = present;
- }
- function toggleCheckSummary () {
- setHiddenSummary(!document.getElementById("showSummariesCheck").checked);
- }
- function selectAll(event, box) {
- var box = document.getElementById(box);
- for (var i = 0; i < box.options.length; i++) {
- box.options[i].selected = true;
- }
- var mgr = new eventManager(event);
- mgr.cancelBubble();
- }
- function unselectAll(event, box) {
- var box = document.getElementById(box);
- for (var i = 0; i < box.options.length; i++) {
- box.options[i].selected = false;
- }
- var mgr = new eventManager(event);
- mgr.cancelBubble();
- }
- function refresh() {
- resetDialog()
- }
- function clearDialogs() {
- visBox.innerHTML = "";
- invisBox.innerHTML = "";
-
- rc = null;
- selectedGroup = null;
- if (document.getElementById("showSummariesCheck"))
- document.getElementById("showSummariesCheck").checked = false;
- }
- function resetDialog() {
- removeMessage();
- var rowcolswitch = false;
- var rowSelections = getSelected("r");
- var colSelections = getSelected("c");
- var summarySelected = false;
- if (rowSelections.length && colSelections.length) { //Both rows and columns selected
- displayCommonMessage(strNoSelectionsMsg, MESSAGE_TYPE_INFO, [], []);
- return;
- } else if (!rowSelections.length && !colSelections.length) {//No rows or columns selected
- if( !isLevelSelected("r") && !isLevelSelected("c") ) {
- clearDialogs();
- displayCommonMessage(strNoSelectionsMsg, MESSAGE_TYPE_INFO, [], []);
- return;
- }
- else {
- if( isLevelSelected("r") ) {
- xtabgroup = getSelectedLevelNum();
- xtabgroup ++;
- rc = "R";
- }
- else {
- xtabgroup = getSelectedLevelNum();
- xtabgroup ++;
- rc = "C";
- }
- }
- }
- else {
- if (rowSelections.length) {
- if (rc != "R")
- rowcolswitch = true;
- rc = "R";
- xtabgroup = (rowSelections[0].getAttribute("summary"))? (parseInt(rowSelections[0].getAttribute("group")) + 1) : rowSelections[0].getAttribute("group");
- if(rowSelections[0].getAttribute("summary"))
- summarySelected = true;
- for (var i = 1;i < rowSelections.length;i++) {
- var tempgroup = (rowSelections[i].getAttribute("summary"))? (parseInt(rowSelections[i].getAttribute("group")) + 1) : rowSelections[i].getAttribute("group");
- if (tempgroup != xtabgroup) {
- clearDialogs();
- displayCommonMessage(strIncorrectRowsSelMsg, MESSAGE_TYPE_INFO, [], []);
- return;
- }
- }
- } else {
- if (rc != "C")
- rowcolswitch = true;
- rc = "C";
- xtabgroup = (colSelections[0].getAttribute("summary"))? (parseInt(colSelections[0].getAttribute("group")) + 1) : colSelections[0].getAttribute("group");
- if(colSelections[0].getAttribute("summary"))
- summarySelected = true;
- for (var i = 1;i < colSelections.length;i++) {
- var tempgroup = (colSelections[i].getAttribute("summary"))? (parseInt(colSelections[i].getAttribute("group")) + 1) : colSelections[i].getAttribute("group");
- if (tempgroup != xtabgroup) {
- displayCommonMessage(strIncorrectRowsSelMsg, MESSAGE_TYPE_INFO, [], []);
- clearDialogs();
- return;
- }
- }
- }
- }
- popSelections();
- if ((xtabgroup == selectedGroup) && (!rowcolswitch)) {
- preSelectOptions(visBox);
- return;
- } else {
- selectedGroup = xtabgroup;
- }
-
- catarr = categories[rc][parseInt(xtabgroup)];
- //Bug 468335 : Check if the summary is selected; only then bump up the group number to retrieve child categories if catarr is empty
- if(summarySelected)
- {
- //in a chart with no legend, only the column summary is shown
- //when selected, it has a group of 1 less the categories we wanna show...
- //so, bump it up by one and give it a whirl...
- if (!catarr)
- catarr = categories[rc][parseInt(xtabgroup) + 1];
- }
- populateDialogs();
- }
- function init() {
- topparent.openActionPane();
- ContextMenu.initialize(true,false);
- visBox = document.getElementById("shownCategories");
- invisBox = document.getElementById("hiddenCategories");
- resetDialog();
- }
- function categoryRecord(name, code, vis, level, index) {
- this._name = name;
- this._code = code;
- this._vis = vis;
- this._level = level;
- this._index = index;
- }
- function popSelections() {
- var selects = getSelected("r");
- if (selects.length == 0)
- selects = getSelected("c");
- selections = new Array();
- for (var i = 0; i < selects.length; i++) {
- selections[selects[i].getAttribute("ppdsId")] = true;
- }
- }
- function populateDialogs() {
- visBox.innerHTML = "";
- invisBox.innerHTML = "";
- if (catarr){
- for (var i = 0;i < catarr.length; i++) {
- if (catarr[i]._vis)
- {
- visBox.options[visBox.options.length] = new Option(catarr[i]._name,catarr[i]._index);
- visBox.options[visBox.options.length - 1].label = catarr[i]._name;
- }
- else
- {
- invisBox.options[invisBox.options.length] = new Option(catarr[i]._name,catarr[i]._index);
- invisBox.options[invisBox.options.length - 1].label = catarr[i]._name;
- }
- }
- }
- if (isHiddenSummary())
- document.getElementById("showSummariesCheck").checked = false;
- else
- document.getElementById("showSummariesCheck").checked = true;
- preSelectOptions(visBox);
- }
- function preSelectOptions(box) {
- for (var i = 0; i < box.length; i++) {
- var catCode = catarr[box[i].value]._code;
- if(catCode.charAt(0) == 'T')
- box[i].selected = selections[catCode];
- else
- box[i].selected = selections[parseInt(catarr[box[i].value]._code)];
- }
- }
- function switchVis(element) {
- element._vis = !element._vis;
- }
- function moveSelectedOptions(event, direction) {
- var fromBox = visBox;
- var toBox = invisBox;
- var options = new Array();
- var array = catarr;
- if (direction == "left") {
- fromBox = invisBox;
- toBox = visBox;
- }
- for (var i = fromBox.options.length - 1; i >= 0; i--) {
- //Find all selected options in reverse order;
- if (fromBox.options[i].selected) {
- options[options.length] = fromBox.options[i];
- switchVis(array[fromBox.options[i].value]); //switch its visibility;
- fromBox.options[i] = null;
- }
- }
- insertOptions(options,toBox);
- var mgr = new eventManager(event);
- mgr.cancelBubble();
- }
- function insertOptions(options, dialog) {
- //Works backwards for efficiency. Assumes options not already in select
- var opCtr = 0;
- var dptr = dialog.options.length - 1;
- for (var i = options.length - 1; i >= 0; i--) {
- dialog.options[dialog.options.length] = options[i]; //First add them to the end.
- }
- if (dptr != -1) {
- for (var i = dptr + options.length;opCtr < options.length; i--) {
- if ((dptr < 0) || (dialog.options[dptr].value < options[opCtr].value)) {
- //Insert the next option at i
- dialog.options[i] = options[opCtr];
- opCtr++;
- } else {
- //Move this option down to make room (by the number of options left to insert)
- dialog.options[i] = new Option(dialog.options[dptr].label,dialog.options[dptr].value);
- dialog.options[i].label = dialog.options[dptr].label;
- dptr--;
- }
- }
- }
- }
- function applyChanges() {
- var command = "MH:1\t";
- var groupNum = (xtabgroup == 0)? 0: xtabgroup - 1;
- command += rc + groupNum;
- var numCats = 0;
- if (catarr){
- for (var i = 0;i < catarr.length;i++) {
- if (!catarr[i]._vis) {
- command += "\t" + catarr[i]._code;
- numCats++;
- }
- }
- }
- else {
- topparent.closeActionPane();
- return;
- }
- if (!numCats)
- command = "MS:2\t" + rc + groupNum;
- if(hiddenSummaries[rc][parseInt(xtabgroup)-1]._present != hiddenSummaries[rc][parseInt(xtabgroup)-1]._original) {
- if (groupNum == 0)
- command += "\t\tET:" + rc + "0";
- else
- command += "\t\tES:" + rc + groupNum;
- }
- //close the pane...
- topparent.closeActionPane();
- command += "\t\tMQ";
-
- topparent.getXtabFrame().doit(command);
- }
|