/*global $, alert, g_cus, g_de, g_api, g_db, g_ul, btoa, console, i18n */
var g_gd = {
webapiurl: "/api/Cmd/GetData",
// webapiurl: "/CmdF/GetData",
debugmode: true,
projectname: "CHIPMOS",
relpath: "/Main",
debugmode: window.location.host === '192.168.119.110',
debugcolor: "#732C6B"
};
var g_ul = {
/**
* Get form data and do db ui check
* @method GetFormParameters
* @param {String} i_sFormName 表單名稱
* @return {Object} Dictionary
*/
GetFormParameters: function (i_sFormName) {
'use strict';
var aData = $('#' + i_sFormName).serializeArray(),
aDisableData = $('#' + i_sFormName + " :disabled"),
dicData = {},
idx,
obj;
for (idx in aData) {
if (aData.hasOwnProperty(idx)) {
obj = aData[idx];
//if (obj.value.length !== 0) {
// dicData[obj.name] = obj.value;
//}
dicData[obj.name] = obj.value;
//dicData[obj.name] = (0 === obj.value.length) ? null : obj.value;
}
}
// Handle Disalbe
for (idx in aDisableData) {
if (aDisableData.hasOwnProperty(idx)) {
obj = aDisableData[idx];
if (typeof (obj.name) !== 'undefined' && typeof (obj.value) !== 'undefined') {
dicData[obj.name] = obj.value;
}
}
}
return dicData;
},
/**
* Get form data and do db ui check
* @method GetFormParameters
* @param {String} i_sFormName 表單名稱
* @return {Object} Dictionary
*/
ClearFormParameters: function (i_sFormName) {
'use strict';
var aData = $("#" + i_sFormName).serializeArray();
$.each(aData, function (idx, value) {
$("#" + value.name).val("");
});
},
/**
* Get token from db
* @returns {String} Token in localStorage
*/
GetToken: function () {
'use strict';
return g_db.GetItem("token");
},
/**
* Set token to db
* @param {String} sTokenValue api token
*/
SetToken: function (sTokenValue) {
'use strict';
g_db.SetItem("token", sTokenValue);
},
SetLang: function (sLang) {
'use strict';
g_db.SetItem("lang", sLang);
},
GetLang: function (sLang) {
'use strict';
return g_db.GetItem("lang");
},
/**
* Get trace stack
*/
TraceStackDump: function () {
var dicTraceStackData = {},
dicTraceStackDataLevel = {},
ldicTraceStackDataList = [],
curArguments = null,
iLevel = 0,
iIdx = 0,
iLim = 0,
oPara = null,
bFindButtonEvent = false;
curArguments = arguments;
do {
dicTraceStackDataLevel = {};
dicTraceStackDataLevel.name = curArguments.callee.name;
dicTraceStackDataLevel.parameters = [];
iLim = curArguments.length;
if (iLim > 0) {
oPara = curArguments["0"];
if (typeof (oPara) === "object" && oPara.hasOwnProperty("currentTarget")) {
bFindButtonEvent = true;
dicTraceStackDataLevel.buttonclick = oPara.currentTarget.id;
}
else {
for (iIdx = 0; iIdx < iLim; iIdx++) {
oPara = curArguments[iIdx.toString()];
dicTraceStackDataLevel.parameters.push(curArguments[iIdx.toString()]);
}
}
}
if (iLevel > 0) {
ldicTraceStackDataList.push($.extend({}, dicTraceStackDataLevel));
}
if (curArguments.callee.caller === null) {
break;
}
curArguments = curArguments.callee.caller.arguments;
iLevel = iLevel + 1;
}
while (bFindButtonEvent === false);
dicTraceStackData.stack = ldicTraceStackDataList;
return dicTraceStackData;
}
};
var g_api = {
ConnectLiteWithToken: function (i_sModuleName, i_sFuncName, i_dicData, i_sSuccessFunc, i_FailFunc, i_bAsyn) {
this.ConnectLiteWithoutToken(i_sModuleName, i_sFuncName, i_dicData, i_sSuccessFunc, i_FailFunc, i_bAsyn);
},
ConnectLite: function (i_sModuleName, i_sFuncName, i_dicData, i_sSuccessFunc, i_FailFunc, i_bAsyn) {
this.ConnectLiteWithToken(i_sModuleName, i_sFuncName, i_dicData, i_sSuccessFunc, i_FailFunc, i_bAsyn);
},
ConnectLiteWithoutToken: function (i_sModuleName, i_sFuncName, i_dicData, i_sSuccessFunc, i_FailFunc, i_bAsyn) {
var dicData = {},
dicParameters = {},
token = g_ul.GetToken();
dicParameters.MODULE = i_sModuleName;
dicParameters.PROJECT = g_gd.PROJECT;
dicParameters.PROJECTVER = g_gd.PROJECTVER;
dicParameters.TYPE = i_sFuncName;
dicParameters.TRACEDUMP = null; // g_ul.TraceStackDump();
dicParameters.DATA = i_dicData;
if (token !== null) {
dicParameters.TOKEN = token;
}
dicParameters.CUSTOMDATA = {};
if (localStorage.getItem('program_id') !== null) {
dicParameters.CUSTOMDATA.program_id = localStorage.getItem('program_id');
}
if (localStorage.getItem('module_id')) {
dicParameters.CUSTOMDATA.module_id = localStorage.getItem('module_id');
}
if (g_cus.GetUserInfo() !== null) {
dicParameters.CUSTOMDATA.user_id = g_cus.GetUserInfo().user_id;
dicParameters.CUSTOMDATA.dept_id = g_cus.GetUserInfo().dept_id;
dicParameters.CUSTOMDATA.role_id = localStorage.getItem('roleid');
}
/// Test Only
//dicParameters.CUSTOMDATA.program_id = "accountmanage";
//dicParameters.CUSTOMDATA.role_id = "admin";
dicData.url = i_dicData.hasOwnProperty("url") ? i_dicData.url : g_gd.webapiurl;
dicData.successfunc = i_sSuccessFunc;
dicData.dicparameters = dicParameters;
dicData.failfunc = ("function" === typeof (i_FailFunc)) ? i_FailFunc : function (jqXHR, textStatus, errorThrown) {
g_de.Alert("ConnectLite Fail jqXHR:" + jqXHR + " textStatus:" + textStatus + " errorThrown:" + errorThrown);
};
dicData.useasync = ("boolean" === typeof (i_bAsyn)) ? i_bAsyn : true;
this.AjaxPost(dicData);
},
AjaxPost: function (i_dicData) {
'use strict';
var defaultOption = {
useasync: true,
successfunc: null,
failfunc: null,
alwaysfunc: null,
url: null,
dicparameters: null
},
runOption = $.extend(defaultOption, i_dicData);
if (true !== runOption.useasync) {
$.ajax({
type: 'POST',
url: runOption.url,
data: "=" + btoa2(encodeURIComponent(JSON.stringify(runOption.dicparameters))),
success: runOption.successfunc,
error: runOption.failfunc,
async: false
}).always(runOption.alwaysfunc);
} else {
$.post(runOption.url,
"=" + btoa2(encodeURIComponent(JSON.stringify(runOption.dicparameters))))
.done(runOption.successfunc)
.fail(runOption.failfunc)
.always(runOption.alwaysfunc);
}
}
};
var g_de = {
isInit: false,
init: function () {
'use strict';
var self = this;
if (false === this.isInit) {
self.isInit = true;
}
},
/**
* Write log to debug area
* @method Log
* @param {String} msg [Message to dump]
*/
Log: function (msg) {
'use strict';
var v = "[" + new Date() + "] " + msg + "\r\n";
this.init();
$('#txtDebugArea', parent.document).append(v);
console.log(v);
},
Alert: function (msg) {
'use strict';
var v = "Alert [" + new Date() + "] " + msg + "\r\n";
this.init();
$('#txtError').append(v);
console.log(v);
//alert(v);
}
};
var g_db = {
/**
* Check the capability
* @private
* @method SupportLocalStorage
* @return {Object} description
*/
SupportLocalStorage: function () {
'use strict';
return typeof (localStorage) !== "undefined";
},
/**
* Insert data
* @private
* @method SetItem
* @param {Object} sKey
* @param {Object} sValue
* @return {Object} description
*/
SetItem: function (sKey, sValue) {
'use strict';
var bRes = false;
if (this.SupportLocalStorage()) {
localStorage.setItem(sKey, sValue);
bRes = true;
}
return bRes;
},
/**
* Fetch data
* @private
* @method GetItem
* @param {Object} sKey
* @return {Object} description
*/
GetItem: function (sKey) {
'use strict';
var sRes = null;
if (this.SupportLocalStorage()) {
sRes = localStorage.getItem(sKey);
}
return sRes;
},
/**
* Remove data
* @private
* @method RemoveItem
* @param {Object} sKey
* @return {Object} description
*/
RemoveItem: function (sKey) {
'use strict';
var bRes = false;
if (this.SupportLocalStorage()) {
localStorage.removeItem(sKey);
bRes = true;
}
return bRes;
},
/**
* Description for GetDic
* @private
* @method GetDic
* @return {Object} description
*/
GetDic: function (sKey) {
'use strict';
var dicRes = {},
vTemp;
if (this.SupportLocalStorage()) {
vTemp = localStorage.getItem(sKey);
if (null !== vTemp) {
dicRes = JSON.parse(vTemp);
}
}
return dicRes;
},
/**
* Description for SetDic
* @private
* @method SetDic
* @return {Object} description
*/
SetDic: function (sKey, dicValue) {
'use strict';
var bRes = false;
if (this.SupportLocalStorage()) {
localStorage.setItem(sKey, JSON.stringify(dicValue));
bRes = true;
}
return bRes;
}
};
var g_cus = {
FocusFirstComponent: function () {
var obj = $("input:visible:enabled");
if (obj.length > 0) {
obj[0].focus();
}
},
HotKeyDisableFlag: false,
Buttons: {
PageBtn: [{
id: 'btnFirst',
"data-i18n": "common.first",
hotkey: "f"
}, {
id: 'btnPrev',
"data-i18n": "common.previous",
hotkey: "p"
}, {
id: 'btnJump',
"data-toggle": "modal",
"data-i18n": "common.jump",
hotkey: "j"
}, {
id: 'btnNext',
"data-i18n": "common.next",
hotkey: "n"
}, {
id: 'btnLast',
"data-i18n": "common.last",
hotkey: "l"
}],
GridPageBtn: [{
id: 'btnFirst',
"data-i18n": "pager.first",
hotkey: "f"
}, {
id: 'btnPrev',
"data-i18n": "pager.previous",
hotkey: "p"
}, {
id: 'btnNext',
"data-i18n": "pager.next",
hotkey: "n"
}, {
id: 'btnLast',
"data-i18n": "pager.last",
hotkey: "l"
}],
ConfirmBtn: [{
id: 'btnOK',
"data-i18n": "common.ok",
hotkey: "ctrl + enter"
}, {
id: 'btnCancel',
"data-i18n": "common.cancel",
hotkey: "esc"
}],
Master1DetailBtn: [{
id: 'btnMaster', //單頭
'data-i18n': 'common.master',
hotkey: "m"
}, {
id: 'btnSingle', //單身
'data-i18n': 'common.single',
hotkey: "s"
}],
Master2DetailBtn: [{
id: 'btnMaster',
'data-i18n': 'common.master',
hotkey: "m"
}, {
id: 'btnSingle1',
'data-i18n': 'common.detail1',
hotkey: "s"
}, {
id: 'btnSingle2',
'data-i18n': 'common.detail2',
hotkey: "a"
}]
},
commonActionHokey: {
'btnQuery': 'q',
'btnAdd': 'f1',
'btnUpd': 'u',
'btnDel': 'f2',
'btnDisable': 'x',
'btnCopy': 'c',
'btnExport': 'o'
},
DisableHotkeyDom: function (dom) {
dom.focus(function () {
g_cus.HotKeyDisableFlag = true;
});
dom.focusout(function () {
g_cus.HotKeyDisableFlag = false;
})
},
GetProgramID: function () {
return localStorage.getItem('program_id');
},
IsEditModeBtn: function (lWholeBtns, i_sID) {
var bRes = false;
for (sKey1 in lWholeBtns) {
if (lWholeBtns.hasOwnProperty(sKey1)) {
oData1 = lWholeBtns[sKey1];
if (oData1.id !== i_sID) {
continue;
}
if (oData1.hasOwnProperty("edit") === true && oData1.edit === true) {
bRes = true;
break;
}
}
}
return bRes;
},
FixHokeyData: function (lOriginBtns, lWholeBtns) {
var lRes = [],
sKey1 = null,
oData1 = null,
dicWholeBtns = {};
for (sKey1 in lWholeBtns) {
if (lWholeBtns.hasOwnProperty(sKey1)) {
oData1 = lWholeBtns[sKey1];
if (oData1.hasOwnProperty("hotkey") === true) {
dicWholeBtns[oData1.id] = oData1.hotkey;
}
}
}
for (sKey1 in lOriginBtns) {
if (lOriginBtns.hasOwnProperty(sKey1)) {
oData1 = lOriginBtns[sKey1];
// Hotkey Priority: JS > Default
if (dicWholeBtns.hasOwnProperty(oData1.id) === true) {
oData1.hotkey = dicWholeBtns[oData1.id];
}
else if (this.commonActionHokey.hasOwnProperty(oData1.id) === true) {
oData1.hotkey = this.commonActionHokey[oData1.id];
}
lRes.push(oData1);
}
}
return lRes;
},
datetimePickerInitInfo: {
orientation: "top auto",
autoclose: true,
dateFormat: 'yy/mm/dd',
dayNames: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
dayNamesMin: ["日", "一", "二", "三", "四", "五", "六"],
monthNames: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
monthNamesShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
prevText: "上月",
nextText: "次月",
weekHeader: "週",
showMonthAfterYear: true
},
ParseDateTime: function (i_sDataString) {
var nIdx = -1,
sOperation = "",
sDateString = "",
sRes = i_sDataString;
do {
if (i_sDataString === null || i_sDataString.trim().length === 0) {
break;
}
nIdx = i_sDataString.match(/\d/);
if (nIdx !== null && nIdx.index !== 0) {
sOperation = i_sDataString.substr(0, nIdx.index);
sDateString = new Date(i_sDataString.substr(nIdx.index)).formate("yyyy/MM/dd HH:mm:ss");
sRes = sOperation + sDateString;
}
else {
sRes = new Date(i_sDataString).formate("yyyy/MM/dd HH:mm:ss");
}
}
while (false);
return sRes;
},
dicDefaultActions: {
btncreate: function () {
'use strict';
alert("No Create");
},
btndelete: function () {
'use strict';
alert("No Delete");
},
btnupdate: function () {
'use strict';
alert("No Update");
},
btnread: function () {
'use strict';
alert("No Read");
},
btnmark: function () {
'use strict';
alert("No Mark");
}
},
/**
* Multilanguage
* @param {String} lng Locale name
*/
ChangLang: function (lng, fpCallback) {
'use strict';
var dtNow = (new Date()).getTime(),
i18NOptions = {
useLocalStorage: true,
localStorageExpirationTime: 60,
lng: lng,
fallbackLng: [],
resGetPath: '/Main/Scripts/lang/__lng__.js?' + dtNow,
useCookie: false,
debug: false,
load: 'current'
};
g_ul.SetLang(lng);
i18n.init(i18NOptions, function () {
try {
g_cus.RefreshLang();
if ($.isFunction(fpCallback) === true) {
fpCallback(i18n);
}
} catch (e) {
alert(e);
}
});
},
/**
* Refresh all languageid. Attention: Need to call after ChangeLang callback
*/
RefreshLang: function () {
'use strict';
$("body").i18n();
$("input[placeholderid]").each(function (num, ele) {
$(ele).removeAttr("placeholder");
$(ele).attr("placeholder", i18n.t($(ele).attr("placeholderid")));
});
},
LoadBasicJSCSS: function (relpath, i_sCSSFiles, i_sJSFiles) {
'use strict';
var dtNow = (new Date()).getTime(),
//loadCSS = function (href) {
// var cssLink = $("");
// $("head").append(cssLink);
//},
//loadJS = function (src) {
// var jsLink = $("";
}
else if (Array[i].filetype == "css") { //if filename is an external CSS file
item += ""
}
}
$("head").append(item);
};
var array = [];
array.push({ href: "/Scripts/3rd/assets/plugins/jquery-ui/jquery-ui.min.css", filetype: "css" });
array.push({ href: "/Scripts/3rd/assets/css/font.css", filetype: "css" });
array.push({ href: "/Scripts/3rd/assets/plugins/pace-master/themes/blue/pace-theme-flash.css", filetype: "css" });
array.push({ href: "/Scripts/3rd/assets/plugins/uniform/css/uniform.default.min.css", filetype: "css" });
array.push({ href: "/Scripts/3rd/assets/plugins/bootstrap/css/bootstrap.min.css", filetype: "css" });
array.push({ href: "/Scripts/3rd/assets/plugins/fontawesome/css/font-awesome.css", filetype: "css" });
array.push({ href: "/Scripts/3rd/assets/plugins/line-icons/simple-line-icons.css", filetype: "css" });
array.push({ href: "/Scripts/3rd/assets/plugins/offcanvasmenueffects/css/menu_cornerbox.css", filetype: "css" });
array.push({ href: "/Scripts/3rd/assets/plugins/waves/waves.min.css", filetype: "css" });
array.push({ href: "/Scripts/3rd/assets/plugins/switchery/switchery.min.css", filetype: "css" });
array.push({ href: "/Scripts/3rd/assets/plugins/3d-bold-navigation/css/style.css", filetype: "css" });
array.push({ href: "/Scripts/3rd/assets/plugins/toastr/toastr.min.css", filetype: "css" });
array.push({ href: "/Scripts/3rd/assets/css/jquery.contextMenu.css", filetype: "css" });
//array.push({ href: "/Scripts/3rd/assets/css/screen.css", filetype: "css" });
array.push({ href: "/Scripts/3rd/assets/css/modern.min.css", filetype: "css" });
array.push({ href: "/Scripts/3rd/assets/css/themes/green.css", filetype: "css" });
array.push({ href: "/Scripts/3rd/assets/css/custom.css", filetype: "css" });
array.push({ href: "/Scripts/3rd/assets/css/flexigrid.css", filetype: "css" });
array.push({ href: "/Scripts/3rd/assets/css/flexigrid.pack.css", filetype: "css" });
//// Styles
//loadCSS("/Scripts/3rd/assets/plugins/jquery-ui/jquery-ui.min.css");
//loadCSS("/Scripts/3rd/assets/css/font.css");
//loadCSS("/Scripts/3rd/assets/plugins/pace-master/themes/blue/pace-theme-flash.css");
//loadCSS("/Scripts/3rd/assets/plugins/uniform/css/uniform.default.min.css");
//loadCSS("/Scripts/3rd/assets/plugins/bootstrap/css/bootstrap.min.css");
//loadCSS("/Scripts/3rd/assets/plugins/fontawesome/css/font-awesome.css");
//loadCSS("/Scripts/3rd/assets/plugins/line-icons/simple-line-icons.css");
//loadCSS("/Scripts/3rd/assets/plugins/offcanvasmenueffects/css/menu_cornerbox.css");
//loadCSS("/Scripts/3rd/assets/plugins/waves/waves.min.css");
//loadCSS("/Scripts/3rd/assets/plugins/switchery/switchery.min.css");
//loadCSS("/Scripts/3rd/assets/plugins/3d-bold-navigation/css/style.css");
//loadCSS("/Scripts/3rd/assets/plugins/toastr/toastr.min.css");
//// Theme Styles
////loadCSS("/Scripts/3rd/assets/css/modern.min.css");
//loadCSS("/Scripts/3rd/assets/css/themes/green.css");
//loadCSS("/Scripts/3rd/assets/css/custom.css");
////各頁面請拿掉重複檔案
//loadCSS('/Scripts/3rd/assets/css/flexigrid.css');
//loadCSS('/Scripts/3rd/assets/css/flexigrid.pack.css');
if ($.isArray(i_sCSSFiles) === true) {
$.each(i_sCSSFiles, function (idx, value) {
// loadCSS(value);
array.push({ href: value, filetype: "css" });
});
}
array.push({ href: "/Scripts/3rd/base64.js", filetype: "js" });
array.push({ href: "/Scripts/3rd/assets/plugins/3d-bold-navigation/js/modernizr.js", filetype: "js" });
array.push({ href: "/Scripts/3rd/assets/plugins/offcanvasmenueffects/js/snap.svg-min.js", filetype: "js" });
array.push({ href: "/Scripts/3rd/i18next-1.10.1.min.js", filetype: "js" });
array.push({ href: "/Scripts/3rd/assets/plugins/jquery-ui/jquery-ui.min.js", filetype: "js" });
array.push({ href: "/Scripts/3rd/assets/plugins/pace-master/pace.min.js", filetype: "js" });
array.push({ href: "/Scripts/3rd/assets/plugins/jquery-blockui/jquery.blockui.js", filetype: "js" });
array.push({ href: "/Scripts/3rd/assets/plugins/bootstrap/js/bootstrap.min.js", filetype: "js" });
array.push({ href: "/Scripts/3rd/assets/plugins/jquery-slimscroll/jquery.slimscroll.min.js", filetype: "js" });
array.push({ href: "/Scripts/3rd/assets/plugins/switchery/switchery.min.js", filetype: "js" });
array.push({ href: "/Scripts/3rd/assets/plugins/uniform/jquery.uniform.min.js", filetype: "js" });
array.push({ href: "/Scripts/3rd/assets/plugins/offcanvasmenueffects/js/classie.js", filetype: "js" });
array.push({ href: "/Scripts/3rd/assets/plugins/waves/waves.min.js", filetype: "js" });
array.push({ href: "/Scripts/3rd/assets/plugins/toastr/toastr.min.js", filetype: "js" });
array.push({ href: "/Scripts/3rd/assets/js/modern.min.js", filetype: "js" });
array.push({ href: "/Scripts/3rd/ResizeSensor.js", filetype: "js" });
array.push({ href: "/Scripts/3rd/assets/plugins/jquery-validation/jquery.validate.min.js", filetype: "js" });
array.push({ href: "/Scripts/GlobalSetting.js", filetype: "js" });
array.push({ href: "/Scripts/lib/widget/CommPop_m.js", filetype: "js" });
array.push({ href: "/Scripts/lib/widget/CommPop_s.js", filetype: "js" });
array.push({ href: "/Scripts/lib/widget/Footer.js", filetype: "js" });
array.push({ href: "/Scripts/lib/widget/PageTitle.js", filetype: "js" });
array.push({ href: "/Scripts/lib/widget/QuestPop.js", filetype: "js" });
array.push({ href: "/Scripts/lib/widget/StateBar.js", filetype: "js" });
array.push({ href: "/Scripts/lib/widget/ToolBar2.js", filetype: "js" });
array.push({ href: "/Scripts/3rd/linq.js", filetype: "js" });
array.push({ href: "/Scripts/3rd/jquery.page.js", filetype: "js" });
array.push({ href: "/Scripts/3rd/flexigrid.js", filetype: "js" });
array.push({ href: "/Scripts/3rd/jquery.contextMenu.js", filetype: "js" });
array.push({ href: "/Scripts/3rd/jquery.ui.position.min.js", filetype: "js" });
array.push({ href: "/Scripts/lib/widget/Grid.js", filetype: "js" });
array.push({ href: "/Scripts/lib/widget/Profile.js", filetype: "js" });
array.push({ href: "/Scripts/lib/widget/frozen.js", filetype: "js" });
//// loadJS
//loadJS("/Scripts/3rd/base64.js");
//loadJS("/Scripts/3rd/assets/plugins/3d-bold-navigation/js/modernizr.js");
//loadJS("/Scripts/3rd/assets/plugins/offcanvasmenueffects/js/snap.svg-min.js");
//loadJS("/Scripts/3rd/i18next-1.10.1.min.js");
//loadJS("/Scripts/3rd/assets/plugins/jquery-ui/jquery-ui.min.js");
//loadJS("/Scripts/3rd/assets/plugins/pace-master/pace.min.js");
//loadJS("/Scripts/3rd/assets/plugins/jquery-blockui/jquery.blockui.js");
//loadJS("/Scripts/3rd/assets/plugins/bootstrap/js/bootstrap.min.js");
//loadJS("/Scripts/3rd/assets/plugins/jquery-slimscroll/jquery.slimscroll.min.js");
//loadJS("/Scripts/3rd/assets/plugins/switchery/switchery.min.js");
//loadJS("/Scripts/3rd/assets/plugins/uniform/jquery.uniform.min.js");
//loadJS("/Scripts/3rd/assets/plugins/offcanvasmenueffects/js/classie.js");
//loadJS("/Scripts/3rd/assets/plugins/waves/waves.min.js");
//loadJS("/Scripts/3rd/assets/plugins/toastr/toastr.min.js");
//loadJS("/Scripts/3rd/assets/js/modern.min.js");
//loadJS("/Scripts/3rd/assets/plugins/jquery-validation/jquery.validate.min.js");
//loadJS("/Scripts/GlobalSetting.js");
//loadJS("/Scripts/lib/widget/CommPop_m.js");
//loadJS("/Scripts/lib/widget/CommPop_s.js");
//loadJS("/Scripts/lib/widget/Footer.js");
//loadJS("/Scripts/lib/widget/PageTitle.js");
//loadJS("/Scripts/lib/widget/QuestPop.js");
//loadJS("/Scripts/lib/widget/StateBar.js");
//loadJS("/Scripts/lib/widget/ToolBar2.js");
//loadJS("/Scripts/3rd/linq.js");
////各頁面請拿掉重複檔案
//loadJS('/Scripts/3rd/jquery.page.js');
//loadJS('/Scripts/3rd/flexigrid.js');
//loadJS('/Scripts/lib/widget/Grid.js');
//loadJS('/Scripts/lib/widget/Profile.js');
// Add block effect
if ($.isArray(i_sJSFiles) === true) {
$.each(i_sJSFiles, function (idx, value) {
//loadJS(value);
array.push({ href: value, filetype: "js" });
});
}
loadjscssfile(array);
$(document).ajaxStart(this.OpenBlock).ajaxStop(this.CloseBlock);
},
OpenBlock: function () {
if (window === window.parent) {
if (window.hasOwnProperty("OpenBlock") === true) {
window.OpenBlock();
}
else {
$.blockUI.defaults.css = {
padding: 0,
margin: 0,
width: '30%',
top: '41%',
left: '35%',
textAlign: 'center',
cursor: 'wait'
};
$.blockUI({ message: "", css: { color: "#FFF" } });
}
}
else {
//$(window.parent.document).blockUI();
window.parent.OpenBlock();
}
},
OpenBlock: function () {
if (window === window.parent) {
if (window.hasOwnProperty("OpenBlock") === true) {
window.OpenBlock();
}
else {
$.blockUI.defaults.css = {
padding: 0,
margin: 0,
width: '30%',
top: '41%',
left: '35%',
textAlign: 'center',
cursor: 'wait'
};
$.blockUI({ message: "
", css: { color: "#FFF" } });
}
}
else {
//$(window.parent.document).blockUI();
window.parent.OpenBlock();
}
},
CloseBlock: function () {
if (window === window.parent) {
if (window.hasOwnProperty("CloseBlock") === true) {
window.CloseBlock();
}
else {
$.unblockUI();
}
}
else {
window.parent.CloseBlock();
}
},
SetupBorcaseRevicer: function (i_sUserName) {
var chat = $.connection.codingChatHub;
// 建立連線後,我們接著來定義 client 端的 function 來讓 Server 端的 hub 呼叫。
chat.client.hello = function (message) {
alert(message)
}
chat.client.sendAllMessge = function (message) {
alert(message)
}
// 將連線打開
$.connection.hub.start();
},
dynamicHokeyEnable: true,
dynamicHokeySelectorMap : {},
KeyCodeConvert: function (e) {
var keyMapping = {
3: "break",
8: "backspace / delete",
9: "tab",
12: 'clear',
13: "enter",
16: "shift",
17: "ctrl ",
18: "alt",
19: "pause/break",
20: "caps lock",
27: "escape",
32: "spacebar",
33: "page up",
34: "page down",
35: "end",
36: "home ",
37: "left arrow ",
38: "up arrow ",
39: "right arrow",
40: "down arrow ",
41: "select",
42: "print",
43: "execute",
44: "Print Screen",
45: "insert ",
46: "delete",
48: "0",
49: "1",
50: "2",
51: "3",
52: "4",
53: "5",
54: "6",
55: "7",
56: "8",
57: "9",
58: ":",
59: "semicolon (firefox), equals",
60: "<",
61: "equals (firefox)",
63: "ß",
64: "@ (firefox)",
65: "a",
66: "b",
67: "c",
68: "d",
69: "e",
70: "f",
71: "g",
72: "h",
73: "i",
74: "j",
75: "k",
76: "l",
77: "m",
78: "n",
79: "o",
80: "p",
81: "q",
82: "r",
83: "s",
84: "t",
85: "u",
86: "v",
87: "w",
88: "x",
89: "y",
90: "z",
91: "Windows Key / Left ⌘ / Chromebook Search key",
92: "right window key ",
93: "Windows Menu / Right ⌘",
96: "numpad 0 ",
97: "numpad 1 ",
98: "numpad 2 ",
99: "numpad 3 ",
100: "numpad 4 ",
101: "numpad 5 ",
102: "numpad 6 ",
103: "numpad 7 ",
104: "numpad 8 ",
105: "numpad 9 ",
106: "multiply ",
107: "add",
108: "numpad period (firefox)",
109: "subtract ",
110: "decimal point",
111: "divide ",
112: "f1 ",
113: "f2 ",
114: "f3 ",
115: "f4 ",
116: "f5 ",
117: "f6 ",
118: "f7 ",
119: "f8 ",
120: "f9 ",
121: "f10",
122: "f11",
123: "f12",
124: "f13",
125: "f14",
126: "f15",
127: "f16",
128: "f17",
129: "f18",
130: "f19",
131: "f20",
132: "f21",
133: "f22",
134: "f23",
135: "f24",
144: "num lock ",
145: "scroll lock",
160: "^",
161: '!',
163: "#",
164: '$',
165: 'ù',
166: "page backward",
167: "page forward",
169: "closing paren (AZERTY)",
170: '*',
171: "~ + * key",
173: "minus (firefox), mute/unmute",
174: "decrease volume level",
175: "increase volume level",
176: "next",
177: "previous",
178: "stop",
179: "play/pause",
180: "e-mail",
181: "mute/unmute (firefox)",
182: "decrease volume level (firefox)",
183: "increase volume level (firefox)",
186: "semi-colon / ñ",
187: "equal sign ",
188: "comma",
189: "dash ",
190: "period ",
191: "forward slash / ç",
192: "grave accent / ñ",
193: "?, / or °",
194: "numpad period (chrome)",
219: "open bracket ",
220: "back slash ",
221: "close bracket ",
222: "single quote ",
223: "`",
224: "left or right ⌘ key (firefox)",
225: "altgr",
226: "< /git >",
230: "GNOME Compose Key",
233: "XF86Forward",
234: "XF86Back",
255: "toggle touchpad"
},
sKey = keyMapping[e.keyCode],
btn = null;
if (sKey === "escape") {
sKey = "esc";
}
else if (e.keyCode >= 112 && e.keyCode <= 123) {
sKey = "f" + (e.keyCode - 111).toString();
}
if (e.ctrlKey === true) {
sKey = "ctrl + " + sKey;
}
return sKey;
},
SetupDynamicHotkey: function (sHotKey, triggerSelector) {
this.dynamicHokeySelectorMap[sHotKey] = triggerSelector;
},
RemoveDynamicHotkey: function (sHotKey) {
delete this.dynamicHokeySelectorMap[sHotKey];
},
UISetup: function (dicSetup) {
'use strict';
var dicActions = {},
self = this;
// For display javascript exception on UI
window.onerror = function (message, source, lineno, colno, error) {
$('#lblDisplay').text(source + " line:" + lineno + " colno:" + colno + " " + message);
};
// For datetimepicker behavior
$('.cusdatecontrol,.date-picker').on("click", function (event) {
event.preventDefault();
var oDatepicker = $(this);
if (!oDatepicker.hasClass('date-picker')) {//如果是input就直接取input
oDatepicker = $(this).prev();
oDatepicker = oDatepicker[0].tagName === 'LABEL' ? oDatepicker.prev() : oDatepicker;//如果有驗證控件則要往前再取
}
if (oDatepicker.is(":disabled") === false) {
oDatepicker.datepicker(g_cus.datetimePickerInitInfo);
oDatepicker.datepicker('show');
}
});
// Dynamic HotKey Press
$(document).on('keydown', function (e) {
do {
if (self.dynamicHokeyEnable === false) {
break;
}
var sKey = self.KeyCodeConvert(e);
if (self.dynamicHokeySelectorMap.hasOwnProperty(sKey) === true) {
var sSelector = self.dynamicHokeySelectorMap[sKey];
$(sSelector).each(function (index) {
if ($(this).is(":disabled") === false) {
$(this).trigger("click");
return false;
}
});
}
}
while (false);
});
// /// Move to Dashboard.js since choosing to reduce loading and avoid screen flicher.
// Click Menu function
//$(".divleftmenu_function").on("click", function () {
// window.location.href = window.location.origin + $(this).attr('content');
//});
// Click Menu Module
//$(".divleftmenu_module").on("click", function () {
// var disply = $(this).parent().children("li:visible").length > 0;
// $(this).parent().children("li").css("display", !disply ? "block" : "none");
//});
//if (typeof (dicSetup) !== 'undefined' && dicSetup.hasOwnProperty("actions")) {
// dicDefaultActions = $.extend(dicDefaultActions, dicSetup.actions);
//}
//$('button[id^="btn"]').on("click", function () {
// var btnName = $(this)[0].id;
// if (dicDefaultActions.hasOwnProperty(btnName) === true) {
// dicDefaultActions[btnName]();
// }
//});
if (g_gd.debugmode) {
$("#tab1").css(
{
"background-image": "url(../../Content/img/Debug.png)",
"background-repeat": "repeat"
});
}
},
SetPrivilege: function (dic) {
'use strict';
g_db.SetDic("privileges", dic);
},
GetPrivilege: function () {
'use strict';
return g_db.GetDic("privileges");
},
SetUserInfo: function (dic) {
'use strict';
g_db.SetDic("userinfo", dic);
},
GetUserInfo: function () {
'use strict';
return g_db.GetDic("userinfo");
},
FillBasicColumn: function (oridata) {
'use strict';
var dicData = {},
dtNow = (new Date()).formate("yyyy-MM-dd HH:mm:ss.S");
dicData.create_user = g_cus.GetUserInfo().user_id;
dicData.update_user = g_cus.GetUserInfo().user_id;
dicData.create_dept_id = g_cus.GetUserInfo().dept_id;
dicData.update_dept_id = g_cus.GetUserInfo().dept_id;
dicData.create_date = dtNow;
dicData.update_date = dtNow;
return $.extend(oridata, dicData);
},
FillBaseColumnByArray: function (dataarray) {
'use strict';
$.each(dataarray, function (key, item) {
var dicData = {},
dtNow = (new Date()).formate("yyyy-MM-dd HH:mm:ss.S");
dicData.create_user = g_cus.GetUserInfo().user_id;
dicData.update_user = g_cus.GetUserInfo().user_id;
dicData.create_dept_id = g_cus.GetUserInfo().dept_id;
dicData.update_dept_id = g_cus.GetUserInfo().dept_id;
dicData.create_date = dtNow;
dicData.update_date = dtNow;
dicData.biz_unit = g_cus.GetUserInfo().biz_unit;
$.extend(item.data, dicData);
});
return dataarray;
},
GetMenu: function () {
'use strict';
var self = this,
dicPrivilege = self.GetPrivilege(),
sFavorites = self.GetUserInfo().favorites || '',
sKey = null,
oValue = null,
sKey2 = null,
oValue2 = null,
sResult = "",
aModule = [],
dicModule = {},
existsModule = [],
fpSort = function (a, b) {
return a.SORT - b.SORT;
};
dicModule.favorites = { PARENTID: '-1', ID: 'favorites', NAME: 'menu.favorite', functions: [] };//我的最愛模塊 Add By John
dicPrivilege.sort(fpSort);
// Module
for (sKey in dicPrivilege) {
if (dicPrivilege.hasOwnProperty(sKey)) {
oValue = dicPrivilege[sKey];
if (oValue.ISLEAF === false) {
oValue.functions = [];
dicModule[$.trim(oValue.ID)] = oValue;
}
}
}
// Function
for (sKey in dicPrivilege) {
if (dicPrivilege.hasOwnProperty(sKey)) {
oValue = dicPrivilege[sKey];
if (oValue.ISLEAF === true) {
dicModule[$.trim(oValue.PARENTID)].functions.push(oValue);
}
if (sFavorites.indexOf($.trim(oValue.ID)) > -1) {
dicModule.favorites.functions.push(oValue);
}
}
}
// Sort all tier2 functions
for (sKey in dicModule) {
if (dicModule.hasOwnProperty(sKey)) {
aModule.push(dicModule[sKey]);
existsModule.push(sKey);
}
}
// Sort Module
var oModule = $('
" + $.trim(aModule[sKey].NAME) + "