@textback/notification-widget 2.0.1-103212 → 2.0.1-103341
Sign up to get free protection for your applications and to get access to all the features.
- package/build/index.js +3 -3
- package/build/sdk.js +2 -2
- package/package.json +1 -1
- package/server.js +224 -224
- package/src/sdk/sdk.js +7 -6
- package/src/sdk/widget/widget.js +7 -7
- package/src/widget/components/tb-notification-widget/index.js +3 -2
- package/src/widget/components/tb-nw-wahunter/index.js +45 -5
- package/views/sdk.html +259 -215
- package/webpack.dev.js +3 -2
package/views/sdk.html
CHANGED
@@ -1,126 +1,132 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
|
-
<head>
|
4
|
-
<meta charset="UTF-8"
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0"
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8" />
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6
6
|
<title>SDK Test</title>
|
7
7
|
|
8
8
|
<style>
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
button {
|
10
|
+
margin-right: 10px;
|
11
|
+
}
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
.tb-buttons,
|
14
|
+
.tb-btn-wrapper,
|
15
|
+
.tb-btn {
|
16
|
+
box-sizing: border-box;
|
17
|
+
text-align: center;
|
18
|
+
}
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
.tb-btn-wrapper {
|
21
|
+
position: relative;
|
22
|
+
display: inline-block;
|
23
|
+
}
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
.tb-btn-tooltip {
|
26
|
+
position: absolute;
|
27
|
+
opacity: 0;
|
28
|
+
visibility: hidden;
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
41
|
+
.tb-btn-tooltip:before,
|
42
|
+
.tb-btn-tooltip:after {
|
43
|
+
content: " ";
|
44
|
+
height: 0;
|
45
|
+
position: absolute;
|
46
|
+
width: 0;
|
47
|
+
border: 10px solid transparent;
|
48
|
+
}
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
.tb-btn-tooltip:before {
|
51
|
+
position: absolute;
|
52
|
+
top: -19px;
|
53
|
+
left: 70px;
|
54
|
+
z-index: 2;
|
55
|
+
border-bottom-color: #fff;
|
56
|
+
}
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
58
|
+
.tb-btn-tooltip:after {
|
59
|
+
position: absolute;
|
60
|
+
top: -25px;
|
61
|
+
left: 67px;
|
62
|
+
z-index: 1;
|
63
|
+
border: 13px solid transparent;
|
64
|
+
border-bottom-color: rgba(0, 0, 0, 0.05);
|
65
|
+
}
|
65
66
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
67
|
+
.tb-btn {
|
68
|
+
text-decoration: none;
|
69
|
+
display: inline-block;
|
70
|
+
width: 150px;
|
71
|
+
padding: 10px 25px;
|
72
|
+
margin-top: 5px;
|
73
|
+
margin-bottom: 5px;
|
74
|
+
border-radius: 25px;
|
75
|
+
color: #fff !important;
|
76
|
+
font-size: 15px;
|
77
|
+
font-family: "Open Sans", "Droid Sans", Arial, sans-serif;
|
78
|
+
line-height: 17px;
|
79
|
+
transition: box-shadow 0.4s;
|
80
|
+
}
|
80
81
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
82
|
+
.tb-btn img {
|
83
|
+
width: 30px;
|
84
|
+
height: 30px;
|
85
|
+
display: inline-block;
|
86
|
+
margin: -10px 0px -10px -15px;
|
87
|
+
}
|
87
88
|
|
88
|
-
|
89
|
-
|
90
|
-
|
89
|
+
.tb-btn:hover {
|
90
|
+
box-shadow: 0 2px 4px 1px rgba(0, 0, 0, 0.4);
|
91
|
+
}
|
91
92
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
93
|
+
.tb-btn:hover + .tb-btn-tooltip {
|
94
|
+
opacity: 1;
|
95
|
+
visibility: visible;
|
96
|
+
}
|
96
97
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
98
|
+
.tb-btn.tb-vk {
|
99
|
+
background-color: #45668e;
|
100
|
+
}
|
101
|
+
.tb-btn.tb-tg {
|
102
|
+
background-color: #1e96c8;
|
103
|
+
}
|
104
|
+
.tb-btn.tb-facebook {
|
105
|
+
background-color: #3b5998;
|
106
|
+
}
|
107
|
+
.tb-btn.tb-viber {
|
108
|
+
background-color: #59267c;
|
109
|
+
}
|
110
|
+
.tb-btn.tb-whatsapp {
|
111
|
+
background-color: #189d0e;
|
112
|
+
}
|
113
|
+
.tb-btn.tb-whatsappb {
|
114
|
+
background-color: #189d0e;
|
115
|
+
}
|
115
116
|
</style>
|
116
117
|
|
117
118
|
<!-- <link rel="stylesheet" href="/views/tilda.css"> -->
|
118
|
-
</head>
|
119
|
-
<body>
|
119
|
+
</head>
|
120
|
+
<body>
|
121
|
+
<tb-notification-widget
|
122
|
+
widget-id="7c235bba-dd4e-9185-97e1-018f834cdc4f"
|
123
|
+
api-path="https://api.textback.io/api"
|
124
|
+
>
|
125
|
+
</tb-notification-widget>
|
120
126
|
<div class="container-fluid">
|
121
|
-
|
122
|
-
|
123
|
-
|
127
|
+
<div class="row-fluid">
|
128
|
+
<div class="col-lg-12">
|
129
|
+
<!-- <h1>Buttons</h1>
|
124
130
|
<div>
|
125
131
|
<button type="button" id="sign_tg" class="btn btn-primary">Telegram</button>
|
126
132
|
<button type="button" id="sign_vk" class="btn btn-small btn-white">VKontakte</button>
|
@@ -133,142 +139,180 @@
|
|
133
139
|
<div>
|
134
140
|
<button type="button" id="sign_random" class="btn btn-lg btn-white"><i class="fa fa-refresh"></i> Subscribe to random messenger</button>
|
135
141
|
</div> -->
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
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> -->
|
142
|
+
<div class="tb-buttons">
|
143
|
+
<div class="tb-btn-wrapper" id="tb-link">
|
144
|
+
<a href="#" id="sign_tg" class="tb-btn tb-tg">
|
145
|
+
<img
|
146
|
+
src="//cdn.jsdelivr.net/npm/@textback/notification-widget@latest/src/widget/icons/icon_tg.svg"
|
147
|
+
alt=""
|
148
|
+
/>
|
149
|
+
Telegram
|
150
|
+
</a>
|
151
|
+
<div class="tb-btn-tooltip">
|
152
|
+
Нажмите "<strong>Start</strong>" в приложении Telegram
|
153
|
+
</div>
|
154
|
+
</div>
|
155
|
+
<div class="tb-btn-wrapper" id="tb-link">
|
156
|
+
<a href="#" id="sign_vk" class="tb-btn tb-vk">
|
157
|
+
<img
|
158
|
+
src="//cdn.jsdelivr.net/npm/@textback/notification-widget@latest/src/widget/icons/icon_vk.svg"
|
159
|
+
alt=""
|
160
|
+
/>
|
161
|
+
VK
|
162
|
+
</a>
|
163
|
+
<div class="tb-btn-tooltip">
|
164
|
+
Нажмите "<strong>Разрешить</strong>" во всплывающем окне
|
165
|
+
</div>
|
166
|
+
</div>
|
167
|
+
<div class="tb-btn-wrapper" id="tb-link">
|
168
|
+
<a href="#" id="sign_fb" class="tb-btn tb-facebook">
|
169
|
+
<img
|
170
|
+
src="//cdn.jsdelivr.net/npm/@textback/notification-widget@latest/src/widget/icons/icon_facebook.svg"
|
171
|
+
alt=""
|
172
|
+
/>
|
173
|
+
Facebook
|
174
|
+
</a>
|
175
|
+
<div class="tb-btn-tooltip">
|
176
|
+
Нажмите "<strong>Начать</strong>" в Facebook Messenger
|
177
|
+
</div>
|
194
178
|
</div>
|
179
|
+
<div class="tb-btn-wrapper" id="tb-link">
|
180
|
+
<a href="#" id="sign_viber" class="tb-btn tb-viber">
|
181
|
+
<img
|
182
|
+
src="//cdn.jsdelivr.net/npm/@textback/notification-widget@latest/src/widget/icons/icon_viber.svg"
|
183
|
+
alt=""
|
184
|
+
/>
|
185
|
+
Viber
|
186
|
+
</a>
|
187
|
+
<div class="tb-btn-tooltip">
|
188
|
+
У вас должно быть установлено
|
189
|
+
<strong>Viber Desktop приложение</strong>
|
190
|
+
</div>
|
191
|
+
</div>
|
192
|
+
<div class="tb-btn-wrapper" id="tb-link">
|
193
|
+
<a href="#" id="sign_wa" class="tb-btn tb-whatsapp">
|
194
|
+
<img
|
195
|
+
src="//cdn.jsdelivr.net/npm/@textback/notification-widget@latest/src/widget/icons/icon_whatsapp.svg"
|
196
|
+
alt=""
|
197
|
+
/>
|
198
|
+
WhatsApp
|
199
|
+
</a>
|
200
|
+
<div class="tb-btn-tooltip">
|
201
|
+
Отправьте <strong>предзаполненный текст</strong> в WhatsApp без
|
202
|
+
изменений
|
203
|
+
</div>
|
204
|
+
</div>
|
205
|
+
<div class="tb-btn-wrapper" id="tb-link">
|
206
|
+
<a href="#" id="sign_wab" class="tb-btn tb-whatsapp">
|
207
|
+
<img
|
208
|
+
src="//cdn.jsdelivr.net/npm/@textback/notification-widget@latest/src/widget/icons/icon_whatsappb.svg"
|
209
|
+
alt=""
|
210
|
+
/>
|
211
|
+
WhatsApp
|
212
|
+
</a>
|
213
|
+
<div class="tb-btn-tooltip">
|
214
|
+
Отправьте <strong>предзаполненный текст</strong> в WhatsApp без
|
215
|
+
изменений
|
216
|
+
</div>
|
217
|
+
</div>
|
218
|
+
</div>
|
219
|
+
|
220
|
+
<!-- <script src="https://zapier.com/zapbook/embed/widget.js?services=TextBack&container=true&limit=10"></script> -->
|
195
221
|
</div>
|
222
|
+
</div>
|
196
223
|
</div>
|
197
224
|
|
198
225
|
<script>
|
199
|
-
|
200
|
-
|
201
|
-
|
226
|
+
var TextBack = {
|
227
|
+
someProp: 123,
|
228
|
+
};
|
202
229
|
</script>
|
203
230
|
|
204
|
-
|
205
|
-
|
206
|
-
<script src="//cdn.jsdelivr.net/npm/@textback/notification-widget@latest/build/sdk.js"></script>
|
207
|
-
<!-- <script src="/build/sdk.js"></script> -->
|
231
|
+
<!-- <script src="//cdn.jsdelivr.net/npm/@textback/notification-widget@latest/build/sdk.js"></script> -->
|
232
|
+
<script src="/build/sdk.js"></script>
|
208
233
|
|
209
234
|
<script type="text/javascript">
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
235
|
+
var config = {
|
236
|
+
widgetId: "7c235bba-dd4e-9185-97e1-018f834cdc4f",
|
237
|
+
apiPath: "https://tb-apisrv-dev.textback.io/api",
|
238
|
+
};
|
214
239
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
240
|
+
var off = TextBack.SDK.on("widget.init", function (event) {
|
241
|
+
console.log(`First widget has been initialized. ${event.widgetId}`);
|
242
|
+
off();
|
243
|
+
});
|
219
244
|
|
220
|
-
|
221
|
-
|
222
|
-
|
245
|
+
TextBack.SDK.on("subscription.start", function (event) {
|
246
|
+
console.log("subscription.start", event);
|
247
|
+
});
|
223
248
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
249
|
+
TextBack.SDK.initWidget(config).then(
|
250
|
+
function (widget) {
|
251
|
+
// Facebook
|
252
|
+
document
|
253
|
+
.getElementById("sign_fb")
|
254
|
+
.addEventListener("click", function (event) {
|
255
|
+
event.preventDefault();
|
256
|
+
widget.subscribe("fb");
|
229
257
|
});
|
230
258
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
259
|
+
// Telegram
|
260
|
+
document
|
261
|
+
.getElementById("sign_tg")
|
262
|
+
.addEventListener("click", function (event) {
|
263
|
+
event.preventDefault();
|
264
|
+
widget.subscribe("tg");
|
235
265
|
});
|
236
266
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
267
|
+
// VKontakte
|
268
|
+
document
|
269
|
+
.getElementById("sign_vk")
|
270
|
+
.addEventListener("click", function (event) {
|
271
|
+
event.preventDefault();
|
272
|
+
widget.subscribe("vk");
|
241
273
|
});
|
242
274
|
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
275
|
+
// Viber
|
276
|
+
document
|
277
|
+
.getElementById("sign_viber")
|
278
|
+
.addEventListener("click", function (event) {
|
279
|
+
event.preventDefault();
|
280
|
+
widget.subscribe("viber");
|
247
281
|
});
|
248
282
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
283
|
+
// WhatsApp
|
284
|
+
document
|
285
|
+
.getElementById("sign_wa")
|
286
|
+
.addEventListener("click", function (event) {
|
287
|
+
event.preventDefault();
|
288
|
+
widget.subscribe("whatsapp");
|
253
289
|
});
|
254
290
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
291
|
+
// WhatsApp Business
|
292
|
+
document
|
293
|
+
.getElementById("sign_wab")
|
294
|
+
.addEventListener("click", function (event) {
|
295
|
+
event.preventDefault();
|
296
|
+
widget.subscribe("whatsappb");
|
259
297
|
});
|
260
|
-
},
|
261
|
-
|
262
|
-
|
298
|
+
},
|
299
|
+
function (err) {
|
300
|
+
console.log("error", err);
|
301
|
+
}
|
302
|
+
);
|
263
303
|
|
264
|
-
|
265
|
-
//
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
304
|
+
TextBack.SDK.getWidget(config.widgetId).then(function (widget) {
|
305
|
+
// Random
|
306
|
+
document
|
307
|
+
.getElementById("sign_random")
|
308
|
+
.addEventListener("click", function (event) {
|
309
|
+
var channels = widget.getEnabledChannels();
|
310
|
+
var channelIndexToSubscribe = Math.floor(
|
311
|
+
Math.random() * channels.length
|
312
|
+
);
|
313
|
+
widget.subscribe(channels[channelIndexToSubscribe].channel);
|
314
|
+
});
|
315
|
+
});
|
272
316
|
</script>
|
273
|
-
</body>
|
317
|
+
</body>
|
274
318
|
</html>
|
package/webpack.dev.js
CHANGED
@@ -2,8 +2,9 @@ const merge = require('webpack-merge');
|
|
2
2
|
const common = require('./webpack.common.js');
|
3
3
|
|
4
4
|
module.exports = merge(common, {
|
5
|
-
|
6
|
-
|
5
|
+
mode: 'development',
|
6
|
+
devtool: 'eval-source-map',
|
7
|
+
watch: true,
|
7
8
|
/*devServer: {
|
8
9
|
contentBase: './build',
|
9
10
|
port: 8081,
|