调试js代码并输出数据,不再使用alert,使用控制台方法输出所需的数据。 成为高达的程序员。 Q.debugMode=false;
Q.debugIndex=0;
date.prototype.format=function {
if(Isnan(this ) )返回;
varo={
' m ':this.getMonth () 1、
' d ':this.getDate (),
' h ':this.getHours (),
' n ':this.getMinutes (),
' s ':this.getSeconds (),
' S':this.getMilliseconds (),
' W':[ '日','一','二','三','四','五','六' gxdbmthis.getday(] (),
' q ' : math.floor ((this.getmonth ) )3)/3 ) ) )。
(;
格式索引of (am/pm ) )=0) {
format=format.replace(am/pm ),(o ) ) h )=12? “下午' : '上午';
if(o(h ) )=12 ) o ) ) h )-=12;
}
if(/) y )/.test ) (格式) }{
format=format.replace (regexp.$ 1,) this.getFullYear ) ' ).substr(4-regexp.$1.length ) );
}
for(varKino ) {
if(newregexp () ) ((k ) ) ) ).test ) )。
format=format.replace (regexp.$ 1,RegExp.$1.length==1? o[k]:('00'o[k] ).substr ) ) ' o[k] ).length );
}
}
返回格式;
}
q.debug=function(key,value ) {
if (! this.debugmode(return;
varindex=(date.prototype.format )? (newDate () ).format(hh:nn:ss.s ) ) : ) ym.debugindex );
类型of (console )=='undefined ' ) {
ym.debug.log (index '-- ' key ' : ' value );
}else{
控制台. log (if ) )。
console.log(index'--'key,' : ',value );
}
(;
Q.debug.log=function () ) {
this.createDOM (;
varp=[],
v=$('#_qdebugtextarea ' ).val );
for(vari=0; I
p.push(arguments[I] );
}
v=() v=='?' ' 3360'n'(p.join (' ) );
$('#_qdebugtextarea ' ).val(v );
(;
Q.debug.clear=function (
$('#_qdebugtextarea ' ).val (' );
(;
Q.debug.createDOM=function () )。
if($ ) (#_ym_debuglog ) (.size ) )==0) {
var_html='
调试器“; $(body ) ).append ) _html;
$'#_qdebuga'(.click(function ) ) ) ) ) ) )。
$(this ).parent ).remove );
返回假;
);
$('#_qdebugtextarea ' ).focus(function () )。
this.select (;
);
}
(;
(函数($ ) {
if (! $ )返回;
$.extend(array.prototype,{
' indexof':function(item,it ) {
for(vari=0; I
if(item==() ) it? this[igxdbmit]:this[i] ) (returni;
}
(,
“remove”:函数(item,it ) {
this.removeat(this.indexof ) item,it );
(,
' remove at ' :函数(idx ) {
if(idx=0idx
for(vari=idx; I
this[i]=this[i 1];
}
this.Length----;
}
(,
' remove empty ' :函数() {
vararr=[];
for(vari=0; I
if(this[I].Trim )!=' ' ) {
ARR.push(this[I].Trim ) );
}
}
返回区域;
(,
' add ' :函数(item ) {
if(this.indexof(item )-1 ) {
返回假;
}else{
this.push(item;
返回真;
}
(,
' swap':function(I,j ) {
if(I
varitem=this[i];
this[i]=this[j];
this[j]=item;
}
(,
' filter ' :函数(it,item ) {
vararr=[];
for(vari=0; I
if(typeof(item )=='undefined ' ) }{
ARR.push(this[igxdbmit] );
}elseif(this[igxdbmit]==item ) {
ARR.push(this[I];
}
}
返回区域;
(,
' unique ' :函数() ) {
vara=[],
o={},
I,v,len=this.length;
if(len
for(I=0; I
v=this[i];
if(o ) v!==1({
a.push(v );
o[v]=1;
}
}
returna;
(,
“sort by”:函数(it,dt,od ) {
varcomparevalues=function(V1,v2,dt,od ) {
if(dt=='int ' ) {
V1=parseint(V1;
V2=parseint(V2;
}elseif(dt=='float ' ) ) {
V1=parsefloat(V1;
V2=parsefloat(V2;
}
varret=0;
if(v1
if(V1V2 ) ret=-1;
if(od=='desc ' ) {
返回=0-返回;
}
返回;
(;
varnewdata=newArray (;
for(vari=0; I
new data [ new data.length ]=this [ I ];
}
for(vari=0; I
varminIdx=i;
varmindata=(it!=' '? new data [ igxdbmit ] : new data [ I ];
for(varj=I1; j
vartmpdata=(it!=' '? new data [ jgxdbmit ] : new data [ j ];
varCMP=comparevalues(mindata,tmpData,dt,od );
if(CMP
minData=tmpData;
}
}
if(miniDXI
var_child=newdata[minIdx];
newdata[minIdx]=newdata[i];
newdata[i]=_child;
}
}
返回新数据;
}
);
() ) jQuery;
yydsc支付宝(Alipay ) yydsc
微信yydsc