1
- // Open Pixel v1.0.0 | Published By Dockwa, Inc. | Created By Stuart Yamartino | MIT License
1
+ // Open Pixel v1.0.0 | Published By Dockwa | Created By Stuart Yamartino | MIT License
2
2
; ( function ( window , document , pixelFunc , pixelFuncName , pixelEndpoint , versionNumber ) {
3
3
'use strict' ;
4
4
5
5
var _createClass = function ( ) { function defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ( ) ;
6
6
7
- var _typeof = typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ? function ( obj ) { return typeof obj ; } : function ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol ? "symbol" : typeof obj ; } ;
7
+ var _typeof = typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ? function ( obj ) { return typeof obj ; } : function ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } ;
8
8
9
9
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
10
10
11
11
var Config = {
12
12
id : '' ,
13
13
version : versionNumber
14
- } ;
15
14
16
- // check if a varaible is not undefined, null, or blank
17
- var isset = function isset ( variable ) {
15
+ // check if a variable is not undefined, null, or blank
16
+ } ; var isset = function isset ( variable ) {
18
17
return typeof variable !== "undefined" && variable !== null && variable !== '' ;
19
18
} ;
20
19
@@ -30,12 +29,12 @@ var guid = function guid() {
30
29
} ) + ( 1 * new Date ( ) ) . toString ( 36 ) ;
31
30
} ;
32
31
33
- // reduces all optinal data down to a string
32
+ // reduces all optional data down to a string
34
33
var optinalData = function optinalData ( data ) {
35
34
if ( isset ( data ) === false ) {
36
35
return '' ;
37
36
} else if ( ( typeof data === 'undefined' ? 'undefined' : _typeof ( data ) ) === 'object' ) {
38
- // runs optinalData again to reduce to string incase something else was returned
37
+ // runs optinalData again to reduce to string in case something else was returned
39
38
return optinalData ( JSON . stringify ( data ) ) ;
40
39
} else if ( typeof data === 'function' ) {
41
40
// runs the function and calls optinalData again to reduce further if it isn't a string
@@ -77,7 +76,7 @@ var Cookie = {
77
76
return '__' + pixelFuncName + '_' ;
78
77
} ,
79
78
set : function set ( name , value , minutes ) {
80
- var path = arguments . length <= 3 || arguments [ 3 ] === undefined ? "/" : arguments [ 3 ] ;
79
+ var path = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : "/" ;
81
80
82
81
var expires = "" ;
83
82
if ( isset ( minutes ) ) {
@@ -142,7 +141,6 @@ var Cookie = {
142
141
143
142
var Url = {
144
143
// http://stackoverflow.com/a/901144/1231563
145
-
146
144
getParameterByName : function getParameterByName ( name , url ) {
147
145
if ( ! url ) url = window . location . href ;
148
146
name = name . replace ( / [ \[ \] ] / g, "\\$&" ) ;
@@ -247,11 +245,11 @@ var Pixel = function () {
247
245
} , // get the utm concent
248
246
utm_campaign : function utm_campaign ( key ) {
249
247
return Cookie . getUtm ( key ) ;
250
- } } ;
248
+ } // get the utm campaign
249
+ } ;
251
250
}
252
251
} , {
253
252
key : 'setParam' ,
254
- // get the utm campaign
255
253
value : function setParam ( key , val ) {
256
254
if ( isset ( val ) ) {
257
255
this . params . push ( key + '=' + val ) ;
@@ -270,8 +268,8 @@ var Pixel = function () {
270
268
window . navigator . sendBeacon ( this . getSourceUrl ( ) ) ;
271
269
}
272
270
} , {
273
- key : 'sendImg ' ,
274
- value : function sendImg ( ) {
271
+ key : 'sendImage ' ,
272
+ value : function sendImage ( ) {
275
273
this . img = document . createElement ( 'img' ) ;
276
274
this . img . src = this . getSourceUrl ( ) ;
277
275
this . img . style . display = 'none' ;
@@ -323,7 +321,7 @@ window.addEventListener('unload', function () {
323
321
// set 10 minutes page close cookie
324
322
// Cookie.throttle('pageclose');
325
323
new Pixel ( 'pageclose' , now ( ) , function ( ) {
326
- // if a link was clicked in the last 5 seconds that goes to an extenal host, pass it through as event data
324
+ // if a link was clicked in the last 5 seconds that goes to an external host, pass it through as event data
327
325
if ( isset ( Config . externalHost ) && now ( ) - Config . externalHost . time < 5 * 1000 ) {
328
326
return Config . externalHost . link ;
329
327
}
0 commit comments