@textback/notification-widget 2.0.1-84986 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.js +291 -291
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/notificationwidget.iml +9 -0
- package/.idea/vcs.xml +6 -0
- package/build/index.js +3 -3
- package/build/sdk.js +2 -2
- package/package.json +70 -70
- package/promote_tag.sh +1 -1
- package/readme.md +569 -569
- package/server.js +1 -1
- package/src/libraries/ai.1.0.11.js +4088 -4088
- package/src/libraries/localization/locales/index.js +8 -8
- 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/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 -195
- package/src/sdk/events/observer.js +46 -46
- package/src/sdk/index.js +5 -5
- package/src/sdk/sdk.js +67 -67
- 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 -67
- package/src/sdk/utils/find.js +7 -7
- package/src/sdk/utils/loadConfig.js +20 -20
- package/src/sdk/utils/loadDeepLink.js +48 -48
- 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 -192
- package/src/widget/components/tb-notification-button/index.js +34 -34
- package/src/widget/components/tb-notification-button/styles.scss +657 -657
- package/src/widget/components/tb-notification-widget/normalize.scss +395 -395
- package/src/widget/components/tb-nw-wahunter/styles.scss +471 -471
- package/src/widget/config.js +5 -5
- package/src/widget/icons/icon_chat_window.svg +1 -1
- package/src/widget/icons/icon_close.svg +1 -1
- package/src/widget/icons/icon_facebook.svg +7 -7
- package/src/widget/icons/icon_facebook_circle.svg +7 -7
- 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 -17
- package/src/widget/icons/icon_viber.svg +75 -75
- package/src/widget/icons/icon_viber_circle.svg +67 -67
- 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_new.svg +127 -127
- package/src/widget/icons/icon_whatsappb.svg +147 -147
- package/src/widget/icons/icon_whatsappb_circle.svg +3 -3
- package/src/widget/icons/icon_whatsappb_new.svg +127 -127
- package/src/widget/icons/paper-plane-arrow.svg +3 -3
- package/src/widget/icons/tb-logo.svg +21 -21
- package/src/widget/index.js +28 -28
- package/src/widget/locales/cs.js +42 -42
- package/src/widget/locales/en.js +42 -42
- package/src/widget/locales/ro.js +41 -41
- package/src/widget/utils/cookiesEx.js +41 -41
- package/src/widget/utils/stringifyAttributes.js +19 -19
- package/src/widget/utils/widgetsStorage.js +28 -28
- package/src/widget/widget.entry.js +3 -3
- package/tests/gf.html +35 -35
- package/tests/gf.js +21 -21
- package/tests/index.js +61 -61
- package/views/examples.ejs +3 -3
- package/views/sdk.html +274 -274
- package/webpack.common.js +72 -72
- package/webpack.dev.js +15 -15
- package/webpack.prod.js +10 -10
@@ -1,21 +1,21 @@
|
|
1
|
-
import apiErrorHandler from './apiErrorHandler.js';
|
2
|
-
|
3
|
-
const cache = {};
|
4
|
-
|
5
|
-
|
6
|
-
export default function loadConfig(widgetId, apiPath) {
|
7
|
-
if (!widgetId) {
|
8
|
-
return Promise.reject('Widget id required');
|
9
|
-
}
|
10
|
-
|
11
|
-
if (cache[widgetId]) {
|
12
|
-
return cache[widgetId];
|
13
|
-
}
|
14
|
-
|
15
|
-
const loadingPromise = fetch(`${apiPath}/endUserNotifications/widgets/${widgetId}`).then(apiErrorHandler);
|
16
|
-
loadingPromise.then(() => {
|
17
|
-
cache[widgetId] = loadingPromise;
|
18
|
-
});
|
19
|
-
|
20
|
-
return loadingPromise;
|
1
|
+
import apiErrorHandler from './apiErrorHandler.js';
|
2
|
+
|
3
|
+
const cache = {};
|
4
|
+
|
5
|
+
|
6
|
+
export default function loadConfig(widgetId, apiPath) {
|
7
|
+
if (!widgetId) {
|
8
|
+
return Promise.reject('Widget id required');
|
9
|
+
}
|
10
|
+
|
11
|
+
if (cache[widgetId]) {
|
12
|
+
return cache[widgetId];
|
13
|
+
}
|
14
|
+
|
15
|
+
const loadingPromise = fetch(`${apiPath}/endUserNotifications/widgets/${widgetId}`).then(apiErrorHandler);
|
16
|
+
loadingPromise.then(() => {
|
17
|
+
cache[widgetId] = loadingPromise;
|
18
|
+
});
|
19
|
+
|
20
|
+
return loadingPromise;
|
21
21
|
};
|
@@ -1,48 +1,48 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
import apiErrorHandler from './apiErrorHandler.js';
|
4
|
-
|
5
|
-
const cache = {};
|
6
|
-
|
7
|
-
export const deeplinkUpdater = (apiPath, deeplink) => {
|
8
|
-
let _promises = [];
|
9
|
-
|
10
|
-
return data => {
|
11
|
-
Promise.all(_promises).then(() => {
|
12
|
-
let _data = JSON.stringify({
|
13
|
-
id: deeplink,
|
14
|
-
insecureContext: { data: data }
|
15
|
-
});
|
16
|
-
|
17
|
-
let _promise = fetch(
|
18
|
-
`${apiPath}/endUserNotifications/deepLinks`,
|
19
|
-
{
|
20
|
-
method: 'PATCH',
|
21
|
-
body: _data
|
22
|
-
}
|
23
|
-
);
|
24
|
-
|
25
|
-
_promises.push(_promise);
|
26
|
-
|
27
|
-
return _promises;
|
28
|
-
});
|
29
|
-
};
|
30
|
-
};
|
31
|
-
|
32
|
-
export default function loadDeepLink(apiPath, options = {}) {
|
33
|
-
const body = JSON.stringify(options);
|
34
|
-
|
35
|
-
if (cache[body]) {
|
36
|
-
return cache[body];
|
37
|
-
}
|
38
|
-
|
39
|
-
cache[body] = fetch(`${apiPath}/endUserNotifications/deepLinks`, {
|
40
|
-
method: 'POST',
|
41
|
-
headers: {
|
42
|
-
'Content-Type': 'application/json'
|
43
|
-
},
|
44
|
-
body
|
45
|
-
}).then(apiErrorHandler);
|
46
|
-
|
47
|
-
return cache[body];
|
48
|
-
};
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
import apiErrorHandler from './apiErrorHandler.js';
|
4
|
+
|
5
|
+
const cache = {};
|
6
|
+
|
7
|
+
export const deeplinkUpdater = (apiPath, deeplink) => {
|
8
|
+
let _promises = [];
|
9
|
+
|
10
|
+
return data => {
|
11
|
+
Promise.all(_promises).then(() => {
|
12
|
+
let _data = JSON.stringify({
|
13
|
+
id: deeplink,
|
14
|
+
insecureContext: { data: data }
|
15
|
+
});
|
16
|
+
|
17
|
+
let _promise = fetch(
|
18
|
+
`${apiPath}/endUserNotifications/deepLinks`,
|
19
|
+
{
|
20
|
+
method: 'PATCH',
|
21
|
+
body: _data
|
22
|
+
}
|
23
|
+
);
|
24
|
+
|
25
|
+
_promises.push(_promise);
|
26
|
+
|
27
|
+
return _promises;
|
28
|
+
});
|
29
|
+
};
|
30
|
+
};
|
31
|
+
|
32
|
+
export default function loadDeepLink(apiPath, options = {}) {
|
33
|
+
const body = JSON.stringify(options);
|
34
|
+
|
35
|
+
if (cache[body]) {
|
36
|
+
return cache[body];
|
37
|
+
}
|
38
|
+
|
39
|
+
cache[body] = fetch(`${apiPath}/endUserNotifications/deepLinks`, {
|
40
|
+
method: 'POST',
|
41
|
+
headers: {
|
42
|
+
'Content-Type': 'application/json'
|
43
|
+
},
|
44
|
+
body
|
45
|
+
}).then(apiErrorHandler);
|
46
|
+
|
47
|
+
return cache[body];
|
48
|
+
};
|
@@ -1,26 +1,26 @@
|
|
1
|
-
const cache = {};
|
2
|
-
|
3
|
-
export default function loadScript(url) {
|
4
|
-
if (cache[url]){
|
5
|
-
return cache[url];
|
6
|
-
}
|
7
|
-
|
8
|
-
cache[url] = new Promise((resolve, reject) => {
|
9
|
-
let ready = false;
|
10
|
-
const scriptElement = document.createElement("script");
|
11
|
-
|
12
|
-
scriptElement.type = "text/javascript";
|
13
|
-
scriptElement.src = url;
|
14
|
-
scriptElement.async = true;
|
15
|
-
scriptElement.onload = scriptElement.onreadystatechange = function() {
|
16
|
-
if (!ready && (!this.readyState || this.readyState == "complete")) {
|
17
|
-
ready = true;
|
18
|
-
resolve();
|
19
|
-
}
|
20
|
-
};
|
21
|
-
scriptElement.onerror = scriptElement.onabort = reject;
|
22
|
-
document.head.appendChild(scriptElement);
|
23
|
-
});
|
24
|
-
|
25
|
-
return cache[url];
|
1
|
+
const cache = {};
|
2
|
+
|
3
|
+
export default function loadScript(url) {
|
4
|
+
if (cache[url]){
|
5
|
+
return cache[url];
|
6
|
+
}
|
7
|
+
|
8
|
+
cache[url] = new Promise((resolve, reject) => {
|
9
|
+
let ready = false;
|
10
|
+
const scriptElement = document.createElement("script");
|
11
|
+
|
12
|
+
scriptElement.type = "text/javascript";
|
13
|
+
scriptElement.src = url;
|
14
|
+
scriptElement.async = true;
|
15
|
+
scriptElement.onload = scriptElement.onreadystatechange = function() {
|
16
|
+
if (!ready && (!this.readyState || this.readyState == "complete")) {
|
17
|
+
ready = true;
|
18
|
+
resolve();
|
19
|
+
}
|
20
|
+
};
|
21
|
+
scriptElement.onerror = scriptElement.onabort = reject;
|
22
|
+
document.head.appendChild(scriptElement);
|
23
|
+
});
|
24
|
+
|
25
|
+
return cache[url];
|
26
26
|
}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import apiErrorHandler from './apiErrorHandler.js';
|
2
|
-
|
3
|
-
export default function loadSubscriptions(uuid, widgetId, apiPath){
|
4
|
-
const subscribedUsers = fetch(`${apiPath}/endUserNotifications/widgets/${widgetId}/subscribedUsers/${uuid}`).then(apiErrorHandler);
|
5
|
-
return subscribedUsers;
|
6
|
-
}
|
1
|
+
import apiErrorHandler from './apiErrorHandler.js';
|
2
|
+
|
3
|
+
export default function loadSubscriptions(uuid, widgetId, apiPath){
|
4
|
+
const subscribedUsers = fetch(`${apiPath}/endUserNotifications/widgets/${widgetId}/subscribedUsers/${uuid}`).then(apiErrorHandler);
|
5
|
+
return subscribedUsers;
|
6
|
+
}
|
@@ -1,34 +1,34 @@
|
|
1
|
-
function parseQueryString(query) {
|
2
|
-
const vars = query.split('&'),
|
3
|
-
queryString = {};
|
4
|
-
|
5
|
-
if (query.length > 0) {
|
6
|
-
for (var i = 0; i < vars.length; i++) {
|
7
|
-
const pair = vars[i].split('='),
|
8
|
-
key = decodeURIComponent(pair[0]),
|
9
|
-
value = decodeURIComponent(pair[1]);
|
10
|
-
|
11
|
-
if (!key)
|
12
|
-
continue;
|
13
|
-
|
14
|
-
switch ( typeof queryString[key] ) {
|
15
|
-
// If first entry with this name
|
16
|
-
case 'undefined':
|
17
|
-
queryString[key] = value;
|
18
|
-
break;
|
19
|
-
// If second entry with this name
|
20
|
-
case 'string': {
|
21
|
-
const arr = [ queryString[key], value ];
|
22
|
-
queryString[ key ] = arr;
|
23
|
-
break;
|
24
|
-
}
|
25
|
-
// If third or later entry with this name
|
26
|
-
default:
|
27
|
-
queryString[key].push(value);
|
28
|
-
}
|
29
|
-
}
|
30
|
-
}
|
31
|
-
return queryString;
|
32
|
-
}
|
33
|
-
|
1
|
+
function parseQueryString(query) {
|
2
|
+
const vars = query.split('&'),
|
3
|
+
queryString = {};
|
4
|
+
|
5
|
+
if (query.length > 0) {
|
6
|
+
for (var i = 0; i < vars.length; i++) {
|
7
|
+
const pair = vars[i].split('='),
|
8
|
+
key = decodeURIComponent(pair[0]),
|
9
|
+
value = decodeURIComponent(pair[1]);
|
10
|
+
|
11
|
+
if (!key)
|
12
|
+
continue;
|
13
|
+
|
14
|
+
switch ( typeof queryString[key] ) {
|
15
|
+
// If first entry with this name
|
16
|
+
case 'undefined':
|
17
|
+
queryString[key] = value;
|
18
|
+
break;
|
19
|
+
// If second entry with this name
|
20
|
+
case 'string': {
|
21
|
+
const arr = [ queryString[key], value ];
|
22
|
+
queryString[ key ] = arr;
|
23
|
+
break;
|
24
|
+
}
|
25
|
+
// If third or later entry with this name
|
26
|
+
default:
|
27
|
+
queryString[key].push(value);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
return queryString;
|
32
|
+
}
|
33
|
+
|
34
34
|
export default parseQueryString;
|
@@ -1,25 +1,25 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
export default class WindowHelper {
|
4
|
-
constructior() {}
|
5
|
-
|
6
|
-
static get center() {
|
7
|
-
return {
|
8
|
-
x: Math.floor(window.innerWidth * 0.5),
|
9
|
-
y: Math.floor(window.innerHeight * 0.5)
|
10
|
-
};
|
11
|
-
}
|
12
|
-
|
13
|
-
static getRatio(percent) {
|
14
|
-
let r = percent / 100;
|
15
|
-
return {
|
16
|
-
width: Math.floor(window.innerWidth * r),
|
17
|
-
height: Math.floor(window.innerHeight * r)
|
18
|
-
};
|
19
|
-
}
|
20
|
-
|
21
|
-
static getRatioPropString(percent) {
|
22
|
-
let ratioObj = this.getRatio(percent);
|
23
|
-
return `width=${ratioObj.width},height=${ratioObj.height}`;
|
24
|
-
}
|
25
|
-
}
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
export default class WindowHelper {
|
4
|
+
constructior() {}
|
5
|
+
|
6
|
+
static get center() {
|
7
|
+
return {
|
8
|
+
x: Math.floor(window.innerWidth * 0.5),
|
9
|
+
y: Math.floor(window.innerHeight * 0.5)
|
10
|
+
};
|
11
|
+
}
|
12
|
+
|
13
|
+
static getRatio(percent) {
|
14
|
+
let r = percent / 100;
|
15
|
+
return {
|
16
|
+
width: Math.floor(window.innerWidth * r),
|
17
|
+
height: Math.floor(window.innerHeight * r)
|
18
|
+
};
|
19
|
+
}
|
20
|
+
|
21
|
+
static getRatioPropString(percent) {
|
22
|
+
let ratioObj = this.getRatio(percent);
|
23
|
+
return `width=${ratioObj.width},height=${ratioObj.height}`;
|
24
|
+
}
|
25
|
+
}
|