JSFiddle - React, Tailwind, and code Playground

by Oliver Kelso

JavaScript

//PULSE vMATT.0
var pulse = {

    config: {
        dc: "//ens-activatesandbox.activate.ensighten.com/no-content", // pulse gif url
        //dl: hp_dataLayer, // dataobject
        at: 'sc' // analytics vendor
    },

    params: {},

    /**
     * Encode string
     */
    pEncode: function(string) {
        if (typeof encodeURIComponent == "function") {
            return encodeURIComponent(string);
        } else {
            return escape(string);
        }
    },

    /**
     * Parse parameter string and encode values
     */
    parseParams: function(string) {
        if (typeof string === 'string') {
            string = (string.match("/;+$/")) ? string.replace(/;+$/, "") : string; // remove trailing semicolon

            var parsed = string.split(";"); // split string on semicolon

            var arrayLength = parsed.length;
            for (var i = 0; i < arrayLength; i++) {
                if (parsed[i] !== "undefined") {
                    parsed[i] = this.pEncode(parsed[i]); // encode array values
                }
            }

            return parsed.join(";"); // return string           
        } else {
            return string;
        }
    },

    /**
     * Page data
     */
    collect: function() {
        this.params = {};
        this.params.ti = document.title || ""; // page title
        this.params.sr = screen.width + "x" + screen.height; // screen resolution
        this.params.ref = document.referrer || ""; // referrer
        this.params.ul = navigator.language || navigator.userLanguage || navigator.browserLanguage || "unknown"; // browser language
        this.params.cd = screen.colorDepth || "unknown"; // browser color depth
        this.params.bs = this.bScreen();
        this.params.sip = document.location.hostname; // current host name
        this.params.uri = document.location.pathname; // current path
        this.params.bh = new Date().getHours(); // current hour of the day
        this.params.tz = new...