800 lines
23 KiB
JavaScript
800 lines
23 KiB
JavaScript
//构造函数
|
||
function Common() {
|
||
var newid;
|
||
}
|
||
|
||
//全选功能
|
||
Common.prototype.checkAll = function (tableName, itemName) {
|
||
var i = 0;
|
||
while (true) {
|
||
var e = document.getElementById(tableName + ":" + i + ":" + itemName);
|
||
if (e == null) {
|
||
break;
|
||
}
|
||
if (e.disabled != true) {
|
||
e.checked = document.getElementById("chkall").checked;
|
||
}
|
||
i += 1;
|
||
}
|
||
};
|
||
|
||
//检测是否选择要处理的数据
|
||
Common.prototype.checkSelect = function (checkName) {
|
||
var checkboxes=document.getElementsByName(checkName);
|
||
var common_selfjs_tip1 = document.getElementById("common_selfjs_tip1").value;
|
||
var result=0;
|
||
if(checkboxes.length){
|
||
for(i = 0; i <checkboxes.length; i++) {
|
||
var checkbox=checkboxes[i];
|
||
if(checkbox.checked == true){
|
||
result=1;
|
||
break;
|
||
}
|
||
}
|
||
if(result==0){
|
||
alert(common_selfjs_tip1);
|
||
return false;
|
||
}
|
||
}
|
||
else if(checkboxes.checked!=true){
|
||
alert(common_selfjs_tip1);
|
||
return false;
|
||
}
|
||
return true;
|
||
};
|
||
|
||
//提示用户是否确定要执行
|
||
Common.prototype.checkExecute = function () {
|
||
var str="";
|
||
var common_selfjs_tip2 = document.getElementById("common_selfjs_tip2").value;
|
||
if(event.srcElement.title==null){
|
||
str=common_selfjs_tip2;
|
||
}
|
||
else{
|
||
str=event.srcElement.title;
|
||
}
|
||
return confirm(common_selfjs_tip3+str+"?");
|
||
};
|
||
|
||
//获取选择的数据
|
||
Common.prototype.getChecked = function (checkName, hiddenId) {
|
||
if(!common.checkSelect(checkName)){
|
||
return false;
|
||
}
|
||
var checkbox = document.getElementsByName(checkName);
|
||
if (checkbox != null && checkbox.length != 0) {
|
||
for (i = 0; i < checkbox.length; i++) {
|
||
if (checkbox[i].checked) {
|
||
document.getElementById(hiddenId).value += checkbox[i].value + ",";
|
||
}
|
||
}
|
||
}
|
||
return common.checkExecute();
|
||
};
|
||
|
||
//弹出新窗口
|
||
Common.prototype.openWindow = function (name, url, winLeft, winTop, winWidth, winHeight, allowScroll) {
|
||
var query;
|
||
par = "toobar=no,location=no,directories=no,status=0,";
|
||
par += "scrollbars=" + allowScroll + ",menubar=0,resizable=yes,copyhistory=no,";
|
||
par += "width=" + winWidth + ",height=" + winHeight + ",left=" + winLeft + ",top=" + winTop;
|
||
if (this.newid) {
|
||
if (!this.newid.closed) {
|
||
this.newid.close();
|
||
}
|
||
this.newid = window.open(url, name, par);
|
||
} else {
|
||
this.newid = window.open(url, name, par);
|
||
}
|
||
};
|
||
|
||
//弹出新窗口在中间位置
|
||
Common.prototype.openWinCenter = function (name, url, winSize, allowScroll) {
|
||
var winWidth="700";
|
||
var winHeight="500";
|
||
if(winSize=="L"){
|
||
winWidth="900";
|
||
winHeight="500";
|
||
}
|
||
else if(winSize=="S"){
|
||
winWidth="500";
|
||
winHeight="300";
|
||
}
|
||
winLeft = (screen.width - winWidth) / 2;
|
||
winTop = (screen.height - winHeight) / 2 - 10;
|
||
if (winLeft < 0) {
|
||
winLeft = 5;
|
||
}
|
||
if (winTop < 0) {
|
||
winTop = 5;
|
||
}
|
||
common.openWindow(name, url, winLeft, winTop, winWidth,winHeight, "auto");
|
||
};
|
||
|
||
Common.prototype.showAdvancedQuery = function (aq) {
|
||
var common_selfjs_tip4 = document.getElementById("common_selfjs_tip4").value;
|
||
var common_selfjs_tip5 = document.getElementById("common_selfjs_tip5").value;
|
||
if (event.srcElement.value == common_selfjs_tip4) {
|
||
document.getElementById(aq).style.display = "block";
|
||
event.srcElement.value = common_selfjs_tip5;
|
||
} else {
|
||
document.getElementById(aq).style.display = "none";
|
||
event.srcElement.value = common_selfjs_tip4;
|
||
}
|
||
};
|
||
|
||
Common.prototype.disableTag = function (tagName) {
|
||
var elements = document.getElementsByTagName(tagName);
|
||
if (elements != null && elements.length != null) {
|
||
for (i = 0; i < elements.length; i++) {
|
||
if(elements[i].type=="button"||elements[i].type=="submit"||elements[i].type=="reset"){
|
||
elements[i].disabled = "true";
|
||
}
|
||
}
|
||
}
|
||
if (elements != null && elements.length == null) {
|
||
elements.disabled = "true";
|
||
}
|
||
};
|
||
//重置
|
||
Common.prototype.reset= function (url) {
|
||
url+="?";
|
||
var act=document.getElementById("act");
|
||
var uuids=document.getElementsByName("uuid");
|
||
if(act!=null){
|
||
url+="&act="+act.value;
|
||
}
|
||
if(uuids!=null&&uuids[0]!=null&&uuids[0].value!=null){
|
||
url+="&uuid="+uuids[0].value;
|
||
}
|
||
self.location=url;
|
||
};
|
||
//页面onload需要执行的动作
|
||
Common.prototype.load= function () {
|
||
//执行focus的动作
|
||
var errorMsgs=document.getElementsByName("ErrorMessagePanel");
|
||
if(errorMsgs.length>0){
|
||
for(var i=0;i<errorMsgs.length;i++){
|
||
var errorNode=errorMsgs[i].parentNode.firstChild;
|
||
if(errorNode.type==null){
|
||
errorNode=errorNode.nextSibling;
|
||
}
|
||
if((errorNode.type=='text'||errorNode.type=='password'||errorNode.type=='textarea')
|
||
&&errorNode.readOnly!=true&&errorNode.style.disabled!=true){
|
||
errorNode.focus();
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
var allNodes = document.all;
|
||
if (allNodes) {
|
||
if (allNodes.length > 0) {
|
||
for (var i = 0; i < allNodes.length; i++) {
|
||
var node = allNodes[i];
|
||
if ((node.type == 'text' || node.type == 'password' || node.type == 'textarea')
|
||
&& node.readOnly != true && node.disabled != true) {
|
||
node.focus();
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
};
|
||
|
||
//页面onload需要执行的动作
|
||
Common.prototype.checkEnter= function (form) {
|
||
//执行focus的动作
|
||
if(event.keyCode==13){
|
||
if(event.srcElement.type=='textarea') return;
|
||
var obj;
|
||
try{
|
||
obj=form.document.all.tags("input");
|
||
}catch(ex){}
|
||
if(!obj) return;
|
||
var objs = [];
|
||
if(!obj.length) objs[0] = obj;
|
||
else objs = obj;
|
||
for(var i=0; i<objs.length; i++) {
|
||
var temp = objs[i];
|
||
if(temp.type=='submit') {
|
||
temp.focus();
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
};
|
||
|
||
//初始化一个common对象
|
||
var common = new Common();
|
||
|
||
function MM_swapImgRestore(id) { //v3.0
|
||
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
|
||
}
|
||
function MM_preloadImages() { //v3.0
|
||
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
|
||
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
|
||
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
|
||
}
|
||
function MM_findObj(n, d) { //v4.0
|
||
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
|
||
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
|
||
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
|
||
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
|
||
if(!x && document.getElementById) x=document.getElementById(n); return x;
|
||
}
|
||
function MM_swapImage() { //v3.0
|
||
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
|
||
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
|
||
}
|
||
|
||
function MM_swapLogout() { //v3.0
|
||
var i,j=0,x,a=new Array('Image13','','../../../common/manager/img/logout_2.gif',1); document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
|
||
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
|
||
}
|
||
|
||
//清空错误信息
|
||
function clearErrorMsg(errorObj) {
|
||
var lastNode = errorObj.parentNode.childNodes[errorObj.parentNode.childNodes.length - 1];
|
||
if (lastNode.id == "ErrorMessagePanel") {
|
||
errorObj.parentNode.removeChild(lastNode);
|
||
}
|
||
var childNode = errorObj.childNodes[errorObj.childNodes.length - 1];
|
||
if (childNode&&childNode.id == "ErrorMessagePanel") {
|
||
errorObj.removeChild(childNode);
|
||
}
|
||
}
|
||
//在errorObj后输出错误信息
|
||
function appendErrorMsg(errorObj,errorMsg) {
|
||
var label = document.createElement("label");
|
||
label.id = "ErrorMessagePanel";
|
||
label.className = "errorMessage";
|
||
errorObj.parentNode.appendChild(label);
|
||
label.innerHTML = errorMsg;
|
||
}
|
||
//将错误信息插入insertObj中
|
||
function insertErrorMsg(insertObj,errorMsg) {
|
||
var label = document.createElement("label");
|
||
label.id = "ErrorMessagePanel";
|
||
label.className = "errorMessage";
|
||
insertObj.appendChild(label);
|
||
label.innerHTML = errorMsg;
|
||
}
|
||
//判断是否在范围内
|
||
function isInRange(value,min,max) {
|
||
if(/\D/.exec(value)||value<min||value>max){
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
/************************************************************************************************************
|
||
* DHTML modal dialog box
|
||
*
|
||
* Created: August, 26th, 2006
|
||
* @class Purpose of class: Display a modal dialog box on the screen.
|
||
*
|
||
* Css files used by this script: modal-message.css
|
||
*
|
||
* Demos of this class: demo-modal-message-1.html
|
||
*
|
||
* Update log:
|
||
*
|
||
************************************************************************************************************/
|
||
|
||
|
||
/**
|
||
* @constructor
|
||
*/
|
||
DHTML_modalMessage = function()
|
||
{
|
||
var url; // url of modal message
|
||
var htmlOfModalMessage; // html of modal message
|
||
|
||
var divs_transparentDiv; // Transparent div covering page content
|
||
var divs_content; // Modal message div.
|
||
var layoutCss; // Name of css file;
|
||
var width; // Width of message box
|
||
var height; // Height of message box
|
||
|
||
var existingBodyOverFlowStyle; // Existing body overflow css
|
||
var dynContentObj; // Reference to dynamic content object
|
||
var cssClassOfMessageBox; // Alternative css class of message box - in case you want a different appearance on one of them
|
||
var shadowDivVisible; // Shadow div visible ?
|
||
var shadowOffset; // X and Y offset of shadow(pixels from content box)
|
||
|
||
this.url = ''; // Default url is blank
|
||
this.htmlOfModalMessage = ''; // Default message is blank
|
||
this.layoutCss = 'modal-message.css'; // Default CSS file
|
||
this.height = 200; // Default height of modal message
|
||
this.width = 400; // Default width of modal message
|
||
this.cssClassOfMessageBox = false; // Default alternative css class for the message box
|
||
this.shadowDivVisible = true; // Shadow div is visible by default
|
||
this.shadowOffset = 5; // Default shadow offset.
|
||
|
||
|
||
|
||
}
|
||
|
||
DHTML_modalMessage.prototype = {
|
||
// {{{ setSource(urlOfSource)
|
||
/**
|
||
* Set source of the modal dialog box
|
||
*
|
||
*
|
||
* @public
|
||
*/
|
||
setSource : function(urlOfSource)
|
||
{
|
||
this.url = urlOfSource;
|
||
|
||
}
|
||
// }}}
|
||
,
|
||
// {{{ setHtmlContent(newHtmlContent)
|
||
/**
|
||
* Setting static HTML content for the modal dialog box.
|
||
*
|
||
* @param String newHtmlContent = Static HTML content of box
|
||
*
|
||
* @public
|
||
*/
|
||
setHtmlContent : function(newHtmlContent)
|
||
{
|
||
this.htmlOfModalMessage = newHtmlContent;
|
||
|
||
}
|
||
// }}}
|
||
,
|
||
// {{{ setSize(width,height)
|
||
/**
|
||
* Set the size of the modal dialog box
|
||
*
|
||
* @param int width = width of box
|
||
* @param int height = height of box
|
||
*
|
||
* @public
|
||
*/
|
||
setSize : function(width,height)
|
||
{
|
||
if(width)this.width = width;
|
||
if(height)this.height = height;
|
||
}
|
||
// }}}
|
||
,
|
||
// {{{ setCssClassMessageBox(newCssClass)
|
||
/**
|
||
* Assign the message box to a new css class.(in case you wants a different appearance on one of them)
|
||
*
|
||
* @param String newCssClass = Name of new css class (Pass false if you want to change back to default)
|
||
*
|
||
* @public
|
||
*/
|
||
setCssClassMessageBox : function(newCssClass)
|
||
{
|
||
this.cssClassOfMessageBox = newCssClass;
|
||
if(this.divs_content){
|
||
if(this.cssClassOfMessageBox)
|
||
this.divs_content.className=this.cssClassOfMessageBox;
|
||
else
|
||
this.divs_content.className='modalDialog_contentDiv';
|
||
}
|
||
|
||
}
|
||
// }}}
|
||
,
|
||
// {{{ setShadowOffset(newShadowOffset)
|
||
/**
|
||
* Specify the size of shadow
|
||
*
|
||
* @param Int newShadowOffset = Offset of shadow div(in pixels from message box - x and y)
|
||
*
|
||
* @public
|
||
*/
|
||
setShadowOffset : function(newShadowOffset)
|
||
{
|
||
this.shadowOffset = newShadowOffset
|
||
|
||
}
|
||
// }}}
|
||
,
|
||
// {{{ display()
|
||
/**
|
||
* Display the modal dialog box
|
||
*
|
||
*
|
||
* @public
|
||
*/
|
||
display : function()
|
||
{
|
||
// ================ hide all select, Hubing added, begin ===============
|
||
//var selects = document.getElementsByTagName("select");
|
||
|
||
//if(selects) {
|
||
// for(var i=0; i<selects.length; i++) {
|
||
// var sel = selects[i];
|
||
// sel.style.display = "none";
|
||
// }
|
||
//}
|
||
// ================ hide all select, Hubing added, end =================
|
||
|
||
if(!this.divs_transparentDiv){
|
||
this.__createDivs();
|
||
}
|
||
|
||
// Redisplaying divs
|
||
this.divs_transparentDiv.style.display='block';
|
||
this.divs_content.style.display='block';
|
||
this.divs_shadow.style.display='block';
|
||
|
||
this.__resizeDivs();
|
||
|
||
/* Call the __resizeDivs method twice in case the css file has changed. The first execution of this method may not catch these changes */
|
||
//window.refToThisModalBoxObj = this;
|
||
//setTimeout('window.refToThisModalBoxObj.__resizeDivs()',150);
|
||
|
||
this.__insertContent(); // Calling method which inserts content into the message div.
|
||
}
|
||
// }}}
|
||
,
|
||
// {{{ ()
|
||
/**
|
||
* Display the modal dialog box
|
||
*
|
||
*
|
||
* @public
|
||
*/
|
||
setShadowDivVisible : function(visible)
|
||
{
|
||
this.shadowDivVisible = visible;
|
||
}
|
||
// }}}
|
||
,
|
||
// {{{ close()
|
||
/**
|
||
* Close the modal dialog box
|
||
*
|
||
*
|
||
* @public
|
||
*/
|
||
close : function()
|
||
{
|
||
document.documentElement.style.overflow = ''; // Setting the CSS overflow attribute of the <html> tag back to default.
|
||
/* Hiding divs */
|
||
this.divs_transparentDiv.style.display='none';
|
||
this.divs_content.style.display='none';
|
||
this.divs_shadow.style.display='none';
|
||
|
||
}
|
||
// }}}
|
||
,
|
||
// {{{ __createDivs()
|
||
/**
|
||
* Create the divs for the modal dialog box
|
||
*
|
||
*
|
||
* @private
|
||
*/
|
||
__createDivs : function()
|
||
{
|
||
// Creating transparent div
|
||
this.divs_transparentDiv = document.createElement('DIV');
|
||
this.divs_transparentDiv.className='modalDialog_transparentDivs';
|
||
this.divs_transparentDiv.style.left = '0px';
|
||
this.divs_transparentDiv.style.top = '0px';
|
||
document.body.appendChild(this.divs_transparentDiv);
|
||
// Creating content div
|
||
this.divs_content = document.createElement('DIV');
|
||
this.divs_content.className = 'modalDialog_contentDiv';
|
||
this.divs_content.id = 'DHTMLSuite_modalBox_contentDiv';
|
||
document.body.appendChild(this.divs_content);
|
||
// Creating shadow div
|
||
this.divs_shadow = document.createElement('DIV');
|
||
this.divs_shadow.className = 'modalDialog_contentDiv_shadow';
|
||
document.body.appendChild(this.divs_shadow);
|
||
|
||
}
|
||
// }}}
|
||
,
|
||
// {{{ __resizeDivs()
|
||
/**
|
||
* Resize the message divs
|
||
*
|
||
*
|
||
* @private
|
||
*/
|
||
__resizeDivs : function()
|
||
{
|
||
|
||
var topOffset = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
|
||
var leftOffset = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);
|
||
|
||
if(this.cssClassOfMessageBox)
|
||
this.divs_content.className=this.cssClassOfMessageBox;
|
||
else
|
||
this.divs_content.className='modalDialog_contentDiv';
|
||
|
||
if(!this.divs_transparentDiv)return;
|
||
document.documentElement.style.overflow = 'hidden';
|
||
|
||
var bodyWidth = document.documentElement.clientWidth;
|
||
var bodyHeight = document.documentElement.clientHeight;
|
||
|
||
var bodyWidth, bodyHeight;
|
||
if (self.innerHeight){ // all except Explorer
|
||
|
||
bodyWidth = self.innerWidth;
|
||
bodyHeight = self.innerHeight;
|
||
} else if (document.documentElement && document.documentElement.clientHeight) {
|
||
// Explorer 6 Strict Mode
|
||
bodyWidth = document.documentElement.clientWidth;
|
||
bodyHeight = document.documentElement.clientHeight;
|
||
} else if (document.body) {// other Explorers
|
||
|
||
bodyWidth = document.body.clientWidth;
|
||
bodyHeight = document.body.clientHeight;
|
||
}
|
||
|
||
|
||
// Setting width and height of content div
|
||
this.divs_content.style.width = this.width + 'px';
|
||
this.divs_content.style.height= this.height + 'px';
|
||
|
||
// Creating temporary width variables since the actual width of the content div could be larger than this.width and this.height(i.e. padding and border)
|
||
var tmpWidth = this.divs_content.offsetWidth;
|
||
var tmpHeight = this.divs_content.offsetHeight;
|
||
|
||
|
||
// Setting width and height of left transparent div
|
||
//this.divs_transparentDiv.style.width = Math.ceil((bodyWidth - tmpWidth) / 2) + 'px';
|
||
//this.divs_transparentDiv.style.height = bodyHeight + 'px';
|
||
|
||
// Setting size extremely large for bottom, left and right side transparent divs.
|
||
this.divs_transparentDiv.style.top = topOffset;
|
||
this.divs_transparentDiv.style.left = leftOffset;
|
||
this.divs_transparentDiv.style.height = '100%';
|
||
this.divs_transparentDiv.style.width = '100%';
|
||
document.body.scroll='no';
|
||
|
||
|
||
this.divs_content.style.left = (Math.ceil((bodyWidth - tmpWidth) / 2) + leftOffset) + 'px';
|
||
this.divs_content.style.top = (Math.ceil((bodyHeight - tmpHeight) / 2) + topOffset) + 'px';
|
||
|
||
this.divs_shadow.style.left = (this.divs_content.style.left.replace('px','')/1 + this.shadowOffset) + 'px';
|
||
this.divs_shadow.style.top = (this.divs_content.style.top.replace('px','')/1 + this.shadowOffset) + 'px';
|
||
this.divs_shadow.style.height = tmpHeight + 'px';
|
||
this.divs_shadow.style.width = tmpWidth + 'px';
|
||
|
||
|
||
|
||
if(!this.shadowDivVisible)this.divs_shadow.style.display='none'; // Hiding shadow if it has been disabled
|
||
|
||
|
||
}
|
||
// }}}
|
||
,
|
||
// {{{ __insertContent()
|
||
/**
|
||
* Insert content into the content div
|
||
*
|
||
*
|
||
* @private
|
||
*/
|
||
__insertContent : function()
|
||
{
|
||
if(this.url){ // url specified - load content dynamically
|
||
ajax_loadContent('DHTMLSuite_modalBox_contentDiv',this.url);
|
||
}else{ // no url set, put static content inside the message box
|
||
this.divs_content.innerHTML = this.htmlOfModalMessage;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
function modelDialog_displayStaticMessage(messageContent,cssClass) {
|
||
var messageObj = new DHTML_modalMessage(); // We only create one object of this class
|
||
messageObj.setShadowOffset(5); // Large shadow
|
||
|
||
messageObj.setHtmlContent(messageContent);
|
||
messageObj.setSize(300,50);
|
||
messageObj.setCssClassMessageBox(cssClass);
|
||
messageObj.setSource(false); // no html source since we want to use a static message here.
|
||
messageObj.setShadowDivVisible(false); // Disable shadow for these boxes
|
||
messageObj.display();
|
||
}
|
||
|
||
/*
|
||
* Display waiting Info
|
||
*/
|
||
function waitForSubmit() {
|
||
waitFlag = true;
|
||
var messageObj = new DHTML_modalMessage();
|
||
var waitInfo = "<table style='FILTER: Alpha(opacity=90);height:80;width:280' cellSpacing=1 cellPadding=1 bgColor=#4065A5 summary='Loader Layout' border=0 >"
|
||
+ "<tr>" + " <td align=center valign=middle bgColor=#ffffff>";
|
||
var common_managerjs_tip2 = document.getElementById("common_managerjs_tip2").value;
|
||
waitInfo += "<div ><img src='../../../common/manager/img/loading.gif'/> <SPAN style='FONT-SIZE: 10pt'><STRONG>"+common_managerjs_tip2+"</STRONG></SPAN></div></table>";
|
||
|
||
messageObj.setShadowOffset(0); // Large shadow
|
||
messageObj.setHtmlContent(waitInfo);
|
||
messageObj.setSize(300, 40);
|
||
messageObj.setSource(false); // no html source since we want to use a static message here.
|
||
messageObj.setShadowDivVisible(false); // Disable shadow for these boxes
|
||
messageObj.display(false);
|
||
}
|
||
|
||
var waitFlag = false; //操作正在进行中为true
|
||
|
||
function keyDownDeal()
|
||
{
|
||
if((window.event.keyCode==13 || window.event.keyCode==32)&& waitFlag) // 操作进行中,屏蔽回车键,解决BUG 33033
|
||
{
|
||
window.event.keyCode = 0;
|
||
window.event.returnValue = false;
|
||
}
|
||
}
|
||
|
||
document.body.onkeydown = keyDownDeal;
|
||
|
||
function modelDialog_closeMessage() {
|
||
messageObj.close();
|
||
}
|
||
|
||
/*去掉textStr两头的空格*/
|
||
function trim(str) {
|
||
var ret = str;
|
||
ret = ret.replace(/^\s+/, "");
|
||
ret = ret.replace(/\s+$/, "");
|
||
return ret;
|
||
}
|
||
|
||
function isChinese(str)
|
||
{
|
||
var lst = /[u00-uFF]/;
|
||
return !lst.test(str);
|
||
}
|
||
function strlen(str)
|
||
{
|
||
var strlength=0;
|
||
for (i=0;i<str.length;i++)
|
||
{
|
||
if (isChinese(str.charAt(i))==true)
|
||
strlength=strlength + 2;
|
||
else
|
||
strlength=strlength + 1;
|
||
}
|
||
return strlength;
|
||
}
|
||
String.prototype.trim = function() {return this.replace(/(^\s*)|(\s*$)/g,"");} //去掉前后空格
|
||
String.prototype.Trim = function() {return this.replace(/(^\s*)|(\s*$)/g,"");} //去掉前后空格
|
||
String.prototype.Ltrim = function(){return this.replace(/(^\s*)/g, "");} //去掉左空格
|
||
String.prototype.Rtrim = function(){return this.replace(/(\s*$)/g, "");} //去掉右空格
|
||
//获取字符串字节数
|
||
String.prototype.bytes = function (){
|
||
var bytesCount = 0;
|
||
for (var i = 0; i < this.length; i++){
|
||
var c = this.charAt(i);
|
||
if (/^[\u0000-\u00ff]$/.test(c)){ //匹配双字节
|
||
bytesCount += 1;
|
||
}
|
||
else
|
||
{
|
||
bytesCount += 2;
|
||
}
|
||
}
|
||
return bytesCount;
|
||
}
|
||
String.prototype.formatByLength = function(length){
|
||
if(this.length>length && length > 3){
|
||
return this.substring(0,length-2)+"...";
|
||
}else{
|
||
return this;
|
||
}
|
||
}
|
||
String.prototype.checkIpIsOk = function(){
|
||
MaskStr = this;
|
||
/* 有效性校验 */
|
||
var IPPattern = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
|
||
if(!IPPattern.test(MaskStr)){
|
||
return false;
|
||
}
|
||
|
||
/* 检查域值 */
|
||
var IPArray = MaskStr.split(".");
|
||
var ip1 = parseInt(IPArray[0]);
|
||
var ip2 = parseInt(IPArray[1]);
|
||
var ip3 = parseInt(IPArray[2]);
|
||
var ip4 = parseInt(IPArray[3]);
|
||
if ( ip1<0 || ip1>255 /* 每个域值范围0-255 */
|
||
|| ip2<0 || ip2>255
|
||
|| ip3<0 || ip3>255
|
||
|| ip4<0 || ip4>255 ){
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
//Array的删除方法--真正的删除 !!使用方法 array = array.del(n);
|
||
Array.prototype.del=function(n) { //n表示第几项,从0开始算起。
|
||
//prototype为对象原型,注意这里为对象增加自定义方法的方法。
|
||
if(n<0){ //如果n<0,则不进行任何操作。
|
||
return this;
|
||
}
|
||
else{
|
||
this[n] = null;
|
||
return this.slice(0,n).concat(this.slice(n+1,this.length));
|
||
}
|
||
/*
|
||
concat方法:返回一个新数组,这个新数组是由两个或更多数组组合而成的。
|
||
这里就是返回this.slice(0,n)/this.slice(n+1,this.length)
|
||
组成的新数组,这中间,刚好少了第n项。
|
||
slice方法: 返回一个数组的一段,两个参数,分别指定开始和结束的位置。
|
||
*/
|
||
}
|
||
Array.prototype.add = function(obj){
|
||
this[this.length] = obj;
|
||
}
|
||
Array.prototype.contains = function(str){
|
||
if(this.length == 0){return false}
|
||
for(var i=0;i<this.length;i++){
|
||
if(this[i] == str){
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
function createXMLHttpRequest(){
|
||
http_request_return = false;
|
||
//开始初始化XMLHttpRequest对象
|
||
if(window.XMLHttpRequest) { //Mozilla 浏览器
|
||
|
||
http_request_return = new XMLHttpRequest();
|
||
if (http_request_return.overrideMimeType) {//设置MiME类别
|
||
http_request_return.overrideMimeType('text/xml');
|
||
}
|
||
}else if (window.ActiveXObject) { // IE浏览器
|
||
try {
|
||
http_request_return = new ActiveXObject("Msxml2.XMLHTTP");
|
||
} catch (e) {
|
||
try {
|
||
http_request_return = new ActiveXObject("Microsoft.XMLHTTP");
|
||
} catch (e) {}
|
||
}
|
||
}
|
||
return http_request_return;
|
||
}
|
||
|
||
function getNumFromPx(px){
|
||
if(px.indexOf("px")>-1){
|
||
px = px.replace("px","");
|
||
px *= 1;
|
||
}
|
||
return px;
|
||
};
|
||
|
||
|
||
//js检索浏览器
|
||
|
||
function getExplorer() {
|
||
var explorer = window.navigator.userAgent ;
|
||
var getexplorer;
|
||
//ie
|
||
if (explorer.indexOf("MSIE") >= 0) {
|
||
getexplorer="ie";
|
||
}
|
||
//firefox
|
||
else if (explorer.indexOf("Firefox") >= 0) {
|
||
getexplorer="Firefox";
|
||
}
|
||
//Chrome
|
||
else if(explorer.indexOf("Chrome") >= 0){
|
||
getexplorer="Chrome";
|
||
}
|
||
//Opera
|
||
else if(explorer.indexOf("Opera") >= 0){
|
||
getexplorer="Opera";
|
||
}
|
||
//Safari
|
||
else if(explorer.indexOf("Safari") >= 0){
|
||
getexplorer="Safari";
|
||
}
|
||
return getexplorer;
|
||
}
|