///
/** DIV or element center * @ return */jQuery. fn. mCenterDiv = function () {this.css ("position", "absolute"); this.css ("border", "1px solid # ccc"); this.css ("top ", ($ (window ). height ()-this. height ()/2 + $ (window ). scrollTop () + "px"); this.css ("left", ($ (window ). width ()-this. width ()/2 + $ (window ). scrollLeft () + "px"); this. show (100); return this;};/** get URL parameter * @ param name parameter * @ return */jQuery. mGetUrlParam = Function (name) {var reg = new RegExp ("(^ | &)" + name + "= ([^ &] *) (& | $ )"); var r = window. location. search. substr (1 ). match (reg); if (r! = Null) return unescape (r [2]); return null ;};/** multiplication function, used to obtain the exact multiplication result * @ param arg1 parameter 1 * @ param arg2 parameter 2 * @ return */jQuery. mAccMul = function (arg1, arg2) {var m = 0, s1 = arg1.toString (), s2 = arg2.toString (); try {m + = s1.split (". ") [1]. length} catch (e) {}try {m + = s2.split (". ") [1]. length} catch (e) {} return Number (s1.replace (". "," ") * Number (s2.replace (". "," ")/Math. pow (10, m)}/** rounds the value (Retain 2 decimal places) and format it into the amount form * @ param num value (Number or String) * @ return amount Format String, such as '123' */jQuery. mFormatCurrency = function (num) {num = num. toString (). replace (/\ $ | \,/g, ''); if (isNaN (num) num =" 0 "; sign = (num = Math. abs (num); num = Math. floor (num * 100 + 0.50000000001); cents = num % 100; num = Math. floor (num/100 ). toString (); if (cents <10) cents = "0" + cents; for (var I = 0; I <Math. Floor (num. length-(1 + I)/3); I ++) num = num. substring (0, num. length-(4 * I + 3) + ',' + num. substring (num. length-(4 * I + 3); return (sign )? '': '-') + Num + '. '+ cents);}/** Regular Expression verification * @ param s verification string * @ param type verification type: money, china, mobile, etc. * @ return */jQuery. mCheck = function (s, type) {var objbool = false; var objexp = ""; switch (type) {case 'money': // amount format, the format is defined as a positive number with decimal places. after the decimal point, a maximum of three objexp = "^ [0-9] + [\.] [0-9] {0, 3} $ "; break; case 'numletter _': // The combination of letters, numbers, and underscores (_) is objexp = "^ [0-9a-zA-Z \ _] + $"; break; case 'numletter ': // an objexp = "^ [0-9a-z A-Z] + $ "; break; case 'numletterchina': // consisting of Chinese characters, letters, numbers objexp =" ^ [0-9a-zA-Z \ u4e00-\ u9fa5] + $ "; break; case 'e-mail ': // mail address format objexp = "^ ([a-zA-Z0-9 _\. \-]) + \ @ ([a-zA-Z0-9 \-]) + \.) + ([a-zA-Z0-9] {2, 4}) + $ "; break; case 'tel ': // fixed-line format objexp =/^ (\ d {2, 3 }\)) | (\ d {3 }\-))? (\ (0 \ d {2, 3} \) | 0 \ d {2, 3 }-)? [1-9] \ d {6, 7} (\-\ d {1, 4 })? $/; Break; case 'mobile': // mobile phone number objexp = "^ (13 [0-9] | 15 [0-9] | 18 [0-9]) ([0-9] {8}) $ "; break; case 'decimal': // floating point number objexp =" ^ [0-9] + ([.] [0-9] + )? $ "; Break; case 'url': // url objexp =" (http: // | https: //) {0, 1} [\ w \/\.\? \ & \ =] + "; Break; case 'date': // date YYYY-MM-DD format objexp =/^ (\ d {}) (-| \/) (\ d {1, 2}) \ 2 (\ d {1, 2}) $/; break; case 'int ': // integer objexp = "^ [0-9] * [1-9] [0-9] * $"; break; case 'int + ': // a positive integer contains 0 objexp = "^ \ d + $"; break; case 'int -': // The negative integer contains 0 objexp = "^ (-\ d +) | (0 +) $"; break; case 'China ': // Chinese objexp =/^ [\ u0391-\ uFFE5] + $/; break;} var re = new RegExp (objexp); if (re. test (s) {return true;} else {return false ;}}; /** obtain the control value * @ param controlID Control ID * @ param controltype type, for example, text radio * @ return */jQuery. mGetValue = function (controlID, controltype) {var objValue = ""; switch (controltype) {case 'text': // text input box objValue = $. trim ($ ("#" + controlID + ""). attr ("value"); // The value is left and right spaces break; case 'radio ': // single statement objValue = $ ("input [name = '" + controlID + "']: checked "). attr ("value"); break; case 'select': // drop-down list objValue = $ ("#" + controlID + ""). attr ("value"); break; case 'checkbox': // multiple choice box $ ("input [name = '" + controlID + "']: checked "). each (function () {objValue + = $ (this ). val () + "," ;}); break; default: break;} return objValue ;}; /** set the control value * @ param controlID Control ID * @ param controltype type, such as text radio * @ param controlvalue bound value * @ return */jQuery. mSetValue = function (controlID, controltype, controlvalue) {switch (controltype) {case 'text': // text input box // $ ("# txtUserID "). attr ("value", 'This is the bound content'); // fill in the content // $ ("input [name = 'radio1'] [value = 'shanghai']"). attr ("checked", true); // radio Group radio: set the value = 'shanghai' project to the currently selected item // $ ("# select1 "). attr ("value", 'portuguese '); // select from the drop-down box: set the project with value = 'China' to the selected item // $ ("input [name = 'checkbox1'] [value = 'black'], [value = 'blue'] "). attr ("checked", true); // multi-choice box: set multiple values to the selected item $ ("#" + controlID + ""). attr ("value", controlvalue); // fill in the content break; case 'radio ': // single orders $ ("input [name = '" + controlID + "'] [value = '" + controlvalue + "']"). attr ("checked", true); break; case 'select': // drop-down list $ ("#" + controlID + ""). attr ("value", controlvalue); break; case 'checkbox ': // multiple choice box $ ("input [name = '" + controlID + "'] [value = '" + controlvalue + "'], [value = '"+ controlvalue +"'] "). attr ("checked", true); // multiple selection box: set multiple values to the selected item break; default: break ;};/** determines whether the object is empty, undefined or null * @ param object * @ return */jQuery. mIsNull = function (obj) {if (obj = "" | obj = "undefined" | obj = null) {return true ;} else {return false ;}}/** automatically jumps to the url * @ param url to jump to the url * @ return */jQuery. mAutoNav = function (url) {if ($. browser. msie) {var referLink = document. createElement ('A'); referLink. href = url; document. body. appendChild (referLink); referLink. click ();} else {location. href = url;}/** Center screen display processing progress * @ param info display text * @ param type mode 0 mask 1 unmask * @ param typepic image 0: load 1: OK 2: error * @ return */jQuery. mMaskLoad = function (info, type, typepic) {var pic = ""; switch (typepic) {case 0: // loading pic = ". /Images/loading.gif "; break; case 1: // OK pic = ". /Images/right.png "; break; case 2: // error pic = ". /Images/error.png "; break; default: // pic = ". /Images/loading.gif "; break;} if (type = 0) {$ (" ).css ({display: "block", width: "100%", position: "absolute", left: "0", top: "0", opacity: "0.3", height: "100%", filter: "alpha (opacity = 30 )", background: "# ccc "}). appendTo ("body") ;}; $ (").css ({position:" absolute ", top:" 50% ", padding:" 12px 5px 10px 30px ", width: "auto", height: "16px", border: "1px solid # D1D1D1", background: "# ffffff url ('" + pic + "') no-repeat scroll 5px center ", display:" block ", left: ($ (document. body ). outerWidth (true)-190)/2, top: ($ (window ). height ()-45)/2 rows before .html (info ). appendTo ("body") ;};/** hide the processing progress in the center of the screen * @ return */jQuery. mMaskLoadClose = function () {$ (". datagrid-mask "). remove (); $ (". datagrid-mask-msg "). remove () ;};/** after the control, create a SPAN as the TIP prompt * @ param o use this * @ param tip to prompt the text * @ param typepic image 0: load 1: OK 2: error * @ return */jQuery. mTip = function (o, tip, typepic) {var pic = ""; switch (typepic) {case 0: // loading pic = ". /Images/loading.gif "; break; case 1: // OK pic = ". /Images/right.png "; break; case 2: // error pic = ". /Images/error.png "; break; default: // pic = ". /Images/loading.gif "; break;} var eTip = document. createElement ("span"); var objid = $ (o ). attr ("id") + "_ tipDiv"; var value = $ (o ). val (); // absolute path var x = $ (o ). offset (). top; var y = $ (o ). offset (). left; var w = $ (o ). width (); var h = $ (o ). height (); eTip. setAttribute ("id", objid); try {document. body. appendChild (eTip);} catch (e) {}$ ("#" + objid ). hide (); $ ("#" + objid).css ({top: x, left: y + w + 10, height: h, position: "absolute ",}); $ ("#" + objid).html ("" + tip); $ ("#" + objid ). show ();}