/** * 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); } if(window.menuDefineJson){ // genSCFMenu(); } } 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); } } /** * Generate product table * */ function genProdTable(oProdMenu){ try { //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++) { 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; //oA.onmouseenter = getProdIdOnClick; //gouse oProwCell.appendChild(oA); oProdRow.appendChild(oProwCell); oProdMenuTableBody.appendChild(oProdRow); //show selected product functions $("a#"+arrProdId[j]).addClass("folder-close"); if (sSelectedProdId.length > 0 && sSelectedProdId == arrProdId[j]) { genProdFunc(oProdMenuTableBody, sSelectedProdId); $("a#"+arrProdId[j]).addClass("folder-open"); } /*//gouse for test s $(document).mouseup(function (e){ var sEE = $("#menuDiv"); if(!sEE.is(e.target) && sEE.has(e.target).length ===0) { }else{ sEE.hide(); } }); //gouse for test e*/ } //oA.mouseleave = document.getElementById('menuDiv').style.display = 'none'; } 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); /*//gouse for test s var div = document.createElement('div'); div.setAttribute("id", "menuDiv"); div.style.cssText = 'width: 250px; height: 100%; background: white; cursor: default; padding: 20px; position: fixed; top:0; bottom: 0; left: 250; right:1000; text-align:left; vertical-align: bottom; z-index:999; line-height: 3;'; div.setAttribute("onmouseleave", "div.style.display:none"); div.appendChild(oProdFuncTableBody); document.body.appendChild(div); //gouse for test e*/ //generate function rows genFuncRow(sProdId, arrProdFuncsId, oProdFuncTableBody); } catch (e) { showExcpt("MainMenu", e); } } /** * Generate produc function rows */ function genFuncRow(sProdId, arrProdFuncsId, oProdFuncTableBody){ try { /*//gouse for test s var sEE = document.getElementById('menuDiv'); $(document).ready(function(){ sEE.style.display = 'none'; }); //gouse for test e*/ 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++) { 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 = "0px"; oProdFuncCell.style.paddingLeft = "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); /*//gouse for test s var sEE = document.getElementById('menuDiv'); $(document).ready(function(){ sEE.style.display = 'none'; }); //gouse for test e*/ } } 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"; $("a#"+sProdId).removeClass("folder-close"); $("a#"+sProdId).addClass("folder-open"); } else { funcs.style.display = "none"; $("a#"+sProdId).removeClass("folder-open"); $("a#"+sProdId).addClass("folder-close"); } } else { var selected = sSelectedProdId; sSelectedProdId = sProdId; var pid = obj.getAttribute("pid"); genProdTable(document.getElementById(pid)); $("a#"+sProdId).removeClass("folder-close"); $("a#"+sProdId).addClass("folder-open"); } } 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"]; oForm.C_PROC_INFO.disabled = true; //oForm.C_MSG_CONTENT.disabled = true; //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); } } function genSCFMenu(){ $("#ARFProdMenu").html(""); $.each(menuDefineJson,function(i,a){ //alert(a["@desc"]); $("#topul").append("
  • "+a["@desc"]+"
  • "); $.each(a.item, function (j,b){ $("#"+a["@desc"]).append(""); //alert(b["@desc"]); $.each(b.item, function (k,c){ //alert(c["@desc"]); } ) } ) }); }