@textback/notification-widget 2.0.1-84986 → 2.0.1

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 (85) hide show
  1. package/.eslintrc.js +291 -291
  2. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  3. package/.idea/misc.xml +6 -0
  4. package/.idea/modules.xml +8 -0
  5. package/.idea/notificationwidget.iml +9 -0
  6. package/.idea/vcs.xml +6 -0
  7. package/build/index.js +3 -3
  8. package/build/sdk.js +2 -2
  9. package/package.json +70 -70
  10. package/promote_tag.sh +1 -1
  11. package/readme.md +569 -569
  12. package/server.js +1 -1
  13. package/src/libraries/ai.1.0.11.js +4088 -4088
  14. package/src/libraries/localization/locales/index.js +8 -8
  15. package/src/libraries/localization/text.js +9 -9
  16. package/src/libraries/t.js +82 -82
  17. package/src/sdk/channels/channel.js +30 -30
  18. package/src/sdk/channels/facebook.js +13 -13
  19. package/src/sdk/channels/skype.js +12 -12
  20. package/src/sdk/channels/telegram.js +18 -18
  21. package/src/sdk/channels/viber.js +12 -12
  22. package/src/sdk/channels/vk-modal/vk-modal.html +17 -17
  23. package/src/sdk/channels/vk-modal/vk-modal.js +25 -25
  24. package/src/sdk/channels/vk-modal/vk-modal.scss +116 -116
  25. package/src/sdk/channels/vk.js +195 -195
  26. package/src/sdk/events/observer.js +46 -46
  27. package/src/sdk/index.js +5 -5
  28. package/src/sdk/sdk.js +67 -67
  29. package/src/sdk/utils/apiErrorHandler.js +11 -11
  30. package/src/sdk/utils/appInsights.js +88 -88
  31. package/src/sdk/utils/browserInfo.js +8 -8
  32. package/src/sdk/utils/constants.js +17 -17
  33. package/src/sdk/utils/cookies.js +67 -67
  34. package/src/sdk/utils/find.js +7 -7
  35. package/src/sdk/utils/loadConfig.js +20 -20
  36. package/src/sdk/utils/loadDeepLink.js +48 -48
  37. package/src/sdk/utils/loadScript.js +25 -25
  38. package/src/sdk/utils/loadSubscriptions.js +6 -6
  39. package/src/sdk/utils/parseQueryString.js +33 -33
  40. package/src/sdk/utils/windowHelper.js +25 -25
  41. package/src/sdk/widget/widget.js +192 -192
  42. package/src/widget/components/tb-notification-button/index.js +34 -34
  43. package/src/widget/components/tb-notification-button/styles.scss +657 -657
  44. package/src/widget/components/tb-notification-widget/normalize.scss +395 -395
  45. package/src/widget/components/tb-nw-wahunter/styles.scss +471 -471
  46. package/src/widget/config.js +5 -5
  47. package/src/widget/icons/icon_chat_window.svg +1 -1
  48. package/src/widget/icons/icon_close.svg +1 -1
  49. package/src/widget/icons/icon_facebook.svg +7 -7
  50. package/src/widget/icons/icon_facebook_circle.svg +7 -7
  51. package/src/widget/icons/icon_instagram_circle.svg +95 -95
  52. package/src/widget/icons/icon_skype.svg +44 -44
  53. package/src/widget/icons/icon_skype_circle.svg +46 -46
  54. package/src/widget/icons/icon_skype_new.svg +113 -113
  55. package/src/widget/icons/icon_tg.svg +25 -25
  56. package/src/widget/icons/icon_tg_circle.svg +17 -17
  57. package/src/widget/icons/icon_viber.svg +75 -75
  58. package/src/widget/icons/icon_viber_circle.svg +67 -67
  59. package/src/widget/icons/icon_viber_new.svg +102 -102
  60. package/src/widget/icons/icon_vk.svg +14 -14
  61. package/src/widget/icons/icon_vk_circle.svg +16 -16
  62. package/src/widget/icons/icon_whatsapp.svg +147 -147
  63. package/src/widget/icons/icon_whatsapp_circle.svg +3 -3
  64. package/src/widget/icons/icon_whatsapp_new.svg +127 -127
  65. package/src/widget/icons/icon_whatsappb.svg +147 -147
  66. package/src/widget/icons/icon_whatsappb_circle.svg +3 -3
  67. package/src/widget/icons/icon_whatsappb_new.svg +127 -127
  68. package/src/widget/icons/paper-plane-arrow.svg +3 -3
  69. package/src/widget/icons/tb-logo.svg +21 -21
  70. package/src/widget/index.js +28 -28
  71. package/src/widget/locales/cs.js +42 -42
  72. package/src/widget/locales/en.js +42 -42
  73. package/src/widget/locales/ro.js +41 -41
  74. package/src/widget/utils/cookiesEx.js +41 -41
  75. package/src/widget/utils/stringifyAttributes.js +19 -19
  76. package/src/widget/utils/widgetsStorage.js +28 -28
  77. package/src/widget/widget.entry.js +3 -3
  78. package/tests/gf.html +35 -35
  79. package/tests/gf.js +21 -21
  80. package/tests/index.js +61 -61
  81. package/views/examples.ejs +3 -3
  82. package/views/sdk.html +274 -274
  83. package/webpack.common.js +72 -72
  84. package/webpack.dev.js +15 -15
  85. package/webpack.prod.js +10 -10
package/views/sdk.html CHANGED
@@ -1,274 +1,274 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>SDK Test</title>
7
-
8
- <style>
9
- button {
10
- margin-right: 10px;
11
- }
12
-
13
- .tb-buttons,
14
- .tb-btn-wrapper,
15
- .tb-btn {
16
- box-sizing: border-box;
17
- text-align: center;
18
- }
19
-
20
- .tb-btn-wrapper {
21
- position: relative;
22
- display: inline-block;
23
- }
24
-
25
- .tb-btn-tooltip {
26
- position: absolute;
27
- opacity: 0;
28
- visibility: hidden;
29
-
30
- background-color: rgba(255, 255, 255, 0.9);
31
- padding: 5px 7px;
32
- border-radius: 3px;
33
- color: #6f7b8a;
34
- font-size: 10px;
35
- z-index: 10;
36
- top: 52px;
37
- box-shadow: 0 2px 4px 1px rgba(0, 0, 0, 0.2);
38
- transition: opacity 0.4s;
39
- }
40
-
41
- .tb-btn-tooltip:before, .tb-btn-tooltip:after {
42
- content: ' ';
43
- height: 0;
44
- position: absolute;
45
- width: 0;
46
- border: 10px solid transparent;
47
- }
48
-
49
- .tb-btn-tooltip:before {
50
- position: absolute;
51
- top: -19px;
52
- left: 70px;
53
- z-index: 2;
54
- border-bottom-color: #fff;
55
- }
56
-
57
- .tb-btn-tooltip:after {
58
- position: absolute;
59
- top: -25px;
60
- left: 67px;
61
- z-index: 1;
62
- border: 13px solid transparent;
63
- border-bottom-color: rgba(0, 0, 0, 0.05);
64
- }
65
-
66
- .tb-btn {
67
- text-decoration: none;
68
- display: inline-block;
69
- width: 150px;
70
- padding: 10px 25px;
71
- margin-top: 5px;
72
- margin-bottom: 5px;
73
- border-radius: 25px;
74
- color: #fff !important;
75
- font-size: 15px;
76
- font-family: 'Open Sans', 'Droid Sans', Arial, sans-serif;
77
- line-height: 17px;
78
- transition: box-shadow 0.4s;
79
- }
80
-
81
- .tb-btn img {
82
- width: 30px;
83
- height: 30px;
84
- display: inline-block;
85
- margin: -10px 0px -10px -15px;
86
- }
87
-
88
- .tb-btn:hover {
89
- box-shadow: 0 2px 4px 1px rgba(0, 0, 0, 0.4);
90
- }
91
-
92
- .tb-btn:hover + .tb-btn-tooltip {
93
- opacity: 1;
94
- visibility: visible;
95
- }
96
-
97
- .tb-btn.tb-vk {
98
- background-color: #45668e;
99
- }
100
- .tb-btn.tb-tg {
101
- background-color: #1E96C8;
102
- }
103
- .tb-btn.tb-facebook {
104
- background-color: #3b5998;
105
- }
106
- .tb-btn.tb-viber {
107
- background-color: #59267c;
108
- }
109
- .tb-btn.tb-whatsapp {
110
- background-color: #189d0e;
111
- }
112
- .tb-btn.tb-whatsappb {
113
- background-color: #189d0e;
114
- }
115
- </style>
116
-
117
- <!-- <link rel="stylesheet" href="/views/tilda.css"> -->
118
- </head>
119
- <body>
120
- <div class="container-fluid">
121
- <div class="row-fluid">
122
- <div class="col-lg-12">
123
- <!-- <h1>Buttons</h1>
124
- <div>
125
- <button type="button" id="sign_tg" class="btn btn-primary">Telegram</button>
126
- <button type="button" id="sign_vk" class="btn btn-small btn-white">VKontakte</button>
127
- <button type="button" id="sign_fb">Facebook</button>
128
- <button type="button" id="sign_viber">Viber</button>
129
- <button type="button" id="sign_wa" class="btn btn-success">WhatsApp</button>
130
- </div>
131
-
132
- <h1>Random</h1>
133
- <div>
134
- <button type="button" id="sign_random" class="btn btn-lg btn-white"><i class="fa fa-refresh"></i>&nbsp;&nbsp;Subscribe to random messenger</button>
135
- </div> -->
136
- <div class="tb-buttons">
137
- <div class="tb-btn-wrapper" id="tb-link">
138
- <a href="#" id="sign_tg" class="tb-btn tb-tg">
139
- <img src="//unpkg.com/@textback/notification-widget@latest/src/widget/icons/icon_tg.svg" alt="">
140
- Telegram
141
- </a>
142
- <div class="tb-btn-tooltip">
143
- Нажмите "<strong>Start</strong>" в приложении Telegram
144
- </div>
145
- </div>
146
- <div class="tb-btn-wrapper" id="tb-link">
147
- <a href="#" id="sign_vk" class="tb-btn tb-vk">
148
- <img src="//unpkg.com/@textback/notification-widget@latest/src/widget/icons/icon_vk.svg" alt="">
149
- VK
150
- </a>
151
- <div class="tb-btn-tooltip">
152
- Нажмите "<strong>Разрешить</strong>" во всплывающем окне
153
- </div>
154
- </div>
155
- <div class="tb-btn-wrapper" id="tb-link">
156
- <a href="#" id="sign_fb" class="tb-btn tb-facebook">
157
- <img src="//unpkg.com/@textback/notification-widget@latest/src/widget/icons/icon_facebook.svg" alt="">
158
- Facebook
159
- </a>
160
- <div class="tb-btn-tooltip">
161
- Нажмите "<strong>Начать</strong>" в Facebook Messenger
162
- </div>
163
- </div>
164
- <div class="tb-btn-wrapper" id="tb-link">
165
- <a href="#" id="sign_viber" class="tb-btn tb-viber">
166
- <img src="//unpkg.com/@textback/notification-widget@latest/src/widget/icons/icon_viber.svg" alt="">
167
- Viber
168
- </a>
169
- <div class="tb-btn-tooltip">
170
- У вас должно быть установлено <strong>Viber Desktop приложение</strong>
171
- </div>
172
- </div>
173
- <div class="tb-btn-wrapper" id="tb-link">
174
- <a href="#" id="sign_wa" class="tb-btn tb-whatsapp">
175
- <img src="//unpkg.com/@textback/notification-widget@latest/src/widget/icons/icon_whatsapp.svg" alt="">
176
- WhatsApp
177
- </a>
178
- <div class="tb-btn-tooltip">
179
- Отправьте <strong>предзаполненный текст</strong> в WhatsApp без изменений
180
- </div>
181
- </div>
182
- <div class="tb-btn-wrapper" id="tb-link">
183
- <a href="#" id="sign_wab" class="tb-btn tb-whatsapp">
184
- <img src="//unpkg.com/@textback/notification-widget@latest/src/widget/icons/icon_whatsappb.svg" alt="">
185
- WhatsApp
186
- </a>
187
- <div class="tb-btn-tooltip">
188
- Отправьте <strong>предзаполненный текст</strong> в WhatsApp без изменений
189
- </div>
190
- </div>
191
- </div>
192
-
193
- <!-- <script src="https://zapier.com/zapbook/embed/widget.js?services=TextBack&container=true&limit=10"></script> -->
194
- </div>
195
- </div>
196
- </div>
197
-
198
- <script>
199
- var TextBack = {
200
- someProp: 123,
201
- };
202
- </script>
203
-
204
-
205
-
206
- <script src="//unpkg.com/@textback/notification-widget@latest/build/sdk.js"></script>
207
- <!-- <script src="/build/sdk.js"></script> -->
208
-
209
- <script type="text/javascript">
210
- var config = {
211
- widgetId: 'a74bf35b-bbef-482d-b4aa-0c6795021806',
212
- apiPath: 'https://tb-apisrv-dev.textback.io/api',
213
- };
214
-
215
- var off = TextBack.SDK.on('widget.init', function(event) {
216
- console.log(`First widget has been initialized. ${event.widgetId}`);
217
- off();
218
- });
219
-
220
- TextBack.SDK.on('subscription.start', function(event) {
221
- console.log('subscription.start', event);
222
- });
223
-
224
- TextBack.SDK.initWidget(config).then( function(widget) {
225
- // Facebook
226
- document.getElementById('sign_fb').addEventListener('click', function(event) {
227
- event.preventDefault();
228
- widget.subscribe('fb');
229
- });
230
-
231
- // Telegram
232
- document.getElementById('sign_tg').addEventListener('click', function(event) {
233
- event.preventDefault();
234
- widget.subscribe('tg');
235
- });
236
-
237
- // VKontakte
238
- document.getElementById('sign_vk').addEventListener('click', function(event) {
239
- event.preventDefault();
240
- widget.subscribe('vk');
241
- });
242
-
243
- // Viber
244
- document.getElementById('sign_viber').addEventListener('click', function(event) {
245
- event.preventDefault();
246
- widget.subscribe('viber');
247
- });
248
-
249
- // WhatsApp
250
- document.getElementById('sign_wa').addEventListener('click', function(event) {
251
- event.preventDefault();
252
- widget.subscribe('whatsapp');
253
- });
254
-
255
- // WhatsApp Business
256
- document.getElementById('sign_wab').addEventListener('click', function(event) {
257
- event.preventDefault();
258
- widget.subscribe('whatsappb');
259
- });
260
- }, function(err) {
261
- console.log('error', err)
262
- });
263
-
264
- // TextBack.SDK.getWidget(config.widgetId).then(function(widget){
265
- // // Random
266
- // document.getElementById('sign_random').addEventListener('click', function(event) {
267
- // var channels = widget.getEnabledChannels();
268
- // var channelIndexToSubscribe = Math.floor(Math.random() * channels.length);
269
- // widget.subscribe(channels[channelIndexToSubscribe].channel);
270
- // });
271
- // });
272
- </script>
273
- </body>
274
- </html>
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>SDK Test</title>
7
+
8
+ <style>
9
+ button {
10
+ margin-right: 10px;
11
+ }
12
+
13
+ .tb-buttons,
14
+ .tb-btn-wrapper,
15
+ .tb-btn {
16
+ box-sizing: border-box;
17
+ text-align: center;
18
+ }
19
+
20
+ .tb-btn-wrapper {
21
+ position: relative;
22
+ display: inline-block;
23
+ }
24
+
25
+ .tb-btn-tooltip {
26
+ position: absolute;
27
+ opacity: 0;
28
+ visibility: hidden;
29
+
30
+ background-color: rgba(255, 255, 255, 0.9);
31
+ padding: 5px 7px;
32
+ border-radius: 3px;
33
+ color: #6f7b8a;
34
+ font-size: 10px;
35
+ z-index: 10;
36
+ top: 52px;
37
+ box-shadow: 0 2px 4px 1px rgba(0, 0, 0, 0.2);
38
+ transition: opacity 0.4s;
39
+ }
40
+
41
+ .tb-btn-tooltip:before, .tb-btn-tooltip:after {
42
+ content: ' ';
43
+ height: 0;
44
+ position: absolute;
45
+ width: 0;
46
+ border: 10px solid transparent;
47
+ }
48
+
49
+ .tb-btn-tooltip:before {
50
+ position: absolute;
51
+ top: -19px;
52
+ left: 70px;
53
+ z-index: 2;
54
+ border-bottom-color: #fff;
55
+ }
56
+
57
+ .tb-btn-tooltip:after {
58
+ position: absolute;
59
+ top: -25px;
60
+ left: 67px;
61
+ z-index: 1;
62
+ border: 13px solid transparent;
63
+ border-bottom-color: rgba(0, 0, 0, 0.05);
64
+ }
65
+
66
+ .tb-btn {
67
+ text-decoration: none;
68
+ display: inline-block;
69
+ width: 150px;
70
+ padding: 10px 25px;
71
+ margin-top: 5px;
72
+ margin-bottom: 5px;
73
+ border-radius: 25px;
74
+ color: #fff !important;
75
+ font-size: 15px;
76
+ font-family: 'Open Sans', 'Droid Sans', Arial, sans-serif;
77
+ line-height: 17px;
78
+ transition: box-shadow 0.4s;
79
+ }
80
+
81
+ .tb-btn img {
82
+ width: 30px;
83
+ height: 30px;
84
+ display: inline-block;
85
+ margin: -10px 0px -10px -15px;
86
+ }
87
+
88
+ .tb-btn:hover {
89
+ box-shadow: 0 2px 4px 1px rgba(0, 0, 0, 0.4);
90
+ }
91
+
92
+ .tb-btn:hover + .tb-btn-tooltip {
93
+ opacity: 1;
94
+ visibility: visible;
95
+ }
96
+
97
+ .tb-btn.tb-vk {
98
+ background-color: #45668e;
99
+ }
100
+ .tb-btn.tb-tg {
101
+ background-color: #1E96C8;
102
+ }
103
+ .tb-btn.tb-facebook {
104
+ background-color: #3b5998;
105
+ }
106
+ .tb-btn.tb-viber {
107
+ background-color: #59267c;
108
+ }
109
+ .tb-btn.tb-whatsapp {
110
+ background-color: #189d0e;
111
+ }
112
+ .tb-btn.tb-whatsappb {
113
+ background-color: #189d0e;
114
+ }
115
+ </style>
116
+
117
+ <!-- <link rel="stylesheet" href="/views/tilda.css"> -->
118
+ </head>
119
+ <body>
120
+ <div class="container-fluid">
121
+ <div class="row-fluid">
122
+ <div class="col-lg-12">
123
+ <!-- <h1>Buttons</h1>
124
+ <div>
125
+ <button type="button" id="sign_tg" class="btn btn-primary">Telegram</button>
126
+ <button type="button" id="sign_vk" class="btn btn-small btn-white">VKontakte</button>
127
+ <button type="button" id="sign_fb">Facebook</button>
128
+ <button type="button" id="sign_viber">Viber</button>
129
+ <button type="button" id="sign_wa" class="btn btn-success">WhatsApp</button>
130
+ </div>
131
+
132
+ <h1>Random</h1>
133
+ <div>
134
+ <button type="button" id="sign_random" class="btn btn-lg btn-white"><i class="fa fa-refresh"></i>&nbsp;&nbsp;Subscribe to random messenger</button>
135
+ </div> -->
136
+ <div class="tb-buttons">
137
+ <div class="tb-btn-wrapper" id="tb-link">
138
+ <a href="#" id="sign_tg" class="tb-btn tb-tg">
139
+ <img src="//cdn.jsdelivr.net/npm/@textback/notification-widget@latest/src/widget/icons/icon_tg.svg" alt="">
140
+ Telegram
141
+ </a>
142
+ <div class="tb-btn-tooltip">
143
+ Нажмите "<strong>Start</strong>" в приложении Telegram
144
+ </div>
145
+ </div>
146
+ <div class="tb-btn-wrapper" id="tb-link">
147
+ <a href="#" id="sign_vk" class="tb-btn tb-vk">
148
+ <img src="//cdn.jsdelivr.net/npm/@textback/notification-widget@latest/src/widget/icons/icon_vk.svg" alt="">
149
+ VK
150
+ </a>
151
+ <div class="tb-btn-tooltip">
152
+ Нажмите "<strong>Разрешить</strong>" во всплывающем окне
153
+ </div>
154
+ </div>
155
+ <div class="tb-btn-wrapper" id="tb-link">
156
+ <a href="#" id="sign_fb" class="tb-btn tb-facebook">
157
+ <img src="//cdn.jsdelivr.net/npm/@textback/notification-widget@latest/src/widget/icons/icon_facebook.svg" alt="">
158
+ Facebook
159
+ </a>
160
+ <div class="tb-btn-tooltip">
161
+ Нажмите "<strong>Начать</strong>" в Facebook Messenger
162
+ </div>
163
+ </div>
164
+ <div class="tb-btn-wrapper" id="tb-link">
165
+ <a href="#" id="sign_viber" class="tb-btn tb-viber">
166
+ <img src="//cdn.jsdelivr.net/npm/@textback/notification-widget@latest/src/widget/icons/icon_viber.svg" alt="">
167
+ Viber
168
+ </a>
169
+ <div class="tb-btn-tooltip">
170
+ У вас должно быть установлено <strong>Viber Desktop приложение</strong>
171
+ </div>
172
+ </div>
173
+ <div class="tb-btn-wrapper" id="tb-link">
174
+ <a href="#" id="sign_wa" class="tb-btn tb-whatsapp">
175
+ <img src="//cdn.jsdelivr.net/npm/@textback/notification-widget@latest/src/widget/icons/icon_whatsapp.svg" alt="">
176
+ WhatsApp
177
+ </a>
178
+ <div class="tb-btn-tooltip">
179
+ Отправьте <strong>предзаполненный текст</strong> в WhatsApp без изменений
180
+ </div>
181
+ </div>
182
+ <div class="tb-btn-wrapper" id="tb-link">
183
+ <a href="#" id="sign_wab" class="tb-btn tb-whatsapp">
184
+ <img src="//cdn.jsdelivr.net/npm/@textback/notification-widget@latest/src/widget/icons/icon_whatsappb.svg" alt="">
185
+ WhatsApp
186
+ </a>
187
+ <div class="tb-btn-tooltip">
188
+ Отправьте <strong>предзаполненный текст</strong> в WhatsApp без изменений
189
+ </div>
190
+ </div>
191
+ </div>
192
+
193
+ <!-- <script src="https://zapier.com/zapbook/embed/widget.js?services=TextBack&container=true&limit=10"></script> -->
194
+ </div>
195
+ </div>
196
+ </div>
197
+
198
+ <script>
199
+ var TextBack = {
200
+ someProp: 123,
201
+ };
202
+ </script>
203
+
204
+
205
+
206
+ <script src="//cdn.jsdelivr.net/npm/@textback/notification-widget@latest/build/sdk.js"></script>
207
+ <!-- <script src="/build/sdk.js"></script> -->
208
+
209
+ <script type="text/javascript">
210
+ var config = {
211
+ widgetId: 'a74bf35b-bbef-482d-b4aa-0c6795021806',
212
+ apiPath: 'https://tb-apisrv-dev.textback.io/api',
213
+ };
214
+
215
+ var off = TextBack.SDK.on('widget.init', function(event) {
216
+ console.log(`First widget has been initialized. ${event.widgetId}`);
217
+ off();
218
+ });
219
+
220
+ TextBack.SDK.on('subscription.start', function(event) {
221
+ console.log('subscription.start', event);
222
+ });
223
+
224
+ TextBack.SDK.initWidget(config).then( function(widget) {
225
+ // Facebook
226
+ document.getElementById('sign_fb').addEventListener('click', function(event) {
227
+ event.preventDefault();
228
+ widget.subscribe('fb');
229
+ });
230
+
231
+ // Telegram
232
+ document.getElementById('sign_tg').addEventListener('click', function(event) {
233
+ event.preventDefault();
234
+ widget.subscribe('tg');
235
+ });
236
+
237
+ // VKontakte
238
+ document.getElementById('sign_vk').addEventListener('click', function(event) {
239
+ event.preventDefault();
240
+ widget.subscribe('vk');
241
+ });
242
+
243
+ // Viber
244
+ document.getElementById('sign_viber').addEventListener('click', function(event) {
245
+ event.preventDefault();
246
+ widget.subscribe('viber');
247
+ });
248
+
249
+ // WhatsApp
250
+ document.getElementById('sign_wa').addEventListener('click', function(event) {
251
+ event.preventDefault();
252
+ widget.subscribe('whatsapp');
253
+ });
254
+
255
+ // WhatsApp Business
256
+ document.getElementById('sign_wab').addEventListener('click', function(event) {
257
+ event.preventDefault();
258
+ widget.subscribe('whatsappb');
259
+ });
260
+ }, function(err) {
261
+ console.log('error', err)
262
+ });
263
+
264
+ // TextBack.SDK.getWidget(config.widgetId).then(function(widget){
265
+ // // Random
266
+ // document.getElementById('sign_random').addEventListener('click', function(event) {
267
+ // var channels = widget.getEnabledChannels();
268
+ // var channelIndexToSubscribe = Math.floor(Math.random() * channels.length);
269
+ // widget.subscribe(channels[channelIndexToSubscribe].channel);
270
+ // });
271
+ // });
272
+ </script>
273
+ </body>
274
+ </html>