callpixelsjs-rails 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b2c0ef2df998258513cac5f0d6f0b3ccf9d9b71
4
- data.tar.gz: 2f3dbe63b7f19edcc49992a5c85b649f4f21b547
3
+ metadata.gz: bc2e5d9260ec76000e3d2c7449fecaae270af1ea
4
+ data.tar.gz: 2a2e186dafd4fb760d0d2617a4e4574487cb0134
5
5
  SHA512:
6
- metadata.gz: 9e4096c448774c12e21f54e9bef4d8ca0a412364e1b2f3f81d6914c85b2f205275baee90ac9005e322dde921b21d3ad9926726bfff444f24dc4773efcba1094b
7
- data.tar.gz: 836894e3d01086546e0d8037d773cab8b647a2cdf9e15a36681a8b8dfeea0659f81134bd3122ae5f2a0d3f8c5c75b55911d166502ee5234adb3cfee4114ce3f7
6
+ metadata.gz: 0bf788e71b56f3f2717bc9664befa6eae8ac5bdde8ed52806133362d09bd897ecc2f867bb5f2b4016dd31508cf50c52787341bcb9a1cc5142f7aa37c8550dd4d
7
+ data.tar.gz: 9e897d3b0db2c448d6142faf633f650c4ee65d6a470e1990d605efd6d96bd2504b99188bce347b9df1ac5cfa2e56b1129519de3b95a7f64454af728194e87772
@@ -1,5 +1,5 @@
1
1
  module Callpixelsjs
2
2
  module Rails
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -1015,15 +1015,20 @@
1015
1015
  for (var primary_key in numbers) {
1016
1016
  var number = numbers[primary_key];
1017
1017
  if (number.is_active === 'true') {
1018
- if (typeof(grouped[number.campaign_key]) === 'undefined') grouped[number.campaign_key] = [];
1019
- grouped[number.campaign_key].push(number.id);
1018
+ if (typeof(grouped[number.campaign_key]) === 'undefined'){
1019
+ grouped[number.campaign_key] = [];
1020
+ grouped[number.campaign_key]['ids'] = [];
1021
+ grouped[number.campaign_key]['hashes'] = [];
1022
+ }
1023
+ grouped[number.campaign_key]['ids'].push(number.id);
1024
+ grouped[number.campaign_key]['hashes'].push(number.id_as_hash);
1020
1025
  }
1021
1026
  }
1022
1027
  // ping each group of number_ids
1023
1028
  for (var campaign_key in grouped) {
1024
1029
  var payload = {
1025
- campaign_key: campaign_key,
1026
- ids: grouped[campaign_key]
1030
+ ids: grouped[campaign_key].ids,
1031
+ hashes: grouped[campaign_key].hashes
1027
1032
  };
1028
1033
  Callpixels.Base.Request.connection().postJSON('/api/v1/numbers/ping', payload, [Callpixels.Base.Model.update, callback], this);
1029
1034
  }
@@ -1,2 +1,2 @@
1
1
  /*! callpixels 13-08-2014 */
2
- !function(){"undefined"==typeof window.Callpixels&&(window.Callpixels={});var a={};a.assert_required_keys=function(){for(var a=Array.prototype.slice.call(arguments),b=a.shift(),c=0;c<a.length;c++){var d=a[c];if("undefined"==typeof b||"undefined"==typeof b[d])throw"ArgumentError: Required keys are not defined: "+a.join(", ")}return b},a.merge=function(b,c){for(var d in c)try{b[d]=c[d].constructor==Object?a.merge(b[d],c[d]):c[d]}catch(e){b[d]=c[d]}return b},a.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)},a.ieVersion=function(){return null==a._ieVersion&&(a._ieVersion=function(){for(var a=3,b=document.createElement("div"),c=b.getElementsByTagName("i");b.innerHTML="<!--[if gt IE "+ ++a+"]><i></i><![endif]-->",c[0];);return a>4?a:!1}()),(6==a._ieVersion||7==a._ieVersion)&&null==Callpixels.easyxdm_loaded&&(Callpixels.easyxdm_loaded=!1),a._ieVersion},Callpixels.Base=a}(),function(a){var b=function(a,c,d){return 1===arguments.length?b.get(a):b.set(a,c,d)};b._document=document,b._navigator=navigator,b.defaults={path:"/"},b.get=function(a){return b._cachedDocumentCookie!==b._document.cookie&&b._renewCache(),b._cache[a]},b.set=function(a,c,d){return d=b._getExtendedOptions(d),b._document.cookie=b._generateCookieString(a,c,d),b},b._getExtendedOptions=function(c){return{path:c&&c.path||b.defaults.path,domain:c&&c.domain||b.defaults.domain,secure:c&&c.secure!==a?c.secure:b.defaults.secure}},b._isValidDate=function(a){return"[object Date]"===Object.prototype.toString.call(a)&&!isNaN(a.getTime())},b._generateCookieString=function(a,b,c){return a=encodeURIComponent(a),b=(b+"").replace(/[^!#$&-+\--:<-\[\]-~]/g,encodeURIComponent),c=c||{},a=a+"="+b+(c.path?";path="+c.path:""),a+=c.domain?";domain="+c.domain:"",a+=c.secure?";secure":""},b._getCookieObjectFromString=function(c){var d={};c=c?c.split("; "):[];for(var e=0;e<c.length;e++){var f=b._getKeyValuePairFromCookieString(c[e]);d[f.key]===a&&(d[f.key]=f.value)}return d},b._getKeyValuePairFromCookieString=function(a){var b=a.indexOf("="),b=0>b?a.length:b;return{key:decodeURIComponent(a.substr(0,b)),value:decodeURIComponent(a.substr(b+1))}},b._renewCache=function(){b._cache=b._getCookieObjectFromString(b._document.cookie),b._cachedDocumentCookie=b._document.cookie},b._areEnabled=function(){return b._navigator.cookieEnabled||"1"===b.set("cookies.js",1).get("cookies.js")},b.enabled=b._areEnabled(),"function"==typeof define&&define.amd?define(function(){return b}):"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=b),exports.Cookies=b):b,Callpixels.Base.Cookies=b}(),function(){var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="};Base64.encode=function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=Base64._utf8_encode(a);j<a.length;)b=a.charCodeAt(j++),c=a.charCodeAt(j++),d=a.charCodeAt(j++),e=b>>2,f=(3&b)<<4|c>>4,g=(15&c)<<2|d>>6,h=63&d,isNaN(c)?g=h=64:isNaN(d)&&(h=64),i=i+Base64._keyStr.charAt(e)+Base64._keyStr.charAt(f)+Base64._keyStr.charAt(g)+Base64._keyStr.charAt(h);return i},Base64.decode=function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");j<a.length;)e=Base64._keyStr.indexOf(a.charAt(j++)),f=Base64._keyStr.indexOf(a.charAt(j++)),g=Base64._keyStr.indexOf(a.charAt(j++)),h=Base64._keyStr.indexOf(a.charAt(j++)),b=e<<2|f>>4,c=(15&f)<<4|g>>2,d=(3&g)<<6|h,i+=String.fromCharCode(b),64!=g&&(i+=String.fromCharCode(c)),64!=h&&(i+=String.fromCharCode(d));return i=Base64._utf8_decode(i)},Base64._utf8_encode=function(string){string=string.replace(eval("/\\r\\n/g"),eval("String('\\n')"));for(var utftext="",n=0;n<string.length;n++){var c=string.charCodeAt(n);128>c?utftext+=String.fromCharCode(c):c>127&&2048>c?(utftext+=String.fromCharCode(c>>6|192),utftext+=String.fromCharCode(63&c|128)):(utftext+=String.fromCharCode(c>>12|224),utftext+=String.fromCharCode(c>>6&63|128),utftext+=String.fromCharCode(63&c|128))}return utftext},Base64._utf8_decode=function(a){for(var b="",c=0,d=c1=c2=0;c<a.length;)d=a.charCodeAt(c),128>d?(b+=String.fromCharCode(d),c++):d>191&&224>d?(c2=a.charCodeAt(c+1),b+=String.fromCharCode((31&d)<<6|63&c2),c+=2):(c2=a.charCodeAt(c+1),c3=a.charCodeAt(c+2),b+=String.fromCharCode((15&d)<<12|(63&c2)<<6|63&c3),c+=3);return b},Callpixels.Base.Base64=Base64}(),function(){var a=Callpixels.Base,b=function(b){function c(){a.assert_required_keys(b,"type","primary_key"),"undefined"==typeof Callpixels.Base.Data._store[b.type]&&(Callpixels.Base.Data._store[b.type]={}),"undefined"==typeof Callpixels.Base.Data._store[b.type][b.primary_key]&&(Callpixels.Base.Data._store[b.type][b.primary_key]={})}var d=this;d.get=function(){var a={};if("undefined"==typeof arguments[0])a=Callpixels.Base.Data._store[b.type][b.primary_key];else if(1===arguments.length)a=Callpixels.Base.Data._store[b.type][b.primary_key][arguments[0]];else for(var c=0;c<arguments.length;c++){var d=arguments[c];a[d]=Callpixels.Base.Data._store[b.type][b.primary_key][d]}return a},d.set=function(a,c){return Callpixels.Base.Data._store[b.type][b.primary_key][a]=c,c},d.merge=function(a){for(var c in a)Callpixels.Base.Data._store[b.type][b.primary_key][c]=a[c];return a},c()};b._store={},Callpixels.Base.Data=b}(),function(){var a=Callpixels.Base,b=Callpixels.Base.Data,c=function(){this.api_host_uri="/api/v1/",this.type="model",this.primary_key=function(a){return c.primary_key(this.type,a)},this.store=function(a){if("undefined"!=typeof a){var b=this.primary_key();if("undefined"==typeof a[b])throw"ArgumentError: Expected to receive primary_key "+b;"undefined"==typeof this._store&&(this._store=new Callpixels.Base.Data({type:this.type,primary_key:a[b]})),this._store.merge(a),c.update_visitor_id(a)}return this._store},this.get_data=function(a,b){return this.connection().getJSON(this.api_host_uri+a,null,[c.update,b],this)},this.post_data=function(a,b,d){return this.connection().postJSON(this.api_host_uri+a,b,[c.update,d],this)},this.set=function(){return"function"==typeof this["set_"+arguments[0]]&&(arguments[1]=this["set_"+arguments[0]].apply(this,[arguments[1]])),this._store.set.apply(this,arguments)},this.get=function(){return this._store.get.apply(this,arguments)},this.connection=function(){return Callpixels.Base.Request.connection()}};c.inflections={number:"numbers",campaign:"campaigns"},c.update=function(d){for(var e in d){var f=e,g=d[e];if("undefined"!=typeof c.inflections[e]&&(f=c.inflections[e]),"undefined"!=typeof b._store[f])if(a.isArray(g))for(var h=0;h<g.length;h++)c.update_record(f,g[h]);else c.update_record(f,g[h])}return d},c.update_record=function(a,b){if(c.update_visitor_id(b),"undefined"!=typeof b.id){var d=c.primary_key(a);for(var e in b)Callpixels.Base.Data._store[a][b[d]][e]=b[e];return!0}return!1},c.update_visitor_id=function(a){"undefined"!=typeof a&&"undefined"!=typeof a.visitor_id&&Callpixels.Base.Cookies.set("CallPixels-vid",a.visitor_id)},c.primary_key=function(a,b){return"undefined"==typeof c.primary_keys&&(c.primary_keys={}),"undefined"==typeof c.primary_keys[a]&&(c.primary_keys[a]="id"),"undefined"!=typeof b&&(c.primary_keys[a]=b),c.primary_keys[a]},Callpixels.Base.Model=c}(),function(){var Base=window.Callpixels.Base,Cookies=window.Callpixels.Base.Cookies,Request=function(options){function initialize(a){config=Base.assert_required_keys(a,"http_prefix","addr","urlregex")}function with_ie_scripts(a){Callpixels.easyxdm_loaded?a():self.loadScript(http_prefix+"://cdn.jsdelivr.net/easyxdm/2.4.17.1/easyXDM.min.js",function(){self.loadScript(http_prefix+"://cdn.jsdelivr.net/easyxdm/2.4.17.1/json2.js",function(){Callpixels.easyxdm_loaded=!0,a()})})}var self=this,config={};self.getJSON=function(a,b,c,d){"function"==typeof c&&(c=[c]),"undefined"==typeof d&&(d=self);var e=function(){self.apiRequest(a,function(a){response=JSON.parse(a);for(var b in c)"function"==typeof c[b]&&c[b].apply(d,[response])},b)};6==Base.ieVersion()||7==Base.ieVersion()?with_ie_scripts(e):e()},self.postJSON=function(){return self.getJSON.apply(this,arguments)},self.apiRequest=function(request_uri,callbackFunctions,payload){function ignored(){}function runCallbacks(a){for(var b in callbackFunctions)"function"==typeof callbackFunctions[b]&&callbackFunctions[b](a)}function forwardResponse(){runCallbacks(xdr.responseText)}function sendXdm(){var remote=http_prefix+"://"+addr+"/ie_provider",swf=http_prefix+"://"+addr+"/easyxdm.swf",rpc=eval('new window.easyXDM.Rpc({ remote: "'+remote+'", swf: "'+swf+'"},{remote: {request: {}}});');rpc.request({url:"/"+request_url.match(urlregex)[1],method:"POST",data:payload},function(a){runCallbacks(a.data)})}var http_prefix=config.http_prefix,addr=config.addr,urlregex=eval(config.urlregex),request_url=http_prefix+"://"+addr+request_uri;if(payload&&"undefined"!=typeof Cookies.get("CallPixels-vid")&&"null"!==Cookies.get("CallPixels-vid")&&(payload.visitor_id=Cookies.get("CallPixels-vid")),"function"==typeof callbackFunctions&&(callbackFunctions=[callbackFunctions]),window.XDomainRequest){var xdr=new XDomainRequest;xdr.onload=forwardResponse,xdr.onprogress=ignored,xdr.onerror=ignored,xdr.ontimeout=ignored,xdr.timeout=3e4,payload?(xdr.open("post",request_url),xdr.send(self.buildPost(payload))):(xdr.open("get",request_url),xdr.send())}else if(6==Base.ieVersion()||7==Base.ieVersion())with_ie_scripts(sendXdm);else{var request=new XMLHttpRequest;payload?(request.open("POST",request_url,!1),request.setRequestHeader("Content-Type","application/json"),request.send(JSON.stringify(payload))):(request.open("GET",request_url,!1),request.send()),200===request.status&&runCallbacks(request.responseText)}},self.buildPost=function(a){var b="";for(var c in a)b+=c+"="+a[c]+"&";return b},self.loadScript=function(a,b){var c=document.getElementsByTagName("script")[0],d=document.createElement("script");d.type="text/javascript",d.async=!1,d.src=a;var e=function(a,b){"loaded"==a.readyState||"complete"==a.readyState?b():setTimeout(function(){e(a,b)},100)};"function"==typeof b&&("undefined"!=typeof d.addEventListener?d.addEventListener("load",b,!1):d.onreadystatechange=function(){d.onreadystatechange=null,e(d,b)}),c.parentNode.insertBefore(d,c)},initialize(options),self.config=config};Request.connection=function(){return"undefined"==typeof window.Callpixels._connection&&(window.Callpixels._connection=new Callpixels.Base.Request({addr:"callpixels.com",http_prefix:"http",urlregex:"/\\/\\/[^\\/]*\\/(.*)/"})),window.Callpixels._connection},Callpixels.Base.Request=Request}(),function(){function tags_to_script_tags(a){var b="";for(var c in a){var d=a[c];b=b+"&"+c+"="+d}return b}var Base=Callpixels.Base,Cookies=Callpixels.Base.Cookies,Base64=Callpixels.Base.Base64,Request=Callpixels.Base.Request,RequestNumber=function(options){function initialize(a){config=Base.assert_required_keys(a,"campaign_key")}function getParts(a){for(var b={},c=0;c<a.length;c++){var d=getUrlParts(a[c]);for(var e in d)b[e]=d[e]}return b}function getUrlParts(url){var objURL=new Object;try{url=url.match(eval("/\\?(.*)/"))[0]}catch(e){return objURL}return url.replace(new RegExp("([^?=&]+)(=([^&]*))?","g"),function(a,b,c,d){objURL[b.toLowerCase()]=d}),objURL}function getGACookies(){var a=["__utma","__utmb","__utmc","__utmz","__utmv"],b=new Object;for(var c in a){var d=extractCookie(a[c]);if(!(d||c>0))break;d&&(b[a[c]]=d)}return b}function extractCookie(a){var b=new RegExp(a+"=([^;]*)","g");try{return b.exec(document.cookie)[1]}catch(c){return!1}}function findOne(a,b){for(var c in b)for(var d in a)if(d==b[c])return a[d];return!1}var self=this,config={},resource_url="/api/v1/numbers?";self.perform=function(callback){function sendGARequest(a,b){body.ga=Base64.encode(a),body.c=Base64.encode(JSON.stringify(b)),Request.connection().getJSON(request_url,body,callback)}if("function"!=typeof callback)throw"ArgumentError: Expected to receive a callback function";var request_url=resource_url+"&campaign_key="+config.campaign_key;config.default_number_replacement&&(request_url=request_url+"&default_number="+config.default_number_replacement),config.message_replacement&&(request_url=request_url+"&message="+config.message_replacement);var body=new Object,uri=document.location.href;body.u=Base64.encode(uri),body.st=Base64.encode(tags_to_script_tags(config.number_matching_tags));var ou=Cookies.get("CallPixels-ou");getParts([document.location.href]).cpreset||!ou?Cookies.set("CallPixels-ou",body.u):body.ou=ou;var ga_acct="FAILED";try{_gaq.push(function(){ga_acct=eval("_gat._getTrackerByName()._getAccount()"),sendGARequest(ga_acct,getGACookies())})}catch(e){try{ga(function(tracker){var clientId=tracker.get("clientId"),allTrackers=eval("ga.getAll()");ga_acct=allTrackers[0].get("trackingId");var ga_cookies={};ga_cookies.__utma=clientId,ga_cookies.mp="yes",sendGARequest(ga_acct,ga_cookies)})}catch(f){Request.connection().getJSON(request_url,body,callback)}}},initialize(options)};Callpixels.Base.RequestNumber=RequestNumber}(),window.Callpixels.Cache={},function(){function a(b){if("undefined"!=typeof Callpixels.Base.Data._store){var c=Callpixels.Base.Data._store.numbers;if("undefined"!=typeof c){var d={};for(var e in c){var f=c[e];"true"===f.is_active&&("undefined"==typeof d[f.campaign_key]&&(d[f.campaign_key]=[]),d[f.campaign_key].push(f.id))}for(var g in d){var h={campaign_key:g,ids:d[g]};Callpixels.Base.Request.connection().postJSON("/api/v1/numbers/ping",h,[Callpixels.Base.Model.update,b],this)}}}setTimeout(a,15e3)}var b=Callpixels.Base;Callpixels.Number=function(a){function c(a){g.store(a),g.set("is_active","true")}function d(a){return"string"==typeof a&&(a=Callpixels.Number.extract_tags_from_string(a)),{tag_values:a,ids:[e("id")],campaign_key:e("campaign_key")}}function e(a){return g.get(a)}function f(){if(g.get("is_per_visitor")===!1)throw"Error: Tried to add tags to non per-visitor number."}var g=this;g.type="numbers",g.add_tags=function(a,b){f(),g.post_data("numbers/tag",d(a),b)},g.remove_tags=function(a,b){f(),g.post_data("numbers/untag",d(a),b)},g.remove_tags_by_keys=function(a,b){f(),"string"==typeof a&&(a=a.split(","));var c={tag_keys:a,ids:[e("id")],campaign_key:e("campaign_key")};g.post_data("numbers/untag/keys",c,b)},g.clear_tags=function(a){f();var b={ids:[e("id")],campaign_key:e("campaign_key"),all:"true"};g.post_data("numbers/untag",b,a)},g.release=function(){g.set("is_active","false")},g.initiate_call=function(a,c,d){"undefined"==typeof c&&(c={}),c.dial=a,c=b.merge(g.get("id","campaign_key"),c),g.post_data("numbers/initiate_call",c,d)},c(a)},Callpixels.Number.extract_tags_from_string=function(a){for(var b={},a=a.split(","),c=0;c<a.length;c++){var d=a[c].split(":");b[d[0]]=d[1]}return b},Callpixels.Number.prototype=new Callpixels.Base.Model,a()}(),function(){var a=Callpixels.Base.RequestNumber,b=function(b){function c(a){d.store(a)}var d=this;d.type="campaigns",d.primary_key("campaign_key"),d.numbers=[],d.request_number=function(b,c){d.set("number_matching_tags",b),new a(d.get("campaign_key","number_matching_tags")).perform(function(a){var b=new Callpixels.Number(a.number);c.apply(d,[b])})},d.numbers=function(){var a=[];if("undefined"!=typeof Callpixels.Base.Data._store){var b=Callpixels.Base.Data._store.numbers;if("undefined"!=typeof b)for(var c in b){var e=b[c];d.get("campaign_key")==e.campaign_key&&a.push(new Callpixels.Number(e))}}return a},d.set_number_matching_tags=function(a){if("string"==typeof a&&(a=Callpixels.Number.extract_tags_from_string(a)),!a||"object"!=typeof a||a instanceof Array)throw"ArgumentError: Expected number_matching_tags to be an object. eg: {tag: 'value'}";return a},c(b)};b.prototype=new Callpixels.Base.Model,Callpixels.Campaign=b}();
2
+ !function(){"undefined"==typeof window.Callpixels&&(window.Callpixels={});var a={};a.assert_required_keys=function(){for(var a=Array.prototype.slice.call(arguments),b=a.shift(),c=0;c<a.length;c++){var d=a[c];if("undefined"==typeof b||"undefined"==typeof b[d])throw"ArgumentError: Required keys are not defined: "+a.join(", ")}return b},a.merge=function(b,c){for(var d in c)try{b[d]=c[d].constructor==Object?a.merge(b[d],c[d]):c[d]}catch(e){b[d]=c[d]}return b},a.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)},a.ieVersion=function(){return null==a._ieVersion&&(a._ieVersion=function(){for(var a=3,b=document.createElement("div"),c=b.getElementsByTagName("i");b.innerHTML="<!--[if gt IE "+ ++a+"]><i></i><![endif]-->",c[0];);return a>4?a:!1}()),(6==a._ieVersion||7==a._ieVersion)&&null==Callpixels.easyxdm_loaded&&(Callpixels.easyxdm_loaded=!1),a._ieVersion},Callpixels.Base=a}(),function(a){var b=function(a,c,d){return 1===arguments.length?b.get(a):b.set(a,c,d)};b._document=document,b._navigator=navigator,b.defaults={path:"/"},b.get=function(a){return b._cachedDocumentCookie!==b._document.cookie&&b._renewCache(),b._cache[a]},b.set=function(a,c,d){return d=b._getExtendedOptions(d),b._document.cookie=b._generateCookieString(a,c,d),b},b._getExtendedOptions=function(c){return{path:c&&c.path||b.defaults.path,domain:c&&c.domain||b.defaults.domain,secure:c&&c.secure!==a?c.secure:b.defaults.secure}},b._isValidDate=function(a){return"[object Date]"===Object.prototype.toString.call(a)&&!isNaN(a.getTime())},b._generateCookieString=function(a,b,c){return a=encodeURIComponent(a),b=(b+"").replace(/[^!#$&-+\--:<-\[\]-~]/g,encodeURIComponent),c=c||{},a=a+"="+b+(c.path?";path="+c.path:""),a+=c.domain?";domain="+c.domain:"",a+=c.secure?";secure":""},b._getCookieObjectFromString=function(c){var d={};c=c?c.split("; "):[];for(var e=0;e<c.length;e++){var f=b._getKeyValuePairFromCookieString(c[e]);d[f.key]===a&&(d[f.key]=f.value)}return d},b._getKeyValuePairFromCookieString=function(a){var b=a.indexOf("="),b=0>b?a.length:b;return{key:decodeURIComponent(a.substr(0,b)),value:decodeURIComponent(a.substr(b+1))}},b._renewCache=function(){b._cache=b._getCookieObjectFromString(b._document.cookie),b._cachedDocumentCookie=b._document.cookie},b._areEnabled=function(){return b._navigator.cookieEnabled||"1"===b.set("cookies.js",1).get("cookies.js")},b.enabled=b._areEnabled(),"function"==typeof define&&define.amd?define(function(){return b}):"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=b),exports.Cookies=b):b,Callpixels.Base.Cookies=b}(),function(){var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="};Base64.encode=function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=Base64._utf8_encode(a);j<a.length;)b=a.charCodeAt(j++),c=a.charCodeAt(j++),d=a.charCodeAt(j++),e=b>>2,f=(3&b)<<4|c>>4,g=(15&c)<<2|d>>6,h=63&d,isNaN(c)?g=h=64:isNaN(d)&&(h=64),i=i+Base64._keyStr.charAt(e)+Base64._keyStr.charAt(f)+Base64._keyStr.charAt(g)+Base64._keyStr.charAt(h);return i},Base64.decode=function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");j<a.length;)e=Base64._keyStr.indexOf(a.charAt(j++)),f=Base64._keyStr.indexOf(a.charAt(j++)),g=Base64._keyStr.indexOf(a.charAt(j++)),h=Base64._keyStr.indexOf(a.charAt(j++)),b=e<<2|f>>4,c=(15&f)<<4|g>>2,d=(3&g)<<6|h,i+=String.fromCharCode(b),64!=g&&(i+=String.fromCharCode(c)),64!=h&&(i+=String.fromCharCode(d));return i=Base64._utf8_decode(i)},Base64._utf8_encode=function(string){string=string.replace(eval("/\\r\\n/g"),eval("String('\\n')"));for(var utftext="",n=0;n<string.length;n++){var c=string.charCodeAt(n);128>c?utftext+=String.fromCharCode(c):c>127&&2048>c?(utftext+=String.fromCharCode(c>>6|192),utftext+=String.fromCharCode(63&c|128)):(utftext+=String.fromCharCode(c>>12|224),utftext+=String.fromCharCode(c>>6&63|128),utftext+=String.fromCharCode(63&c|128))}return utftext},Base64._utf8_decode=function(a){for(var b="",c=0,d=c1=c2=0;c<a.length;)d=a.charCodeAt(c),128>d?(b+=String.fromCharCode(d),c++):d>191&&224>d?(c2=a.charCodeAt(c+1),b+=String.fromCharCode((31&d)<<6|63&c2),c+=2):(c2=a.charCodeAt(c+1),c3=a.charCodeAt(c+2),b+=String.fromCharCode((15&d)<<12|(63&c2)<<6|63&c3),c+=3);return b},Callpixels.Base.Base64=Base64}(),function(){var a=Callpixels.Base,b=function(b){function c(){a.assert_required_keys(b,"type","primary_key"),"undefined"==typeof Callpixels.Base.Data._store[b.type]&&(Callpixels.Base.Data._store[b.type]={}),"undefined"==typeof Callpixels.Base.Data._store[b.type][b.primary_key]&&(Callpixels.Base.Data._store[b.type][b.primary_key]={})}var d=this;d.get=function(){var a={};if("undefined"==typeof arguments[0])a=Callpixels.Base.Data._store[b.type][b.primary_key];else if(1===arguments.length)a=Callpixels.Base.Data._store[b.type][b.primary_key][arguments[0]];else for(var c=0;c<arguments.length;c++){var d=arguments[c];a[d]=Callpixels.Base.Data._store[b.type][b.primary_key][d]}return a},d.set=function(a,c){return Callpixels.Base.Data._store[b.type][b.primary_key][a]=c,c},d.merge=function(a){for(var c in a)Callpixels.Base.Data._store[b.type][b.primary_key][c]=a[c];return a},c()};b._store={},Callpixels.Base.Data=b}(),function(){var a=Callpixels.Base,b=Callpixels.Base.Data,c=function(){this.api_host_uri="/api/v1/",this.type="model",this.primary_key=function(a){return c.primary_key(this.type,a)},this.store=function(a){if("undefined"!=typeof a){var b=this.primary_key();if("undefined"==typeof a[b])throw"ArgumentError: Expected to receive primary_key "+b;"undefined"==typeof this._store&&(this._store=new Callpixels.Base.Data({type:this.type,primary_key:a[b]})),this._store.merge(a),c.update_visitor_id(a)}return this._store},this.get_data=function(a,b){return this.connection().getJSON(this.api_host_uri+a,null,[c.update,b],this)},this.post_data=function(a,b,d){return this.connection().postJSON(this.api_host_uri+a,b,[c.update,d],this)},this.set=function(){return"function"==typeof this["set_"+arguments[0]]&&(arguments[1]=this["set_"+arguments[0]].apply(this,[arguments[1]])),this._store.set.apply(this,arguments)},this.get=function(){return this._store.get.apply(this,arguments)},this.connection=function(){return Callpixels.Base.Request.connection()}};c.inflections={number:"numbers",campaign:"campaigns"},c.update=function(d){for(var e in d){var f=e,g=d[e];if("undefined"!=typeof c.inflections[e]&&(f=c.inflections[e]),"undefined"!=typeof b._store[f])if(a.isArray(g))for(var h=0;h<g.length;h++)c.update_record(f,g[h]);else c.update_record(f,g[h])}return d},c.update_record=function(a,b){if(c.update_visitor_id(b),"undefined"!=typeof b.id){var d=c.primary_key(a);for(var e in b)Callpixels.Base.Data._store[a][b[d]][e]=b[e];return!0}return!1},c.update_visitor_id=function(a){"undefined"!=typeof a&&"undefined"!=typeof a.visitor_id&&Callpixels.Base.Cookies.set("CallPixels-vid",a.visitor_id)},c.primary_key=function(a,b){return"undefined"==typeof c.primary_keys&&(c.primary_keys={}),"undefined"==typeof c.primary_keys[a]&&(c.primary_keys[a]="id"),"undefined"!=typeof b&&(c.primary_keys[a]=b),c.primary_keys[a]},Callpixels.Base.Model=c}(),function(){var Base=window.Callpixels.Base,Cookies=window.Callpixels.Base.Cookies,Request=function(options){function initialize(a){config=Base.assert_required_keys(a,"http_prefix","addr","urlregex")}function with_ie_scripts(a){Callpixels.easyxdm_loaded?a():self.loadScript(http_prefix+"://cdn.jsdelivr.net/easyxdm/2.4.17.1/easyXDM.min.js",function(){self.loadScript(http_prefix+"://cdn.jsdelivr.net/easyxdm/2.4.17.1/json2.js",function(){Callpixels.easyxdm_loaded=!0,a()})})}var self=this,config={};self.getJSON=function(a,b,c,d){"function"==typeof c&&(c=[c]),"undefined"==typeof d&&(d=self);var e=function(){self.apiRequest(a,function(a){response=JSON.parse(a);for(var b in c)"function"==typeof c[b]&&c[b].apply(d,[response])},b)};6==Base.ieVersion()||7==Base.ieVersion()?with_ie_scripts(e):e()},self.postJSON=function(){return self.getJSON.apply(this,arguments)},self.apiRequest=function(request_uri,callbackFunctions,payload){function ignored(){}function runCallbacks(a){for(var b in callbackFunctions)"function"==typeof callbackFunctions[b]&&callbackFunctions[b](a)}function forwardResponse(){runCallbacks(xdr.responseText)}function sendXdm(){var remote=http_prefix+"://"+addr+"/ie_provider",swf=http_prefix+"://"+addr+"/easyxdm.swf",rpc=eval('new window.easyXDM.Rpc({ remote: "'+remote+'", swf: "'+swf+'"},{remote: {request: {}}});');rpc.request({url:"/"+request_url.match(urlregex)[1],method:"POST",data:payload},function(a){runCallbacks(a.data)})}var http_prefix=config.http_prefix,addr=config.addr,urlregex=eval(config.urlregex),request_url=http_prefix+"://"+addr+request_uri;if(payload&&"undefined"!=typeof Cookies.get("CallPixels-vid")&&"null"!==Cookies.get("CallPixels-vid")&&(payload.visitor_id=Cookies.get("CallPixels-vid")),"function"==typeof callbackFunctions&&(callbackFunctions=[callbackFunctions]),window.XDomainRequest){var xdr=new XDomainRequest;xdr.onload=forwardResponse,xdr.onprogress=ignored,xdr.onerror=ignored,xdr.ontimeout=ignored,xdr.timeout=3e4,payload?(xdr.open("post",request_url),xdr.send(self.buildPost(payload))):(xdr.open("get",request_url),xdr.send())}else if(6==Base.ieVersion()||7==Base.ieVersion())with_ie_scripts(sendXdm);else{var request=new XMLHttpRequest;payload?(request.open("POST",request_url,!1),request.setRequestHeader("Content-Type","application/json"),request.send(JSON.stringify(payload))):(request.open("GET",request_url,!1),request.send()),200===request.status&&runCallbacks(request.responseText)}},self.buildPost=function(a){var b="";for(var c in a)b+=c+"="+a[c]+"&";return b},self.loadScript=function(a,b){var c=document.getElementsByTagName("script")[0],d=document.createElement("script");d.type="text/javascript",d.async=!1,d.src=a;var e=function(a,b){"loaded"==a.readyState||"complete"==a.readyState?b():setTimeout(function(){e(a,b)},100)};"function"==typeof b&&("undefined"!=typeof d.addEventListener?d.addEventListener("load",b,!1):d.onreadystatechange=function(){d.onreadystatechange=null,e(d,b)}),c.parentNode.insertBefore(d,c)},initialize(options),self.config=config};Request.connection=function(){return"undefined"==typeof window.Callpixels._connection&&(window.Callpixels._connection=new Callpixels.Base.Request({addr:"callpixels.com",http_prefix:"http",urlregex:"/\\/\\/[^\\/]*\\/(.*)/"})),window.Callpixels._connection},Callpixels.Base.Request=Request}(),function(){function tags_to_script_tags(a){var b="";for(var c in a){var d=a[c];b=b+"&"+c+"="+d}return b}var Base=Callpixels.Base,Cookies=Callpixels.Base.Cookies,Base64=Callpixels.Base.Base64,Request=Callpixels.Base.Request,RequestNumber=function(options){function initialize(a){config=Base.assert_required_keys(a,"campaign_key")}function getParts(a){for(var b={},c=0;c<a.length;c++){var d=getUrlParts(a[c]);for(var e in d)b[e]=d[e]}return b}function getUrlParts(url){var objURL=new Object;try{url=url.match(eval("/\\?(.*)/"))[0]}catch(e){return objURL}return url.replace(new RegExp("([^?=&]+)(=([^&]*))?","g"),function(a,b,c,d){objURL[b.toLowerCase()]=d}),objURL}function getGACookies(){var a=["__utma","__utmb","__utmc","__utmz","__utmv"],b=new Object;for(var c in a){var d=extractCookie(a[c]);if(!(d||c>0))break;d&&(b[a[c]]=d)}return b}function extractCookie(a){var b=new RegExp(a+"=([^;]*)","g");try{return b.exec(document.cookie)[1]}catch(c){return!1}}function findOne(a,b){for(var c in b)for(var d in a)if(d==b[c])return a[d];return!1}var self=this,config={},resource_url="/api/v1/numbers?";self.perform=function(callback){function sendGARequest(a,b){body.ga=Base64.encode(a),body.c=Base64.encode(JSON.stringify(b)),Request.connection().getJSON(request_url,body,callback)}if("function"!=typeof callback)throw"ArgumentError: Expected to receive a callback function";var request_url=resource_url+"&campaign_key="+config.campaign_key;config.default_number_replacement&&(request_url=request_url+"&default_number="+config.default_number_replacement),config.message_replacement&&(request_url=request_url+"&message="+config.message_replacement);var body=new Object,uri=document.location.href;body.u=Base64.encode(uri),body.st=Base64.encode(tags_to_script_tags(config.number_matching_tags));var ou=Cookies.get("CallPixels-ou");getParts([document.location.href]).cpreset||!ou?Cookies.set("CallPixels-ou",body.u):body.ou=ou;var ga_acct="FAILED";try{_gaq.push(function(){ga_acct=eval("_gat._getTrackerByName()._getAccount()"),sendGARequest(ga_acct,getGACookies())})}catch(e){try{ga(function(tracker){var clientId=tracker.get("clientId"),allTrackers=eval("ga.getAll()");ga_acct=allTrackers[0].get("trackingId");var ga_cookies={};ga_cookies.__utma=clientId,ga_cookies.mp="yes",sendGARequest(ga_acct,ga_cookies)})}catch(f){Request.connection().getJSON(request_url,body,callback)}}},initialize(options)};Callpixels.Base.RequestNumber=RequestNumber}(),window.Callpixels.Cache={},function(){function a(b){if("undefined"!=typeof Callpixels.Base.Data._store){var c=Callpixels.Base.Data._store.numbers;if("undefined"!=typeof c){var d={};for(var e in c){var f=c[e];"true"===f.is_active&&("undefined"==typeof d[f.campaign_key]&&(d[f.campaign_key]=[],d[f.campaign_key].ids=[],d[f.campaign_key].hashes=[]),d[f.campaign_key].ids.push(f.id),d[f.campaign_key].hashes.push(f.id_as_hash))}for(var g in d){var h={ids:d[g].ids,hashes:d[g].hashes};Callpixels.Base.Request.connection().postJSON("/api/v1/numbers/ping",h,[Callpixels.Base.Model.update,b],this)}}}setTimeout(a,15e3)}var b=Callpixels.Base;Callpixels.Number=function(a){function c(a){g.store(a),g.set("is_active","true")}function d(a){return"string"==typeof a&&(a=Callpixels.Number.extract_tags_from_string(a)),{tag_values:a,ids:[e("id")],campaign_key:e("campaign_key")}}function e(a){return g.get(a)}function f(){if(g.get("is_per_visitor")===!1)throw"Error: Tried to add tags to non per-visitor number."}var g=this;g.type="numbers",g.add_tags=function(a,b){f(),g.post_data("numbers/tag",d(a),b)},g.remove_tags=function(a,b){f(),g.post_data("numbers/untag",d(a),b)},g.remove_tags_by_keys=function(a,b){f(),"string"==typeof a&&(a=a.split(","));var c={tag_keys:a,ids:[e("id")],campaign_key:e("campaign_key")};g.post_data("numbers/untag/keys",c,b)},g.clear_tags=function(a){f();var b={ids:[e("id")],campaign_key:e("campaign_key"),all:"true"};g.post_data("numbers/untag",b,a)},g.release=function(){g.set("is_active","false")},g.initiate_call=function(a,c,d){"undefined"==typeof c&&(c={}),c.dial=a,c=b.merge(g.get("id","campaign_key"),c),g.post_data("numbers/initiate_call",c,d)},c(a)},Callpixels.Number.extract_tags_from_string=function(a){for(var b={},a=a.split(","),c=0;c<a.length;c++){var d=a[c].split(":");b[d[0]]=d[1]}return b},Callpixels.Number.prototype=new Callpixels.Base.Model,a()}(),function(){var a=Callpixels.Base.RequestNumber,b=function(b){function c(a){d.store(a)}var d=this;d.type="campaigns",d.primary_key("campaign_key"),d.numbers=[],d.request_number=function(b,c){d.set("number_matching_tags",b),new a(d.get("campaign_key","number_matching_tags")).perform(function(a){var b=new Callpixels.Number(a.number);c.apply(d,[b])})},d.numbers=function(){var a=[];if("undefined"!=typeof Callpixels.Base.Data._store){var b=Callpixels.Base.Data._store.numbers;if("undefined"!=typeof b)for(var c in b){var e=b[c];d.get("campaign_key")==e.campaign_key&&a.push(new Callpixels.Number(e))}}return a},d.set_number_matching_tags=function(a){if("string"==typeof a&&(a=Callpixels.Number.extract_tags_from_string(a)),!a||"object"!=typeof a||a instanceof Array)throw"ArgumentError: Expected number_matching_tags to be an object. eg: {tag: 'value'}";return a},c(b)};b.prototype=new Callpixels.Base.Model,Callpixels.Campaign=b}();
@@ -395,7 +395,7 @@
395
395
  <br clear="both">
396
396
 
397
397
  <footer>
398
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Wed Aug 13 2014 15:37:08 GMT-0400 (EDT)
398
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Wed Aug 13 2014 21:25:08 GMT-0400 (EDT)
399
399
  </footer>
400
400
 
401
401
  <script> prettyPrint(); </script>
@@ -1420,7 +1420,7 @@ with per-visitor numbers enabled.
1420
1420
  <br clear="both">
1421
1421
 
1422
1422
  <footer>
1423
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Wed Aug 13 2014 15:37:08 GMT-0400 (EDT)
1423
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Wed Aug 13 2014 21:25:08 GMT-0400 (EDT)
1424
1424
  </footer>
1425
1425
 
1426
1426
  <script> prettyPrint(); </script>
@@ -128,7 +128,7 @@
128
128
  <br clear="both">
129
129
 
130
130
  <footer>
131
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Wed Aug 13 2014 15:37:08 GMT-0400 (EDT)
131
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Wed Aug 13 2014 21:25:08 GMT-0400 (EDT)
132
132
  </footer>
133
133
 
134
134
  <script> prettyPrint(); </script>
@@ -227,7 +227,7 @@
227
227
  <br clear="both">
228
228
 
229
229
  <footer>
230
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Wed Aug 13 2014 15:37:08 GMT-0400 (EDT)
230
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Wed Aug 13 2014 21:25:08 GMT-0400 (EDT)
231
231
  </footer>
232
232
 
233
233
  <script> prettyPrint(); </script>
@@ -58,7 +58,7 @@
58
58
  <br clear="both">
59
59
 
60
60
  <footer>
61
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Wed Aug 13 2014 15:37:08 GMT-0400 (EDT)
61
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Wed Aug 13 2014 21:25:08 GMT-0400 (EDT)
62
62
  </footer>
63
63
 
64
64
  <script> prettyPrint(); </script>
@@ -204,15 +204,20 @@
204
204
  for (var primary_key in numbers) {
205
205
  var number = numbers[primary_key];
206
206
  if (number.is_active === 'true') {
207
- if (typeof(grouped[number.campaign_key]) === 'undefined') grouped[number.campaign_key] = [];
208
- grouped[number.campaign_key].push(number.id);
207
+ if (typeof(grouped[number.campaign_key]) === 'undefined'){
208
+ grouped[number.campaign_key] = [];
209
+ grouped[number.campaign_key]['ids'] = [];
210
+ grouped[number.campaign_key]['hashes'] = [];
211
+ }
212
+ grouped[number.campaign_key]['ids'].push(number.id);
213
+ grouped[number.campaign_key]['hashes'].push(number.id_as_hash);
209
214
  }
210
215
  }
211
216
  // ping each group of number_ids
212
217
  for (var campaign_key in grouped) {
213
218
  var payload = {
214
- campaign_key: campaign_key,
215
- ids: grouped[campaign_key]
219
+ ids: grouped[campaign_key].ids,
220
+ hashes: grouped[campaign_key].hashes
216
221
  };
217
222
  Callpixels.Base.Request.connection().postJSON('/api/v1/numbers/ping', payload, [Callpixels.Base.Model.update, callback], this);
218
223
  }
@@ -241,7 +246,7 @@
241
246
  <br clear="both">
242
247
 
243
248
  <footer>
244
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Wed Aug 13 2014 15:37:08 GMT-0400 (EDT)
249
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Wed Aug 13 2014 21:25:08 GMT-0400 (EDT)
245
250
  </footer>
246
251
 
247
252
  <script> prettyPrint(); </script>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: callpixelsjs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Hilscher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-13 00:00:00.000000000 Z
11
+ date: 2014-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties