11/*
2- * JavaScript tracker for Snowplow: helpers .js
2+ * JavaScript tracker for Snowplow: SnowPlow .js
33 *
44 * Significant portions copyright 2010 Anthon Pang. Remainder copyright
55 * 2012-2014 Snowplow Analytics Ltd. All rights reserved.
3232 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333 */
3434
35- /*
36- * Is property defined?
37- */
38- SnowPlow . isDefined = function ( property ) {
39- return typeof property !== 'undefined' ;
40- }
41-
42- /**
43- * Is property null?
44- */
45- SnowPlow . isNotNull = function ( property ) {
46- return property !== null ;
47- }
48-
49- /*
50- * Is property a function?
51- */
52- SnowPlow . isFunction = function ( property ) {
53- return typeof property === 'function' ;
54- }
55-
56- /*
57- * Is property an array?
58- */
59- SnowPlow . isArray = ( 'isArray' in Array ) ?
60- Array . isArray :
61- function ( value ) {
62- return Object . prototype . toString . call ( value ) === '[object Array]' ;
63- }
64-
65- /*
66- * Is property an empty array?
67- */
68- SnowPlow . isEmptyArray = function ( property ) {
69- return SnowPlow . isArray ( property ) && property . length < 1 ;
70- }
71-
72- /*
73- * Is property an object?
74- *
75- * @return bool Returns true if property is null, an Object, or subclass of Object (i.e., an instanceof String, Date, etc.)
76- */
77- SnowPlow . isObject = function ( property ) {
78- return typeof property === 'object' ;
79- }
80-
81- /*
82- * Is property a JSON?
83- */
84- SnowPlow . isJson = function ( property ) {
85- return ( SnowPlow . isDefined ( property ) && SnowPlow . isNotNull ( property ) && property . constructor === { } . constructor ) ;
86- }
87-
88- /*
89- * Is property a non-empty JSON?
90- */
91- SnowPlow . isNonEmptyJson = function ( property ) {
92- return SnowPlow . isJson ( property ) && property !== { } ;
93- }
94-
95- /*
96- * Is property a string?
97- */
98- SnowPlow . isString = function ( property ) {
99- return typeof property === 'string' || property instanceof String ;
100- }
101-
102- /*
103- * Is property a non-empty string?
104- */
105- SnowPlow . isNonEmptyString = function ( property ) {
106- return SnowPlow . isString ( property ) && property !== '' ;
107- }
108-
109- /*
110- * Is property a date?
111- */
112- SnowPlow . isDate = function ( property ) {
113- return Object . prototype . toString . call ( property ) === "[object Date]" ;
114- }
115-
11635/*
11736 * UTF-8 encoding
11837 */
@@ -124,11 +43,11 @@ SnowPlow.encodeUtf8 = function (argString) {
12443 * Cleans up the page title
12544 */
12645SnowPlow . fixupTitle = function ( title ) {
127- if ( ! SnowPlow . isString ( title ) ) {
46+ if ( ! Identifiers . isString ( title ) ) {
12847 title = title . text || '' ;
12948
13049 var tmp = SnowPlow . documentAlias . getElementsByTagName ( 'title' ) ;
131- if ( tmp && SnowPlow . isDefined ( tmp [ 0 ] ) ) {
50+ if ( tmp && Identifiers . isDefined ( tmp [ 0 ] ) ) {
13251 title = tmp [ 0 ] . text ;
13352 }
13453 }
@@ -294,7 +213,7 @@ SnowPlow.executePluginMethod = function (methodName, callback) {
294213 for ( i in SnowPlow . plugins ) {
295214 if ( Object . prototype . hasOwnProperty . call ( SnowPlow . plugins , i ) ) {
296215 pluginMethod = SnowPlow . plugins [ i ] [ methodName ] ;
297- if ( SnowPlow . isFunction ( pluginMethod ) ) {
216+ if ( Identifiers . isFunction ( pluginMethod ) ) {
298217 result += pluginMethod ( callback ) ;
299218 }
300219 }
@@ -314,33 +233,4 @@ SnowPlow.fromQuerystring = function (field, url) {
314233 return SnowPlow . decodeWrapper ( match [ 1 ] . replace ( / \+ / g, ' ' ) ) ;
315234}
316235
317- // Base64 module
318- SnowPlow . base64 = require ( 'Base64' ) ;
319-
320- /*
321- * Base64 encode data
322- */
323- SnowPlow . base64encode = SnowPlow . base64 . btoa ;
324-
325- /*
326- * Base64 decode data
327- */
328- SnowPlow . base64decode = SnowPlow . base64 . atob ;
329-
330- /*
331- * Bas64 encode data with URL and Filename Safe Alphabet (base64url)
332- *
333- * See: http://tools.ietf.org/html/rfc4648#page-7
334- */
335- SnowPlow . base64urlencode = function ( data ) {
336- if ( ! data ) return data ;
337-
338- var enc = SnowPlow . base64encode ( data ) ;
339- return enc . replace ( / = / g, '' )
340- . replace ( / \+ / g, '-' )
341- . replace ( / \/ / g, '_' ) ;
342- } ;
343-
344236SnowPlow . murmurhash3_32_gc = require ( 'murmurhash' ) . v3 ;
345-
346- SnowPlow . JSON2 = require ( 'JSON' ) ;
0 commit comments