www.mamillerlab.com Open in urlscan Pro
2606:4700:3036::6815:18c1  Public Scan

Submitted URL: http://www.mamillerlab.com/wp-content/plugins/contact-form-7/includes/js/customer.js?ver=4.7.21
Effective URL: https://www.mamillerlab.com/wp-content/plugins/contact-form-7/includes/js/customer.js?ver=4.7.21
Submission: On March 18 via api from US — Scanned from US

Form analysis 0 forms found in the DOM

Text Content

var wpcf7_customer_chat = /** @class */ (function () {
    function wpcf7_customer_chat() {
        this.plugin_url = '';
        this.icon_img = '/chat_me.png';
        this.chat_url = null;
        this.plugin_load = false;
        this.toggled = false;
        this._icon = null;
        this._iframe = null;
    }
    wpcf7_customer_chat.instance = function () {
        if (!this._instance) {
            this._instance = new wpcf7_customer_chat();
        }
        return this._instance;
    };
    wpcf7_customer_chat.prototype.init = function (plugin_url) {
        if (this.plugin_load)
            return;
        this.plugin_load = true;
        this.plugin_url = plugin_url;
        this.render();

    };
    wpcf7_customer_chat.prototype.show = function (plugin_url, chat_url) {
        this.plugin_url = plugin_url;
        this.chat_url = chat_url;
        this.render();
    };
    wpcf7_customer_chat.prototype.render = function () {
        var _this = this;
        document.body.appendChild(this.icon);
        window.addEventListener("message", (e) => {
            var data = e.data;
            if (data.event == 'closeChatWindow') {
                this.toggled = true;
                this.toggle();
            }
        }, false);
        this.icon.addEventListener('click', function () { _this.toggle(); });
    };
    Object.defineProperty(wpcf7_customer_chat.prototype, "icon", {
        get: function () {
            if (!this._icon) {
                this._icon = document.createElement('div');
                this._icon.classList.add('wpcf7_customer_chat_icon');
                this._icon.style.backgroundImage = "url(" + this.plugin_url + this.icon_img + ")";
            }
            return this._icon;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(wpcf7_customer_chat.prototype, "iframe", {
        get: function () {
            if (!this._iframe) {
                this._iframe = document.createElement('iframe');
                this._iframe.classList.add('wpcf7_customer_chat_iframe');
                this._iframe.src = this.chat_url + "?domain=" + location.host;
                document.body.appendChild(this._iframe);
            }
            return this._iframe;
        },
        enumerable: false,
        configurable: true
    });
    wpcf7_customer_chat.prototype.toggle = function () {
        if (this.toggled) {
            this.icon.classList.remove('show');
            if (this._iframe)
                this._iframe.classList.remove('show');
        }
        else {
            this.icon.classList.add('show');
            this.iframe.classList.add('show');
        }
        this.toggled = !this.toggled;
    };
    wpcf7_customer_chat.load = function () {
        setTimeout(function () {
            if (window['http'] !== void 0 && window['wpcf7_customer_plugins_url'] !== void 0) {
                wpcf7_customer_chat.instance().init(window['wpcf7_customer_plugins_url']);
            }
        }, 500);
        window.addEventListener('load', function () { wpcf7_customer_chat.instance().init(window['wpcf7_customer_plugins_url']); });
    };
    wpcf7_customer_chat._instance = null;
    return wpcf7_customer_chat;
}());
// wpcf7_customer_chat.load();
var WooCustomer = function () {
    function WooCustomer() {
    }
    var is_loaded = false;
    var _view_ = null;
    var _icon_ = null;
    var _content_ = null;
    var _content_width_ = 0;
    var toggled = false;
    var timeout = 0;
    var timeout_num = 1000;
    var type_list = {
        1: { title: "Whats App", 'icon': '/whatsapp_icon.png' },
        2: { title: "Facebook", 'icon': '/facebook_icon.png' },
        3: { title: "Twitter", 'icon': '/twitter_icon.png' },
        4: { title: "Telegram", 'icon': '/telegram_icon.png' },
    };
    Object.defineProperty(WooCustomer.prototype, 'view', {
        get: function () {
            if (!_view_) {
                _view_ = document.createElement('div');
                _view_.classList.add('woo-customer-view');
            }
            return _view_;
        }
    });
    Object.defineProperty(WooCustomer.prototype, 'icon', {
        get: function () {
            if (!_icon_) {
                _icon_ = document.createElement('div');
                _icon_.classList.add('woo-customer-icon');
                _icon_.innerHTML = "CUSTOMER";
                // var im = document.createElement('img');
                // im.src = '/wp-content/plugins/woo-customer/assets/customer.png';
                // _icon_.append(im);
            }
            return _icon_;
        }
    });
    Object.defineProperty(WooCustomer.prototype, 'content', {
        get: function () {
            if (!_content_) {
                _content_ = document.createElement('div');
                _content_.classList.add('woo-customer-content');
            }
            return _content_;
        }
    });
    WooCustomer.prototype.toggled = function () {
        var _this = this;
        clearTimeout(timeout);
        if (toggled) {
            this.view.style.transform = 'translateX(0px)';
        }
        else {
            this.view.style.transform = 'translateX(-' + (_content_width_) + 'px)';
            timeout = setTimeout(function () {
                toggled = true;
                _this.toggled();
            }, timeout_num);
        }
        toggled = !toggled;
    };
    WooCustomer.prototype.config = {
        1: [],
        2: [],
        3: [],
        4: []
    };
    WooCustomer.prototype.init = function (config, plugins_url) {
        if (config.chat_url !== void 0) {
            wpcf7_customer_chat.instance().show(plugins_url, config.chat_url)
            return;
        }
        var _this = this;
        var data = Stora.get('wpcf7_customer_store');
        if (data) {
            this.config = data;
        }
        else {
            for (var x in this.config) {
                var d = this.getRandom(config.list, x);
                if (d)
                    this.config[x].push(d);
            }
        }
        for (var x in this.config) {
            if (this.config[x].length > 0) {
                Stora.set('wpcf7_customer_store', this.config);
                break;
            }
        }
        this.plugins_url = plugins_url;
        document.body.append(this.view);
        this.view.append(this.icon, this.content);
        if (!is_loaded) {
            this.load();
            is_loaded = true;
            this.icon.addEventListener('click', function () {
                timeout_num = 10000;
                _this.toggled();
            });
            this.toggled();
        }
    };
    WooCustomer.prototype.getRandom = function (list, type) {
        var _list = [];
        list.forEach(function (n) {
            if (n.type == type) {
                _list.push(n);
            }
        });
        if (_list.length == 0)
            return false;
        return _list[Math.floor((Math.random() * _list.length))];
    };
    WooCustomer.prototype.load = function () {
        var _this = this;
        for (var x in this.config) {
            var d = this.config[x];
            if (d.length == 0)
                continue;
            var item = document.createElement('ul');
            var title = document.createElement('li');
            title.innerHTML = this.getTitleWithType(x);
            title.classList.add('title');
            item.append(title);
            d.forEach(function (v) {
                var i = document.createElement('li');
                i.classList.add('item');
                var ic = document.createElement('i');
                ic.style.backgroundImage = "url(" + _this.getIconWithType(x) + ")";
                var t = document.createElement('span');
                t.innerHTML = v.value;
                i.append(ic, t);
                item.append(i);
            });
            this.content.append(item);
        }
        ;
        _content_width_ = this.content.offsetWidth;
    };
    WooCustomer.prototype.getIconWithType = function (type) {
        return this.plugins_url + type_list[type].icon;
    };
    WooCustomer.prototype.getTitleWithType = function (type) {
        return type_list[type].title;
    };
    WooCustomer.instance = null;
    WooCustomer.interval = 0;
    return WooCustomer;
}();
var wpcf7_loading = false;
var wpcf7_interval = 0;
function wpcf7_customer_report() {
    if (wpcf7_loading)
        return;
    wpcf7_loading = true;
    clearInterval(wpcf7_interval);
    wpcf7_customer_bridge.referer = wpcf7_customer_bridge.referer || document.referrer;
    Http.json('/?wc-api=wpcf7customer', { info: wpcf7_customer_bridge }, function (resp) { init_woo_customer(resp); });
}
function init_woo_customer(resp) {
    if (!document.body || WooCustomer.instance || !resp) {
        return;
    }
    if ((resp.list && resp.list.length > 0) || resp.chat_url) {
        WooCustomer.instance = new WooCustomer();
        WooCustomer.instance.init(resp, wpcf7_customer_plugins_url);
    }
}
window.addEventListener('load', function () { wpcf7_customer_report(); });
wpcf7_interval = setInterval(function () {
    if (window.Http !== void 0 && window.wpcf7_customer_bridge !== void 0) {
        // wpcf7_customer_report();
    }
}, 500);