Skip to content

Instantly share code, notes, and snippets.

@kyle-mccarthy
Last active February 7, 2018 17:35

Revisions

  1. kyle-mccarthy revised this gist Feb 7, 2018. 1 changed file with 4 additions and 6 deletions.
    10 changes: 4 additions & 6 deletions callrailGoogleMaps.js
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,9 @@
    var callrailGoogleMaps = {
    getNumbers: function() {
    var self = this;
    if (window.CallTrk !== undefined) {
    window.CallTrk.getSwapNumbers(null, function(nums) {
    self.swapNumbers(nums);
    });
    }
    window.CallTrk.getSwapNumbers(null, function(nums) {
    self.swapNumbers(nums);
    });
    },
    getMapPoints: function() {
    if (mapping !== undefined) {
    @@ -29,7 +27,7 @@ var callrailGoogleMaps = {
    },
    init: function() {
    var self = this;
    if (window.mapping === undefined) {
    if (window.mapping === undefined || window.CallTrk === undefined) {
    setTimeout(function() {
    self.init();
    }, 500)
  2. kyle-mccarthy created this gist Feb 7, 2018.
    42 changes: 42 additions & 0 deletions callrailGoogleMaps.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    var callrailGoogleMaps = {
    getNumbers: function() {
    var self = this;
    if (window.CallTrk !== undefined) {
    window.CallTrk.getSwapNumbers(null, function(nums) {
    self.swapNumbers(nums);
    });
    }
    },
    getMapPoints: function() {
    if (mapping !== undefined) {
    return mapping.mapPoint.alllocmap.points;
    }
    return [];
    },
    swapNumbers: function(nums) {
    this.getMapPoints().forEach(function(p) {
    var n = Number(p.appointments.replace(/-/g, ''));
    if (nums[n] !== undefined) {
    var fmtd = (nums[n] + "").replace(/(\d{3})(\d{3})(\d{4})/, '$1-$2-$3');
    p.appointments = fmtd;
    }

    });
    this.reloadMap();
    },
    reloadMap: function() {
    mapping.load()
    },
    init: function() {
    var self = this;
    if (window.mapping === undefined) {
    setTimeout(function() {
    self.init();
    }, 500)
    } else {
    this.getNumbers();
    }
    }
    };

    callrailGoogleMaps.init();