web-manager 3.1.27 → 3.1.29
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +9 -19
- package/lib/account.js +38 -39
- package/package.json +2 -2
package/index.js
CHANGED
@@ -30,6 +30,7 @@ var debug;
|
|
30
30
|
|
31
31
|
// Shortcuts
|
32
32
|
var select;
|
33
|
+
var loadScript;
|
33
34
|
|
34
35
|
|
35
36
|
/**
|
@@ -154,7 +155,7 @@ function Manager() {
|
|
154
155
|
}
|
155
156
|
|
156
157
|
select = this.dom().select;
|
157
|
-
|
158
|
+
loadScript = this.dom().loadScript;
|
158
159
|
}
|
159
160
|
|
160
161
|
/**
|
@@ -330,8 +331,9 @@ function Manager() {
|
|
330
331
|
window.location.href = sendSplit[0] + '?' + newQuery.toString();
|
331
332
|
return;
|
332
333
|
}
|
333
|
-
|
334
|
-
|
334
|
+
|
335
|
+
select('.auth-signedin-true-element').hide();
|
336
|
+
select('.auth-signedin-false-element').show();
|
335
337
|
}
|
336
338
|
|
337
339
|
Manager.prototype.ready = function(fn, options) {
|
@@ -1426,22 +1428,13 @@ function Manager() {
|
|
1426
1428
|
}
|
1427
1429
|
|
1428
1430
|
var load_chatsy = function(This, options) {
|
1429
|
-
var dom = This.dom();
|
1430
|
-
|
1431
1431
|
return new Promise(function(resolve, reject) {
|
1432
1432
|
if (options.libraries.chatsy.enabled === true) {
|
1433
1433
|
var chatsyPath = 'libraries.chatsy.config';
|
1434
1434
|
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
// setInterval(function () {
|
1439
|
-
// log()
|
1440
|
-
// }, 1000);
|
1441
|
-
|
1442
|
-
dom.loadScript({
|
1443
|
-
// src: 'https://app.chatsy.ai/resources/script.js',
|
1444
|
-
src: 'http://localhost:4001/resources/script.js',
|
1435
|
+
loadScript({
|
1436
|
+
src: 'https://app.chatsy.ai/resources/script.js',
|
1437
|
+
// src: 'http://localhost:4001/resources/script.js',
|
1445
1438
|
attributes: [
|
1446
1439
|
{name: 'data-account-id', value: utilities.get(options, chatsyPath + '.accountId', '')},
|
1447
1440
|
{name: 'data-chat-id', value: utilities.get(options, chatsyPath + '.chatId', '')},
|
@@ -1472,9 +1465,6 @@ function Manager() {
|
|
1472
1465
|
|
1473
1466
|
var load_sentry = function(This, options) {
|
1474
1467
|
return new Promise(function(resolve, reject) {
|
1475
|
-
// if (typeof window.Sentry !== 'undefined') {
|
1476
|
-
// return resolve();
|
1477
|
-
// }
|
1478
1468
|
if (options.libraries.sentry.enabled === true) {
|
1479
1469
|
import('@sentry/browser')
|
1480
1470
|
.then(function(mod) {
|
@@ -1538,7 +1528,7 @@ function Manager() {
|
|
1538
1528
|
if (featuresDefault && featuresCustom) {
|
1539
1529
|
cb();
|
1540
1530
|
} else {
|
1541
|
-
|
1531
|
+
loadScript({src: 'https://polyfill.io/v3/polyfill.min.js?flags=always%2Cgated&features=default%2Ces5%2Ces6%2Ces7%2CPromise.prototype.finally%2C%7Ehtml5-elements%2ClocalStorage%2Cfetch%2CURLSearchParams'})
|
1542
1532
|
.then(function() {
|
1543
1533
|
// This.log('Loaded polyfill.io')
|
1544
1534
|
cb();
|
package/lib/account.js
CHANGED
@@ -1,17 +1,15 @@
|
|
1
1
|
/*
|
2
2
|
*/
|
3
|
-
var dom;
|
4
|
-
var utilities;
|
5
|
-
|
6
3
|
function Account(init) {
|
7
4
|
var self = this;
|
5
|
+
|
8
6
|
init = init || {};
|
9
7
|
self.properties = {};
|
10
8
|
self.accountPageInitialized = false;
|
11
9
|
|
12
10
|
try {
|
13
|
-
dom = init.dom || self.Manager.dom();
|
14
|
-
utilities = init.utilities || self.Manager.utilities();
|
11
|
+
self.dom = init.dom || self.Manager.dom();
|
12
|
+
self.utilities = init.utilities || self.Manager.utilities();
|
15
13
|
|
16
14
|
if (new URL(window.location.href).pathname.includes('account')) {
|
17
15
|
self.initializeAccountPage();
|
@@ -93,10 +91,11 @@ Account.prototype.initializeAccountPage = function (options) {
|
|
93
91
|
|
94
92
|
Account.prototype.delete = function (options) {
|
95
93
|
var self = this;
|
94
|
+
|
96
95
|
var user = firebase.auth().currentUser;
|
97
|
-
var errorElement = dom.select('.auth-delete-account-error-message-element');
|
98
|
-
var confirmValue = dom.select('.auth-delete-account-confirmation-input').getValue()
|
99
|
-
var deleteButton = dom.select('.auth-delete-account-btn')
|
96
|
+
var errorElement = self.dom.select('.auth-delete-account-error-message-element');
|
97
|
+
var confirmValue = self.dom.select('.auth-delete-account-confirmation-input').getValue()
|
98
|
+
var deleteButton = self.dom.select('.auth-delete-account-btn')
|
100
99
|
|
101
100
|
deleteButton.setAttribute('disabled', true).addClass('disabled');
|
102
101
|
errorElement.setAttribute('hidden', true);
|
@@ -115,7 +114,7 @@ Account.prototype.delete = function (options) {
|
|
115
114
|
} else {
|
116
115
|
user.getIdToken(false)
|
117
116
|
.then(function(token) {
|
118
|
-
fetch('https://us-central1-' + utilities.get(self.Manager, 'properties.options.libraries.firebase_app.config.projectId', 'unknown') + '.cloudfunctions.net/bm_api', {
|
117
|
+
fetch('https://us-central1-' + self.utilities.get(self.Manager, 'properties.options.libraries.firebase_app.config.projectId', 'unknown') + '.cloudfunctions.net/bm_api', {
|
119
118
|
// fetch('http://localhost:5001/optiic-api/us-central1/bm_api', {
|
120
119
|
method: 'POST',
|
121
120
|
headers: { 'Content-Type': 'application/json' },
|
@@ -173,16 +172,6 @@ Account.prototype.resolve = function (account, options) {
|
|
173
172
|
});
|
174
173
|
}
|
175
174
|
|
176
|
-
function _setAuthItem(selector, value) {
|
177
|
-
dom.select(selector).each(function(e, i) {
|
178
|
-
if (e.tagName === 'INPUT') {
|
179
|
-
dom.select(e).setValue(value);
|
180
|
-
} else {
|
181
|
-
dom.select(e).setInnerHTML(value);
|
182
|
-
}
|
183
|
-
});
|
184
|
-
}
|
185
|
-
|
186
175
|
function uppercase(str) {
|
187
176
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
188
177
|
}
|
@@ -221,6 +210,7 @@ Account.prototype._resolveAccount2 = function (firebaseUser, account, options) {
|
|
221
210
|
*/
|
222
211
|
Account.prototype._resolveAccount = function (firebaseUser, account, options) {
|
223
212
|
var self = this;
|
213
|
+
|
224
214
|
firebaseUser = firebaseUser || {};
|
225
215
|
account = account || {};
|
226
216
|
options = options || {};
|
@@ -266,17 +256,17 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
|
|
266
256
|
// In a try/catch because this lib is used in node sometimes
|
267
257
|
try {
|
268
258
|
currentURL = new URL(window.location.href);
|
269
|
-
isDevelopment = utilities.get(self.Manager, 'properties.meta.environment', '') === 'development';
|
259
|
+
isDevelopment = self.utilities.get(self.Manager, 'properties.meta.environment', '') === 'development';
|
270
260
|
|
271
|
-
if (utilities.get(isDevelopment)) {
|
261
|
+
if (self.utilities.get(isDevelopment)) {
|
272
262
|
currentURL.searchParams
|
273
263
|
.forEach(function(value, key) {
|
274
|
-
var accountValue = utilities.get(account, key, undefined)
|
264
|
+
var accountValue = self.utilities.get(account, key, undefined)
|
275
265
|
if (typeof accountValue !== undefined) {
|
276
266
|
if (value === 'true') { value = true }
|
277
267
|
if (value === 'false') { value = false }
|
278
268
|
|
279
|
-
utilities.set(account, key, value)
|
269
|
+
self.utilities.set(account, key, value)
|
280
270
|
}
|
281
271
|
});
|
282
272
|
}
|
@@ -363,30 +353,40 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
|
|
363
353
|
// var apiUnlinkURL = isDevelopment ? 'http://localhost:5000/discord-unlink' : 'https://api.{{ site.brand.name }}.com/discord-unlink';
|
364
354
|
var cancelURL = isDevelopment ? 'http://localhost:4001/cancel/' : 'https://itwcreativeworks.com/portal/account/manage/';
|
365
355
|
|
366
|
-
var billingSubscribeBtn = dom.select('.auth-billing-subscribe-btn');
|
367
|
-
var billingUpdateBtn = dom.select('.auth-billing-update-btn');
|
368
|
-
var billingPlanId = dom.select('.auth-billing-plan-id-element');
|
369
|
-
var billingFrequencyEl = dom.select('.auth-billing-frequency-element');
|
370
|
-
var billingStartDateEl = dom.select('.auth-billing-start-date-element');
|
371
|
-
var billingExpirationDateEl = dom.select('.auth-billing-expiration-date-element');
|
356
|
+
var billingSubscribeBtn = self.dom.select('.auth-billing-subscribe-btn');
|
357
|
+
var billingUpdateBtn = self.dom.select('.auth-billing-update-btn');
|
358
|
+
var billingPlanId = self.dom.select('.auth-billing-plan-id-element');
|
359
|
+
var billingFrequencyEl = self.dom.select('.auth-billing-frequency-element');
|
360
|
+
var billingStartDateEl = self.dom.select('.auth-billing-start-date-element');
|
361
|
+
var billingExpirationDateEl = self.dom.select('.auth-billing-expiration-date-element');
|
372
362
|
|
373
|
-
var $referralCount = dom.select('.auth-referral-count-element');
|
374
|
-
var $referralCode = dom.select('.auth-referral-code-element');
|
375
|
-
var $referralLink = dom.select('.auth-referral-link-element');
|
376
|
-
var $referralSocialLink = dom.select('a.auth-referral-social-link[data-provider]');
|
363
|
+
var $referralCount = self.dom.select('.auth-referral-count-element');
|
364
|
+
var $referralCode = self.dom.select('.auth-referral-code-element');
|
365
|
+
var $referralLink = self.dom.select('.auth-referral-link-element');
|
366
|
+
var $referralSocialLink = self.dom.select('a.auth-referral-social-link[data-provider]');
|
377
367
|
|
378
|
-
var authCreatedEl = dom.select('.auth-created-element');
|
379
|
-
var authPhoneInput = dom.select('.auth-phone-input');
|
368
|
+
var authCreatedEl = self.dom.select('.auth-created-element');
|
369
|
+
var authPhoneInput = self.dom.select('.auth-phone-input');
|
380
370
|
|
381
371
|
var updateURL = new URL(cancelURL);
|
382
372
|
var referralURL = new URL(window.location.origin || window.location.host);
|
383
373
|
|
374
|
+
function _setAuthItem(selector, value) {
|
375
|
+
self.dom.select(selector).each(function(e, i) {
|
376
|
+
if (e.tagName === 'INPUT') {
|
377
|
+
self.dom.select(e).setValue(value);
|
378
|
+
} else {
|
379
|
+
self.dom.select(e).setInnerHTML(value);
|
380
|
+
}
|
381
|
+
});
|
382
|
+
}
|
383
|
+
|
384
384
|
referralURL.pathname = '/';
|
385
385
|
referralURL.searchParams.set('aff', account.affiliate.code)
|
386
386
|
|
387
387
|
authCreatedEl.setInnerHTML(
|
388
388
|
new Date(
|
389
|
-
parseInt(utilities.get(firebaseUser, 'metadata.a', '0'))
|
389
|
+
parseInt(self.utilities.get(firebaseUser, 'metadata.a', '0'))
|
390
390
|
)
|
391
391
|
.toLocaleString(undefined, {
|
392
392
|
weekday: 'long', year: 'numeric', month: 'long', day: 'numeric',
|
@@ -413,15 +413,14 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
|
|
413
413
|
? '<i class="fas fa-exclamation-triangle mr-1"></i> Expires in ' + daysTillExpire + ' days '
|
414
414
|
: '');
|
415
415
|
|
416
|
-
_setAuthItem('.auth-apikey-element', utilities.get(account, 'api.privateKey', 'n/a'));
|
417
|
-
|
416
|
+
_setAuthItem('.auth-apikey-element', self.utilities.get(account, 'api.privateKey', 'n/a'));
|
418
417
|
|
419
418
|
$referralCount.setInnerHTML(account.affiliate.referrals.length);
|
420
419
|
$referralCode.setInnerHTML(account.affiliate.code).setValue(account.affiliate.code);
|
421
420
|
$referralCode.setInnerHTML(referralURL.toString()).setValue(referralURL.toString());
|
422
421
|
|
423
422
|
var affiliateLinkURI = encodeURIComponent(referralURL.toString());
|
424
|
-
var affiliateLinkTextURI = encodeURIComponent('Sign up for ' + utilities.get(self.Manager, 'properties.global.brand.name', 'this') + ', a useful service:');
|
423
|
+
var affiliateLinkTextURI = encodeURIComponent('Sign up for ' + self.utilities.get(self.Manager, 'properties.global.brand.name', 'this') + ', a useful service:');
|
425
424
|
|
426
425
|
$referralSocialLink
|
427
426
|
.each(function ($el) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "web-manager",
|
3
|
-
"version": "3.1.
|
3
|
+
"version": "3.1.29",
|
4
4
|
"description": "Easily access important variables such as the query string, current domain, and current page in a single object.",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
@@ -28,4 +28,4 @@
|
|
28
28
|
"firebase": "^8.10.1",
|
29
29
|
"lazysizes": "^5.3.2"
|
30
30
|
}
|
31
|
-
}
|
31
|
+
}
|