Angela.array = {//# Array method//index, return position.
Does not exist returns-1; index:function (T, arr) {//# Returns the position of the array where the current value is located if (arr.indexof) {return arr.indexof (t); for (var i = arr.length; i--;)
{if (arr[i] = = t) {return i * 1;
}
};
return-1; }//Returns the key value of the object.
The return value type is an array.
, Getkey:function (data) {//# Returns all the key values of the object var arr = [], k;
For (k in data) {Arr.push (k);
};
return arr; ///Randomly remove a value from the array, random:function (arrays) {//# A random value from the array arrays = Arrays | |
[];
var len = arrays.length, index = Tydic.math.randInt (0, len-1); return Arrays[index] | |
''; }//one-dimensional array, unique:function (array) {//#一维数组去重 array = array | |
[];
for (var i = 0, len = Array.Length i < len; i++) {for (var j = i + 1; j < Array.Length; + +) { if (array[i] = = Array[j]) {Array.splice (J, 1);
j--;
}} return array;
//MAX, the largest item in the array, max:function (array) {//#求数组中最大的项 return Math.max.apply (null, array);
}//min, the smallest item in the array, min:function (array) {//#求数组中最小的项 return Math.min.apply (null, array);
//Remove, remove, remove:function (array, value) {//#移除数组中某值 var length = Array.Length;
while (length--) {if (value = = Array[length]) {array.splice (length, 1);
} return array; }//empty array, Empty:function (array) {//# empty array (Array | |
[]). length = 0;
return array; ///RemoveAt, delete the value at the specified location//@index, index.
Does not pass index, deletes the first, removeat:function (array, index) {//#删除数组中 the value of the specified position Array.splice (index, 1);
return array; //Shuffle array sort, shuffle:function (arr) {//#打乱数组排序 var array = (Arr | |
[]). Concat (), length = array.length, i = length//traversal, TMP = NULL//Temporary
, Rand = TYDIC.MATH.RANDINT//position, pos = 0;
while (i--) {pos = rand (0, length);
Swap random position tmp = Array[pos];
Array[pos] = Array[i];
Array[i] = tmp;
} return array; }
};
Cookie method Set
Angela.cookie = {//# cookie//browser is enough to support cookies enable:!! navigator.cookieenabled//Read cookies, get:function (name) {//#读取 cookie var reg = new RegExp ("(^|)" + NA Me + "(?: = ([^;] *))?
(; |$) "), val = Document.cookie.match (reg); Return Val?
(Val[2] unescape (val[2]): ""; //write cookies, set:function (name, value, expires, path, domain, secure) {//# Write cookie var exp = new D Ate (), expires = Arguments[2] | | NULL, PATH = arguments[3] | | "/", domain = arguments[4] | | NULL, secure = arguments[5] | |
false; Expires?
Exp.setminutes (exp.getminutes () + parseint (expires)): ""; Document.cookie = name + ' = ' + escape (value) + (expires?) '; expires= ' + exp.togmtstring (): ') + (path? ';p ath= ' + path: ') + (domain? ';d omain= ' + domain: ') + (secure?
'; secure ': '; //delete cookies, del:function (name, path, domain, secure) {#删除 cookie var value = $getCookie (name);
if (value!= null) {var exp = new Date ();
Exp.setminutes (Exp.getminutes ()-1000); Path = Path | |
"/"; Document.cookie = name + ' =;expires= ' + exp.togmtstring () + (path? ';p ath= ' + path: ') + (domain? ';d omain= ' + domain: ') + (secure?
'; secure ': '; }
}
};
URL Method Set
Angela.url = {//#URL
//parameter: variable name, URL is empty table from the current page URL
getquery:function (name, url) {
var u = arguments[1] | | win Dow.location.search
, Reg = new RegExp ("(^|&)" + name + "= ([^&]*) (&|$)")
, R = U.substr (U.indexof ("?" ) + 1). Match (Reg)
;
return R!= null<