lint main level components and js files

This commit is contained in:
Matteo Pagliazzi
2019-10-12 17:37:12 +02:00
parent fe4a35d1d1
commit c1ea91803c
25 changed files with 117 additions and 80 deletions

View File

@@ -6,6 +6,7 @@
> >
<div class="row"> <div class="row">
<div class="col-12 text-center"> <div class="col-12 text-center">
<!-- eslint-disable max-len -->
<svg <svg
id="melior" id="melior"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
@@ -17,6 +18,7 @@
fill="#fff" fill="#fff"
></path> ></path>
</svg> </svg>
<!-- eslint-enable max-len -->
</div> </div>
<div class="col-12 text-center"> <div class="col-12 text-center">
<h2>{{ $t('tipTitle', {tipNumber: currentTipNumber}) }}</h2> <h2>{{ $t('tipTitle', {tipNumber: currentTipNumber}) }}</h2>

View File

@@ -484,14 +484,12 @@ import facebook from '@/assets/svg/facebook.svg';
import instagram from '@/assets/svg/instagram.svg'; import instagram from '@/assets/svg/instagram.svg';
import heart from '@/assets/svg/heart.svg'; import heart from '@/assets/svg/heart.svg';
import modifyInventory from './modifyInventory';
import buyGemsModal from './payments/buyGemsModal'; import buyGemsModal from './payments/buyGemsModal';
const IS_PRODUCTION = process.env.NODE_ENV === 'production'; // eslint-disable-line no-process-env const IS_PRODUCTION = process.env.NODE_ENV === 'production'; // eslint-disable-line no-process-env
export default { export default {
components: { components: {
modifyInventory,
buyGemsModal, buyGemsModal,
}, },
data () { data () {

View File

@@ -20,6 +20,7 @@
<template v-for="(klass, item) in visualBuffs"> <template v-for="(klass, item) in visualBuffs">
<span <span
v-if="member.stats.buffs[item] && showVisualBuffs" v-if="member.stats.buffs[item] && showVisualBuffs"
:key="item"
:class="klass" :class="klass"
></span> ></span>
</template> </template>
@@ -31,17 +32,25 @@
<span :class="['chair_' + member.preferences.chair, specialMountClass]"></span> <span :class="['chair_' + member.preferences.chair, specialMountClass]"></span>
<span :class="[getGearClass('back'), specialMountClass]"></span> <span :class="[getGearClass('back'), specialMountClass]"></span>
<span :class="[skinClass, specialMountClass]"></span> <span :class="[skinClass, specialMountClass]"></span>
<!-- eslint-disable max-len-->
<span <span
:class="[member.preferences.size + '_shirt_' + member.preferences.shirt, specialMountClass]" :class="[member.preferences.size + '_shirt_' + member.preferences.shirt, specialMountClass]"
></span> ></span>
<!-- eslint-enable max-len-->
<span :class="['head_0', specialMountClass]"></span> <span :class="['head_0', specialMountClass]"></span>
<!-- eslint-disable max-len-->
<span :class="[member.preferences.size + '_' + getGearClass('armor'), specialMountClass]"></span> <span :class="[member.preferences.size + '_' + getGearClass('armor'), specialMountClass]"></span>
<!-- eslint-enable max-len-->
<span :class="[getGearClass('back_collar'), specialMountClass]"></span> <span :class="[getGearClass('back_collar'), specialMountClass]"></span>
<template v-for="type in ['bangs', 'base', 'mustache', 'beard']"> <template
<!-- eslint-disable-next-line max-len--> v-for="type in ['bangs', 'base', 'mustache', 'beard']"
>
<!-- eslint-disable max-len-->
<span <span
:key="type"
:class="['hair_' + type + '_' + member.preferences.hair[type] + '_' + member.preferences.hair.color, specialMountClass]" :class="['hair_' + type + '_' + member.preferences.hair[type] + '_' + member.preferences.hair.color, specialMountClass]"
></span> ></span>
<!-- eslint-enable max-len-->
</template> </template>
<span :class="[getGearClass('body'), specialMountClass]"></span> <span :class="[getGearClass('body'), specialMountClass]"></span>
<span :class="[getGearClass('eyewear'), specialMountClass]"></span> <span :class="[getGearClass('eyewear'), specialMountClass]"></span>

View File

@@ -170,7 +170,6 @@
import Avatar from './avatar'; import Avatar from './avatar';
import ClassBadge from './members/classBadge'; import ClassBadge from './members/classBadge';
import { mapState } from '@/libs/store'; import { mapState } from '@/libs/store';
import Profile from './userMenu/profile';
import StatsBar from './ui/statsbar'; import StatsBar from './ui/statsbar';
import { toNextLevel } from '@/../../common/script/statHelpers'; import { toNextLevel } from '@/../../common/script/statHelpers';
@@ -185,7 +184,6 @@ import manaIcon from '@/assets/svg/mana.svg';
export default { export default {
components: { components: {
Avatar, Avatar,
Profile,
ClassBadge, ClassBadge,
StatsBar, StatsBar,
}, },

View File

@@ -1,3 +1,5 @@
<!-- eslint-disable -->
<!-- TODO re-enable when used again -->
<template> <template>
<b-modal <b-modal
v-if="user.profile" v-if="user.profile"

View File

@@ -102,7 +102,6 @@ import notifications from '@/mixins/notifications';
import guide from '@/mixins/guide'; import guide from '@/mixins/guide';
import yesterdailyModal from './yesterdailyModal'; import yesterdailyModal from './yesterdailyModal';
import welcomeModal from './achievements/welcome';
import newStuff from './achievements/newStuff'; import newStuff from './achievements/newStuff';
import death from './achievements/death'; import death from './achievements/death';
import lowHealth from './achievements/lowHealth'; import lowHealth from './achievements/lowHealth';
@@ -188,7 +187,6 @@ export default {
joinedGuild, joinedGuild,
joinedChallenge, joinedChallenge,
invitedFriend, invitedFriend,
welcomeModal,
newStuff, newStuff,
death, death,
lowHealth, lowHealth,

View File

@@ -55,6 +55,7 @@
</div> </div>
<div <div
v-for="member in sortedMembers" v-for="member in sortedMembers"
:key="member._id"
class="row" class="row"
> >
<div class="col-10"> <div class="col-10">

View File

@@ -1,15 +1,15 @@
import round from './round'; import round from './round';
function _convertToThousand (num) { function _convertToThousand (num) {
return `${(num / Math.pow(10, 3)).toFixed(1)}k`; return `${(num / (10 ** 3)).toFixed(1)}k`;
} }
function _convertToMillion (num) { function _convertToMillion (num) {
return `${(num / Math.pow(10, 6)).toFixed(1)}m`; return `${(num / (10 ** 6)).toFixed(1)}m`;
} }
function _convertToBillion (num) { function _convertToBillion (num) {
return `${(num / Math.pow(10, 9)).toFixed(1)}b`; return `${(num / (10 ** 9)).toFixed(1)}b`;
} }
export default function roundBigNumber (num) { export default function roundBigNumber (num) {

View File

@@ -26,17 +26,23 @@ const ALLOWED_HIT_TYPES = [
function _doesNotHaveRequiredFields (properties) { function _doesNotHaveRequiredFields (properties) {
if (!isEqual(keys(pick(properties, REQUIRED_FIELDS)), REQUIRED_FIELDS)) { if (!isEqual(keys(pick(properties, REQUIRED_FIELDS)), REQUIRED_FIELDS)) {
// @TODO: Log with Winston? // @TODO: Log with Winston?
// console.log('Analytics tracking calls must include the following properties: ' + JSON.stringify(REQUIRED_FIELDS)); // console.log('Analytics tracking calls must include
// the following properties: ' + JSON.stringify(REQUIRED_FIELDS));
return true; return true;
} }
return false;
} }
function _doesNotHaveAllowedHitType (properties) { function _doesNotHaveAllowedHitType (properties) {
if (!includes(ALLOWED_HIT_TYPES, properties.hitType)) { if (!includes(ALLOWED_HIT_TYPES, properties.hitType)) {
// @TODO: Log with Winston? // @TODO: Log with Winston?
// console.log('Hit type of Analytics event must be one of the following: ' + JSON.stringify(ALLOWED_HIT_TYPES)); // console.log('Hit type of Analytics event must be one
// of the following: ' + JSON.stringify(ALLOWED_HIT_TYPES));
return true; return true;
} }
return false;
} }
function _gatherUserStats (properties) { function _gatherUserStats (properties) {
@@ -79,19 +85,17 @@ export function setUser () {
export function track (properties) { export function track (properties) {
// Use nextTick to avoid blocking the UI // Use nextTick to avoid blocking the UI
Vue.nextTick(() => { Vue.nextTick(() => {
if (_doesNotHaveRequiredFields(properties)) return false; if (_doesNotHaveRequiredFields(properties)) return;
if (_doesNotHaveAllowedHitType(properties)) return false; if (_doesNotHaveAllowedHitType(properties)) return;
amplitude.getInstance().logEvent(properties.eventAction, properties); amplitude.getInstance().logEvent(properties.eventAction, properties);
window.ga('send', properties); window.ga('send', properties);
}); });
} }
export function updateUser (properties) { export function updateUser (properties = {}) {
// Use nextTick to avoid blocking the UI // Use nextTick to avoid blocking the UI
Vue.nextTick(() => { Vue.nextTick(() => {
properties = properties || {};
_gatherUserStats(properties); _gatherUserStats(properties);
forEach(properties, (value, key) => { forEach(properties, (value, key) => {
@@ -127,7 +131,7 @@ export function load () {
let firstScript = document.getElementsByTagName('script')[0]; let firstScript = document.getElementsByTagName('script')[0];
// Google Analytics // Google Analytics
const gaScript = document.createElement('script'); const gaScript = document.createElement('script');
firstScript = document.getElementsByTagName('script')[0]; [firstScript] = document.getElementsByTagName('script');
gaScript.async = 1; gaScript.async = 1;
gaScript.src = '//www.google-analytics.com/analytics.js'; gaScript.src = '//www.google-analytics.com/analytics.js';
firstScript.parentNode.insertBefore(gaScript, firstScript); firstScript.parentNode.insertBefore(gaScript, firstScript);

View File

@@ -3,9 +3,9 @@ import moment from 'moment';
export function setUpAxios (AUTH_SETTINGS) { // eslint-disable-line import/prefer-default-export export function setUpAxios (AUTH_SETTINGS) { // eslint-disable-line import/prefer-default-export
if (!AUTH_SETTINGS) { if (!AUTH_SETTINGS) {
AUTH_SETTINGS = localStorage.getItem('habit-mobile-settings'); AUTH_SETTINGS = localStorage.getItem('habit-mobile-settings'); // eslint-disable-line no-param-reassign, max-len
if (!AUTH_SETTINGS) return false; if (!AUTH_SETTINGS) return false;
AUTH_SETTINGS = JSON.parse(AUTH_SETTINGS); AUTH_SETTINGS = JSON.parse(AUTH_SETTINGS); // eslint-disable-line no-param-reassign
} }
const browserTimezoneOffset = moment().zone(); const browserTimezoneOffset = moment().zone();

View File

@@ -6,7 +6,7 @@ export default function deepFreeze (obj) {
const propNamesLength = propNames.length; const propNamesLength = propNames.length;
// Freeze properties before freezing self // Freeze properties before freezing self
for (let i = 0; i < propNamesLength; i++) { for (let i = 0; i < propNamesLength; i += 1) {
const prop = obj[propNames[i]]; const prop = obj[propNames[i]];
// Freeze prop if it is an object // Freeze prop if it is an object

View File

@@ -6,11 +6,11 @@ const optionalPostMentionRegExStr = '(\\.\\w+)?'; // like dot-TLD
const finalMentionRegEx = new RegExp(`${optionalAnchorTagRegExStr}${mentionRegExStr}${optionalPostMentionRegExStr}`, 'gi'); const finalMentionRegEx = new RegExp(`${optionalAnchorTagRegExStr}${mentionRegExStr}${optionalPostMentionRegExStr}`, 'gi');
export function highlightUsers (text, userName, displayName) { // eslint-disable-line import/prefer-default-export export function highlightUsers (text, userName, displayName) { // eslint-disable-line import/prefer-default-export, max-len
const currentUser = [`@${userName}`, `@${displayName}`].map(escapeRegExp); const currentUser = [`@${userName}`, `@${displayName}`].map(escapeRegExp);
text = text.replace(finalMentionRegEx, (fullMatched, preMention, mentionStr, postMention) => { text = text.replace(finalMentionRegEx, (fullMatched, preMention, mentionStr, postMention) => { // eslint-disable-line no-param-reassign, max-len
if (preMention && preMention.includes('<a') || Boolean(postMention)) { if ((preMention && preMention.includes('<a')) || Boolean(postMention)) {
return fullMatched; return fullMatched;
} }

View File

@@ -27,8 +27,8 @@ export default {
} }
} }
Vue.prototype.$t = function translateString () { Vue.prototype.$t = function translateString (...args) {
return i18n.t.apply(null, arguments); return i18n.t.apply(null, ...args);
}; };
}, },
}; };

View File

@@ -9,6 +9,8 @@ function getApiKey () {
return AUTH_SETTINGS.auth.apiToken; return AUTH_SETTINGS.auth.apiToken;
} }
} }
return null;
} }
export function goToModForm (user) { // eslint-disable-line import/prefer-default-export export function goToModForm (user) { // eslint-disable-line import/prefer-default-export
@@ -18,8 +20,7 @@ export function goToModForm (user) { // eslint-disable-line import/prefer-defaul
if (!apiKey) return; if (!apiKey) return;
const tenMins = 10 * 60 * 1000; const tenMins = 10 * 60 * 1000;
let dateTime; const dateTime = new Date();
dateTime = new Date();
dateTime.setTime(dateTime.getTime() + tenMins); dateTime.setTime(dateTime.getTime() + tenMins);
const expires = `expires=${dateTime.toGMTString()}`; const expires = `expires=${dateTime.toGMTString()}`;

View File

@@ -23,7 +23,7 @@ export function setup () { // eslint-disable-line import/prefer-default-export
// Stripe // Stripe
const stripeScript = document.createElement('script'); const stripeScript = document.createElement('script');
firstScript = document.getElementsByTagName('script')[0]; [firstScript] = document.getElementsByTagName('script');
stripeScript.async = true; stripeScript.async = true;
stripeScript.src = '//checkout.stripe.com/v2/checkout.js'; stripeScript.src = '//checkout.stripe.com/v2/checkout.js';
firstScript.parentNode.insertBefore(stripeScript, firstScript); firstScript.parentNode.insertBefore(stripeScript, firstScript);

View File

@@ -23,7 +23,9 @@ export const avatarEditorUtilies = { // eslint-disable-line import/prefer-defaul
return moment(appearanceSets[set.key].availableUntil).isBefore(moment()); return moment(appearanceSets[set.key].availableUntil).isBefore(moment());
}, },
mapKeysToFreeOption (key, type, subType) { mapKeysToFreeOption (key, type, subType) {
const userPreference = subType ? this.user.preferences[type][subType] : this.user.preferences[type]; const userPreference = subType
? this.user.preferences[type][subType]
: this.user.preferences[type];
const pathKey = subType ? `${type}.${subType}` : `${type}`; const pathKey = subType ? `${type}.${subType}` : `${type}`;
const option = {}; const option = {};
@@ -37,7 +39,9 @@ export const avatarEditorUtilies = { // eslint-disable-line import/prefer-defaul
mapKeysToOption (key, type, subType, set) { mapKeysToOption (key, type, subType, set) {
const option = this.mapKeysToFreeOption(key, type, subType); const option = this.mapKeysToFreeOption(key, type, subType);
const userPurchased = subType ? this.user.purchased[type][subType] : this.user.purchased[type]; const userPurchased = subType
? this.user.purchased[type][subType]
: this.user.purchased[type];
const locked = !userPurchased || !userPurchased[key]; const locked = !userPurchased || !userPurchased[key];
let hide = false; let hide = false;
@@ -90,7 +94,11 @@ export const avatarEditorUtilies = { // eslint-disable-line import/prefer-defaul
setKeys.forEach(key => { setKeys.forEach(key => {
if (subType) { if (subType) {
if (!this.user.purchased[type] || !this.user.purchased[type][subType] || !this.user.purchased[type][subType][key]) owns = false; if (
!this.user.purchased[type]
|| !this.user.purchased[type][subType]
|| !this.user.purchased[type][subType][key]
) owns = false;
return; return;
} }
if (!this.user.purchased[type][key]) owns = false; if (!this.user.purchased[type][key]) owns = false;
@@ -106,8 +114,10 @@ export const avatarEditorUtilies = { // eslint-disable-line import/prefer-defaul
}, },
/** /**
* For gem-unlockable preferences, (a) if owned, select preference (b) else, purchase * For gem-unlockable preferences, (a) if owned, select preference (b) else, purchase
* @param path: User.preferences <-> User.purchased maps like User.preferences.skin=abc <-> User.purchased.skin.abc. * @param path: User.preferences <-> User.purchased maps like
* Pass in this paramater as "skin.abc". Alternatively, pass as an array ["skin.abc", "skin.xyz"] to unlock sets *User.preferences.skin=abc <-> User.purchased.skin.abc.
* Pass in this paramater as "skin.abc". Alternatively, pass as an
* array ["skin.abc", "skin.xyz"] to unlock sets
*/ */
async unlock (path) { async unlock (path) {
const fullSet = path.indexOf(',') !== -1; const fullSet = path.indexOf(',') !== -1;
@@ -132,11 +142,11 @@ export const avatarEditorUtilies = { // eslint-disable-line import/prefer-defaul
if (loginIncentives.indexOf(path) === -1) { if (loginIncentives.indexOf(path) === -1) {
if (fullSet) { if (fullSet) {
if (confirm(this.$t('purchaseFor', { cost: cost * 4 })) !== true) return; if (window.confirm(this.$t('purchaseFor', { cost: cost * 4 })) !== true) return;
// @TODO: implement gem modal // @TODO: implement gem modal
// if (this.user.balance < cost) return $rootScope.openModal('buyGems'); // if (this.user.balance < cost) return $rootScope.openModal('buyGems');
} else if (!get(this.user, `purchased.${path}`)) { } else if (!get(this.user, `purchased.${path}`)) {
if (confirm(this.$t('purchaseFor', { cost: cost * 4 })) !== true) return; if (window.confirm(this.$t('purchaseFor', { cost: cost * 4 })) !== true) return;
// @TODO: implement gem modal // @TODO: implement gem modal
// if (this.user.balance < cost) return $rootScope.openModal('buyGems'); // if (this.user.balance < cost) return $rootScope.openModal('buyGems');
} }
@@ -151,7 +161,7 @@ export const avatarEditorUtilies = { // eslint-disable-line import/prefer-defaul
}); });
this.backgroundUpdate = new Date(); this.backgroundUpdate = new Date();
} catch (e) { } catch (e) {
alert(e.message); window.alert(e.message);
} }
}, },
async buy (item) { async buy (item) {
@@ -169,7 +179,7 @@ export const avatarEditorUtilies = { // eslint-disable-line import/prefer-defaul
}); });
this.backgroundUpdate = new Date(); this.backgroundUpdate = new Date();
} catch (e) { } catch (e) {
alert(e.message); window.alert(e.message);
} }
}, },
}, },

View File

@@ -39,7 +39,7 @@ export default {
}; };
const purchaseForKey = currencyToPurchaseForKey[currency]; const purchaseForKey = currencyToPurchaseForKey[currency];
return confirm(this.$t(purchaseForKey, { cost })); return window.confirm(this.$t(purchaseForKey, { cost }));
}, },
}, },
}; };

View File

@@ -5,21 +5,21 @@ export default {
// https://stackoverflow.com/questions/2685911/is-there-a-way-to-round-numbers-into-a-reader-friendly-format-e-g-1-1k // https://stackoverflow.com/questions/2685911/is-there-a-way-to-round-numbers-into-a-reader-friendly-format-e-g-1-1k
abbrNum: number => { abbrNum: number => {
let decPlaces = 1; let decPlaces = 1;
decPlaces = Math.pow(10, decPlaces); decPlaces = 10 ** decPlaces;
const abbrev = ['k', 'm', 'b', 't']; const abbrev = ['k', 'm', 'b', 't'];
for (let i = abbrev.length - 1; i >= 0; i--) { for (let i = abbrev.length - 1; i >= 0; i -= 1) {
const size = Math.pow(10, (i + 1) * 3); const size = 10 ** ((i + 1) * 3);
if (size <= number) { if (size <= number) {
number = Math.floor(number * decPlaces / size) / decPlaces; number = Math.floor((number * decPlaces) / size) / decPlaces; // eslint-disable-line no-param-reassign, max-len
if (number === 1000 && i < abbrev.length - 1) { if (number === 1000 && i < abbrev.length - 1) {
number = 1; number = 1; // eslint-disable-line no-param-reassign
i++; i += 1;
} }
number += abbrev[i]; number += abbrev[i]; // eslint-disable-line no-param-reassign
break; break;
} }
} }

View File

@@ -109,7 +109,7 @@ export default {
]], ]],
}; };
for (const key in this.chapters) { for (const key of Object.keys(this.chapters)) {
const chapter = this.chapters[key][0][0]; const chapter = this.chapters[key][0][0];
chapter.intro = ` chapter.intro = `
<div class='featured-label'> <div class='featured-label'>
@@ -126,7 +126,8 @@ export default {
}, },
routeChange () { routeChange () {
this.initTour(); this.initTour();
switch (this.$route.name) {
switch (this.$route.name) { // eslint-disable-line default-case
// case 'options.profile.avatar': return goto('intro', 5); // case 'options.profile.avatar': return goto('intro', 5);
case 'stats': return this.goto('stats', 0); case 'stats': return this.goto('stats', 0);
case 'tavern': return this.goto('tavern', 0); case 'tavern': return this.goto('tavern', 0);
@@ -139,6 +140,8 @@ export default {
// @TODO: same page now case 'stable': return this.goto('mounts', 0); // @TODO: same page now case 'stable': return this.goto('mounts', 0);
case 'equipment': return this.goto('equipment', 0); case 'equipment': return this.goto('equipment', 0);
} }
return null;
}, },
hoyo (user) { hoyo (user) {
// @TODO: What is was the timeout for? // @TODO: What is was the timeout for?
@@ -151,13 +154,13 @@ export default {
// @TODO: Add dispatch User.set({'flags.welcomed': true}); // @TODO: Add dispatch User.set({'flags.welcomed': true});
} }
if (chapter === 'classes' && this.user.flags.tour.classes === -2) return; if (chapter === 'classes' && this.user.flags.tour.classes === -2) return;
if (page === -1) page = 0; if (page === -1) page = 0; // eslint-disable-line no-param-reassign
const curr = this.user.flags.tour[chapter]; const curr = this.user.flags.tour[chapter];
if (page !== curr + 1 && !force) return; if (page !== curr + 1 && !force) return;
const opts = {}; // @TODO: chap._options; const opts = {}; // @TODO: chap._options;
opts.steps = []; opts.steps = [];
page += 1; page += 1; // eslint-disable-line no-param-reassign
times(page, p => { times(page, p => {
opts.steps = opts.steps.concat(this.chapters[chapter][p]); opts.steps = opts.steps.concat(this.chapters[chapter][p]);
}); });

View File

@@ -10,7 +10,7 @@ import { CONSTANTS, setLocalSetting } from '@/libs/userlocalManager';
const { STRIPE_PUB_KEY } = process.env; const { STRIPE_PUB_KEY } = process.env;
const habiticaUrl = `${location.protocol}//${location.host}`; const habiticaUrl = `${window.location.protocol}//${window.location.host}`;
export default { export default {
mixins: [notificationsMixin], mixins: [notificationsMixin],
@@ -33,8 +33,11 @@ export default {
return `/paypal/subscribe?sub=${this.subscription.key}${couponString}`; return `/paypal/subscribe?sub=${this.subscription.key}${couponString}`;
}, },
dateTerminated () { dateTerminated () {
if (!this.user.preferences || !this.user.preferences.dateFormat) return this.user.purchased.plan.dateTerminated; if (!this.user.preferences || !this.user.preferences.dateFormat) {
return moment(this.user.purchased.plan.dateTerminated).format(this.user.preferences.dateFormat.toUpperCase()); return this.user.purchased.plan.dateTerminated;
}
return moment(this.user.purchased.plan.dateTerminated)
.format(this.user.preferences.dateFormat.toUpperCase());
}, },
}, },
methods: { methods: {
@@ -96,7 +99,7 @@ export default {
let amount = 500; // 500 = $5 let amount = 500; // 500 = $5
if (sub) amount = sub.price * 100; if (sub) amount = sub.price * 100;
if (data.gift && data.gift.type === 'gems') amount = data.gift.gems.amount / 4 * 100; if (data.gift && data.gift.type === 'gems') amount = (data.gift.gems.amount / 4) * 100;
if (data.group) amount = (sub.price + 3 * (data.group.memberCount - 1)) * 100; if (data.group) amount = (sub.price + 3 * (data.group.memberCount - 1)) * 100;
let paymentType; let paymentType;
@@ -133,7 +136,7 @@ export default {
// @TODO handle with normal notifications? // @TODO handle with normal notifications?
const responseStatus = response.status; const responseStatus = response.status;
if (responseStatus >= 400) { if (responseStatus >= 400) {
alert(`Error: ${response.message}`); window.alert(`Error: ${response.message}`);
return; return;
} }
@@ -214,7 +217,7 @@ export default {
// Success // Success
window.location.reload(true); window.location.reload(true);
// error // error
alert(response.message); window.alert(response.message);
}, },
}); });
}, },
@@ -257,7 +260,7 @@ export default {
this.amazonPayments.type = data.type; this.amazonPayments.type = data.type;
}, },
amazonOnError (error) { amazonOnError (error) {
alert(error.getErrorMessage()); window.alert(error.getErrorMessage());
this.reset(); this.reset();
}, },
reset () { reset () {
@@ -291,7 +294,9 @@ export default {
group = config.group; group = config.group;
} }
let paymentMethod = group ? group.purchased.plan.paymentMethod : this.user.purchased.plan.paymentMethod; let paymentMethod = group
? group.purchased.plan.paymentMethod
: this.user.purchased.plan.paymentMethod;
paymentMethod = paymentMethod === 'Amazon Payments' ? 'amazon' : paymentMethod.toLowerCase(); paymentMethod = paymentMethod === 'Amazon Payments' ? 'amazon' : paymentMethod.toLowerCase();
const queryParams = { const queryParams = {
@@ -322,7 +327,7 @@ export default {
this.loading = false; this.loading = false;
} catch (e) { } catch (e) {
alert(e.response.data.message); window.alert(e.response.data.message);
} }
}, },
}, },

View File

@@ -26,7 +26,9 @@ export default {
if (spell.target === 'self') { if (spell.target === 'self') {
return this.castEnd(null, spell.target); return this.castEnd(null, spell.target);
} if (spell.target === 'party') { }
if (spell.target === 'party') {
if (!this.user.party._id) { if (!this.user.party._id) {
const party = [this.user]; const party = [this.user];
return this.castEnd(party, spell.target); return this.castEnd(party, spell.target);
@@ -36,8 +38,10 @@ export default {
if (!isArray(partyMembers)) { if (!isArray(partyMembers)) {
partyMembers = [this.user]; partyMembers = [this.user];
} }
this.castEnd(partyMembers, spell.target); return this.castEnd(partyMembers, spell.target);
} else if (spell.target === 'tasks') { }
if (spell.target === 'tasks') {
const userTasks = this.$store.state.tasks.data; const userTasks = this.$store.state.tasks.data;
// exclude rewards // exclude rewards
let tasks = userTasks.habits let tasks = userTasks.habits
@@ -50,7 +54,9 @@ export default {
return true; return true;
}); });
return this.castEnd(tasks, spell.target); return this.castEnd(tasks, spell.target);
} else if (spell.target === 'user') { }
if (spell.target === 'user') {
const result = await this.castEnd(member, spell.target); const result = await this.castEnd(member, spell.target);
if (member.id === this.user.id) { if (member.id === this.user.id) {
@@ -58,7 +64,8 @@ export default {
} }
return result; return result;
} else { }
// If the cast target has to be selected (and can be cancelled) // If the cast target has to be selected (and can be cancelled)
document.addEventListener('keyup', this.handleCastCancelKeyUp); document.addEventListener('keyup', this.handleCastCancelKeyUp);
@@ -67,7 +74,6 @@ export default {
}); });
return null; return null;
}
}, },
async castEnd (target, type) { async castEnd (target, type) {
if (!this.$store.state.spellOptions.castingSpell) return null; if (!this.$store.state.spellOptions.castingSpell) return null;

View File

@@ -1,16 +1,16 @@
export default { export default {
methods: { methods: {
userLevelStyle (user, style) { userLevelStyle (user, style) {
style = style || ''; style = style || ''; // eslint-disable-line no-param-reassign, max-len
const npc = user && user.backer && user.backer.npc ? user.backer.npc : ''; const npc = user && user.backer && user.backer.npc ? user.backer.npc : '';
const level = user && user.contributor && user.contributor.level ? user.contributor.level : ''; const level = user && user.contributor && user.contributor.level ? user.contributor.level : '';
style += this.userLevelStyleFromLevel(level, npc, style); style += this.userLevelStyleFromLevel(level, npc, style); // eslint-disable-line no-param-reassign, max-len
return style; return style;
}, },
userLevelStyleFromLevel (level, npc, style) { userLevelStyleFromLevel (level, npc, style) {
style = style || ''; style = style || ''; // eslint-disable-line no-param-reassign, max-len
if (npc) style += ' npc'; if (npc) style += ' npc'; // eslint-disable-line no-param-reassign, max-len
style += level ? ` tier${level}` : ' no-tier'; style += level ? ` tier${level}` : ' no-tier'; // eslint-disable-line no-param-reassign, max-len
return style; return style;
}, },

View File

@@ -430,7 +430,7 @@ router.beforeEach((to, from, next) => {
router.app.$root.$emit('bv::hide::modal', 'profile'); router.app.$root.$emit('bv::hide::modal', 'profile');
} }
next(); return next();
}); });
export default router; export default router;

View File

@@ -59,7 +59,7 @@ export async function join (store, payload) {
try { try {
response = await axios.post(`/api/v4/groups/${groupId}/join`); response = await axios.post(`/api/v4/groups/${groupId}/join`);
} catch (err) { } catch (err) {
alert(err.response.data.message); window.alert(err.response.data.message);
return null; return null;
} }