You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

672 lines
22 KiB

// JScript 檔
///Class代號: MessageBox
///Class名稱: 讀取MessageBox.xml文件信息
///程式說明:   從MessageBox.xml文件中循環讀取符合要求的信息
///ShowArtAlert
///ShowArtCodeAndGo
///ShowArtCodeAndClose
///xx.YYYY/MM/DD VER AUTHOR COMMENTS(說明修改的內容)
///01.2010/12/31 1.00 Ethan CREATE
var ___strCulture = "zh-tw";
var ___strBGColor = "#333";
var ___stralertwidth = "20em";
var art;
var icons;
/********************************************
* 函數名稱:
* 目的:開啟彈出視窗
* 作者:Gary
* 時間:2014/03/12
* 參數說明:
url:目的地網址
width :開啟視窗之寬度
id:給予開啟視窗ID,以便指定ID關閉
*********************************************/
function open_art(url, width, id, height) {
sid = (id != null) ? id : 'default';
$.dialog.open(url, {//Modify By Jack 20140815 將art修改為$原因是在ie9中會報錯
// 在open()方法中,init會等待iframe加載完畢後執行
id: sid,
width: width,
height: height,
lock: true,
background: ___strBGColor, // 背景色
opacity: 0.87, // 透明度
init: function () {
var iframe = this.iframe.contentWindow;
var top = window; // 引用頂層頁面window對象
},
close: function (here) {
try {
___CloseWaitingForm();
} catch (e) {
}
}
});
}
/********************************************
* 函數名稱:
* 目的:關閉彈出視窗
* 作者:Gary
* 時間:2014/03/12
* 參數說明:
id:輸入ID 即可以關閉該視窗,否則將全部關閉
*********************************************/
function close_art(id) {
if (id != null) {
var art1 = $.dialog.list[id]; //Modify By Jack 20140815 將art修改為$原因是在ie9中會報錯
art1.close();
} else {
var list = $.dialog.list; //Modify By Jack 20140815 將art修改為$原因是在ie9中會報錯
for (var intLen in list) {
list[intLen].close();
}
}
}
function ShowArtCodeAndGoPop(strCode, url, StrPara, id) {
var msg = ShowMessage(strCode, '');
$.dialog({
title: '提示',
content: msg,
icon: icons,
ok: function () {
window.parent.open_art('../Pop/' + url + '.aspx?Action=' + StrPara, 1000, url);
window.parent.close_art(id);
return false;
},
close: function (here) {
try {
___CloseWaitingForm();
} catch (e) {
}
},
lock: true,
background: ___strBGColor, // 背景色
opacity: 0.87 // 透明度
});
}
/********************************************
* 函數名稱:
* 目的:彈出視窗搖晃
* 作者:Gary
* 時間:2014/03/12
* 使用說明:視窗.shake();
*********************************************/
artDialog.fn.shake = function () {
var style = this.DOM.wrap[0].style,
p = [4, 8, 4, 0, -4, -8, -4, 0],
fx = function () {
style.marginLeft = p.shift() + 'px';
if (p.length <= 0) {
style.marginLeft = 0;
clearInterval(timerId);
};
};
p = p.concat(p.concat(p));
timerId = setInterval(fx, 13);
return this;
};
/********************************************
* 函數名稱:
* 目的:顯示提示訊息,替代ALERT功能
* 作者:Gary
* 時間:2014/03/12
* 參數說明:
strCode:MessageBox.xml有該代號內容,顯示代號內容,如果沒有,直接顯示strCode值
*********************************************/
function ShowArtAlert(strCode, StrPara, strCulture, strCtlId) {
if (StrPara != undefined) ___strCulture = strCulture;
if (StrPara == undefined) StrPara = '';
var msg = ShowMessage(decodeURIComponent(strCode), StrPara);
//msg = decodeURIComponent(strCode);
var dialog = $.dialog({
title: '提示',
icon: icons,
content: msg,
ok: true,
lock: true,
close: function (here) {
try {
___CloseWaitingForm();
} catch (e) {
}
},
background: ___strBGColor, // 背景色
opacity: 0.87 // 透明度
});
if (icons == 'x') {
dialog.shake && dialog.shake();
}
$("#" + strCtlId).focus();
}
/********************************************
* 函數名稱:
* 目的:顯示提示訊息,替代ALERT功能,並且跳轉頁面
* 作者:Gary
* 時間:2014/03/12
* 參數說明:
strCode:MessageBox.xml有該代號內容,顯示代號內容,如果沒有,直接顯示strCode值
url : 目的地網址
*********************************************/
function ShowArtCodeAndGo(strCode, tipsPara, StrPara, url, strCulture) {
if (StrPara != undefined) ___strCulture = strCulture;
if (StrPara == undefined) StrPara = '';
var msg = ShowMessage(strCode, tipsPara);
$.dialog({
title: '提示',
content: msg,
icon: icons,
ok: function () {
window.top.OpenPageTab(url, StrPara);
//self.location.href = url;
return false;
},
close: function (here) {
try {
___CloseWaitingForm();
window.top.OpenPageTab(url, StrPara);
} catch (e) { }
},
lock: true,
background: ___strBGColor, // 背景色
opacity: 0.87 // 透明度
});
}
/********************************************
* 函數名稱:
* 目的:顯示提示訊息,替代ALERT功能,並且關閉頁面
* 作者:Gary
* 時間:2014/03/12
* 參數說明:
strCode:MessageBox.xml有該代號內容,顯示代號內容,如果沒有,直接顯示strCode值
id : 關閉視窗之ID
*********************************************/
function ShowArtCodeAndClose(strCode, id) {
var msg = ShowMessage(strCode, '');
$.dialog({
title: '提示',
content: msg,
icon: icons,
ok: function () {
window.parent.close_art(id);
return false;
},
close: function (here) {
try {
___CloseWaitingForm();
} catch (e) { }
},
lock: true,
background: ___strBGColor, // 背景色
opacity: 0.87 // 透明度
});
}
function ShowArtCodeAndCloseAndClickBtn(strCode, id, btnid) {
var msg = ShowMessage(strCode, '');
$.dialog({
title: '提示',
content: msg,
icon: icons,
ok: function () {
//alert('hi');
window.parent.$('#' + btnid).click();
window.parent.close_art(id);
return false;
},
close: function (here) {
try {
___CloseWaitingForm();
} catch (e) {
}
},
lock: true,
background: ___strBGColor, // 背景色
opacity: 0.87 // 透明度
});
}
function ShowArtCodeAndPop(strCode, StrPara, url, strCulture) {
var msg = ShowMessage(strCode, '');
$.dialog({
title: '提示',
content: msg,
icon: icons,
ok: function () {
//window.top.OpenPageTab(url, StrPara);
window.parent.open_art('../Pop/' + url + '.aspx?Action=' + StrPara, 1000, Url);
//self.location.href = url;
return false;
},
close: function (here) {
try {
___CloseWaitingForm();
} catch (e) {
}
},
lock: true,
background: ___strBGColor, // 背景色
opacity: 0.87 // 透明度
});
}
//---------------------------------------------------------------------[在頁面上彈出信息提示] (函數)
//Author :Ethan
//Last Modify :2010/12/21
function Show(strCode, StrPara, strCulture) {
if (StrPara != undefined) ___strCulture = strCulture;
if (StrPara == undefined) StrPara = '';
var msg = ShowMessage(strCode, StrPara);
var dialog = $.dialog({
title: '提示',
icon: Show,
content: msg,
close: function (here) {
try {
___CloseWaitingForm();
} catch (e) { }
},
ok: true,
lock: true,
background: ___strBGColor, // 背景色
opacity: 0.87 // 透明度
});
if (icons == 'x') {
dialog.shake && dialog.shake();
}
}
//---------------------------------------------------------------------[給指定的Web控件,彈出確認框信息提示] (函數)
//Author :Ethan
//Last Modify :2010/12/21
var _________confrimReturn = 0;
var _________strCtrlId = "";
/// <summary>
/// 刪除按鈕事件
/// </summary>
/// <param name="strCode">提示訊息代碼</param>
/// <param name="StrPara">提示訊息參數,沒有的時候傳空</param>
/// <param name="strCulture">語言版本,默認是zh-tw:繁體中文</param>
/// <param name="objSource">觸發刪除的控件</param>
/// <param name="blShowWaitingWhenOk">當選擇確定後是否立即關閉Waiting畫面,True:立即關閉;默認Flase:不立即關閉</param>
function ShowConfirm(strCode, strPara, strCulture, objSource, blShowWaitingWhenOk) {
_________strCtrlId = objSource.id;
if (strCulture != undefined && strCulture != "") ___strCulture = strCulture;
if (blShowWaitingWhenOk != undefined && blShowWaitingWhenOk != "") blShowWaitingWhenOk = false;
if (strPara == undefined) strPara = '';
var msg = ShowMessage(strCode, strPara);
if (status == "XML Error!") {
var dialog = art.dialog({
title: '提示',
icon: icons,
content: msg,
ok: true,
lock: true,
close: function (here) {
try {
___CloseWaitingForm();
} catch (e) {
}
},
background: ___strBGColor, // 背景色
opacity: 0.87 // 透明度
});
if (icons == 'x') {
dialog.shake && dialog.shake();
}
return false;
}
else {
var blreturn = false;
var blflag = false;
artDialog({
id: 'Confirm',
icon: 'question',
fixed: true,
lock: true,
background: ___strBGColor, // 背景色
opacity: 0.87, // 透明度
content: msg,
ok: function (here) {
blreturn = true;
blflag = true;
_________confrimReturn = 1;
//alert(blreturn);
$.dialog.tips('執行確認操作');
confirmReturn(true);
},
cancel: function (here) {
_________confrimReturn = -1;
blflag = true;
//alert(blreturn);
$.dialog.tips('執行取消操作');
confirmReturn(false);
}
//,close: function (here) {
// try {
// //___CloseWaitingForm();
// } catch (e) {
// }
//}
});
if (_________confrimReturn == 1) {
_________confrimReturn = 0;
if (blShowWaitingWhenOk) {
___CloseWaitingForm(); //確認後,立即關閉Waiting畫面
} else {
fnShowWaitingDiv(); //確認後,開啟Waiting畫面(預設效果)
}
return true;
} else if (_________confrimReturn == -1) {
___CloseWaitingForm(); //刪除取消後,應該立即關閉Waiting畫面
return false;
} else {
___CloseWaitingForm(); //刪除點擊關閉後,應該立即關閉Waiting畫面
return false;
}
}
}
function confirmReturn(blFlag) {
//alert(22);
if (blFlag) {
//確認
_________confrimReturn = 1;
} else {
//取消
_________confrimReturn = -1;
}
if (document.getElementById(_________strCtrlId).type == "button" || document.getElementById(_________strCtrlId).type == "submit" || document.getElementById(_________strCtrlId).tagName == "LABEL") {
//alert("1111");Add by Alina 201401015 專案基本資料添加的document.getElementById(_________strCtrlId).tagName == "LABEL",觸發源是一個Lable標籤
document.getElementById(_________strCtrlId).click();
} else {
//alert("222");
document.getElementById(_________strCtrlId).blur();
var changeBody = document.getElementById(_________strCtrlId).getAttribute("onchange");
//alert(changeBody);
setTimeout(changeBody, 50);
}
}
//---------------------------------------------------------------------[彈出信息提示,並轉向指的頁面] (函數)
//Author :Ethan
//Last Modify :2010/12/21
function ShowAndRedirect(strCode, StrPara, url, strCulture) {
if (StrPara != undefined) ___strCulture = strCulture;
var msg = ShowMessage(strCode, StrPara);
//alert(msg);
var dialog = art.dialog({
title: '提示',
icon: icons,
content: msg,
ok: true,
cancle: true,
close: function (here) {
try {
___CloseWaitingForm();
} catch (e) { }
},
lock: true,
background: ___strBGColor, // 背景色
opacity: 0.87 // 透明度
});
if (icons == 'x') {
dialog.shake && dialog.shake();
}
self.location.href = url;
}
//---------------------------------------------------------------------[彈出信息提示,並轉向指的頁面] (函數)
//Author :Ethan
//Last Modify :2010/12/21
function ShowAndBaseRedirect(strCode, StrPara, url, strCulture) {
if (StrPara != undefined) ___strCulture = strCulture;
var msg = ShowMessage(strCode, StrPara);
//alert(msg);
var dialog = art.dialog({
title: '提示',
icon: icons,
content: msg,
ok: true,
cancle: true,
close: function (here) {
try {
___CloseWaitingForm();
} catch (e) {
}
},
lock: true,
background: ___strBGColor, // 背景色
opacity: 0.87 // 透明度
});
if (icons == 'x') {
dialog.shake && dialog.shake();
}
window.parent.location.href = url;
}
/*************************************************************************
程式代號:BasePage
程式名稱:app_code/BasePage.cs使用
**************************************************************************/
function ReplMsgDesc(vstrMsg, vstrPara) {
var vntArray = vstrPara.split('$');
for (var i = 0; i < vntArray.length; i++) {
var strRepl = '{' + i + '}';
var intPos = vstrMsg.indexOf(strRepl);
if (intPos != -1) {
vstrMsg = vstrMsg.replace(strRepl, vntArray[i]);
}
}
return vstrMsg
}
//ShowMessage(strCode,vstrPara)
//strCode 消息代號
//vstrPara 帶入消息中的字串參數
//strCode為E0001時得" Save error!Table:{0}{1} ",vstrPara為"def$abc"
//會將{0}用def替換掉.{1}用abc替換掉
function ShowMessage(strCode, vstrPara) {
//alert(strCode);
var strOut = 'XML fail!';
var url = window.location.href;
url = document.location.protocol + "//" + document.location.host + '/DataSource/MessageBox.xml';
var objxmlDoc = LoadXml(url);
if (objxmlDoc == null) {
if (document.location.pathname.indexOf('/') == 0) {
url = document.location.protocol + "//" + document.location.host + "/" + document.location.pathname.split("/")[1] + '/DataSource/MessageBox.xml';
}
else {
url = document.location.protocol + "//" + document.location.host + "/" + document.location.pathname.split("/")[0] + '/DataSource/MessageBox.xml';
}
objxmlDoc = LoadXml(url);
}
if (typeof (objxmlDoc) == 'object') {
try {
___strCulture = ___strCulture ? ___strCulture.toLowerCase() : 'zh-tw';
//Modified by Gary,20140411 Start. 修正Chrome無法正確找到資料
var strMsg = "";
$(objxmlDoc).find('MessageContent').each(function () {
var sTitle = $(this).find('MsgID').text();
if (sTitle == strCode) {
strMsg = $(this).find(___strCulture).text();
strIcons = $(this).find('icons').text();
}
});
icons = (strIcons != null || strIcons != "") ? strIcons : "";
strOut = ReplMsgDesc(strMsg, vstrPara);
}
catch (e) {
//strOut = '沒找到對應消息ID{' + strCode + '}!\n請參見' + url;
strOut = strCode;
}
}
return strOut;
}
//讀取XML擋
function LoadXml(vstrReq) {
return xmlhttpTest(vstrReq)
}
function PostXML(vstrURL, vstrXML) {
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.Open("POST", vstrURL, false);
//xmlhttp.setRequestHeader("Content-Type", "text/xml");
xmlhttp.setRequestHeader("Content-Type", "msxml-document");
//try { xmlhttp.responseType = "msxml-document"; } catch (e) { }
xmlhttp.Send(vstrXML);
if (xmlhttp.responseXML.xml != "") {
var objDoc = new ActiveXObject("Microsoft.XMLDOM");
objDoc.async = false;
objDoc.loadXML(xmlhttp.responseXML.xml);
return objDoc;
}
}
function xmlhttpTest(url) {
//判斷別是否支持標準XMLHttpRequest對象.
if (window.XMLHttpRequest) {
var oXmlHttp = new XMLHttpRequest();
} else {
//'Microsoft.XMLHTTP' 放在最前面以兼容ie6.
var MSXML = ['Microsoft.XMLHTTP', 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'];
for (var n = 0; n < MSXML.length; n++) {
try {
var oXmlHttp = new ActiveXObject(MSXML[n]);
break;
} catch (e) { }
}
}
try {
oXmlHttp.open("GET", url, false);
//Modified by Ethan ,20130315 Start.兼容IE10
//oXmlHttp.setRequestHeader("Content-Type", "text/xml");
try { oXmlHttp.responseType = 'msxml-document'; } catch (e) { }
//Modified by Ethan ,20130315 End.兼容IE10
oXmlHttp.send(null);
if (oXmlHttp.status == 200) {
oXmlHttp.responseXML;
} else {
return null;
}
return oXmlHttp.responseXML;
} catch (e) {
return null;
}
}
/**
* 非IE??器兼容selectNodes
*/
//if(!isIE) {
try {
var ex;
XMLDocument.prototype.__proto__.__defineGetter__("xml", function () {
try {
return new XMLSerializer().serializeToString(this);
} catch (ex) {
var d = document.createElement("div");
d.appendChild(this.cloneNode(true));
return d.innerHTML;
}
});
Element.prototype.__proto__.__defineGetter__("xml", function () {
try {
return new XMLSerializer().serializeToString(this);
} catch (ex) {
var d = document.createElement("div");
d.appendChild(this.cloneNode(true));
return d.innerHTML;
}
});
XMLDocument.prototype.__proto__.__defineGetter__("text", function () {
return this.firstChild.textContent
});
Element.prototype.__proto__.__defineGetter__("text", function () {
return this.textContent
});
if (document.implementation && document.implementation.createDocument) {
XMLDocument.prototype.loadXML = function (xmlString) {
try {
var childNodes = this.childNodes;
for (var i = childNodes.length - 1; i >= 0; i--)
this.removeChild(childNodes[i]);
var dp = new DOMParser();
var newDOM = dp.parseFromString(xmlString, "text/xml");
var newElt = this.importNode(newDOM.documentElement, true);
this.appendChild(newElt);
return true;
} catch (ex) {
return false;
}
};
// check for XPath implementation
if (document.implementation.hasFeature("XPath", "3.0")) {
// prototying the XMLDocument
XMLDocument.prototype.selectNodes = function (cXPathString, xNode) {
if (!xNode) {
xNode = this;
}
var oNSResolver = this.createNSResolver(this.documentElement)
var aItems = this.evaluate(cXPathString, xNode, oNSResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
var aResult = [];
for (var i = 0; i < aItems.snapshotLength; i++) {
aResult[i] = aItems.snapshotItem(i);
}
return aResult;
}
// prototying the Element
Element.prototype.selectNodes = function (cXPathString) {
if (this.ownerDocument.selectNodes) {
return this.ownerDocument.selectNodes(cXPathString, this);
} else {
throw "For XML Elements Only";
}
}
}
// check for XPath implementation
if (document.implementation.hasFeature("XPath", "3.0")) {
// prototying the XMLDocument
XMLDocument.prototype.selectSingleNode = function (cXPathString, xNode) {
if (!xNode) {
xNode = this;
}
var xItems = this.selectNodes(cXPathString, xNode);
if (xItems.length > 0) {
return xItems[0];
} else {
return null;
}
}
// prototying the Element
Element.prototype.selectSingleNode = function (cXPathString) {
if (this.ownerDocument.selectSingleNode) {
return this.ownerDocument.selectSingleNode(cXPathString, this);
} else {
throw "For XML Elements Only";
}
}
}
}
} catch (ex) { }