Whether the group Array Extension contains element attributes:
// Extended Function (whether it contains an element)
Array. Prototype. Contains = Function (E)
{
For (I = 0; I < This . Length; I ++)
{
If ( This [I] = E)
Return True ;
}
Return False ;
}
/* Usage: var temp = [1, 2, 3, 4, 5]; VaR status = Temp. Contains (1 );
*/
Date Format:
Date. Prototype. Formate = function (FMT ){
VaR O = {
"M + ": This . Getmonth () + 1, // Month
"D + ": This . Getdate (), // Day
"H + ": This . Gethours () % 12 = 0? 12: This . Gethours () % 12, // Hours
"H + ": This . Gethours (), // Hours
"M + ": This . Getminutes (), // Minute
"S + ": This . Getseconds (), // Seconds
"Q +": Math. Floor (( This . Getmonth () + 3)/3 ), // Quarter
"F ": This . Getmilliseconds () // Millisecond
};
VaR Week = {
"0": "/u65e5 ",
"1": "/u4e00 ",
"2": "/u4e8c ",
"3": "/u4e09 ",
"4": "/u56db ",
"5": "/u4e94 ",
"6": "/u516d"
};
If (/(Y +)/. Test (FMT ))
{
FMt = FMT. Replace (Regexp. $1 ,( This . Getfullyear () + ""). substr (4-Regexp. $1. Length ));
}
If (/(E +)/. Test (FMT ))
{
FMt = FMT. Replace (Regexp. $1, (Regexp. $1. length> 1 )? (Regexp. $1. length> 2? "/U661f/u671f": "/u5468"): "") + week [ This . Getday () + ""]);
}
For ( VaR K In O)
{
If ( New Regexp ("(" + K + ")"). Test (FMT ))
{
FMt = FMT. Replace (Regexp. $1, (Regexp. $1. Length = 1 )? (O [k]): ("00" + O [k]). substr ("" + O [k]). Length )));
}
}
Return FMT;
}