@textback/notification-widget 2.0.0 → 2.0.1-102913
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.js +291 -291
- package/build/index.js +12 -0
- package/build/sdk.js +9 -0
- package/package.json +70 -68
- package/promote_tag.sh +1 -1
- package/readme.md +569 -490
- package/server.js +8 -4
- package/src/libraries/ai.1.0.11.js +4088 -4088
- package/src/libraries/localization/locales/cs.js +14 -12
- package/src/libraries/localization/locales/en.js +14 -12
- package/src/libraries/localization/locales/index.js +8 -8
- package/src/libraries/localization/locales/pl.js +14 -12
- package/src/libraries/localization/locales/ro.js +14 -12
- package/src/libraries/localization/locales/ru.js +13 -12
- package/src/libraries/localization/locales/uk.js +14 -12
- package/src/libraries/localization/text.js +9 -9
- package/src/libraries/t.js +82 -82
- package/src/sdk/channels/channel.js +30 -30
- package/src/sdk/channels/facebook.js +13 -13
- package/src/sdk/channels/factory.js +3 -3
- package/src/sdk/channels/skype.js +12 -12
- package/src/sdk/channels/telegram.js +18 -18
- package/src/sdk/channels/viber.js +12 -12
- package/src/sdk/channels/vk-modal/vk-modal.html +17 -17
- package/src/sdk/channels/vk-modal/vk-modal.js +25 -25
- package/src/sdk/channels/vk-modal/vk-modal.scss +116 -116
- package/src/sdk/channels/vk.js +195 -184
- package/src/sdk/channels/whatsapp.js +16 -10
- package/src/sdk/channels/whatsappb.js +27 -0
- package/src/sdk/events/observer.js +46 -46
- package/src/sdk/index.js +5 -5
- package/src/sdk/sdk.js +67 -30
- package/src/sdk/utils/apiErrorHandler.js +11 -11
- package/src/sdk/utils/appInsights.js +88 -88
- package/src/sdk/utils/browserInfo.js +8 -8
- package/src/sdk/utils/constants.js +17 -17
- package/src/sdk/utils/cookies.js +67 -50
- package/src/sdk/utils/find.js +7 -7
- package/src/sdk/utils/loadConfig.js +20 -20
- package/src/sdk/utils/loadDeepLink.js +48 -21
- package/src/sdk/utils/loadScript.js +25 -25
- package/src/sdk/utils/loadSubscriptions.js +6 -6
- package/src/sdk/utils/parseQueryString.js +33 -33
- package/src/sdk/utils/windowHelper.js +25 -25
- package/src/sdk/widget/widget.js +192 -140
- package/src/widget/components/index.js +6 -2
- package/src/widget/components/tb-notification-button/facebook.js +9 -2
- package/src/widget/components/tb-notification-button/index.js +34 -34
- package/src/widget/components/tb-notification-button/styles.scss +657 -433
- package/src/widget/components/tb-notification-button/telegram.js +9 -2
- package/src/widget/components/tb-notification-button/viber.js +9 -2
- package/src/widget/components/tb-notification-button/vk.js +59 -50
- package/src/widget/components/tb-notification-button/whatsapp.js +15 -8
- package/src/widget/components/tb-notification-button/whatsappb.js +58 -0
- package/src/widget/components/tb-notification-widget/index.js +589 -384
- package/src/widget/components/tb-notification-widget/normalize.scss +395 -394
- package/src/widget/components/tb-notification-widget/styles.scss +502 -139
- package/src/widget/components/tb-nw-wahunter/index.js +259 -0
- package/src/widget/components/tb-nw-wahunter/styles.scss +471 -0
- package/src/widget/config.js +5 -5
- package/src/widget/icons/icon_chat_window.svg +1 -0
- package/src/widget/icons/icon_close.svg +1 -0
- package/src/widget/icons/icon_facebook.svg +7 -7
- package/src/widget/icons/icon_facebook_circle.svg +7 -9
- package/src/widget/icons/icon_instagram_circle.svg +95 -95
- package/src/widget/icons/icon_skype.svg +44 -44
- package/src/widget/icons/icon_skype_circle.svg +46 -46
- package/src/widget/icons/icon_skype_new.svg +113 -113
- package/src/widget/icons/icon_tg.svg +25 -25
- package/src/widget/icons/icon_tg_circle.svg +17 -27
- package/src/widget/icons/icon_viber.svg +75 -75
- package/src/widget/icons/icon_viber_circle.svg +67 -77
- package/src/widget/icons/icon_viber_new.svg +102 -102
- package/src/widget/icons/icon_vk.svg +14 -14
- package/src/widget/icons/icon_vk_circle.svg +16 -16
- package/src/widget/icons/icon_whatsapp.svg +147 -147
- package/src/widget/icons/icon_whatsapp_circle.svg +3 -3
- package/src/widget/icons/icon_whatsapp_hollow.svg +128 -0
- package/src/widget/icons/icon_whatsapp_new.svg +127 -127
- package/src/widget/icons/icon_whatsappb.svg +147 -0
- package/src/widget/icons/icon_whatsappb_circle.svg +4 -0
- package/src/widget/icons/icon_whatsappb_new.svg +127 -0
- package/src/widget/icons/paper-plane-arrow.svg +3 -0
- package/src/widget/icons/tb-logo.svg +21 -0
- package/src/widget/index.js +28 -28
- package/src/widget/locales/cs.js +42 -0
- package/src/widget/locales/en.js +42 -20
- package/src/widget/locales/index.js +2 -2
- package/src/widget/locales/pl.js +41 -19
- package/src/widget/locales/ro.js +41 -20
- package/src/widget/locales/ru.js +40 -19
- package/src/widget/locales/uk.js +40 -19
- package/src/widget/utils/cookiesEx.js +41 -41
- package/src/widget/utils/getLocale.js +4 -2
- package/src/widget/utils/stringifyAttributes.js +19 -19
- package/src/widget/utils/text.js +2 -1
- package/src/widget/utils/widgetsStorage.js +28 -28
- package/src/widget/widget.entry.js +3 -4
- package/tests/gf.html +35 -35
- package/tests/gf.js +21 -21
- package/tests/index.js +61 -61
- package/views/examples.ejs +7 -3
- package/views/sdk.html +274 -256
- package/webpack.common.js +72 -72
- package/webpack.dev.js +15 -15
- package/webpack.prod.js +10 -10
- package/src/widget/components/tb-notification-button/skype.js +0 -47
- package/src/widget/icons/text-back-badge.png +0 -0
- package/src/widget/locales/cz.js +0 -20
@@ -1,21 +1,23 @@
|
|
1
1
|
module.exports = {
|
2
2
|
facebook: 'Facebook',
|
3
|
-
'
|
3
|
+
'facebookExtended': 'Poslat přes Facebook',
|
4
4
|
skype: 'Skype',
|
5
5
|
'sign-skype': 'Poslat přes Skype',
|
6
6
|
telegram: 'Telegram',
|
7
|
-
'
|
7
|
+
'telegramExtended': 'Poslat přes Telegram',
|
8
8
|
viber: 'Viber',
|
9
|
-
'
|
10
|
-
vkontakte: '
|
11
|
-
'
|
12
|
-
'sign-vk': 'Poslat přes
|
9
|
+
'viberExtended': 'Poslat přes Viber',
|
10
|
+
vkontakte: 'VK',
|
11
|
+
'vkontakteLogin': 'VK Login',
|
12
|
+
'sign-vk': 'Poslat přes VK',
|
13
13
|
whatsapp: 'WhatsApp',
|
14
|
-
|
15
|
-
'
|
16
|
-
'
|
17
|
-
'
|
18
|
-
'
|
19
|
-
'
|
14
|
+
whatsappb: 'WA Business',
|
15
|
+
'whatsappExtended': 'Poslat přes WhatsApp',
|
16
|
+
'whatsappbExtended': 'Poslat přes WhatsApp',
|
17
|
+
'telegramTip': 'Stiskněte <strong>"Start"</strong><br/> v aplikaci Telegram',
|
18
|
+
'facebookTip': 'Stiskněte <strong>"Začít"</strong><br/> v Facebook Messenger',
|
19
|
+
'viberTip': ' Musíte mít nainstalovanou <br/><strong>Viber Desktop aplikaci</strong>',
|
20
|
+
'vkontakteTip': 'Stiskněte <strong>"Povolit"</strong><br/> ve vyskakovacím okně',
|
21
|
+
'whatsappTip': 'Pošlete <strong>předvyplněný text</strong><br/> přes WhatsApp bez změn',
|
20
22
|
'whatsapp_prefixtext': 'Pro připojení nic neměňte ani nemažte a klikněte na tlačítko "Odeslat"'
|
21
23
|
};
|
@@ -1,21 +1,23 @@
|
|
1
1
|
module.exports = {
|
2
2
|
facebook: 'Facebook',
|
3
|
-
'
|
3
|
+
'facebookExtended': 'Send to Messenger',
|
4
4
|
skype: 'Skype',
|
5
5
|
'sign-skype': 'Send to Skype',
|
6
6
|
telegram: 'Telegram',
|
7
|
-
'
|
7
|
+
'telegramExtended': 'Send to Telegram',
|
8
8
|
viber: 'Viber',
|
9
|
-
'
|
10
|
-
vkontakte: '
|
11
|
-
'
|
12
|
-
'sign-vk': 'Send to
|
9
|
+
'viberExtended': 'Send to Viber',
|
10
|
+
vkontakte: 'VK',
|
11
|
+
'vkontakteLogin': 'VK Sing In',
|
12
|
+
'sign-vk': 'Send to VK',
|
13
13
|
whatsapp: 'WhatsApp',
|
14
|
-
|
15
|
-
'
|
16
|
-
'
|
17
|
-
'
|
18
|
-
'
|
19
|
-
'
|
14
|
+
whatsappb: 'WA Business',
|
15
|
+
'whatsappExtended': 'Send to WhatsApp',
|
16
|
+
'whatsappbExtended': 'Send to WhatsApp',
|
17
|
+
'telegramTip': 'Tap <strong>"Start"</strong></br> when enter Telegram App',
|
18
|
+
'facebookTip': 'Tap <strong>"Get started"</strong><br/>in Facebook Messenger',
|
19
|
+
'viberTip': '<strong>Viber Desktop App</strong></br> should be installed on your PC',
|
20
|
+
'vkontakteTip': 'Press <strong>"Allow messages"</strong><br/>in a popup window',
|
21
|
+
'whatsappTip': '<strong>Send generated text</strong><br/>in WhatsApp',
|
20
22
|
'whatsapp_prefixtext': 'Send generated text in WhatsApp'
|
21
23
|
};
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module.exports = {
|
2
|
-
main: require('./en'),
|
3
|
-
ru: require('./ru'),
|
4
|
-
pl: require('./pl'),
|
5
|
-
ro: require('./ro'),
|
6
|
-
uk: require('./uk'),
|
7
|
-
cz: require('./cs'),
|
8
|
-
'cs-CZ': require('./cs'),
|
1
|
+
module.exports = {
|
2
|
+
main: require('./en'),
|
3
|
+
ru: require('./ru'),
|
4
|
+
pl: require('./pl'),
|
5
|
+
ro: require('./ro'),
|
6
|
+
uk: require('./uk'),
|
7
|
+
cz: require('./cs'),
|
8
|
+
'cs-CZ': require('./cs'),
|
9
9
|
};
|
@@ -1,21 +1,23 @@
|
|
1
1
|
module.exports = {
|
2
2
|
facebook: 'Facebook',
|
3
|
-
'
|
3
|
+
'facebookExtended': 'Zapisz się Facebook',
|
4
4
|
skype: 'Skype',
|
5
5
|
'sign-skype': 'Zapisz się Skype',
|
6
6
|
telegram: 'Telegram',
|
7
|
-
'
|
7
|
+
'telegramExtended': 'Zapisz się Telegram',
|
8
8
|
viber: 'Viber',
|
9
|
-
'
|
10
|
-
vkontakte: '
|
11
|
-
'
|
12
|
-
'sign-vk': 'Zapisz się
|
9
|
+
'viberExtended': 'Zapisz się Viber',
|
10
|
+
vkontakte: 'VK',
|
11
|
+
'vkontakteLogin': 'VK Login',
|
12
|
+
'sign-vk': 'Zapisz się VK',
|
13
13
|
whatsapp: 'WhatsApp',
|
14
|
-
|
15
|
-
'
|
16
|
-
'
|
17
|
-
'
|
18
|
-
'
|
19
|
-
'
|
14
|
+
whatsappb: 'WA Business',
|
15
|
+
'whatsappExtended': 'Zapisz się WhatsApp',
|
16
|
+
'whatsappbExtended': 'Zapisz się WhatsApp Business',
|
17
|
+
'telegramTip': 'Нажмите <strong>"Start"</strong></br>в приложении Telegram',
|
18
|
+
'facebookTip': 'Нажмите <strong>"Начать"</strong><br/>в Facebook Messenger',
|
19
|
+
'viberTip': ' У вас должно быть установлено<br/><strong>Viber Desktop приложение</strong>',
|
20
|
+
'vkontakteTip': 'Нажмите <strong>"Разрешить"</strong><br/>во всплывающем окне',
|
21
|
+
'whatsappTip': 'Отправьте <strong>предзаполненный текст</strong><br/>в WhatsApp без изменений',
|
20
22
|
'whatsapp_prefixtext': 'Wyślij bez zmiany tej wiadomości'
|
21
23
|
};
|
@@ -1,21 +1,23 @@
|
|
1
1
|
module.exports = {
|
2
2
|
facebook: 'Facebook',
|
3
|
-
'
|
3
|
+
'facebookExtended': 'Abonează-te Facebook',
|
4
4
|
skype: 'Skype',
|
5
5
|
'sign-skype': 'Abonează-te Skype',
|
6
6
|
telegram: 'Telegram',
|
7
|
-
'
|
7
|
+
'telegramExtended': 'Abonează-te Telegram',
|
8
8
|
viber: 'Viber',
|
9
|
-
'
|
10
|
-
vkontakte: '
|
11
|
-
'
|
12
|
-
'sign-vk': 'Abonează-te
|
9
|
+
'viberExtended': 'Abonează-te Viber',
|
10
|
+
vkontakte: 'VK',
|
11
|
+
'vkontakteLogin': 'VK Login',
|
12
|
+
'sign-vk': 'Abonează-te VK',
|
13
13
|
whatsapp: 'WhatsApp',
|
14
|
-
|
15
|
-
'
|
16
|
-
'
|
17
|
-
'
|
18
|
-
'
|
19
|
-
'
|
14
|
+
whatsappb: 'WhatsApp',
|
15
|
+
'whatsappExtended': 'Abonează-te WhatsApp',
|
16
|
+
'whatsappbExtended': 'Abonează-te WhatsApp',
|
17
|
+
'telegramTip': 'Нажмите <strong>"Start"</strong></br>в приложении Telegram',
|
18
|
+
'facebookTip': 'Нажмите <strong>"Начать"</strong><br/>в Facebook Messenger',
|
19
|
+
'viberTip': ' У вас должно быть установлено<br/><strong>Viber Desktop приложение</strong>',
|
20
|
+
'vkontakteTip': 'Нажмите <strong>"Разрешить"</strong><br/>во всплывающем окне',
|
21
|
+
'whatsappTip': 'Отправьте <strong>предзаполненный текст</strong><br/>в WhatsApp без изменений',
|
20
22
|
'whatsapp_prefixtext': 'Trimiteți fără a schimba acest mesaj'
|
21
23
|
};
|
@@ -1,21 +1,22 @@
|
|
1
1
|
module.exports = {
|
2
2
|
facebook: 'Facebook',
|
3
|
-
'
|
3
|
+
'facebookExtended': 'Подписаться в Facebook',
|
4
4
|
skype: 'Skype',
|
5
5
|
'sign-skype': 'Подписаться в Skype',
|
6
6
|
telegram: 'Telegram',
|
7
|
-
'
|
7
|
+
'telegramExtended': 'Подписаться в Telegram',
|
8
8
|
viber: 'Viber',
|
9
|
-
'
|
10
|
-
vkontakte: '
|
11
|
-
'
|
12
|
-
'sign-vk': 'Подписаться
|
9
|
+
'viberExtended': 'Подписаться в Viber',
|
10
|
+
vkontakte: 'VK',
|
11
|
+
'vkontakteLogin': 'VK Login',
|
12
|
+
'sign-vk': 'Подписаться ВКонтакте',
|
13
13
|
whatsapp: 'WhatsApp',
|
14
|
-
'
|
15
|
-
'
|
16
|
-
'
|
17
|
-
'
|
18
|
-
'
|
19
|
-
'
|
14
|
+
'whatsappExtended': 'Подписаться в WhatsApp',
|
15
|
+
'whatsappbExtended': 'Подписаться в WhatsApp',
|
16
|
+
'telegramTip': 'Нажмите <strong>"Start"</strong></br>в приложении Telegram',
|
17
|
+
'facebookTip': 'Нажмите <strong>"Начать"</strong><br/>в Facebook Messenger',
|
18
|
+
'viberTip': ' У вас должно быть установлено<br/><strong>Viber Desktop приложение</strong>',
|
19
|
+
'vkontakteTip': 'Нажмите <strong>"Разрешить"</strong><br/>во всплывающем окне',
|
20
|
+
'whatsappTip': 'Отправьте <strong>предзаполненный текст</strong><br/>в WhatsApp без изменений',
|
20
21
|
'whatsapp_prefixtext': 'Отправьте не изменяя это сообщение'
|
21
22
|
};
|
@@ -1,21 +1,23 @@
|
|
1
1
|
module.exports = {
|
2
2
|
facebook: 'Facebook',
|
3
|
-
'
|
3
|
+
'facebookExtended': 'Підписатися на Facebook',
|
4
4
|
skype: 'Skype',
|
5
5
|
'sign-skype': 'Підписатися на Skype',
|
6
6
|
telegram: 'Telegram',
|
7
|
-
'
|
7
|
+
'telegramExtended': 'Підписатися на Telegram',
|
8
8
|
viber: 'Viber',
|
9
|
-
'
|
10
|
-
vkontakte: '
|
11
|
-
'
|
12
|
-
'sign-vk': 'Підписатися на
|
9
|
+
'viberExtended': 'Підписатися на Viber',
|
10
|
+
vkontakte: 'VK',
|
11
|
+
'vkontakteLogin': 'VK Login',
|
12
|
+
'sign-vk': 'Підписатися на VK',
|
13
13
|
whatsapp: 'WhatsApp',
|
14
|
-
|
15
|
-
'
|
16
|
-
'
|
17
|
-
'
|
18
|
-
'
|
19
|
-
'
|
14
|
+
whatsappb: 'WA Business',
|
15
|
+
'whatsappExtended': 'Підписатися на WhatsApp',
|
16
|
+
'whatsappbExtended': 'Підписатися на WhatsApp Business',
|
17
|
+
'telegramTip': 'Нажмите <strong>"Start"</strong></br>в приложении Telegram',
|
18
|
+
'facebookTip': 'Нажмите <strong>"Начать"</strong><br/>в Facebook Messenger',
|
19
|
+
'viberTip': ' У вас должно быть установлено<br/><strong>Viber Desktop приложение</strong>',
|
20
|
+
'vkontakteTip': 'Нажмите <strong>"Разрешить"</strong><br/>во всплывающем окне',
|
21
|
+
'whatsappTip': 'Отправьте <strong>предзаполненный текст</strong><br/>в WhatsApp без изменений',
|
20
22
|
'whatsapp_prefixtext': 'Надішліть не зраджуючи це повідомлення'
|
21
23
|
};
|
@@ -1,9 +1,9 @@
|
|
1
|
-
const locales = require('./locales');
|
2
|
-
|
3
|
-
function text(string, locale) {
|
4
|
-
const dictionary = locales[locale] || locales[locale.split('-')[0]] || locales[locale.split('_')[0]] || locales.main;
|
5
|
-
|
6
|
-
return dictionary[string] || locales.main[string] || string;
|
7
|
-
}
|
8
|
-
|
9
|
-
export default text;
|
1
|
+
const locales = require('./locales');
|
2
|
+
|
3
|
+
function text(string, locale) {
|
4
|
+
const dictionary = locales[locale] || locales[locale.split('-')[0]] || locales[locale.split('_')[0]] || locales.main;
|
5
|
+
|
6
|
+
return dictionary[string] || locales.main[string] || string;
|
7
|
+
}
|
8
|
+
|
9
|
+
export default text;
|
package/src/libraries/t.js
CHANGED
@@ -1,82 +1,82 @@
|
|
1
|
-
// local-scoped modification of https://github.com/jasonmoo/t.js
|
2
|
-
var blockregex = /\{\{(([@!]?)(.+?))\}\}(([\s\S]+?)(\{\{:\1\}\}([\s\S]+?))?)\{\{\/\1\}\}/g,
|
3
|
-
valregex = /\{\{([=%])(.+?)\}\}/g;
|
4
|
-
|
5
|
-
function t(template) {
|
6
|
-
this.t = template;
|
7
|
-
}
|
8
|
-
|
9
|
-
function scrub(val) {
|
10
|
-
return new Option(val).innerHTML.replace(/"/g,""");
|
11
|
-
}
|
12
|
-
|
13
|
-
function get_value(vars, key) {
|
14
|
-
var parts = key.split('.');
|
15
|
-
while (parts.length) {
|
16
|
-
if (!(parts[0] in vars)) {
|
17
|
-
return false;
|
18
|
-
}
|
19
|
-
vars = vars[parts.shift()];
|
20
|
-
}
|
21
|
-
return vars;
|
22
|
-
}
|
23
|
-
|
24
|
-
function render(fragment, vars) {
|
25
|
-
return fragment
|
26
|
-
.replace(blockregex, function(_, __, meta, key, inner, if_true, has_else, if_false) {
|
27
|
-
|
28
|
-
var val = get_value(vars,key), temp = "", i;
|
29
|
-
|
30
|
-
if (!val) {
|
31
|
-
|
32
|
-
// handle if not
|
33
|
-
if (meta == '!') {
|
34
|
-
return render(inner, vars);
|
35
|
-
}
|
36
|
-
// check for else
|
37
|
-
if (has_else) {
|
38
|
-
return render(if_false, vars);
|
39
|
-
}
|
40
|
-
|
41
|
-
return "";
|
42
|
-
}
|
43
|
-
|
44
|
-
// regular if
|
45
|
-
if (!meta) {
|
46
|
-
return render(if_true, vars);
|
47
|
-
}
|
48
|
-
|
49
|
-
// process array/obj iteration
|
50
|
-
if (meta == '@') {
|
51
|
-
// store any previous vars
|
52
|
-
// reuse existing vars
|
53
|
-
_ = vars._key;
|
54
|
-
__ = vars._val;
|
55
|
-
for (i in val) {
|
56
|
-
if (val.hasOwnProperty(i)) {
|
57
|
-
vars._key = i;
|
58
|
-
vars._val = val[i];
|
59
|
-
temp += render(inner, vars);
|
60
|
-
}
|
61
|
-
}
|
62
|
-
vars._key = _;
|
63
|
-
vars._val = __;
|
64
|
-
return temp;
|
65
|
-
}
|
66
|
-
|
67
|
-
})
|
68
|
-
.replace(valregex, function(_, meta, key) {
|
69
|
-
var val = get_value(vars,key);
|
70
|
-
|
71
|
-
if (val || val === 0) {
|
72
|
-
return meta == '%' ? scrub(val) : val;
|
73
|
-
}
|
74
|
-
return "";
|
75
|
-
});
|
76
|
-
}
|
77
|
-
|
78
|
-
t.prototype.render = function (vars) {
|
79
|
-
return render(this.t, vars);
|
80
|
-
};
|
81
|
-
|
82
|
-
export default t;
|
1
|
+
// local-scoped modification of https://github.com/jasonmoo/t.js
|
2
|
+
var blockregex = /\{\{(([@!]?)(.+?))\}\}(([\s\S]+?)(\{\{:\1\}\}([\s\S]+?))?)\{\{\/\1\}\}/g,
|
3
|
+
valregex = /\{\{([=%])(.+?)\}\}/g;
|
4
|
+
|
5
|
+
function t(template) {
|
6
|
+
this.t = template;
|
7
|
+
}
|
8
|
+
|
9
|
+
function scrub(val) {
|
10
|
+
return new Option(val).innerHTML.replace(/"/g,""");
|
11
|
+
}
|
12
|
+
|
13
|
+
function get_value(vars, key) {
|
14
|
+
var parts = key.split('.');
|
15
|
+
while (parts.length) {
|
16
|
+
if (!(parts[0] in vars)) {
|
17
|
+
return false;
|
18
|
+
}
|
19
|
+
vars = vars[parts.shift()];
|
20
|
+
}
|
21
|
+
return vars;
|
22
|
+
}
|
23
|
+
|
24
|
+
function render(fragment, vars) {
|
25
|
+
return fragment
|
26
|
+
.replace(blockregex, function(_, __, meta, key, inner, if_true, has_else, if_false) {
|
27
|
+
|
28
|
+
var val = get_value(vars,key), temp = "", i;
|
29
|
+
|
30
|
+
if (!val) {
|
31
|
+
|
32
|
+
// handle if not
|
33
|
+
if (meta == '!') {
|
34
|
+
return render(inner, vars);
|
35
|
+
}
|
36
|
+
// check for else
|
37
|
+
if (has_else) {
|
38
|
+
return render(if_false, vars);
|
39
|
+
}
|
40
|
+
|
41
|
+
return "";
|
42
|
+
}
|
43
|
+
|
44
|
+
// regular if
|
45
|
+
if (!meta) {
|
46
|
+
return render(if_true, vars);
|
47
|
+
}
|
48
|
+
|
49
|
+
// process array/obj iteration
|
50
|
+
if (meta == '@') {
|
51
|
+
// store any previous vars
|
52
|
+
// reuse existing vars
|
53
|
+
_ = vars._key;
|
54
|
+
__ = vars._val;
|
55
|
+
for (i in val) {
|
56
|
+
if (val.hasOwnProperty(i)) {
|
57
|
+
vars._key = i;
|
58
|
+
vars._val = val[i];
|
59
|
+
temp += render(inner, vars);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
vars._key = _;
|
63
|
+
vars._val = __;
|
64
|
+
return temp;
|
65
|
+
}
|
66
|
+
|
67
|
+
})
|
68
|
+
.replace(valregex, function(_, meta, key) {
|
69
|
+
var val = get_value(vars,key);
|
70
|
+
|
71
|
+
if (val || val === 0) {
|
72
|
+
return meta == '%' ? scrub(val) : val;
|
73
|
+
}
|
74
|
+
return "";
|
75
|
+
});
|
76
|
+
}
|
77
|
+
|
78
|
+
t.prototype.render = function (vars) {
|
79
|
+
return render(this.t, vars);
|
80
|
+
};
|
81
|
+
|
82
|
+
export default t;
|
@@ -1,31 +1,31 @@
|
|
1
|
-
import { Observer, EVENTS } from '../events/observer.js';
|
2
|
-
|
3
|
-
export default class Channel {
|
4
|
-
constructor(channelData = {}, deeplink, widget) {
|
5
|
-
this.config = channelData;
|
6
|
-
|
7
|
-
this.channel = channelData.channel;
|
8
|
-
this.channelId = channelData.channelId;
|
9
|
-
this.enabled = channelData.enabled;
|
10
|
-
this.id = channelData.id;
|
11
|
-
this.slug = channelData.slug;
|
12
|
-
|
13
|
-
this.deeplink = deeplink;
|
14
|
-
this.widget = widget;
|
15
|
-
|
16
|
-
this.initPromise = null;
|
17
|
-
this.hasError = false;
|
18
|
-
}
|
19
|
-
|
20
|
-
subscribe() {
|
21
|
-
Observer.trigger(EVENTS.SUBSCRIBE_START, {
|
22
|
-
widgetId: this.widget.id,
|
23
|
-
channel: this,
|
24
|
-
});
|
25
|
-
}
|
26
|
-
|
27
|
-
reportError(...args) {
|
28
|
-
console.error(...args);
|
29
|
-
this.hasError = true;
|
30
|
-
}
|
1
|
+
import { Observer, EVENTS } from '../events/observer.js';
|
2
|
+
|
3
|
+
export default class Channel {
|
4
|
+
constructor(channelData = {}, deeplink, widget) {
|
5
|
+
this.config = channelData;
|
6
|
+
|
7
|
+
this.channel = channelData.channel;
|
8
|
+
this.channelId = channelData.channelId;
|
9
|
+
this.enabled = channelData.enabled;
|
10
|
+
this.id = channelData.id;
|
11
|
+
this.slug = channelData.slug;
|
12
|
+
|
13
|
+
this.deeplink = deeplink;
|
14
|
+
this.widget = widget;
|
15
|
+
|
16
|
+
this.initPromise = null;
|
17
|
+
this.hasError = false;
|
18
|
+
}
|
19
|
+
|
20
|
+
subscribe() {
|
21
|
+
Observer.trigger(EVENTS.SUBSCRIBE_START, {
|
22
|
+
widgetId: this.widget.id,
|
23
|
+
channel: this,
|
24
|
+
});
|
25
|
+
}
|
26
|
+
|
27
|
+
reportError(...args) {
|
28
|
+
console.error(...args);
|
29
|
+
this.hasError = true;
|
30
|
+
}
|
31
31
|
}
|
@@ -1,13 +1,13 @@
|
|
1
|
-
import Channel from './channel.js';
|
2
|
-
import windowHelper from '../utils/windowHelper.js';
|
3
|
-
|
4
|
-
export default class FacebookChannel extends Channel {
|
5
|
-
constructor(channelData = {}, deeplink, widget) {
|
6
|
-
super(channelData, deeplink, widget);
|
7
|
-
}
|
8
|
-
|
9
|
-
subscribe() {
|
10
|
-
super.subscribe();
|
11
|
-
window.open(`https://m.me/${this.id}?ref=${this.deeplink}`, 'tb_facebook'
|
12
|
-
}
|
13
|
-
}
|
1
|
+
import Channel from './channel.js';
|
2
|
+
import windowHelper from '../utils/windowHelper.js';
|
3
|
+
|
4
|
+
export default class FacebookChannel extends Channel {
|
5
|
+
constructor(channelData = {}, deeplink, widget) {
|
6
|
+
super(channelData, deeplink, widget);
|
7
|
+
}
|
8
|
+
|
9
|
+
subscribe() {
|
10
|
+
super.subscribe();
|
11
|
+
window.open(`https://m.me/${this.id}?ref=${this.deeplink}`, 'tb_facebook');
|
12
|
+
}
|
13
|
+
}
|
@@ -1,16 +1,14 @@
|
|
1
1
|
import FacebookChannel from './facebook.js';
|
2
|
-
import SkypeChannel from './skype.js';
|
3
2
|
import TelegramChannel from './telegram.js';
|
4
3
|
import ViberChanel from './viber.js';
|
5
4
|
import VKChannel from './vk.js';
|
6
5
|
import WhatsappChannel from './whatsapp.js';
|
6
|
+
import WhatsappbChannel from './whatsappb.js';
|
7
7
|
|
8
8
|
function getConstructor(channel) {
|
9
9
|
switch(channel) {
|
10
10
|
case 'facebook':
|
11
11
|
return FacebookChannel;
|
12
|
-
case 'skype':
|
13
|
-
return SkypeChannel;
|
14
12
|
case 'tg':
|
15
13
|
return TelegramChannel;
|
16
14
|
case 'viber':
|
@@ -19,6 +17,8 @@ function getConstructor(channel) {
|
|
19
17
|
return VKChannel;
|
20
18
|
case 'whatsapp':
|
21
19
|
return WhatsappChannel;
|
20
|
+
case 'whatsappb':
|
21
|
+
return WhatsappbChannel;
|
22
22
|
default:
|
23
23
|
return null;
|
24
24
|
}
|
@@ -1,13 +1,13 @@
|
|
1
|
-
import Channel from './channel.js';
|
2
|
-
import constants from '../utils/constants.js';
|
3
|
-
|
4
|
-
export default class SkypeChannel extends Channel {
|
5
|
-
constructor(channelData = {}, deeplink, widget) {
|
6
|
-
super(channelData, deeplink, widget);
|
7
|
-
}
|
8
|
-
|
9
|
-
subscribe() {
|
10
|
-
super.subscribe();
|
11
|
-
window.open(`https://join.skype.com/bot/${this.id}?add`, 'tb_skype'
|
12
|
-
}
|
1
|
+
import Channel from './channel.js';
|
2
|
+
import constants from '../utils/constants.js';
|
3
|
+
|
4
|
+
export default class SkypeChannel extends Channel {
|
5
|
+
constructor(channelData = {}, deeplink, widget) {
|
6
|
+
super(channelData, deeplink, widget);
|
7
|
+
}
|
8
|
+
|
9
|
+
subscribe() {
|
10
|
+
super.subscribe();
|
11
|
+
window.open(`https://join.skype.com/bot/${this.id}?add`, 'tb_skype');
|
12
|
+
}
|
13
13
|
}
|
@@ -1,18 +1,18 @@
|
|
1
|
-
import Channel from './channel.js';
|
2
|
-
import constants from '../utils/constants.js';
|
3
|
-
|
4
|
-
export default class TelegramChannel extends Channel {
|
5
|
-
constructor(channelData = {}, deeplink, widget) {
|
6
|
-
super(channelData, deeplink, widget);
|
7
|
-
}
|
8
|
-
|
9
|
-
subscribe() {
|
10
|
-
super.subscribe();
|
11
|
-
|
12
|
-
if (this.widget.config.tgRedirector) {
|
13
|
-
return window.open(`${this.widget.config.tgRedirector}${this.id}?start=${this.deeplink}`, 'tb_tg'
|
14
|
-
}
|
15
|
-
|
16
|
-
return window.open(`https://telegram.me/${this.id}?start=${this.deeplink}`, 'tb_tg'
|
17
|
-
}
|
18
|
-
}
|
1
|
+
import Channel from './channel.js';
|
2
|
+
import constants from '../utils/constants.js';
|
3
|
+
|
4
|
+
export default class TelegramChannel extends Channel {
|
5
|
+
constructor(channelData = {}, deeplink, widget) {
|
6
|
+
super(channelData, deeplink, widget);
|
7
|
+
}
|
8
|
+
|
9
|
+
subscribe() {
|
10
|
+
super.subscribe();
|
11
|
+
|
12
|
+
if (this.widget.config.tgRedirector) {
|
13
|
+
return window.open(`${this.widget.config.tgRedirector}${this.id}?start=${this.deeplink}`, 'tb_tg');
|
14
|
+
}
|
15
|
+
|
16
|
+
return window.open(`https://telegram.me/${this.id}?start=${this.deeplink}`, 'tb_tg');
|
17
|
+
}
|
18
|
+
}
|
@@ -1,13 +1,13 @@
|
|
1
|
-
import Channel from './channel.js';
|
2
|
-
import constants from '../utils/constants.js';
|
3
|
-
|
4
|
-
export default class ViberChannel extends Channel {
|
5
|
-
constructor(channelData = {}, deeplink, widget) {
|
6
|
-
super(channelData, deeplink, widget);
|
7
|
-
}
|
8
|
-
|
9
|
-
subscribe() {
|
10
|
-
super.subscribe();
|
11
|
-
window.open(`viber://pa?chatURI=${this.id}&context=${this.deeplink}`, 'viber'
|
12
|
-
}
|
1
|
+
import Channel from './channel.js';
|
2
|
+
import constants from '../utils/constants.js';
|
3
|
+
|
4
|
+
export default class ViberChannel extends Channel {
|
5
|
+
constructor(channelData = {}, deeplink, widget) {
|
6
|
+
super(channelData, deeplink, widget);
|
7
|
+
}
|
8
|
+
|
9
|
+
subscribe() {
|
10
|
+
super.subscribe();
|
11
|
+
window.open(`viber://pa?chatURI=${this.id}&context=${this.deeplink}`, 'viber');
|
12
|
+
}
|
13
13
|
}
|