123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- Array.prototype.remove = function(element) {
- for (var i = 0, n = 0; i < this.length; i++) {
- if (this[i] != element) {
- this[n++] = this[i];
- }
- }
- if (n < i)
- this.length -= 1;
- };
- Array.prototype.contains = function(element) {
- for (var i = 0; i < this.length; i++) {
- if (this[i] == element) {
- return true;
- }
- }
- return false;
- };
- Array.prototype.indexOfObj = function(objKey, objVal) {
- if (!objKey)
- return -1;
- for (var i = 0; i < this.length; i++) {
- var _obj = this[i];
- if (typeof _obj == 'object' && _obj["" + objKey + ""] == objVal) {
- return i;
- }
- }
- return -1;
- };
- Array.prototype.getObjElements = function(objKey, objVal) {
- var _elements = [];
- if (!objKey)
- return 'undefined';
- for (var i = 0; i < this.length; i++) {
- var _obj = this[i];
- if (typeof _obj == 'object' && _obj["" + objKey + ""] == objVal) {
- _elements.push(_obj);
- }
- }
- return _elements;
- };
- String.escape = function(A) {
- return A.replace(/('|\\)/g, "\\$1");
- };
- String.leftPad = function(D, B, C) {
- var A = new String(D);
- if (C === null || C === undefined || C === "") {
- C = " ";
- }
- while (A.length < B) {
- A = C + A;
- }
- return A;
- };
- String.format = function(B) {
- var A = Array.prototype.slice.call(arguments, 1);
- return B.replace(/\{(\d+)\}/g, function(C, D) {
- return A[D];
- });
- };
- String.prototype.toggle = function(B, A) {
- return this == B ? A : B;
- };
- String.prototype.trim = function() {
- return this.replace(/^\s+|\s+$/g, "");
- };
- String.prototype.endWith = function (str) {
- var _allLen = this.length;
- var _strLen = str.length;
- var _subLen = this.lastIndexOf(str);
- if (_allLen == (_subLen + _strLen)) {
- return true;
- }
- return false;
- };
- String.prototype.startWith = function(str){
- if(str == null || str == "" || this.length == 0 || str.length > this.length) {
- return false;
- }
- if(this.substr(0,str.length) == str) {
- return true;
- }
-
- return false;
- };
- //remove comma from number string
- String.prototype.rawNum = function(){
- return this.replace(/,/g,"");
- };
- //extend window.showModalDialog
- var _smd = window.showModalDialog;
- window.showModalDialog = function(sURL, vArguments, sFeatures){
- var rv = _smd(sURL, vArguments, sFeatures);
- if(typeof rv == "undefined" || typeof rv.errorFlag == "undefined"){
- return rv;
- } else {
- if (typeof window.dialogArguments == "undefined") {
- window.top.location.href = "userlogout.action";
- } else {
- var _rv = new Object();
- _rv.errorFlag = true;
- window.returnValue = _rv;
- window.close();
- }
- }
- };
|