retreaverjs-rails 0.2.20 → 0.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/lib/retreaverjs/rails/version.rb +1 -1
  3. data/package.json +1 -1
  4. data/src/retreaver/campaign.js +11 -13
  5. data/vendor/assets/javascripts/retreaver.js +11 -13
  6. data/vendor/assets/javascripts/retreaver.min.js +2 -2
  7. data/vendor/documentation/javascript/dev/Retreaver.Campaign.html +654 -0
  8. data/vendor/documentation/javascript/dev/Retreaver.Number.html +1615 -0
  9. data/vendor/documentation/javascript/dev/Retreaver.html +330 -0
  10. data/vendor/documentation/javascript/dev/campaign.js.html +270 -0
  11. data/vendor/documentation/javascript/dev/global.html +232 -0
  12. data/vendor/documentation/javascript/dev/index.html +67 -0
  13. data/vendor/documentation/javascript/dev/number.js.html +274 -0
  14. data/vendor/documentation/javascript/dev/retreaver.js.html +84 -0
  15. data/vendor/documentation/javascript/dev/scripts/linenumber.js +17 -0
  16. data/vendor/documentation/javascript/dev/scripts/prettify/Apache-License-2.0.txt +202 -0
  17. data/vendor/documentation/javascript/dev/scripts/prettify/lang-css.js +2 -0
  18. data/vendor/documentation/javascript/dev/scripts/prettify/prettify.js +28 -0
  19. data/vendor/documentation/javascript/dev/styles/jsdoc-default.css +290 -0
  20. data/vendor/documentation/javascript/dev/styles/prettify-jsdoc.css +111 -0
  21. data/vendor/documentation/javascript/dev/styles/prettify-tomorrow.css +132 -0
  22. data/vendor/documentation/javascript/v1/Retreaver.Campaign.html +3 -3
  23. data/vendor/documentation/javascript/v1/Retreaver.Number.html +1 -1
  24. data/vendor/documentation/javascript/v1/Retreaver.html +1 -1
  25. data/vendor/documentation/javascript/v1/campaign.js.html +12 -14
  26. data/vendor/documentation/javascript/v1/global.html +2 -2
  27. data/vendor/documentation/javascript/v1/index.html +1 -1
  28. data/vendor/documentation/javascript/v1/number.js.html +1 -1
  29. data/vendor/documentation/javascript/v1/retreaver.js.html +1 -1
  30. metadata +18 -3
@@ -0,0 +1,330 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>JSDoc: Namespace: Retreaver</title>
6
+
7
+ <script src="scripts/prettify/prettify.js"> </script>
8
+ <script src="scripts/prettify/lang-css.js"> </script>
9
+ <!--[if lt IE 9]>
10
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
+ <![endif]-->
12
+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14
+ </head>
15
+
16
+ <body>
17
+
18
+ <div id="main">
19
+
20
+ <h1 class="page-title">Namespace: Retreaver</h1>
21
+
22
+
23
+
24
+
25
+
26
+ <section>
27
+
28
+ <header>
29
+ <h2>
30
+ Retreaver
31
+ </h2>
32
+
33
+ </header>
34
+
35
+ <article>
36
+ <div class="container-overview">
37
+
38
+
39
+
40
+
41
+
42
+
43
+ <dl class="details">
44
+
45
+
46
+
47
+ <dt class="tag-version">Version:</dt>
48
+ <dd class="tag-version"><ul class="dummy"><li>dev</li></ul></dd>
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+ <dt class="tag-source">Source:</dt>
67
+ <dd class="tag-source"><ul class="dummy"><li>
68
+ <a href="retreaver.js.html">retreaver.js</a>, <a href="retreaver.js.html#line2">line 2</a>
69
+ </li></ul></dd>
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+ </dl>
78
+
79
+
80
+
81
+
82
+ </div>
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+ <h3 class="subsection-title">Classes</h3>
92
+
93
+ <dl>
94
+ <dt><a href="Retreaver.Campaign.html">Campaign</a></dt>
95
+ <dd></dd>
96
+
97
+ <dt><a href="Retreaver.Number.html">Number</a></dt>
98
+ <dd></dd>
99
+ </dl>
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+ <h3 class="subsection-title">Methods</h3>
108
+
109
+ <dl>
110
+
111
+ <dt>
112
+ <h4 class="name" id="configure"><span class="type-signature">&lt;static> </span>configure<span class="signature">(options)</span><span class="type-signature"></span></h4>
113
+
114
+
115
+ </dt>
116
+ <dd>
117
+
118
+
119
+ <div class="description">
120
+ Configure the retreaver client library.
121
+ </div>
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+ <h5>Parameters:</h5>
130
+
131
+
132
+ <table class="params">
133
+ <thead>
134
+ <tr>
135
+
136
+ <th>Name</th>
137
+
138
+
139
+ <th>Type</th>
140
+
141
+
142
+
143
+
144
+
145
+ <th class="last">Description</th>
146
+ </tr>
147
+ </thead>
148
+
149
+ <tbody>
150
+
151
+
152
+ <tr>
153
+
154
+ <td class="name"><code>options</code></td>
155
+
156
+
157
+ <td class="type">
158
+
159
+
160
+ <span class="param-type">Object</span>
161
+
162
+
163
+
164
+ </td>
165
+
166
+
167
+
168
+
169
+
170
+ <td class="description last">
171
+ <h6>Properties</h6>
172
+
173
+
174
+ <table class="params">
175
+ <thead>
176
+ <tr>
177
+
178
+ <th>Name</th>
179
+
180
+
181
+ <th>Type</th>
182
+
183
+
184
+
185
+
186
+
187
+ <th class="last">Description</th>
188
+ </tr>
189
+ </thead>
190
+
191
+ <tbody>
192
+
193
+
194
+ <tr>
195
+
196
+ <td class="name"><code>host</code></td>
197
+
198
+
199
+ <td class="type">
200
+
201
+
202
+ <span class="param-type">String</span>
203
+
204
+
205
+
206
+ </td>
207
+
208
+
209
+
210
+
211
+
212
+ <td class="description last">Retreaver API Host</td>
213
+ </tr>
214
+
215
+
216
+
217
+ <tr>
218
+
219
+ <td class="name"><code>prefix</code></td>
220
+
221
+
222
+ <td class="type">
223
+
224
+
225
+ <span class="param-type">String</span>
226
+
227
+
228
+
229
+ </td>
230
+
231
+
232
+
233
+
234
+
235
+ <td class="description last">http or https</td>
236
+ </tr>
237
+
238
+
239
+ </tbody>
240
+ </table>
241
+ </td>
242
+ </tr>
243
+
244
+
245
+ </tbody>
246
+ </table>
247
+
248
+
249
+
250
+ <dl class="details">
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+
270
+ <dt class="tag-source">Source:</dt>
271
+ <dd class="tag-source"><ul class="dummy"><li>
272
+ <a href="retreaver.js.html">retreaver.js</a>, <a href="retreaver.js.html#line8">line 8</a>
273
+ </li></ul></dd>
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+ </dl>
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+
290
+
291
+
292
+
293
+
294
+
295
+ <h5>Example</h5>
296
+
297
+ <pre class="prettyprint"><code>Retreaver.configure({host: 'api.rtvrapi.com', prefix: 'https'});</code></pre>
298
+
299
+
300
+ </dd>
301
+
302
+ </dl>
303
+
304
+
305
+
306
+
307
+
308
+ </article>
309
+
310
+ </section>
311
+
312
+
313
+
314
+
315
+ </div>
316
+
317
+ <nav>
318
+ <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="Retreaver.Campaign.html">Campaign</a></li><li><a href="Retreaver.Number.html">Number</a></li></ul><h3>Namespaces</h3><ul><li><a href="Retreaver.html">Retreaver</a></li></ul><h3><a href="global.html">Global</a></h3>
319
+ </nav>
320
+
321
+ <br clear="both">
322
+
323
+ <footer>
324
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Mon Jun 17 2024 14:31:16 GMT+0300 (EEST)
325
+ </footer>
326
+
327
+ <script> prettyPrint(); </script>
328
+ <script src="scripts/linenumber.js"> </script>
329
+ </body>
330
+ </html>
@@ -0,0 +1,270 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>JSDoc: Source: retreaver/campaign.js</title>
6
+
7
+ <script src="scripts/prettify/prettify.js"> </script>
8
+ <script src="scripts/prettify/lang-css.js"> </script>
9
+ <!--[if lt IE 9]>
10
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
+ <![endif]-->
12
+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14
+ </head>
15
+
16
+ <body>
17
+
18
+ <div id="main">
19
+
20
+ <h1 class="page-title">Source: retreaver/campaign.js</h1>
21
+
22
+
23
+
24
+
25
+
26
+ <section>
27
+ <article>
28
+ <pre class="prettyprint source"><code>(function() {
29
+ // Dependencies
30
+ var RequestNumber = Retreaver.Base.RequestNumber;
31
+ /**
32
+ * @constructor
33
+ * @memberOf Retreaver
34
+ * @param {Object} options
35
+ * @param {String} options.campaign_key - Campaign key
36
+ * @example
37
+ * var campaign = new Retreaver.Campaign({ campaign_key: '67d9fb1917ae8f4eaff36831b41788c3' });
38
+ */
39
+ var Campaign = function(options) {
40
+
41
+ function initialize(data) {
42
+ // initialize data store
43
+ self.store(data);
44
+ }
45
+
46
+ function find_and_replace_number(replacement_numbers) {
47
+ for (var i = 0; i &lt; replacement_numbers.length; i++) {
48
+ var rn = replacement_numbers[i];
49
+
50
+ Retreaver.Vendor.findAndReplaceDOMText(document.getElementsByTagName('body')[0], {
51
+ find: rn['find'],
52
+ replace: rn['replace_with']
53
+ });
54
+
55
+ var links = document.getElementsByTagName('a');
56
+ for (var j = 0; j &lt; links.length; j++) {
57
+ var link = links[j];
58
+ var href = link.getAttribute('href');
59
+
60
+ if (href !== null) {
61
+ var match = href.match(/^(tel:|clk[a-z]\/tel\/)(.*)/);
62
+ if (match && match[2] === rn['find']) {
63
+ link.setAttribute('href', match[1] + rn['replace_with']);
64
+ }
65
+ }
66
+ }
67
+ }
68
+ }
69
+
70
+ var self = this;
71
+ self.type = 'campaigns';
72
+ self.primary_key('campaign_key');
73
+ self.numbers = [];
74
+
75
+ self.handle_true_call_integration = function(number) {
76
+ const trueCallConfig = number.get("integrations")["truecall.com"];
77
+ // debugger
78
+ if (typeof(trueCallConfig) == 'undefined') {
79
+ return;
80
+ }
81
+
82
+ // Load the trueCall script into the page it it's missing
83
+ if(!document.getElementById("__tc_script") || !window.TrueCall) {
84
+ (function () {
85
+ const trueCallScriptTag = document.createElement('script');
86
+ trueCallScriptTag.type = 'text/javascript';
87
+ trueCallScriptTag.async = true;
88
+ trueCallScriptTag.defer = true;
89
+ trueCallScriptTag.dataset.tc_campaign_id = trueCallConfig["tcCampaignId"];
90
+ trueCallScriptTag.id = "__tc_script"
91
+ trueCallScriptTag.src = 'https://static.truecall.com/tc-retreaver.js';
92
+ (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(trueCallScriptTag);
93
+ })();
94
+ }
95
+
96
+ const obtainTrueCallId = new Promise(function(resolve) {
97
+ const trueCallInterval = setInterval(function() {
98
+ if (window.TrueCall && window.TrueCall.getId()) {
99
+ resolve(window.TrueCall.getId())
100
+ clearInterval(trueCallInterval);
101
+ }
102
+ }, trueCallConfig["checkIntervalMs"]); // Try to get the trueCallId every X milliseconds
103
+ })
104
+
105
+ obtainTrueCallId.then(function (trueCallId) {
106
+ const tags = {};
107
+ tags[trueCallConfig["tagName"]] = trueCallId;
108
+ number.replace_tags(tags);
109
+ });
110
+ }
111
+
112
+ /**
113
+ * Fetch a campaign number.
114
+ * @memberOf Retreaver.Campaign
115
+ * @function request_number
116
+ * @instance
117
+ * @param {Object} [tags] - A collection of tags as key-value pairs. The number returned will match these tags.
118
+ * @param {getNumberCallback} callback - Callback fired if the request completes successfully.
119
+ * @param {Function} error_callback - Callback fired if the request raises an error.
120
+ * @example
121
+ * campaign.request_number({calling_about: 'support'}, function (number) {
122
+ * alert(number.get('number'))
123
+ * }, function(response){
124
+ * alert('something went wrong: ' + response);
125
+ * };
126
+ */
127
+ self.request_number = function(tags, callback, error_callback) {
128
+ // if the first argument is a function, the user has decided to skip passing tags
129
+ // therefore cascade the arguments upwards so that everything works as expected
130
+ if (typeof(tags) === 'function') {
131
+ // argument 3 becomes argument 2
132
+ error_callback = callback;
133
+ // argument 2 becomes argument 1
134
+ callback = tags;
135
+ // argument 1 becomes an empty tags object
136
+ tags = {};
137
+ }
138
+
139
+ if (typeof callback === 'undefined') {
140
+ callback = function () {
141
+ };
142
+ }
143
+
144
+ if (typeof tags === 'undefined') {
145
+ tags = {};
146
+ }
147
+
148
+ // assign the tags (this is important since it runs it through set_number_matching_tags)
149
+ self.set('number_matching_tags', tags);
150
+ // request the number
151
+ new RequestNumber(self.get('campaign_key', 'number_matching_tags')).perform(function(data) {
152
+ // did retreaver return a valid number?
153
+ if (typeof(data) !== 'undefined' && typeof(data.number) !== 'undefined' && data.number !== '') {
154
+ var number = new Retreaver.Number(data.number);
155
+ number.add_tags({"gosho": "123"}, function(data){
156
+ console.log("tagged");
157
+ })
158
+ // initialize number
159
+ try {
160
+ self.handle_true_call_integration(number);
161
+ } catch (e) {
162
+ console.error("Could not integrate with truecall.com, ", e);
163
+ }
164
+
165
+ // if there is a replacement in the response, replace all occurrences
166
+ // of that number on the page with the retreaver number
167
+ if (typeof(data.number.replacement_numbers) !== 'undefined') {
168
+ find_and_replace_number(data.number.replacement_numbers);
169
+ }
170
+ // call callback
171
+ callback.apply(self, [number]);
172
+ }
173
+ // otherwise fire the error callback
174
+ else if (typeof(error_callback) === 'function') {
175
+ error_callback.apply(self, [data]);
176
+ }
177
+ });
178
+ };
179
+
180
+ /**
181
+ * Auto replace all numbers on page according to campaign settings
182
+ * Calls campaign.request_number
183
+ * @memberOf Retreaver.Campaign
184
+ * @function auto_replace_numbers
185
+ * @instance
186
+ * @param {Object} [tags] - A collection of tags as key-value pairs. The number returned will match these tags.
187
+ * @param {getNumberCallback} callback - Callback fired if the request completes successfully.
188
+ * @param {Function} error_callback - Callback fired if the request raises an error.
189
+ * @example
190
+ * campaign.auto_replace_numbers({calling_about: 'support'}, function (number) {
191
+ * alert(number.get('number'))
192
+ * }, function(response){
193
+ * alert('something went wrong: ' + response);
194
+ * };
195
+ */
196
+ self.auto_replace_numbers = function(tags, callback, error_callback) {
197
+ if (typeof callback === 'undefined') {
198
+ callback = function() {};
199
+ }
200
+
201
+ if (typeof error_callback === 'undefined') {
202
+ error_callback = function() {};
203
+ }
204
+ self.request_number(tags, callback, error_callback);
205
+ };
206
+
207
+ /**
208
+ * Retreaver.Campaign#request_number callback fired after the request completes.
209
+ * @callback getNumberCallback
210
+ * @param {Retreaver.Number} - The number that was returned
211
+ */
212
+
213
+ self.numbers = function() {
214
+ var output = [];
215
+ if (typeof(Retreaver.Base.Data._store) !== 'undefined') {
216
+ // get numbers
217
+ var numbers = Retreaver.Base.Data._store['numbers'];
218
+ // present?
219
+ if (typeof(numbers) !== 'undefined') {
220
+ // collect numbers matching this campaign
221
+ for (var primary_key in numbers) {
222
+ var number = numbers[primary_key];
223
+ if (self.get('campaign_key') == number.campaign_key) {
224
+ output.push(new Retreaver.Number(number));
225
+ }
226
+ }
227
+ }
228
+ }
229
+ return output;
230
+ };
231
+
232
+ self.set_number_matching_tags = function(tags) {
233
+ if (typeof(tags) === 'string') {
234
+ tags = Retreaver.Number.extract_tags_from_string(tags);
235
+ }
236
+ if (tags && (typeof tags === "object") && !(tags instanceof Array)) {
237
+ return tags
238
+ } else {
239
+ throw "ArgumentError: Expected number_matching_tags to be an object. eg: {tag: 'value'}";
240
+ }
241
+ };
242
+
243
+ initialize(options);
244
+ };
245
+ Campaign.prototype = new Retreaver.Base.Model();
246
+ Retreaver.Campaign = Campaign;
247
+ })();
248
+ </code></pre>
249
+ </article>
250
+ </section>
251
+
252
+
253
+
254
+
255
+ </div>
256
+
257
+ <nav>
258
+ <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="Retreaver.Campaign.html">Campaign</a></li><li><a href="Retreaver.Number.html">Number</a></li></ul><h3>Namespaces</h3><ul><li><a href="Retreaver.html">Retreaver</a></li></ul><h3><a href="global.html">Global</a></h3>
259
+ </nav>
260
+
261
+ <br clear="both">
262
+
263
+ <footer>
264
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Mon Jun 17 2024 14:31:15 GMT+0300 (EEST)
265
+ </footer>
266
+
267
+ <script> prettyPrint(); </script>
268
+ <script src="scripts/linenumber.js"> </script>
269
+ </body>
270
+ </html>