1
1
( function ( ) {
2
2
var pageWidth = 0 ,
3
3
pageHeight = 0 ,
4
- currentDevice = Countly . passed_data . currentDevice && Countly . passed_data . currentDevice . length ? Countly . passed_data . currentDevice : [ ] ,
4
+ currentDevice = Countly . passed_data . currentDevice && Countly . passed_data . currentDevice . length && Countly . passed_data . currentDevice [ 0 ] ? Countly . passed_data . currentDevice : [ ] ,
5
5
currentMap = Countly . passed_data . currentMap == "scroll" ? "scroll" : "click" ,
6
6
showHeatMap = Countly . passed_data . showHeatMap == false ? false : true ,
7
7
clickMap ,
12
12
document . body . style . position = "relative" ;
13
13
var origtop = document . body . style . top ;
14
14
var toppx = 59 ;
15
- var devices = [
15
+ var allDevices = [
16
16
{
17
17
type : "all" ,
18
18
displayText : "All" ,
32
32
maxWidth : 1024
33
33
} ,
34
34
{
35
- type : "desktop" ,
36
- displayText : "Desktop" ,
35
+ type : "desktop-1280 " ,
36
+ displayText : "Desktop - 1280 " ,
37
37
minWidth : 1024 ,
38
- maxWidth : 10240
38
+ maxWidth : 1280
39
+ } ,
40
+ {
41
+ type : "desktop-1366" ,
42
+ displayText : "Desktop - 1366" ,
43
+ minWidth : 1280 ,
44
+ maxWidth : 1366
45
+ } ,
46
+ {
47
+ type : "desktop-1440" ,
48
+ displayText : "Desktop - 1440" ,
49
+ minWidth : 1366 ,
50
+ maxWidth : 1440
51
+ } ,
52
+ {
53
+ type : "desktop-1600" ,
54
+ displayText : "Desktop - 1600" ,
55
+ minWidth : 1440 ,
56
+ maxWidth : 1600
57
+ } ,
58
+ {
59
+ type : "desktop-1920" ,
60
+ displayText : "Desktop - 1920" ,
61
+ minWidth : 1600 ,
62
+ maxWidth : 1920
39
63
} ,
64
+ {
65
+ type : "desktop-other" ,
66
+ displayText : "Desktop - Other" ,
67
+ minWidth : null ,
68
+ maxWidth : 10240
69
+ }
40
70
] ;
41
71
72
+ var devices = [ ] ;
73
+
42
74
if ( origtop ) {
43
75
toppx += parseInt ( origtop ) ;
44
76
}
49
81
topbar . setAttribute ( "id" , "cly-heatmap-topbar" ) ;
50
82
document . body . appendChild ( topbar ) ;
51
83
52
-
53
-
54
84
if ( currentDevice . length ) {
55
85
pageWidth = Countly . _internals . getDocWidth ( ) ;
56
86
pageWidth = Math . min ( currentDevice [ 0 ] . maxWidth , pageWidth ) ;
62
92
else {
63
93
pageWidth = Countly . _internals . getDocWidth ( ) ;
64
94
pageHeight = Countly . _internals . getDocHeight ( ) - toppx ;
95
+ }
96
+
97
+ for ( var i = 0 ; i < allDevices . length ; i ++ ) {
98
+ if ( ( allDevices [ i ] . minWidth != null ) && ( allDevices [ i ] . minWidth < pageWidth ) ) {
99
+ devices . push ( allDevices [ i ] ) ;
100
+ }
101
+
102
+ if ( allDevices [ i ] . type === "desktop-other" && ( devices . length > 3 ) ) {
103
+ devices . push ( allDevices [ i ] ) ;
104
+ devices [ devices . length - 1 ] . minWidth = devices [ devices . length - 2 ] . maxWidth ;
105
+ }
106
+ }
107
+
108
+ if ( ! currentDevice . length ) {
65
109
currentDevice = devices . filter ( ( deviceObj ) => {
66
110
return deviceObj . minWidth < pageWidth && deviceObj . maxWidth >= pageWidth && deviceObj . type != "all" ;
67
111
} ) ;
205
249
if ( device . type == "all" ) {
206
250
return deviceObj . type == "all" ;
207
251
}
252
+ else if ( device . type == "desktop-other" ) {
253
+ return deviceObj . type == "desktop-other" ;
254
+ }
208
255
else {
209
256
return deviceObj . minWidth < pageWidth && deviceObj . maxWidth >= pageWidth && deviceObj . type != "all" ;
210
257
}
305
352
if ( currentDevice [ 0 ] . type == "all" ) {
306
353
return deviceObj . type == "all" ;
307
354
}
355
+ else if ( currentDevice [ 0 ] . type == "desktop-other" ) {
356
+ return deviceObj . type == "desktop-other" ;
357
+ }
308
358
else {
309
359
return deviceObj . minWidth < pageWidth && deviceObj . maxWidth >= pageWidth && deviceObj . type != "all" ;
310
360
}
473
523
}
474
524
475
525
function loadData ( ) {
476
- sendXmlHttpRequest ( { app_key : Countly . app_key , view : Countly . _internals . getLastView ( ) || window . location . pathname , period : period , deviceType : currentDevice [ 0 ] . type , actionType : actionType } , apiPath , function ( err , clicks ) {
526
+ sendXmlHttpRequest ( { app_key : Countly . app_key , view : Countly . _internals . getLastView ( ) || window . location . pathname , period : period , device : JSON . stringify ( currentDevice [ 0 ] ) , actionType : actionType } , apiPath , function ( err , clicks ) {
477
527
if ( ! err ) {
478
528
dataCache [ currentDevice [ 0 ] . type ] = clicks . data ;
479
529
drawData ( ) ;
538
588
}
539
589
540
590
function loadData ( ) {
541
- sendXmlHttpRequest ( { app_key : Countly . app_key , view : Countly . _internals . getLastView ( ) || window . location . pathname , period : period , deviceType : currentDevice [ 0 ] . type , actionType : actionType } , apiPath , function ( err , scrolls ) {
591
+ sendXmlHttpRequest ( { app_key : Countly . app_key , view : Countly . _internals . getLastView ( ) || window . location . pathname , period : period , device : JSON . stringify ( currentDevice [ 0 ] ) , actionType : actionType } , apiPath , function ( err , scrolls ) {
542
592
if ( ! err ) {
543
593
dataCache [ currentDevice [ 0 ] . type ] = scrolls . data ;
544
594
drawData ( ) ;
728
778
}
729
779
}
730
780
}
731
- } ) ( ) ;
781
+ } ) ( ) ;
0 commit comments