Completed
Push — master ( f95d6f...748f90 )
by Luke
02:26
created

javascripts/respond.js   F

Complexity

Total Complexity 236
Complexity/F 2.48

Size

Lines of Code 778
Function Count 95

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 0
dl 0
loc 778
rs 2.1818
c 0
b 0
f 0
wmc 236
mnd 10
bc 261
fnc 95
bpm 2.7473
cpm 2.4842
noi 22

37 Functions

Rating   Name   Duplication   Size   Complexity  
A cssHelper.parsed 0 14 4
A cssHelper.getViewportHeight 0 3 1
A cssHelper.removeStyle 0 3 1
A ua.toString 0 3 1
A respond.js ➔ domReady 0 6 2
B respond.js ➔ _c 0 36 5
A _13.declaration 0 12 1
A respond.js ➔ _2d 0 7 3
A cssHelper.selectors 0 5 1
A cssHelper.rules 0 5 1
A cssHelper.properties 0 5 1
A respond.js ➔ _2 0 8 3
C _13.mediaQuery 0 35 8
B respond.js ➔ enableCssMediaQueries 0 289 1
C respond.js ➔ _1e 0 45 8
B cssHelper.constructor 0 415 1
A respond.js ➔ _a 0 10 4
A respond.js ➔ _11 0 7 1
C respond.js ➔ _19 0 48 9
B cssHelper.removeListener 0 11 5
B _13.mediaQueryList 0 30 4
A cssHelper.getViewportWidth 0 3 1
A cssHelper.addListener 0 8 3
B respond.js ➔ _2f 0 9 5
B cssHelper.addStyle 0 25 4
A document.onreadystatechange 0 6 2
A cssHelper.mediaQueryLists 0 5 1
A respond.js ➔ _7 0 5 2
A ua.test 0 3 1
A respond.js ➔ _1d 0 4 1
B domReady.constructor 0 48 5
A 0 10 2
A respond.js ➔ _8 0 5 2
B _13.rule 0 32 2
A cssHelper.declarations 0 5 1
A Object.create 0 6 1
B respond.js ➔ _2b 0 19 6

How to fix   Complexity   

Complexity

Complex classes like javascripts/respond.js often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
if(typeof Object.create!=="function"){
2
Object.create=function(o){
0 ignored issues
show
Compatibility Best Practice introduced by
You are extending the built-in type Object. This may have unintended consequences on other objects using this built-in type. Consider subclassing instead.
Loading history...
3
function F(){
4
};
5
F.prototype=o;
6
return new F();
7
};
8
}
9
var ua={toString:function(){
10
return navigator.userAgent;
0 ignored issues
show
Bug introduced by
The variable navigator seems to be never declared. If this is a global, consider adding a /** global: navigator */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
11
},test:function(s){
12
return this.toString().toLowerCase().indexOf(s.toLowerCase())>-1;
13
}};
14
ua.version=(ua.toString().toLowerCase().match(/[\s\S]+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1];
15
ua.webkit=ua.test("webkit");
16
ua.gecko=ua.test("gecko")&&!ua.webkit;
17
ua.opera=ua.test("opera");
18
ua.ie=ua.test("msie")&&!ua.opera;
19
ua.ie6=ua.ie&&document.compatMode&&typeof document.documentElement.style.maxHeight==="undefined";
20
ua.ie7=ua.ie&&document.documentElement&&typeof document.documentElement.style.maxHeight!=="undefined"&&typeof XDomainRequest==="undefined";
0 ignored issues
show
Bug introduced by
The variable XDomainRequest seems to be never declared. If this is a global, consider adding a /** global: XDomainRequest */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
21
ua.ie8=ua.ie&&typeof XDomainRequest!=="undefined";
22
var domReady=function(){
23
var _1=[];
24
var _2=function(){
25
if(!arguments.callee.done){
26
arguments.callee.done=true;
27
for(var i=0;i<_1.length;i++){
28
_1[i]();
29
}
30
}
31
};
32
if(document.addEventListener){
33
document.addEventListener("DOMContentLoaded",_2,false);
34
}
35
if(ua.ie){
36
(function(){
37
try{
38
document.documentElement.doScroll("left");
39
}
40
catch(e){
41
setTimeout(arguments.callee,50);
42
return;
43
}
44
_2();
45
})();
46
document.onreadystatechange=function(){
47
if(document.readyState==="complete"){
48
document.onreadystatechange=null;
49
_2();
50
}
51
};
52
}
53
if(ua.webkit&&document.readyState){
54
(function(){
55
if(document.readyState!=="loading"){
56
_2();
57
}else{
58
setTimeout(arguments.callee,10);
59
}
60
})();
61
}
62
window.onload=_2;
63
return function(fn){
64
if(typeof fn==="function"){
65
_1[_1.length]=fn;
66
}
67
return fn;
68
};
69
}();
70
var cssHelper=function(){
71
var _3={BLOCKS:/[^\s{][^{]*\{(?:[^{}]*\{[^{}]*\}[^{}]*|[^{}]*)*\}/g,BLOCKS_INSIDE:/[^\s{][^{]*\{[^{}]*\}/g,DECLARATIONS:/[a-zA-Z\-]+[^;]*:[^;]+;/g,RELATIVE_URLS:/url\(['"]?([^\/\)'"][^:\)'"]+)['"]?\)/g,REDUNDANT_COMPONENTS:/(?:\/\*([^*\\\\]|\*(?!\/))+\*\/|@import[^;]+;)/g,REDUNDANT_WHITESPACE:/\s*(,|:|;|\{|\})\s*/g,MORE_WHITESPACE:/\s{2,}/g,FINAL_SEMICOLONS:/;\}/g,NOT_WHITESPACE:/\S+/g};
72
var _4,_5=false;
73
var _6=[];
74
var _7=function(fn){
75
if(typeof fn==="function"){
76
_6[_6.length]=fn;
77
}
78
};
79
var _8=function(){
80
for(var i=0;i<_6.length;i++){
81
_6[i](_4);
82
}
83
};
84
var _9={};
85
var _a=function(n,v){
86
if(_9[n]){
87
var _b=_9[n].listeners;
88
if(_b){
89
for(var i=0;i<_b.length;i++){
90
_b[i](v);
91
}
92
}
93
}
94
};
95
var _c=function(_d,_e,_f){
96
if(ua.ie&&!window.XMLHttpRequest){
97
window.XMLHttpRequest=function(){
98
return new ActiveXObject("Microsoft.XMLHTTP");
0 ignored issues
show
Bug introduced by
The variable ActiveXObject seems to be never declared. If this is a global, consider adding a /** global: ActiveXObject */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
99
};
100
}
101
if(!XMLHttpRequest){
0 ignored issues
show
Best Practice introduced by
If you intend to check if the variable XMLHttpRequest is declared in the current environment, consider using typeof XMLHttpRequest === "undefined" instead. This is safe if the variable is not actually declared.
Loading history...
102
return "";
103
}
104
var r=new XMLHttpRequest();
105
try{
106
r.open("get",_d,true);
107
r.setRequestHeader("X_REQUESTED_WITH","XMLHttpRequest");
108
}
109
catch(e){
110
_f();
111
return;
112
}
113
var _10=false;
114
setTimeout(function(){
115
_10=true;
116
},5000);
117
document.documentElement.style.cursor="progress";
118
r.onreadystatechange=function(){
119
if(r.readyState===4&&!_10){
120
if(!r.status&&location.protocol==="file:"||(r.status>=200&&r.status<300)||r.status===304||navigator.userAgent.indexOf("Safari")>-1&&typeof r.status==="undefined"){
0 ignored issues
show
Bug introduced by
The variable navigator seems to be never declared. If this is a global, consider adding a /** global: navigator */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
121
_e(r.responseText);
122
}else{
123
_f();
124
}
125
document.documentElement.style.cursor="";
126
r=null;
127
}
128
};
129
r.send("");
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
130
};
131
var _11=function(_12){
132
_12=_12.replace(_3.REDUNDANT_COMPONENTS,"");
133
_12=_12.replace(_3.REDUNDANT_WHITESPACE,"$1");
134
_12=_12.replace(_3.MORE_WHITESPACE," ");
135
_12=_12.replace(_3.FINAL_SEMICOLONS,"}");
136
return _12;
137
};
138
var _13={mediaQueryList:function(s){
139
var o={};
140
var idx=s.indexOf("{");
141
var lt=s.substring(0,idx);
142
s=s.substring(idx+1,s.length-1);
143
var mqs=[],rs=[];
144
var qts=lt.toLowerCase().substring(7).split(",");
145
for(var i=0;i<qts.length;i++){
146
mqs[mqs.length]=_13.mediaQuery(qts[i],o);
147
}
148
var rts=s.match(_3.BLOCKS_INSIDE);
149
if(rts!==null){
150
for(i=0;i<rts.length;i++){
151
rs[rs.length]=_13.rule(rts[i],o);
152
}
153
}
154
o.getMediaQueries=function(){
155
return mqs;
156
};
157
o.getRules=function(){
158
return rs;
159
};
160
o.getListText=function(){
161
return lt;
162
};
163
o.getCssText=function(){
164
return s;
165
};
166
return o;
167
},mediaQuery:function(s,mql){
168
s=s||"";
169
var not=false,_14;
170
var exp=[];
171
var _15=true;
172
var _16=s.match(_3.NOT_WHITESPACE);
173
for(var i=0;i<_16.length;i++){
174
var _17=_16[i];
175
if(!_14&&(_17==="not"||_17==="only")){
176
if(_17==="not"){
177
not=true;
178
}
179
}else{
180
if(!_14){
181
_14=_17;
182
}else{
183
if(_17.charAt(0)==="("){
184
var _18=_17.substring(1,_17.length-1).split(":");
185
exp[exp.length]={mediaFeature:_18[0],value:_18[1]||null};
186
}
187
}
188
}
189
}
190
return {getList:function(){
191
return mql||null;
192
},getValid:function(){
193
return _15;
194
},getNot:function(){
195
return not;
196
},getMediaType:function(){
197
return _14;
0 ignored issues
show
Bug introduced by
The variable _14 seems to not be initialized for all possible execution paths.
Loading history...
198
},getExpressions:function(){
199
return exp;
200
}};
201
},rule:function(s,mql){
202
var o={};
203
var idx=s.indexOf("{");
204
var st=s.substring(0,idx);
205
var ss=st.split(",");
206
var ds=[];
207
var dts=s.substring(idx+1,s.length-1).split(";");
208
for(var i=0;i<dts.length;i++){
209
ds[ds.length]=_13.declaration(dts[i],o);
210
}
211
o.getMediaQueryList=function(){
212
return mql||null;
213
};
214
o.getSelectors=function(){
215
return ss;
216
};
217
o.getSelectorText=function(){
218
return st;
219
};
220
o.getDeclarations=function(){
221
return ds;
222
};
223
o.getPropertyValue=function(n){
224
for(var i=0;i<ds.length;i++){
225
if(ds[i].getProperty()===n){
226
return ds[i].getValue();
227
}
228
}
229
return null;
230
};
231
return o;
232
},declaration:function(s,r){
233
var idx=s.indexOf(":");
234
var p=s.substring(0,idx);
235
var v=s.substring(idx+1);
236
return {getRule:function(){
237
return r||null;
238
},getProperty:function(){
239
return p;
240
},getValue:function(){
241
return v;
242
}};
243
}};
244
var _19=function(el){
245
if(typeof el.cssHelperText!=="string"){
246
return;
247
}
248
var o={mediaQueryLists:[],rules:[],selectors:{},declarations:[],properties:{}};
249
var _1a=o.mediaQueryLists;
250
var ors=o.rules;
251
var _1b=el.cssHelperText.match(_3.BLOCKS);
252
if(_1b!==null){
253
for(var i=0;i<_1b.length;i++){
254
if(_1b[i].substring(0,7)==="@media "){
255
_1a[_1a.length]=_13.mediaQueryList(_1b[i]);
256
ors=o.rules=ors.concat(_1a[_1a.length-1].getRules());
257
}else{
258
ors[ors.length]=_13.rule(_1b[i]);
259
}
260
}
261
}
262
var oss=o.selectors;
263
var _1c=function(r){
264
var ss=r.getSelectors();
265
for(var i=0;i<ss.length;i++){
266
var n=ss[i];
267
if(!oss[n]){
268
oss[n]=[];
269
}
270
oss[n][oss[n].length]=r;
271
}
272
};
273
for(i=0;i<ors.length;i++){
274
_1c(ors[i]);
275
}
276
var ods=o.declarations;
277
for(i=0;i<ors.length;i++){
278
ods=o.declarations=ods.concat(ors[i].getDeclarations());
279
}
280
var ops=o.properties;
281
for(i=0;i<ods.length;i++){
282
var n=ods[i].getProperty();
283
if(!ops[n]){
284
ops[n]=[];
285
}
286
ops[n][ops[n].length]=ods[i];
287
}
288
el.cssHelperParsed=o;
289
_4[_4.length]=el;
290
return o;
291
};
292
var _1d=function(el,s){
293
el.cssHelperText=_11(s||el.innerHTML);
294
return _19(el);
295
};
296
var _1e=function(){
297
_5=true;
298
_4=[];
299
var _1f=[];
300
var _20=function(){
301
for(var i=0;i<_1f.length;i++){
302
_19(_1f[i]);
303
}
304
var _21=document.getElementsByTagName("style");
305
for(i=0;i<_21.length;i++){
306
_1d(_21[i]);
307
}
308
_5=false;
309
_8();
310
};
311
var _22=document.getElementsByTagName("link");
312
for(var i=0;i<_22.length;i++){
313
var _23=_22[i];
314
if(_23.getAttribute("rel").indexOf("style")>-1&&_23.href&&_23.href.length!==0&&!_23.disabled){
315
_1f[_1f.length]=_23;
316
}
317
}
318
if(_1f.length>0){
319
var c=0;
320
var _24=function(){
321
c++;
322
if(c===_1f.length){
323
_20();
324
}
325
};
326
var _25=function(_26){
327
var _27=_26.href;
328
_c(_27,function(_28){
329
_28=_11(_28).replace(_3.RELATIVE_URLS,"url("+_27.substring(0,_27.lastIndexOf("/"))+"/$1)");
330
_26.cssHelperText=_28;
331
_24();
332
},_24);
333
};
334
for(i=0;i<_1f.length;i++){
335
_25(_1f[i]);
336
}
337
}else{
338
_20();
339
}
340
};
341
var _29={mediaQueryLists:"array",rules:"array",selectors:"object",declarations:"array",properties:"object"};
342
var _2a={mediaQueryLists:null,rules:null,selectors:null,declarations:null,properties:null};
343
var _2b=function(_2c,v){
344
if(_2a[_2c]!==null){
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if _2a._2c !== null is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
345
if(_29[_2c]==="array"){
346
return (_2a[_2c]=_2a[_2c].concat(v));
347
}else{
348
var c=_2a[_2c];
349
for(var n in v){
350
if(v.hasOwnProperty(n)){
351
if(!c[n]){
352
c[n]=v[n];
353
}else{
354
c[n]=c[n].concat(v[n]);
355
}
356
}
357
}
358
return c;
359
}
360
}
361
};
362
var _2d=function(_2e){
363
_2a[_2e]=(_29[_2e]==="array")?[]:{};
364
for(var i=0;i<_4.length;i++){
365
_2b(_2e,_4[i].cssHelperParsed[_2e]);
366
}
367
return _2a[_2e];
368
};
369
domReady(function(){
370
var els=document.body.getElementsByTagName("*");
371
for(var i=0;i<els.length;i++){
372
els[i].checkedByCssHelper=true;
373
}
374
if(document.implementation.hasFeature("MutationEvents","2.0")||window.MutationEvent){
375
document.body.addEventListener("DOMNodeInserted",function(e){
376
var el=e.target;
377
if(el.nodeType===1){
378
_a("DOMElementInserted",el);
379
el.checkedByCssHelper=true;
380
}
381
},false);
382
}else{
383
setInterval(function(){
384
var els=document.body.getElementsByTagName("*");
385
for(var i=0;i<els.length;i++){
386
if(!els[i].checkedByCssHelper){
387
_a("DOMElementInserted",els[i]);
388
els[i].checkedByCssHelper=true;
389
}
390
}
391
},1000);
392
}
393
});
394
var _2f=function(d){
395
if(typeof window.innerWidth!="undefined"){
396
return window["inner"+d];
397
}else{
398
if(typeof document.documentElement!="undefined"&&typeof document.documentElement.clientWidth!="undefined"&&document.documentElement.clientWidth!=0){
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if typeof document.document...lement.clientWidth != 0 is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
399
return document.documentElement["client"+d];
400
}
401
}
402
};
403
return {addStyle:function(s,_30){
404
var el=document.createElement("style");
405
el.setAttribute("type","text/css");
406
document.getElementsByTagName("head")[0].appendChild(el);
407
if(el.styleSheet){
408
el.styleSheet.cssText=s;
409
}else{
410
el.appendChild(document.createTextNode(s));
411
}
412
el.addedWithCssHelper=true;
413
if(typeof _30==="undefined"||_30===true){
414
cssHelper.parsed(function(_31){
0 ignored issues
show
Unused Code introduced by
The parameter _31 is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
415
var o=_1d(el,s);
416
for(var n in o){
417
if(o.hasOwnProperty(n)){
418
_2b(n,o[n]);
419
}
420
}
421
_a("newStyleParsed",el);
422
});
423
}else{
424
el.parsingDisallowed=true;
425
}
426
return el;
427
},removeStyle:function(el){
428
return el.parentNode.removeChild(el);
429
},parsed:function(fn){
430
if(_5){
431
_7(fn);
432
}else{
433
if(typeof _4!=="undefined"){
434
if(typeof fn==="function"){
435
fn(_4);
436
}
437
}else{
438
_7(fn);
439
_1e();
440
}
441
}
442
},mediaQueryLists:function(fn){
443
cssHelper.parsed(function(_32){
0 ignored issues
show
Unused Code introduced by
The parameter _32 is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
444
fn(_2a.mediaQueryLists||_2d("mediaQueryLists"));
445
});
446
},rules:function(fn){
447
cssHelper.parsed(function(_33){
0 ignored issues
show
Unused Code introduced by
The parameter _33 is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
448
fn(_2a.rules||_2d("rules"));
449
});
450
},selectors:function(fn){
451
cssHelper.parsed(function(_34){
0 ignored issues
show
Unused Code introduced by
The parameter _34 is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
452
fn(_2a.selectors||_2d("selectors"));
453
});
454
},declarations:function(fn){
455
cssHelper.parsed(function(_35){
0 ignored issues
show
Unused Code introduced by
The parameter _35 is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
456
fn(_2a.declarations||_2d("declarations"));
457
});
458
},properties:function(fn){
459
cssHelper.parsed(function(_36){
0 ignored issues
show
Unused Code introduced by
The parameter _36 is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
460
fn(_2a.properties||_2d("properties"));
461
});
462
},broadcast:_a,addListener:function(n,fn){
463
if(typeof fn==="function"){
464
if(!_9[n]){
465
_9[n]={listeners:[]};
466
}
467
_9[n].listeners[_9[n].listeners.length]=fn;
468
}
469
},removeListener:function(n,fn){
470
if(typeof fn==="function"&&_9[n]){
471
var ls=_9[n].listeners;
472
for(var i=0;i<ls.length;i++){
473
if(ls[i]===fn){
474
ls.splice(i,1);
475
i-=1;
476
}
477
}
478
}
479
},getViewportWidth:function(){
480
return _2f("Width");
481
},getViewportHeight:function(){
482
return _2f("Height");
483
}};
484
}();
485
domReady(function enableCssMediaQueries(){
486
var _37;
487
var _38={LENGTH_UNIT:/[0-9]+(em|ex|px|in|cm|mm|pt|pc)$/,RESOLUTION_UNIT:/[0-9]+(dpi|dpcm)$/,ASPECT_RATIO:/^[0-9]+\/[0-9]+$/,ABSOLUTE_VALUE:/^[0-9]*(\.[0-9]+)*$/};
488
var _39=[];
489
var _3a=function(){
490
var id="css3-mediaqueries-test";
491
var el=document.createElement("div");
492
el.id=id;
493
var _3b=cssHelper.addStyle("@media all and (width) { #"+id+" { width: 1px !important; } }",false);
494
document.body.appendChild(el);
495
var ret=el.offsetWidth===1;
496
_3b.parentNode.removeChild(_3b);
497
el.parentNode.removeChild(el);
498
_3a=function(){
499
return ret;
500
};
501
return ret;
502
};
503
var _3c=function(){
504
_37=document.createElement("div");
505
_37.style.cssText="position:absolute;top:-9999em;left:-9999em;"+"margin:0;border:none;padding:0;width:1em;font-size:1em;";
506
document.body.appendChild(_37);
507
if(_37.offsetWidth!==16){
508
_37.style.fontSize=16/_37.offsetWidth+"em";
509
}
510
_37.style.width="";
511
};
512
var _3d=function(_3e){
513
_37.style.width=_3e;
514
var _3f=_37.offsetWidth;
515
_37.style.width="";
516
return _3f;
517
};
518
var _40=function(_41,_42){
519
var l=_41.length;
520
var min=(_41.substring(0,4)==="min-");
521
var max=(!min&&_41.substring(0,4)==="max-");
522
if(_42!==null){
523
var _43;
524
var _44;
525
if(_38.LENGTH_UNIT.exec(_42)){
526
_43="length";
527
_44=_3d(_42);
528
}else{
529
if(_38.RESOLUTION_UNIT.exec(_42)){
530
_43="resolution";
531
_44=parseInt(_42,10);
532
var _45=_42.substring((_44+"").length);
533
}else{
534
if(_38.ASPECT_RATIO.exec(_42)){
535
_43="aspect-ratio";
536
_44=_42.split("/");
537
}else{
538
if(_38.ABSOLUTE_VALUE){
539
_43="absolute";
540
_44=_42;
541
}else{
542
_43="unknown";
543
}
544
}
545
}
546
}
547
}
548
var _46,_47;
549
if("device-width"===_41.substring(l-12,l)){
550
_46=screen.width;
0 ignored issues
show
Bug introduced by
The variable screen seems to be never declared. If this is a global, consider adding a /** global: screen */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
551
if(_42!==null){
552
if(_43==="length"){
0 ignored issues
show
Bug introduced by
The variable _43 does not seem to be initialized in case _42 !== null on line 522 is false. Are you sure this can never be the case?
Loading history...
553
return ((min&&_46>=_44)||(max&&_46<_44)||(!min&&!max&&_46===_44));
0 ignored issues
show
Bug introduced by
The variable _44 seems to not be initialized for all possible execution paths.
Loading history...
554
}else{
555
return false;
556
}
557
}else{
558
return _46>0;
559
}
560
}else{
561
if("device-height"===_41.substring(l-13,l)){
562
_47=screen.height;
563
if(_42!==null){
564
if(_43==="length"){
565
return ((min&&_47>=_44)||(max&&_47<_44)||(!min&&!max&&_47===_44));
566
}else{
567
return false;
568
}
569
}else{
570
return _47>0;
571
}
572
}else{
573
if("width"===_41.substring(l-5,l)){
574
_46=document.documentElement.clientWidth||document.body.clientWidth;
575
if(_42!==null){
576
if(_43==="length"){
577
return ((min&&_46>=_44)||(max&&_46<_44)||(!min&&!max&&_46===_44));
578
}else{
579
return false;
580
}
581
}else{
582
return _46>0;
583
}
584
}else{
585
if("height"===_41.substring(l-6,l)){
586
_47=document.documentElement.clientHeight||document.body.clientHeight;
587
if(_42!==null){
588
if(_43==="length"){
589
return ((min&&_47>=_44)||(max&&_47<_44)||(!min&&!max&&_47===_44));
590
}else{
591
return false;
592
}
593
}else{
594
return _47>0;
595
}
596
}else{
597
if("device-aspect-ratio"===_41.substring(l-19,l)){
598
return _43==="aspect-ratio"&&screen.width*_44[1]===screen.height*_44[0];
599
}else{
600
if("color-index"===_41.substring(l-11,l)){
601
var _48=Math.pow(2,screen.colorDepth);
602
if(_42!==null){
603
if(_43==="absolute"){
604
return ((min&&_48>=_44)||(max&&_48<_44)||(!min&&!max&&_48===_44));
605
}else{
606
return false;
607
}
608
}else{
609
return _48>0;
610
}
611
}else{
612
if("color"===_41.substring(l-5,l)){
613
var _49=screen.colorDepth;
614
if(_42!==null){
615
if(_43==="absolute"){
616
return ((min&&_49>=_44)||(max&&_49<_44)||(!min&&!max&&_49===_44));
617
}else{
618
return false;
619
}
620
}else{
621
return _49>0;
622
}
623
}else{
624
if("resolution"===_41.substring(l-10,l)){
625
var res;
626
if(_45==="dpcm"){
0 ignored issues
show
Bug introduced by
The variable _45 seems to not be initialized for all possible execution paths.
Loading history...
627
res=_3d("1cm");
628
}else{
629
res=_3d("1in");
630
}
631
if(_42!==null){
632
if(_43==="resolution"){
633
return ((min&&res>=_44)||(max&&res<_44)||(!min&&!max&&res===_44));
634
}else{
635
return false;
636
}
637
}else{
638
return res>0;
639
}
640
}else{
641
return false;
642
}
643
}
644
}
645
}
646
}
647
}
648
}
649
}
650
};
651
var _4a=function(mq){
652
var _4b=mq.getValid();
653
var _4c=mq.getExpressions();
654
var l=_4c.length;
655
if(l>0){
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if l > 0 is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
656
for(var i=0;i<l&&_4b;i++){
657
_4b=_40(_4c[i].mediaFeature,_4c[i].value);
658
}
659
var not=mq.getNot();
660
return (_4b&&!not||not&&!_4b);
661
}
662
};
663
var _4d=function(mql){
664
var mqs=mql.getMediaQueries();
665
var t={};
666
for(var i=0;i<mqs.length;i++){
667
if(_4a(mqs[i])){
668
t[mqs[i].getMediaType()]=true;
669
}
670
}
671
var s=[],c=0;
672
for(var n in t){
673
if(t.hasOwnProperty(n)){
674
if(c>0){
675
s[c++]=",";
676
}
677
s[c++]=n;
678
}
679
}
680
if(s.length>0){
681
_39[_39.length]=cssHelper.addStyle("@media "+s.join("")+"{"+mql.getCssText()+"}",false);
682
}
683
};
684
var _4e=function(_4f){
685
for(var i=0;i<_4f.length;i++){
686
_4d(_4f[i]);
687
}
688
if(ua.ie){
689
document.documentElement.style.display="block";
690
setTimeout(function(){
691
document.documentElement.style.display="";
692
},0);
693
setTimeout(function(){
694
cssHelper.broadcast("cssMediaQueriesTested");
695
},100);
696
}else{
697
cssHelper.broadcast("cssMediaQueriesTested");
698
}
699
};
700
var _50=function(){
701
for(var i=0;i<_39.length;i++){
702
cssHelper.removeStyle(_39[i]);
703
}
704
_39=[];
705
cssHelper.mediaQueryLists(_4e);
706
};
707
var _51=0;
708
var _52=function(){
709
var _53=cssHelper.getViewportWidth();
710
var _54=cssHelper.getViewportHeight();
711
if(ua.ie){
712
var el=document.createElement("div");
713
el.style.position="absolute";
714
el.style.top="-9999em";
715
el.style.overflow="scroll";
716
document.body.appendChild(el);
717
_51=el.offsetWidth-el.clientWidth;
718
document.body.removeChild(el);
719
}
720
var _55;
721
var _56=function(){
722
var vpw=cssHelper.getViewportWidth();
723
var vph=cssHelper.getViewportHeight();
724
if(Math.abs(vpw-_53)>_51||Math.abs(vph-_54)>_51){
725
_53=vpw;
726
_54=vph;
727
clearTimeout(_55);
728
_55=setTimeout(function(){
729
if(!_3a()){
730
_50();
731
}else{
732
cssHelper.broadcast("cssMediaQueriesTested");
733
}
734
},500);
735
}
736
};
737
window.onresize=function(){
738
var x=window.onresize||function(){
739
};
740
return function(){
741
x();
742
_56();
743
};
744
}();
745
};
746
var _57=document.documentElement;
747
_57.style.marginLeft="-32767px";
748
setTimeout(function(){
749
_57.style.marginTop="";
750
},20000);
751
return function(){
752
if(!_3a()){
753
cssHelper.addListener("newStyleParsed",function(el){
754
_4e(el.cssHelperParsed.mediaQueryLists);
755
});
756
cssHelper.addListener("cssMediaQueriesTested",function(){
757
if(ua.ie){
758
_57.style.width="1px";
759
}
760
setTimeout(function(){
761
_57.style.width="";
762
_57.style.marginLeft="";
763
},0);
764
cssHelper.removeListener("cssMediaQueriesTested",arguments.callee);
765
});
766
_3c();
767
_50();
768
}else{
769
_57.style.marginLeft="";
770
}
771
_52();
772
};
773
}());
774
try{
775
document.execCommand("BackgroundImageCache",false,true);
776
}
777
catch(e){
0 ignored issues
show
Coding Style Comprehensibility Best Practice introduced by
Empty catch clauses should be used with caution; consider adding a comment why this is needed.
Loading history...
778
}
779
780