do more cleanup of code using eslint

This commit is contained in:
janis committed 2023-10-05 13:46:53 +02:00
1 parent 0352bb9051
commit 5c5462186f
24 files changed
+314 -240

No files matched your search

+266 -203
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -3,4 +3,4 @@
* Licensed under the MIT License (MIT)
* https://github.com/mdbassit/Coloris
*/
!function( u,p,s,c ) {let d,f,h,b,i,v,y,g,m,w,l,k,L,E,x,a,n,r=p.createElement( 'canvas' ).getContext( '2d' ),A={r: 0,g: 0,b: 0,h: 0,s: 0,v: 0,a: 1},S={el: '[data-coloris]',parent: 'body',theme: 'default',themeMode: 'light',rtl: !1,wrap: !0,margin: 2,format: 'hex',formatToggle: !1,swatches: [],swatchesOnly: !1,alpha: !0,forceAlpha: !1,focusInput: !0,selectInput: !1,inline: !1,defaultColor: '#000000',clearButton: !1,clearLabel: 'Clear',closeButton: !1,closeLabel: 'Close',onChange: function() {return c;},a11y: {open: 'Open color picker',close: 'Close color picker',clear: 'Clear the selected color',marker: 'Saturation: {s}. Brightness: {v}.',hueSlider: 'Hue slider',alphaSlider: 'Opacity slider',input: 'Color value field',format: 'Color format',swatch: 'Color swatch',instruction: 'Saturation and brightness selector. Use up, down, left and right arrow keys to select.'}},o={},C='',T={},B=!1;function M( e ) {if ( 'object'==typeof e ) for ( let t in e ) switch ( t ) {case 'el':N( e.el ),!1!==e.wrap&&j( e.el );break;case 'parent':( d=p.querySelector( e.parent ) )&&( d.appendChild( f ),S.parent=e.parent,d===p.body&&( d=c ) );break;case 'themeMode':S.themeMode=e.themeMode,'auto'===e.themeMode&&u.matchMedia&&u.matchMedia( '(prefers-color-scheme: dark)' ).matches&&( S.themeMode='dark' );case 'theme':e.theme&&( S.theme=e.theme ),f.className='clr-picker clr-'+S.theme+' clr-'+S.themeMode,S.inline&&I();break;case 'rtl':S.rtl=!!e.rtl,p.querySelectorAll( '.clr-field' ).forEach( function( e ) {return e.classList.toggle( 'clr-rtl',S.rtl );} );break;case 'margin':e.margin*=1,S.margin=( isNaN( e.margin )?S:e ).margin;break;case 'wrap':e.el&&e.wrap&&j( e.el );break;case 'formatToggle':S.formatToggle=!!e.formatToggle,z( 'clr-format' ).style.display=S.formatToggle?'block':'none',S.formatToggle&&( S.format='auto' );break;case 'swatches':Array.isArray( e.swatches )&&function() {let a=[];e.swatches.forEach( function( e,t ) {a.push( '<button type="button" id="clr-swatch-'+t+'" aria-labelledby="clr-swatch-label clr-swatch-'+t+'" style="color: '+e+';">'+e+'</button>' );} ),z( 'clr-swatches' ).innerHTML=a.length?'<div>'+a.join( '' )+'</div>':'',S.swatches=e.swatches.slice();}();break;case 'swatchesOnly':S.swatchesOnly=!!e.swatchesOnly,f.setAttribute( 'data-minimal',S.swatchesOnly );break;case 'alpha':S.alpha=!!e.alpha,f.setAttribute( 'data-alpha',S.alpha );break;case 'inline':S.inline=!!e.inline,f.setAttribute( 'data-inline',S.inline ),S.inline&&( l=e.defaultColor||S.defaultColor,x=F( l ),I(),q( l ) );break;case 'clearButton':'object'==typeof e.clearButton&&( e.clearButton.label&&( S.clearLabel=e.clearButton.label,g.innerHTML=S.clearLabel ),e.clearButton=e.clearButton.show ),S.clearButton=!!e.clearButton,g.style.display=S.clearButton?'block':'none';break;case 'clearLabel':S.clearLabel=e.clearLabel,g.innerHTML=S.clearLabel;break;case 'closeButton':S.closeButton=!!e.closeButton,S.closeButton?f.insertBefore( m,v ):v.appendChild( m );break;case 'closeLabel':S.closeLabel=e.closeLabel,m.innerHTML=S.closeLabel;break;case 'a11y':var a,l,r=e.a11y,n=!1;if ( 'object'==typeof r ) for ( let o in r )r[o]&&S.a11y[o]&&( S.a11y[o]=r[o],n=!0 );n&&( a=z( 'clr-open-label' ),l=z( 'clr-swatch-label' ),a.innerHTML=S.a11y.open,l.innerHTML=S.a11y.swatch,m.setAttribute( 'aria-label',S.a11y.close ),g.setAttribute( 'aria-label',S.a11y.clear ),w.setAttribute( 'aria-label',S.a11y.hueSlider ),k.setAttribute( 'aria-label',S.a11y.alphaSlider ),y.setAttribute( 'aria-label',S.a11y.input ),h.setAttribute( 'aria-label',S.a11y.instruction ) );break;default:S[t]=e[t];}} function H( e,t ) {'string'==typeof e&&'object'==typeof t&&( o[e]=t,B=!0 );} function O( e ) {delete o[e],0===Object.keys( o ).length&&( B=!1,e===C&&D() );} function t( l ) {if ( B ) {let e,r=['el','wrap','rtl','inline','defaultColor','a11y'];for ( e in o ) if ( 'break'===function( e ) {let t=o[e];if ( l.matches( e ) ) {for ( let a in C=e,T={},r.forEach( function( e ) {return delete t[e];} ),t )T[a]=Array.isArray( S[a] )?S[a].slice():S[a];return M( t ),'break';}}( e ) ) break;}} function D() {0<Object.keys( T ).length&&( M( T ),C='',T={} );} function N( e ) {J( p,'click',e,function( e ) {S.inline||( t( e.target ),E=e.target,a=E.value,x=F( a ),f.classList.add( 'clr-open' ),I(),q( a ),( S.focusInput||S.selectInput )&&y.focus( {preventScroll: !0} ),S.selectInput&&y.select(),( n||S.swatchesOnly )&&$().shift().focus(),E.dispatchEvent( new Event( 'open',{bubbles: !0} ) ) );} ),J( p,'input',e,function( e ) {let t=e.target.parentNode;t.classList.contains( 'clr-field' )&&( t.style.color=e.target.value );} );} function I() {let e,t,a,l,r=d,n=u.scrollY,o=f.offsetWidth,c=f.offsetHeight,i={left: !1,top: !1},s={x: 0,y: 0};r&&( a=u.getComputedStyle( r ),e=parseFloat( a.marginTop ),l=parseFloat( a.borderTopWidth ),( s=r.getBoundingClientRect() ).y+=l+n ),S.inline||( a=( t=E.getBoundingClientRect() ).x,l=n+t.y+t.height+S.margin,r?( a-=s.x,l-=s.y,a+o>r.clientWidth&&( a+=t.width-o,i.left=!0 ),l+c>r.clientHeight-e&&c+S.margin<=t.toLine truncated
!function( u,p,s,c ) {let d,f,h,b,i,v,y,g,m,w,l,k,L,E,x,a,n,r=p.createElement( 'canvas' ).getContext( '2d' ),A={r: 0,g: 0,b: 0,h: 0,s: 0,v: 0,a: 1},S={el: '[data-coloris]',parent: 'body',theme: 'default',themeMode: 'light',rtl: !1,wrap: !0,margin: 2,format: 'hex',formatToggle: !1,swatches: [],swatchesOnly: !1,alpha: !0,forceAlpha: !1,focusInput: !0,selectInput: !1,inline: !1,defaultColor: '#000000',clearButton: !1,clearLabel: 'Clear',closeButton: !1,closeLabel: 'Close',onChange: function() {return c;},a11y: {open: 'Open color picker',close: 'Close color picker',clear: 'Clear the selected color',marker: 'Saturation: {s}. Brightness: {v}.',hueSlider: 'Hue slider',alphaSlider: 'Opacity slider',input: 'Color value field',format: 'Color format',swatch: 'Color swatch',instruction: 'Saturation and brightness selector. Use up, down, left and right arrow keys to select.'}},o={},C='',T={},B=!1;function M( e ) {if ( 'object'==typeof e ) for ( let t in e ) switch ( t ) {case 'el':N( e.el ),!1!==e.wrap&&j( e.el );break;case 'parent':( d=p.querySelector( e.parent ) )&&( d.appendChild( f ),S.parent=e.parent,d===p.body&&( d=c ) );break;case 'themeMode':S.themeMode=e.themeMode,'auto'===e.themeMode&&u.matchMedia&&u.matchMedia( '(prefers-color-scheme: dark)' ).matches&&( S.themeMode='dark' );case 'theme':e.theme&&( S.theme=e.theme ),f.className='clr-picker clr-'+S.theme+' clr-'+S.themeMode,S.inline&&I();break;case 'rtl':S.rtl=!!e.rtl,p.querySelectorAll( '.clr-field' ).forEach( function( e ) {return e.classList.toggle( 'clr-rtl',S.rtl );} );break;case 'margin':e.margin*=1,S.margin=( isNaN( e.margin )?S:e ).margin;break;case 'wrap':e.el&&e.wrap&&j( e.el );break;case 'formatToggle':S.formatToggle=!!e.formatToggle,z( 'clr-format' ).style.display=S.formatToggle?'block':'none',S.formatToggle&&( S.format='auto' );break;case 'swatches':Array.isArray( e.swatches )&&function() {let a=[];e.swatches.forEach( function( e,t ) {a.push( '<button type="button" id="clr-swatch-'+t+'" aria-labelledby="clr-swatch-label clr-swatch-'+t+'" style="color: '+e+';">'+e+'</button>' );} ),z( 'clr-swatches' ).innerHTML=a.length?'<div>'+a.join( '' )+'</div>':'',S.swatches=e.swatches.slice();}();break;case 'swatchesOnly':S.swatchesOnly=!!e.swatchesOnly,f.setAttribute( 'data-minimal',S.swatchesOnly );break;case 'alpha':S.alpha=!!e.alpha,f.setAttribute( 'data-alpha',S.alpha );break;case 'inline':S.inline=!!e.inline,f.setAttribute( 'data-inline',S.inline ),S.inline&&( l=e.defaultColor||S.defaultColor,x=F( l ),I(),q( l ) );break;case 'clearButton':'object'==typeof e.clearButton&&( e.clearButton.label&&( S.clearLabel=e.clearButton.label,g.innerHTML=S.clearLabel ),e.clearButton=e.clearButton.show ),S.clearButton=!!e.clearButton,g.style.display=S.clearButton?'block':'none';break;case 'clearLabel':S.clearLabel=e.clearLabel,g.innerHTML=S.clearLabel;break;case 'closeButton':S.closeButton=!!e.closeButton,S.closeButton?f.insertBefore( m,v ):v.appendChild( m );break;case 'closeLabel':S.closeLabel=e.closeLabel,m.innerHTML=S.closeLabel;break;case 'a11y':var a,l,r=e.a11y,n=!1;if ( 'object'==typeof r ) for ( let o in r )r[o]&&S.a11y[o]&&( S.a11y[o]=r[o],n=!0 );n&&( a=z( 'clr-open-label' ),l=z( 'clr-swatch-label' ),a.innerHTML=S.a11y.open,l.innerHTML=S.a11y.swatch,m.setAttribute( 'aria-label',S.a11y.close ),g.setAttribute( 'aria-label',S.a11y.clear ),w.setAttribute( 'aria-label',S.a11y.hueSlider ),k.setAttribute( 'aria-label',S.a11y.alphaSlider ),y.setAttribute( 'aria-label',S.a11y.input ),h.setAttribute( 'aria-label',S.a11y.instruction ) );break;default:S[t]=e[t];}} function H( e,t ) {'string'==typeof e&&'object'==typeof t&&( o[e]=t,B=!0 );} function O( e ) {delete o[e],0===Object.keys( o ).length&&( B=!1,e===C&&D() );} function t( l ) {if ( B ) {let e,r=['el','wrap','rtl','inline','defaultColor','a11y'];for ( e in o ) if ( 'break'===function( e ) {let t=o[e];if ( l.matches( e ) ) {for ( let a in C=e,T={},r.forEach( function( e ) {return delete t[e];} ),t )T[a]=Array.isArray( S[a] )?S[a].slice():S[a];return M( t ),'break';}}( e ) ) break;}} function D() {0<Object.keys( T ).length&&( M( T ),C='',T={} );} function N( e ) {J( p,'click',e,function( e ) {S.inline||( t( e.target ),E=e.target,a=E.value,x=F( a ),f.classList.add( 'clr-open' ),I(),q( a ),( S.focusInput||S.selectInput )&&y.focus( {preventScroll: !0} ),S.selectInput&&y.select(),( n||S.swatchesOnly )&&$().shift().focus(),E.dispatchEvent( new Event( 'open',{bubbles: !0} ) ) );} ),J( p,'input',e,function( e ) {let t=e.target.parentNode;t.classList.contains( 'clr-field' )&&( t.style.color=e.target.value );} );} function I() {let e,t,a,l,r=d,n=u.scrollY,o=f.offsetWidth,c=f.offsetHeight,i={left: !1,top: !1},s={x: 0,y: 0};r&&( a=u.getComputedStyle( r ),e=parseFloat( a.marginTop ),l=parseFloat( a.borderTopWidth ),( s=r.getBoundingClientRect() ).y+=l+n ),S.inline||( a=( t=E.getBoundingClientRect() ).x,l=n+t.y+t.height+S.margin,r?( a-=s.x,l-=s.y,a+o>r.clientWidth&&( a+=t.width-o,i.left=!0 ),l+c>r.clientHeight-e&&c+S.margin<=t.toLine truncated
@@ -187,7 +187,9 @@ export default {
if ( Object.keys( this.cart[ this.event.eventID ][ 'tickets' ] ).length < 1 ) {
try {
delete this.cart[ this.event.eventID ];
} catch {}
} catch {
console.log( 'element nonexistent' );
}
} else {
delete this.cart[ this.event.eventID ][ 'tickets' ][ ticket ];
}
@@ -238,7 +240,7 @@ export default {
}
},
created () {
window.addEventListener( 'visibilitychange', ( e ) => {
window.addEventListener( 'visibilitychange', () => {
this.cart = localStorage.getItem( 'cart' ) ? JSON.parse( localStorage.getItem( 'cart' ) ): {};
}, 1 );
this.cart = localStorage.getItem( 'cart' ) ? JSON.parse( localStorage.getItem( 'cart' ) ): {};
@@ -1,3 +1,4 @@
<!-- eslint-disable no-undef -->
<template>
<div id="notifications" @click="handleNotifications();">
<div class="message-box" :class="[ location, size ]">
@@ -80,7 +81,9 @@ export default {
}
try {
this.queue.splice( this.queue.indexOf( id ), 1 );
} catch {}
} catch {
console.debug( 'queue empty' );
}
if ( this.currentlyDisplayedNotificationID == id ) {
this.handleNotifications();
}
@@ -1,3 +1,4 @@
<!-- eslint-disable no-undef -->
<template>
<div id="popup-backdrop">
<div class="popup-container">
@@ -1,3 +1,4 @@
<!-- eslint-disable no-undef -->
<!--
* libreevent - properties.vue
*
@@ -266,16 +267,16 @@ export default {
}
},
watch: {
draggables ( value ) {
draggables () {
this.loadInternal();
},
active ( value ) {
active () {
this.loadInternal();
},
scaleFactor ( value ) {
scaleFactor () {
this.loadInternal();
},
historyPos ( value ) {
historyPos () {
this.loadInternal();
}
},
@@ -1,3 +1,4 @@
<!-- eslint-disable no-undef -->
<!--
* libreevent - window.vue
*
@@ -74,7 +75,7 @@ export default {
data() {
return {
active: 0,
draggables: { 1: { 'x': 100, 'y': 100, 'h': 100, 'w': 250, 'active': false, 'draggable': true, 'resizable': true, 'id': 1, 'origin': 1, 'shape': 'rectangular', 'type': 'seat', 'startingRow': 1, 'seatNumberingPosition': 1, 'sector': 'A', 'text': { 'text': 'TestText', 'textSize': 20, 'colour': '#20FFFF' }, 'numberingDirection': 'left', 'seatNumberingPosition': 1, 'category': '1' } },
draggables: { 1: { 'x': 100, 'y': 100, 'h': 100, 'w': 250, 'active': false, 'draggable': true, 'resizable': true, 'id': 1, 'origin': 1, 'shape': 'rectangular', 'type': 'seat', 'startingRow': 1, 'sector': 'A', 'text': { 'text': 'TestText', 'textSize': 20, 'colour': '#20FFFF' }, 'numberingDirection': 'left', 'seatNumberingPosition': 1, 'category': '1' } },
available: { 'redo': false, 'undo': false },
scaleFactor: 1,
sizePoll: null,
@@ -206,7 +207,7 @@ export default {
// }
this.save();
},
eventHandler ( e ) {
eventHandler () {
if ( this.prevSize.h != window.innerHeight || this.prevSize.w != window.innerWidth ) {
this.prevSize = { 'h': window.innerHeight, 'w': window.innerWidth };
this.loadSeatplan();
@@ -102,7 +102,7 @@ export default {
}
},
watch: {
origin ( value ) {
origin () {
this.updateOrigin();
}
},
@@ -49,16 +49,16 @@ export default {
}
},
watch: {
origin ( value ) {
origin () {
this.updateStyle();
},
scaleFactor ( value ) {
scaleFactor () {
this.updateStyle();
},
colour ( value ) {
colour () {
this.updateStyle();
},
textSize ( value ) {
textSize () {
this.updateStyle();
}
},
@@ -102,7 +102,7 @@ export default {
}
},
watch: {
origin ( value ) {
origin () {
this.updateOrigin();
}
},
@@ -108,7 +108,7 @@ export default {
},
},
watch: {
origin ( value ) {
origin () {
this.updateOrigin();
}
},
@@ -49,16 +49,16 @@ export default {
}
},
watch: {
origin ( value ) {
origin () {
this.updateStyle();
},
scaleFactor ( value ) {
scaleFactor () {
this.updateStyle();
},
colour ( value ) {
colour () {
this.updateStyle();
},
textSize ( value ) {
textSize () {
this.updateStyle();
}
},
@@ -1,3 +1,4 @@
<!-- eslint-disable no-undef -->
<!--
* libreevent - window.vue
*
@@ -173,7 +174,7 @@ export default {
this.seatChecks();
// TODO: FUTURE Trim scroll box to about 200px more than seatplan size
sessionStorage.setItem( 'seatplan', JSON.stringify( this.scaleDown( this.draggables ) ) );
window.addEventListener( 'visibilitychange', ( e ) => {
window.addEventListener( 'visibilitychange', () => {
this.seatPlanInit();
}, 1 );
},
@@ -237,7 +238,7 @@ export default {
}
} );
},
eventHandler ( e ) {
eventHandler () {
if ( this.prevSize.h != window.innerHeight || this.prevSize.w != window.innerWidth ) {
this.prevSize = { 'h': window.innerHeight, 'w': window.innerWidth };
this.loadSeatplan();
@@ -330,7 +331,7 @@ export default {
this.loadSeatplan();
} else {
if ( ( this.zoomFactor < 0.3 && scale < 0 ) || ( this.zoomFactor > 2.9 && scale > 0 ) ) {
console.log( 'maxZoomLevelReached' );
} else {
this.zoomFactor += scale;
}
@@ -1,3 +1,4 @@
<!-- eslint-disable no-undef -->
<!--
* libreevent - rightClickMenu.vue
*
@@ -1,3 +1,4 @@
<!-- eslint-disable no-undef -->
<!--
* libreevent - settings.vue
*
@@ -51,7 +51,7 @@ export default {
props: {
'cart': {
type: Object,
default: {},
default: {}
// EXAMPLE: { 'TestEvent2': { 'displayName': 'TestEvent2', 'tickets': { 'secAr1s1': { 'displayName': 'Row 1, Seat 1', 'price': 20 } } } }
},
'width': {
+1 -2
View File
@@ -9,7 +9,6 @@
import { createRouter, createWebHistory } from 'vue-router';
import { useUserStore } from '@/stores/userStore';
import { useBackendStore } from '@/stores/backendStore';
import adminRoutes from '@/router/adminRoutes';
import mainRoutes from '@/router/mainRoutes';
@@ -27,7 +26,7 @@ const router = createRouter( {
routes,
} );
router.afterEach( ( to, from ) => {
router.afterEach( ( to ) => {
let userStore = useUserStore();
document.title = to.meta.title ? to.meta.title + userStore.getPageName : 'libreevent';
} );
@@ -1,3 +1,4 @@
<!-- eslint-disable no-undef -->
<!--
* libreevent - AdminView.vue
*
@@ -225,7 +226,7 @@ export default {
methods: {
logout () {
if ( confirm( 'Do you really want to log out?' ) ) {
fetch( '/admin/logout' ).then( _ => {
fetch( '/admin/logout' ).then( () => {
this.userStore.setAdminAuth( false );
this.$router.push( '/admin/login' );
} );
@@ -23,7 +23,7 @@
</div>
<!-- <img :src="event.logo" alt="event logo" class="ticket-logo"> -->
</router-link>
<router-link to="/admin/events/analytics" class="ticket" @click="setActiveTicket( event.eventID );" v-else="new Date( event.date ).getTime() > currentDate">
<router-link to="/admin/events/analytics" class="ticket" @click="setActiveTicket( event.eventID );" v-else>
<div class="ticket-name">
<h3>{{ event.name }}</h3>
<p>{{ event.description }}</p>
@@ -200,7 +200,7 @@ export default {
}
},
watch: {
selectedTemplate( value ) {
selectedTemplate() {
this.loadPageSettings();
}
},
+1 -1
View File
@@ -48,7 +48,7 @@ export default {
}
};
source.onopen = e => {
source.onopen = () => {
self.$refs.notification.createNotification( 'Connected to status service', 5, 'ok', 'normal' );
self.$refs.notification.cancelNotification( startNotification );
};
@@ -492,8 +492,7 @@ export default {
'charset': 'utf-8'
}
};
// TODO: fix url
fetch( url, options ).then( res => {
fetch( '/admin/api/undeployEvent', options ).then( res => {
if ( res.status === 200 ) {
this.hasLiveVersion = false;
this.$refs.notification.createNotification( 'Your event is no longer publicly visible!', 5, 'ok', 'normal' );
@@ -510,7 +509,7 @@ export default {
'charset': 'utf-8'
}
};
fetch( url, options ).then( res => {
fetch( '/admin/api/deleteEvent', options ).then( res => {
if ( res.status === 200 ) {
this.$refs.notification.createNotification( 'Your event has been deleted successfully!', 5, 'ok', 'normal' );
setTimeout( () => {
@@ -534,7 +533,7 @@ export default {
} else if ( action === 'undeploy' ) {
this.$refs.popups.openPopup( 'Do you really want to remove this event from the event listings?', {}, 'confirm' );
this.command = 'undeployEvent';
} else if ( type === 'delete' ) {
} else if ( action === 'delete' ) {
this.$refs.popups.openPopup( 'Do you really want to delete this event? This action cannot be undone', {}, 'confirm' );
this.command = 'deleteEvent';
}
@@ -223,7 +223,7 @@ export default {
},
},
created () {
window.addEventListener( 'visibilitychange', ( e ) => {
window.addEventListener( 'visibilitychange', () => {
this.cart = localStorage.getItem( 'cart' ) ? JSON.parse( localStorage.getItem( 'cart' ) ): {};
this.calculateTotal();
}, 1 );
@@ -1,3 +1,4 @@
<!-- eslint-disable no-undef -->
<!--
* libreevent - GuestPurchaseView.vue
*
@@ -61,7 +62,7 @@ export default {
}
};
source.onopen = e => {
source.onopen = () => {
self.$refs.notification.createNotification( 'Connected to status service', 5, 'ok', 'normal' );
self.$refs.notification.cancelNotification( startNotification );
};