// $Id: MainMenu.js,v 1.15 2011/05/13 03:36:55 yinqiaojun Exp $ /** * for generate main menu */ /** * Data array in strArray * [0 moudle][1 product id][2 name(?)][3 function id][4 fucntion name][5 item id] * [6 item name][7 product type(S or T)][8 new type][9 cata num][10 module description] * [11 product description] [12 function description] */ //Global variables var nNoOfFuncs = 0; // number of functions var sSelectedProdId = ""; //Selected product id var sSelectedFuncId = ""; //Selected function id /** * call showMainMenu() in the end of JSP */ function showMainMenu(){ try { if (!window.strArray) { showMsg("The FAP is invalid.", "There was a problem login in."); return; } //PRODUCT_ID is in catalog and trx if (window.PRODUCT_ID && window.PRODUCT_ID.length > 0) { sSelectedProdId = PRODUCT_ID; } //get function id for catalog and transaction screen if (window.selFuncDesc && window.selFuncDesc.length > 0 && window.selFuncDesc != "null" && window.PRODUCT_ID) { sSelectedFuncId = getFuncIdByFuncDesc(selFuncDesc); } var oProdMenu = document.getElementById("ProdMenu"); if(oProdMenu){ genMainMenu(oProdMenu); } } catch (e) { showExcpt("MainMenu", e); } } function genMainMenu(oProdMenu){ try { if (!window.strArray) { showMsg("The FAP is invalid.", "There was a problem login in."); return; } //init variable if (LOGIN_NAME && LOGIN_NAME == "A") { isSEC = true; } else { isSEC = false; } nNoOfFuncs = strArray.length; genProdTable(oProdMenu); } catch (e) { showExcpt("MainMenu", e); } } //S The below functions copied from the upgrade document #12- Change password George //wayne add for hidden product or function 2015-08-07s var hiddenProdArray = []; //['Pid1', 'Pid2', ...] var hiddenFuncArray = []; //[['Pid1', ['Fid1', 'Fid2'...]], ['Pid2', ['Fid1', 'Fid2'...]], ...] function inHiddenProdArray(ProdID) { for (var x = 0; x < hiddenProdArray.length; x++) { if (ProdID == hiddenProdArray[x]) { return true; } } return false; } function inHiddenFuncArray(prodId, funcId) { for (var i = 0; i < hiddenFuncArray.length; i++) { if (prodId == hiddenFuncArray[i][0]) { var funcArray = hiddenFuncArray[i][1]; for (var j = 0; j < funcArray.length; j++) { if (funcId == funcArray[j]) { return true; } } } } return false; } //wayne add for hid //E The below functions copied from the upgrade document #12- Change password George /** * Generate product table * */ function genProdTable(oProdMenu){ try { //var oProdMenu = document.getElementById("ProdMenu"); //drop product menu table if (oProdMenu.firstChild) { oProdMenu.removeChild(oProdMenu.firstChild); } //create product menu table and append to product menu table cell var oProdMenuTable = document.createElement("table"); oProdMenuTable.setAttribute("id", "ProdMenuTable"); oProdMenuTable.setAttribute("cellspacing", "0"); oProdMenuTable.setAttribute("cellpadding", "0"); oProdMenuTable.className = "ProdItem"; oProdMenu.appendChild(oProdMenuTable); //create product menu table tbody var oProdMenuTableBody = document.createElement("tbody"); oProdMenuTableBody.setAttribute("id", "ProdMenuTableBody"); oProdMenuTable.appendChild(oProdMenuTableBody); var pid = oProdMenu.id; //create product rows in product menu table genProdRow(oProdMenuTableBody, pid); } catch (e) { showExcpt("MainMenu", e); } } /** * Generate product rows */ function genProdRow(oProdMenuTableBody, pid){ try { var arrProdId = new Array(); var arrProdDesc = new Array(); for (var i = 0; i < nNoOfFuncs; i++) { var sProdId = strArray[i][1]; var sProdDesc = strArray[i][11]; if (!arrProdDesc.in_array(sProdDesc)) { arrProdId.push(sProdId); arrProdDesc.push(sProdDesc); } } //add product row var narrProdDescLen = arrProdDesc.length; for (var j = 0; j < narrProdDescLen; j++) { //wayne add for hidden product or function 2015-08-07s if(inHiddenProdArray(arrProdId[j])){ continue; } //wayne add for hidden product or function 2015-08-07e var oProdRow = document.createElement("tr"); var sProdRowId = "row_" + arrProdId[j]; oProdRow.setAttribute("id", sProdRowId); var oProwCell = document.createElement("td"); var sProdCellId = "cell_" + arrProdId[j]; oProwCell.setAttribute("id", sProdCellId); var oA = document.createElement("a"); oA.setAttribute("id", arrProdId[j]); oA.setAttribute("pid", pid); oA.href = "#"; //set class to SelectedProdLink if (arrProdId[j] == sSelectedProdId) { oA.className = "SelectedProdLink"; } else { oA.className = "ProdLink"; } oA.innerHTML = arrProdDesc[j]; oA.onclick = getProdIdOnClick; oProwCell.appendChild(oA); oProdRow.appendChild(oProwCell); oProdMenuTableBody.appendChild(oProdRow); //show selected product functions if (sSelectedProdId.length > 0 && sSelectedProdId == arrProdId[j]) { genProdFunc(oProdMenuTableBody, sSelectedProdId); } } } catch (e) { showExcpt("MainMenu", e); } } /** * Generate produc functions table */ function genProdFunc(oProdTableBody, sSelectedProdId){ try { var sProdId = sSelectedProdId; var arrProdFuncsId = new Array(); //function id under this product for (var i = 0; i < nNoOfFuncs; i++) { if (strArray[i][1] == sProdId) { var sProdFuncId = strArray[i][3]; arrProdFuncsId.push(sProdFuncId); } } // var sProdRow = "row_" + sProdId; //var oProdRow = document.getElementById(sProdRow); //var oProdTableBody = oProdRow.parentNode; var oProdFuncsRow = document.createElement("tr"); oProdTableBody.appendChild(oProdFuncsRow); var oProdCell = document.createElement("td"); oProdCell.setAttribute("id", "selectedSubMenu"); oProdCell.style.paddingRight = "0px"; oProdCell.style.paddingLeft = "0px"; oProdCell.style.paddingBottom = "0px"; oProdCell.style.paddingTop = "0px"; oProdFuncsRow.appendChild(oProdCell); //product function table var oProdFuncTable = document.createElement("table"); oProdFuncTable.setAttribute("id", "ProdFuncTable"); oProdFuncTable.setAttribute("cellspacing", "0"); oProdFuncTable.setAttribute("cellpadding", "0"); oProdFuncTable.className = "FuncItem"; oProdCell.appendChild(oProdFuncTable); //product function table body var oProdFuncTableBody = document.createElement("tbody"); oProdFuncTableBody.setAttribute("id", "ProdFuncTableBody"); oProdFuncTable.appendChild(oProdFuncTableBody); //generate function rows genFuncRow(sProdId, arrProdFuncsId, oProdFuncTableBody); } catch (e) { showExcpt("MainMenu", e); } } /** * Generate produc function rows */ function genFuncRow(sProdId, arrProdFuncsId, oProdFuncTableBody){ try { var arrProdFuncItemId = new Array(); var arrProdFuncDesc = new Array(); //get func desc under this product for (var i = 0; i < nNoOfFuncs; i++) { //var sProdId = strArray[i][1]; var sProdFuncItemId = strArray[i][5]; var sProdFuncDesc = strArray[i][12]; if (strArray[i][1] == sProdId) { arrProdFuncItemId.push(sProdFuncItemId); arrProdFuncDesc.push(sProdFuncDesc); } } //add product row var narrProdFuncsIdLen = arrProdFuncsId.length; for (var j = 0; j < narrProdFuncsIdLen; j++) { //wayne add for hidden product or function 2015-08-07s if(inHiddenFuncArray(sProdId, arrProdFuncsId[j])) continue; //wayne add for hidden product or function 2015-08-07e var oProdFuncRow = document.createElement("tr"); var sProdFuncRowId = "funcrow_" + arrProdFuncsId[j]; oProdFuncRow.setAttribute("id", sProdFuncRowId); var oProdFuncCell = document.createElement("td"); var sProdFuncCellId = "funccell_" + arrProdFuncsId[j]; oProdFuncCell.style.paddingRight = "25px"; //Changed by Syed --old value 0px oProdFuncCell.style.paddingLeft = "23px";//Changed by Syed --old value 14px oProdFuncCell.setAttribute("id", sProdFuncCellId); var oA = document.createElement("a"); oA.setAttribute("id", arrProdFuncsId[j]); oA.href = "#"; if (arrProdFuncsId[j] == sSelectedFuncId) { oA.className = "SelectedFuncLink"; } else { oA.className = "FuncLink"; } oA.innerHTML = arrProdFuncDesc[j]; oA.onclick = getFuncIdOnClick; oProdFuncCell.appendChild(oA); oProdFuncRow.appendChild(oProdFuncCell); oProdFuncTableBody.appendChild(oProdFuncRow); } } catch (e) { showExcpt("MainMenu", e); } } /** * Get product id for product onclick and then generate product menu */ function getProdIdOnClick(evt){ try { var obj = getEvtTarget(evt); var sProdId = obj.id; if (sSelectedProdId == sProdId) { var funcs = document.getElementById("selectedSubMenu"); var status = funcs.style.display; if ("none" == status) { funcs.style.display = "block"; } else { funcs.style.display = "none"; } } else { var selected = sSelectedProdId; sSelectedProdId = sProdId; var pid = obj.getAttribute("pid"); genProdTable(document.getElementById(pid)); } } catch (e) { showExcpt("MainMenu", e); } } /** * Get function id for function onclick and then call funcItemClick() */ function getFuncIdOnClick(evt){ try { var obj = getEvtTarget(evt); var sFuncId = obj.id; sSelectedFuncId = sFuncId; //click function on main menu in the trx, show confirmation msg first if (!isSEC && (window.SYS_FUNCTION_NAME && window.SYS_FUNCTION_NAME.length > 0)) { var bIsView = false; if (SYS_FUNCTION_NAME.indexOf("View") != -1) { bIsView = true; } if (bIsView || isRptFunc) { _funcItemClick(sSelectedFuncId); } else { var isCancel = window.confirm("Data will not be saved if you proceed."); if (isCancel) { _funcItemClick(sSelectedFuncId); } } } else { //disable fields if it is CSX to CE msg func if (window.ITEM_ID) { if (ITEM_ID == "STPDemerge") { var oForm = document.forms["MAINFORM"]; if(oForm.C_PROC_INFO){ oForm.C_PROC_INFO.disabled = true; } if(oForm.C_MSG_CONTENT){ oForm.C_MSG_CONTENT.disabled = true; } if(oForm.C_NEW_MSG_CONTENT){ oForm.C_NEW_MSG_CONTENT.disabled = true; } } } _funcItemClick(sSelectedFuncId); } } catch (e) { showExcpt("MainMenu", e); } } /** * Get function id by function description */ function getFuncIdByFuncDesc(sFuncDesc){ try { for (var i = 0; i < strArray.length; i++) { if (strArray[i][12] == sFuncDesc && strArray[i][1] == PRODUCT_ID) { var sFuncId = strArray[i][3]; return sFuncId; } } } catch (e) { showExcpt("MainMenu", e); } } /** * Get function description by function id */ function getFuncDescByFuncId(sFuncId){ try { for (var i = 0; i < nNoOfFuncs; i++) { if (strArray[i][3] == sFuncId) { var sFuncDesc = strArray[i][12]; return sFuncDesc; } } } catch (e) { showExcpt("MainMenu", e); } } /** * Get function description by function name */ function getFuncDescByFuncNm(sFuncNm){ try { for (var i = 0; i < nNoOfFuncs; i++) { if (strArray[i][4] == sFuncNm) { var sFuncDesc = strArray[i][12]; return sFuncDesc; } } } catch (e) { showExcpt("MainMenu", e); } }