web-manager 3.1.28 → 3.1.29

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 (2) hide show
  1. package/lib/account.js +38 -39
  2. package/package.json +1 -1
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.28",
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": {