mirror of
https://github.com/janishutz/MusicPlayerV2.git
synced 2025-11-25 04:54:23 +00:00
start adding showcase screen
This commit is contained in:
@@ -8,6 +8,8 @@
|
|||||||
<!-- TODO: Update URL -->
|
<!-- TODO: Update URL -->
|
||||||
<script src="https://js-cdn.music.apple.com/musickit/v3/musickit.js"></script>
|
<script src="https://js-cdn.music.apple.com/musickit/v3/musickit.js"></script>
|
||||||
<script src="https://static.janishutz.com/libs/jquery/jquery.min.js"></script>
|
<script src="https://static.janishutz.com/libs/jquery/jquery.min.js"></script>
|
||||||
|
<!-- <script src="https://id.janishutz.com/sdk/sdk.min.js"></script> -->
|
||||||
|
<script src="http://localhost:8080/sdk/sdk.min.js"></script>
|
||||||
<title>MusicPlayer</title>
|
<title>MusicPlayer</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
10
MusicPlayerV2-GUI/package-lock.json
generated
10
MusicPlayerV2-GUI/package-lock.json
generated
@@ -13,6 +13,7 @@
|
|||||||
"@jridgewell/sourcemap-codec": "^1.4.15",
|
"@jridgewell/sourcemap-codec": "^1.4.15",
|
||||||
"@rollup/plugin-inject": "^5.0.5",
|
"@rollup/plugin-inject": "^5.0.5",
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
|
"colorthief": "^2.2.0",
|
||||||
"music-metadata-browser": "^2.5.10",
|
"music-metadata-browser": "^2.5.10",
|
||||||
"musickit-typescript": "^1.2.4",
|
"musickit-typescript": "^1.2.4",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "^2.1.7",
|
||||||
@@ -1585,6 +1586,15 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/colorthief": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/colorthief/-/colorthief-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-jtS2rrSQQMHqE4tkzpZu7l4MDOwKuZTxzsHdhFmxwshCX/5snPIzC+CwwHOwaACa6bwYV3qHwvnCSLqKvsC4Dw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.15.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/computeds": {
|
"node_modules/computeds": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/computeds/-/computeds-0.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/computeds/-/computeds-0.0.1.tgz",
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
"@jridgewell/sourcemap-codec": "^1.4.15",
|
"@jridgewell/sourcemap-codec": "^1.4.15",
|
||||||
"@rollup/plugin-inject": "^5.0.5",
|
"@rollup/plugin-inject": "^5.0.5",
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
|
"colorthief": "^2.2.0",
|
||||||
"music-metadata-browser": "^2.5.10",
|
"music-metadata-browser": "^2.5.10",
|
||||||
"musickit-typescript": "^1.2.4",
|
"musickit-typescript": "^1.2.4",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "^2.1.7",
|
||||||
|
|||||||
@@ -29,13 +29,15 @@
|
|||||||
<div class="slider-wrapper" v-if="isShowingFullScreenPlayer">
|
<div class="slider-wrapper" v-if="isShowingFullScreenPlayer">
|
||||||
<div class="slider-pb-pos">
|
<div class="slider-pb-pos">
|
||||||
<p class="playback-pos">{{ nicePlaybackPos }}</p>
|
<p class="playback-pos">{{ nicePlaybackPos }}</p>
|
||||||
<p class="playback-duration" @click="toggleRemaining()">{{ niceDuration }}</p>
|
<p class="playback-duration" @click="toggleRemaining()" title="Toggle between remaining time and song duration">{{ niceDuration }}</p>
|
||||||
</div>
|
</div>
|
||||||
<sliderView :position="pos" :active="true" :duration="duration" name="main" @pos="( pos ) => player.goToPos( pos )"></sliderView>
|
<sliderView :position="pos" :active="true" :duration="duration" name="main" @pos="( pos ) => player.goToPos( pos )"></sliderView>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="shuffle-repeat" v-if="isShowingFullScreenPlayer">
|
<div class="shuffle-repeat" v-if="isShowingFullScreenPlayer">
|
||||||
<span class="material-symbols-outlined controls" @click="control( 'repeat' )" style="margin-right: auto;">repeat{{ repeatMode }}</span>
|
<span class="material-symbols-outlined controls" @click="control( 'repeat' )" style="margin-right: auto;">repeat{{ repeatMode }}</span>
|
||||||
|
<span class="material-symbols-outlined controls" @click="control( 'start-share' )" style="margin-right: auto;" title="Share your playlist on a public playlist page (opens a configuration window)" v-if="!isConnectedToNotifier">share</span>
|
||||||
|
<span class="material-symbols-outlined controls" @click="control( 'stop-share' )" style="margin-right: auto;" title="Stop sharing your playlist on a public playlist page" v-else>close</span>
|
||||||
<span class="material-symbols-outlined controls" @click="control( 'shuffle' )">shuffle{{ shuffleMode }}</span>
|
<span class="material-symbols-outlined controls" @click="control( 'shuffle' )">shuffle{{ shuffleMode }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -82,11 +84,13 @@
|
|||||||
const nicePlaybackPos = ref( '00:00' );
|
const nicePlaybackPos = ref( '00:00' );
|
||||||
const niceDuration = ref( '00:00' );
|
const niceDuration = ref( '00:00' );
|
||||||
const isShowingRemainingTime = ref( false );
|
const isShowingRemainingTime = ref( false );
|
||||||
|
let isShowingRemainingTimeBackend = false;
|
||||||
const currentlyPlayingSongArtist = ref( '' );
|
const currentlyPlayingSongArtist = ref( '' );
|
||||||
const pos = ref( 0 );
|
const pos = ref( 0 );
|
||||||
const duration = ref( 0 );
|
const duration = ref( 0 );
|
||||||
const notifications = ref( notificationsModule );
|
const notifications = ref( notificationsModule );
|
||||||
const notificationHandler = new NotificationHandler();
|
const notificationHandler = new NotificationHandler();
|
||||||
|
const isConnectedToNotifier = ref( false );
|
||||||
|
|
||||||
const emits = defineEmits( [ 'playerStateChange' ] );
|
const emits = defineEmits( [ 'playerStateChange' ] );
|
||||||
|
|
||||||
@@ -163,6 +167,9 @@
|
|||||||
getDetails();
|
getDetails();
|
||||||
startProgressTracker();
|
startProgressTracker();
|
||||||
}, 2000 );
|
}, 2000 );
|
||||||
|
} else if ( action === 'start-share' ) {
|
||||||
|
// TODO: Open popup, then send data with popup returns
|
||||||
|
notificationHandler.connect( 'test' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,9 +177,15 @@
|
|||||||
const controlUI = ( action: string ) => {
|
const controlUI = ( action: string ) => {
|
||||||
if ( action === 'show' ) {
|
if ( action === 'show' ) {
|
||||||
isShowingFullScreenPlayer.value = true;
|
isShowingFullScreenPlayer.value = true;
|
||||||
|
isShowingRemainingTime.value = isShowingRemainingTimeBackend;
|
||||||
emits( 'playerStateChange', 'show' );
|
emits( 'playerStateChange', 'show' );
|
||||||
} else if ( action === 'hide' ) {
|
} else if ( action === 'hide' ) {
|
||||||
isShowingFullScreenPlayer.value = false;
|
isShowingFullScreenPlayer.value = false;
|
||||||
|
isShowingRemainingTimeBackend = isShowingRemainingTime.value;
|
||||||
|
isShowingRemainingTime.value = false;
|
||||||
|
try {
|
||||||
|
prepNiceDurationTime( player.getPlayingSong() );
|
||||||
|
} catch ( err ) { /* empty */ }
|
||||||
emits( 'playerStateChange', 'hide' );
|
emits( 'playerStateChange', 'hide' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -300,18 +313,7 @@
|
|||||||
hasReachedEnd = false;
|
hasReachedEnd = false;
|
||||||
isPlaying.value = true;
|
isPlaying.value = true;
|
||||||
const playingSong = player.getPlayingSong();
|
const playingSong = player.getPlayingSong();
|
||||||
duration.value = playingSong.duration;
|
prepNiceDurationTime( playingSong );
|
||||||
const minuteCounts = Math.floor( ( playingSong.duration ) / 60 );
|
|
||||||
niceDuration.value = String( minuteCounts ) + ':';
|
|
||||||
if ( ( '' + minuteCounts ).length === 1 ) {
|
|
||||||
niceDuration.value = '0' + minuteCounts + ':';
|
|
||||||
}
|
|
||||||
const secondCounts = Math.floor( ( playingSong.duration ) - minuteCounts * 60 );
|
|
||||||
if ( ( '' + secondCounts ).length === 1 ) {
|
|
||||||
niceDuration.value += '0' + secondCounts;
|
|
||||||
} else {
|
|
||||||
niceDuration.value += secondCounts;
|
|
||||||
}
|
|
||||||
progressTracker = setInterval( () => {
|
progressTracker = setInterval( () => {
|
||||||
pos.value = player.getPlaybackPos();
|
pos.value = player.getPlaybackPos();
|
||||||
if ( pos.value > playingSong.duration - 1 && !hasReachedEnd ) {
|
if ( pos.value > playingSong.duration - 1 && !hasReachedEnd ) {
|
||||||
@@ -319,6 +321,9 @@
|
|||||||
hasReachedEnd = true;
|
hasReachedEnd = true;
|
||||||
if ( repeatMode.value === '_one_on' ) {
|
if ( repeatMode.value === '_one_on' ) {
|
||||||
player.goToPos( 0 );
|
player.goToPos( 0 );
|
||||||
|
setTimeout( () => {
|
||||||
|
control( 'play' );
|
||||||
|
}, 500 );
|
||||||
} else {
|
} else {
|
||||||
control( 'next' );
|
control( 'next' );
|
||||||
}
|
}
|
||||||
@@ -356,6 +361,21 @@
|
|||||||
}, 50 );
|
}, 50 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const prepNiceDurationTime = ( playingSong: Song ) => {
|
||||||
|
duration.value = playingSong.duration;
|
||||||
|
const minuteCounts = Math.floor( ( playingSong.duration ) / 60 );
|
||||||
|
niceDuration.value = String( minuteCounts ) + ':';
|
||||||
|
if ( ( '' + minuteCounts ).length === 1 ) {
|
||||||
|
niceDuration.value = '0' + minuteCounts + ':';
|
||||||
|
}
|
||||||
|
const secondCounts = Math.floor( ( playingSong.duration ) - minuteCounts * 60 );
|
||||||
|
if ( ( '' + secondCounts ).length === 1 ) {
|
||||||
|
niceDuration.value += '0' + secondCounts;
|
||||||
|
} else {
|
||||||
|
niceDuration.value += secondCounts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const stopProgressTracker = () => {
|
const stopProgressTracker = () => {
|
||||||
try {
|
try {
|
||||||
clearInterval( progressTracker );
|
clearInterval( progressTracker );
|
||||||
|
|||||||
@@ -5,10 +5,11 @@
|
|||||||
Loading...
|
Loading...
|
||||||
<!-- TODO: Make prettier -->
|
<!-- TODO: Make prettier -->
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="!$props.isLoggedIn">
|
<div v-else-if="!$props.isLoggedIn" class="not-logged-in">
|
||||||
<p>You are not logged into Apple Music.</p>
|
<p>You are not logged into Apple Music. We therefore can't show you your playlists. <a href="" title="Refreshes the page, allowing you to log in">Change that</a></p>
|
||||||
|
<p>Use the below button to load songs from your local disk</p>
|
||||||
<input class="pl-loader-button" type="file" multiple="true" accept="audio/*" id="pl-loader"><br>
|
<input class="pl-loader-button" type="file" multiple="true" accept="audio/*" id="pl-loader"><br>
|
||||||
<button @click="loadPlaylistFromDisk()" class="pl-loader-button">Load custom playlist from disk</button>
|
<button @click="loadPlaylistFromDisk()" class="pl-loader-button" id="load-button">Load</button>
|
||||||
<p v-if="!hasSelectedSongs">Please select at least one song to proceed!</p>
|
<p v-if="!hasSelectedSongs">Please select at least one song to proceed!</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="playlist-wrapper">
|
<div class="playlist-wrapper">
|
||||||
@@ -87,5 +88,19 @@
|
|||||||
|
|
||||||
.pl-loader-button {
|
.pl-loader-button {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
|
border: none;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 5px;
|
||||||
|
margin: 5px;
|
||||||
|
font-size: 1rem;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
#load-button {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.not-logged-in {
|
||||||
|
width: 80%;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -1,481 +1,298 @@
|
|||||||
<!-- eslint-disable no-undef -->
|
|
||||||
<template>
|
<template>
|
||||||
<div id="popup-backdrop">
|
<div>
|
||||||
<div class="popup-container">
|
<div :class="'popup-backdrop' + ( isShowingPopup ? '' : ' hidden' )" :style="'transform-origin: ' + transformOriginVertical + ';'">
|
||||||
<div class="popup" :class="size">
|
<div class="popup-main">
|
||||||
<div class="close-wrapper"><span class="material-symbols-outlined close-button" @click="closePopup( 'cancel' );" title="Close this popup">close</span></div>
|
<span class="material-symbols-outlined close-icon" @click="closePopup()">close</span>
|
||||||
<div class="message-container">
|
<h2>{{ popupContent.title }}</h2>
|
||||||
<div v-if="contentType === 'string'" class="options">
|
<div v-if="popupContent.popupType === 'information' || popupContent.popupType === 'confirmation'" class="popup-content">
|
||||||
<h3>{{ data.message }}</h3>
|
<p v-html="popupContent.subtitle"></p>
|
||||||
<div class="button-wrapper">
|
</div>
|
||||||
<button @click="closePopup( 'ok' )" title="Close popup" class="buttons fancy-button">Ok</button>
|
<div v-else class="popup-content">
|
||||||
|
<p v-if="isShowingIncomplete" class="incomplete-message">{{ popupContent.incompleteMessage ? popupContent.incompleteMessage : 'Some entries are not filled out. Please fill them out to proceed.' }}</p>
|
||||||
|
<p v-html="popupContent.subtitle"></p>
|
||||||
|
<div v-for="content in popupContent.data" v-bind:key="content.id" class="popup-content-wrapper">
|
||||||
|
<div v-if="content.dataType === 'text'">
|
||||||
|
<label :for="'text-' + content.id">{{ content.name }}</label><br>
|
||||||
|
<input type="text" :id="'text-' + content.id" v-model="data[ content.id ]" class="input">
|
||||||
|
</div>
|
||||||
|
<div v-else-if="content.dataType === 'number'">
|
||||||
|
<label :for="'number-' + content.id">{{ content.name }}</label><br>
|
||||||
|
<input type="number" :id="'number-' + content.id" v-model="data[ content.id ]" class="input">
|
||||||
|
</div>
|
||||||
|
<div v-else-if="content.dataType === 'checkbox'">
|
||||||
|
<label :for="'checkbox-' + content.id">{{ content.name }}</label><br>
|
||||||
|
<label class="switch">
|
||||||
|
<input type="checkbox" v-model="data[ content.id ]">
|
||||||
|
<span class="slider round"></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="content.dataType === 'textbox'">
|
||||||
|
<label :for="'textarea-' + content.id">{{ content.name }}</label><br>
|
||||||
|
<textarea :id="'textarea-' + content.id" v-model="data[ content.id ]" class="textarea"></textarea>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="content.dataType === 'colour'">
|
||||||
|
<label :for="'colour-' + content.id">{{ content.name }}</label><br>
|
||||||
|
<input type="text" :id="'colour-' + content.id" v-model="data[ content.id ]" class="input">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="contentType === 'html'" v-html="data.message" class="options"></div>
|
|
||||||
<div v-else-if="contentType === 'code'" class="options">
|
|
||||||
<h3>{{ data.message }}</h3>
|
|
||||||
<button @click="copy()" id="code-copy" class="buttons fancy-button">Copy</button>
|
|
||||||
<pre>
|
|
||||||
<code>
|
|
||||||
{{ data.options.code }}
|
|
||||||
</code>
|
|
||||||
</pre>
|
|
||||||
</div>
|
|
||||||
<div v-else-if="contentType === 'long-text'" class="options">
|
|
||||||
<h3>{{ data.message }}</h3>
|
|
||||||
<p>{{ data.options.note }}</p>
|
|
||||||
<textarea cols="80" rows="10" v-model="data.selected" id="text-input"></textarea>
|
|
||||||
<div class="button-wrapper">
|
|
||||||
<button @click="closePopup( 'ok' )" title="Save changes" class="buttons fancy-button">{{ data.options.display.save ?? 'Save' }}</button>
|
|
||||||
<button @click="closePopup( 'cancel' )" title="Cancel changes" class="buttons fancy-button">{{ data.options.display.cancel ?? 'Cancel' }}</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-else-if="contentType === 'text'" class="options">
|
|
||||||
<h3>{{ data.message }}</h3>
|
|
||||||
<input type="text" v-model="data.selected">
|
|
||||||
<p>{{ info }}</p>
|
|
||||||
<div class="button-wrapper">
|
|
||||||
<button @click="closePopup( 'ok' )" title="Save changes" class="buttons fancy-button">{{ data.options.display.save ?? 'Save' }}</button>
|
|
||||||
<button @click="closePopup( 'cancel' )" title="Cancel changes" class="buttons fancy-button">{{ data.options.display.cancel ?? 'Cancel' }}</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-else-if="contentType === 'number'" class="options">
|
|
||||||
<h3>{{ data.message }}</h3>
|
|
||||||
<input type="number" v-model="data.selected">
|
|
||||||
<div class="button-wrapper">
|
|
||||||
<button @click="closePopup( 'ok' )" title="Save changes" class="buttons fancy-button">{{ data.options.display.save ?? 'Save' }}</button>
|
|
||||||
<button @click="closePopup( 'cancel' )" title="Cancel changes" class="buttons fancy-button">{{ data.options.display.cancel ?? 'Cancel' }}</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-else-if="contentType === 'settings'" class="options">
|
|
||||||
<h3>{{ data.message }}</h3>
|
|
||||||
<settings v-model:settings="data.options"></settings>
|
|
||||||
<div class="button-wrapper">
|
|
||||||
<button @click="submitSettings( 'ok' )" title="Save changes" class="buttons fancy-button">Save</button>
|
|
||||||
<button @click="closePopup( 'cancel' )" title="Cancel changes" class="buttons fancy-button">Cancel</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-else-if="contentType === 'confirm'" class="confirm options">
|
|
||||||
<h3>{{ data.message }}</h3>
|
|
||||||
<div class="button-wrapper">
|
|
||||||
<button @click="closePopup( 'ok' )" title="Save changes" class="buttons fancy-button">{{ data.options.ok ?? 'Ok' }}</button>
|
|
||||||
<button @click="closePopup( 'cancel' )" title="Cancel changes" class="buttons fancy-button">{{ data.options.display.cancel ?? 'Cancel' }}</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-else-if="contentType === 'dropdown'" class="options">
|
|
||||||
<h3>{{ data.message }}</h3>
|
|
||||||
<select id="select" v-model="data.selected">
|
|
||||||
<option v-for="selectOption in data.options" :key="selectOption.value" :value="selectOption.value">{{ selectOption.displayName }}</option>
|
|
||||||
</select>
|
|
||||||
<div class="button-wrapper">
|
|
||||||
<button @click="closePopup( 'ok' )" title="Save changes" class="buttons fancy-button">{{ data.options.display.save ?? 'Save' }}</button>
|
|
||||||
<button @click="closePopup( 'cancel' )" title="Cancel changes" class="buttons fancy-button">{{ data.options.display.cancel ?? 'Cancel' }}</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-else-if="contentType === 'selection'" class="options selection">
|
|
||||||
<h3>{{ data.message }}</h3>
|
|
||||||
<div v-for="selectOption in data.options.selections" :key="selectOption.value" class="select-button-wrapper">
|
|
||||||
<button class="select-button" @click="closePopupAdvanced( 'ok', selectOption.value )">{{ selectOption.displayName }}</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-else-if="contentType === 'iframe'" class="options iframe-wrapper">
|
|
||||||
<iframe :src="data.options.link" frameborder="0" class="popup-iframe"></iframe>
|
|
||||||
</div>
|
|
||||||
<div v-else-if="contentType === 'editor'" class="options">
|
|
||||||
<!-- Create the toolbar container -->
|
|
||||||
<h3>{{ data.message }}</h3>
|
|
||||||
<p v-if="data.options.note" v-html="data.options.note"></p>
|
|
||||||
<!-- Optional toggles (added via options object) -->
|
|
||||||
<table class="editor-options">
|
|
||||||
<tr v-for="element in data.options.settings" :key="element.id">
|
|
||||||
<td>
|
|
||||||
{{ element.displayName }}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<input type="text" v-if="element.type === 'text'" v-model="data.selected[ element.id ]">
|
|
||||||
<input type="number" v-else-if="element.type === 'number'" v-model="data.selected[ element.id ]">
|
|
||||||
<input type="email" v-else-if="element.type === 'email'" v-model="data.selected[ element.id ]">
|
|
||||||
<select v-else-if="element.type === 'dropdown'" v-model="data.selected[ element.id ]">
|
|
||||||
<option v-for="el in element.options" :key="el.value" :value="el.value">{{ el.displayName }}</option>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<div id="quill-toolbar">
|
|
||||||
<span class="ql-formats">
|
|
||||||
<select class="ql-font" title="Fonts">
|
|
||||||
<option selected="" title="Default"></option>
|
|
||||||
<option value="serif" title="Serif"></option>
|
|
||||||
<option value="monospace" title="Monospace"></option>
|
|
||||||
</select>
|
|
||||||
<select class="ql-size" title="Font size">
|
|
||||||
<option value="small" title="Small"></option>
|
|
||||||
<option selected="" title="Default"></option>
|
|
||||||
<option value="large" title="Large"></option>
|
|
||||||
<option value="huge" title="Huge"></option>
|
|
||||||
</select>
|
|
||||||
</span>
|
|
||||||
<span class="ql-formats">
|
|
||||||
<button class="ql-bold" title="Bold"></button>
|
|
||||||
<button class="ql-italic" title="Italic"></button>
|
|
||||||
<button class="ql-underline" title="Underlined"></button>
|
|
||||||
<button class="ql-strike" title="Strikethrough"></button>
|
|
||||||
</span>
|
|
||||||
<span class="ql-formats">
|
|
||||||
<select class="ql-color" title="Text colour"></select>
|
|
||||||
<select class="ql-background" title="Background colour"></select>
|
|
||||||
</span>
|
|
||||||
<span class="ql-formats">
|
|
||||||
<button class="ql-list" value="ordered" title="Ordered list"></button>
|
|
||||||
<button class="ql-list" value="bullet" title="Bullet points"></button>
|
|
||||||
<select class="ql-align" title="Alignment">
|
|
||||||
<option selected="" title="left"></option>
|
|
||||||
<option value="center" title="center"></option>
|
|
||||||
<option value="right" title="right"></option>
|
|
||||||
<option value="justify" title="block"></option>
|
|
||||||
</select>
|
|
||||||
</span>
|
|
||||||
<span class="ql-formats">
|
|
||||||
<button class="ql-link" title="Insert link"></button>
|
|
||||||
<button class="ql-image" title="Insert image"></button>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Create the editor container -->
|
|
||||||
<div id="quill-editor">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="message-iframe" v-if="data.selected.oldMsg" style="height: 60vh;">
|
|
||||||
<p>Attached message: </p>
|
|
||||||
<iframe :srcdoc="data.selected.oldMsg" frameborder="0" class="message-iframe"></iframe>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="button-wrapper">
|
|
||||||
<button @click="closePopupEditor()" :title="data.options.saveButtonHint" class="buttons fancy-button">{{ data.options.saveButtonDisplay }}</button>
|
|
||||||
<button @click="closePopup( 'cancel' )" title="Cancel changes" class="buttons fancy-button">Cancel</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div style="margin-top: 20px;">
|
||||||
|
<button @click="closePopup()" style="margin-right: 10px;" class="fancy-button" v-if="popupContent.popupType === 'confirmation'">Cancel</button>
|
||||||
|
<button @click="closePopupReturn()" class="fancy-button">Ok</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- Options to be passed in: html, settings (for settings component), strings, confirm, dropdowns, selection -->
|
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
type PopupType = 'confirmation' | 'information' | 'input';
|
||||||
|
|
||||||
<script>
|
interface PopupData {
|
||||||
import settings from '@/components/settingsOptions.vue';
|
/**
|
||||||
import hljs from 'highlight.js';
|
* What to display to the user in front of the input field
|
||||||
import beautify from 'json-beautify';
|
*/
|
||||||
import Quill from 'quill';
|
name: string;
|
||||||
import( 'quill/dist/quill.snow.css' );
|
|
||||||
|
|
||||||
export default {
|
/**
|
||||||
name: 'popupsHandler',
|
* The type of data to display
|
||||||
components: {
|
*/
|
||||||
settings,
|
dataType: 'text' | 'number' | 'checkbox' | 'textbox' | 'colour';
|
||||||
},
|
|
||||||
props: {
|
/**
|
||||||
size: {
|
* ID that is used for internal usage only. May only contain alphanumerical characters, as well as dashes and underscores
|
||||||
type: String,
|
*/
|
||||||
'default': 'normal',
|
id: string;
|
||||||
},
|
|
||||||
},
|
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
contentType: 'dropdown',
|
|
||||||
data: {
|
|
||||||
options: {
|
|
||||||
display: '',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
info: '',
|
|
||||||
editor: null,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
closePopup( message ) {
|
|
||||||
if ( this.data.options.disallowedCharacters ) {
|
|
||||||
for ( let letter in this.data.selected ) {
|
|
||||||
if ( this.data.options.disallowedCharacters.includes( this.data.selected[ letter ] ) ) {
|
|
||||||
this.info = `Illegal character "${ this.data.selected[ letter ] }"`;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
$( '#popup-backdrop' ).fadeOut( 300 );
|
|
||||||
if ( message ) {
|
|
||||||
this.$emit( 'data', { 'data': this.data.selected, 'status': message } );
|
|
||||||
}
|
|
||||||
},
|
|
||||||
closePopupEditor () {
|
|
||||||
this.data.selected;
|
|
||||||
this.data.selected.mail = document.getElementsByClassName( 'ql-editor' )[ 0 ].innerHTML + ( this.data.selected.oldMsg ?? '' );
|
|
||||||
this.closePopup( 'editor' );
|
|
||||||
},
|
|
||||||
selectTicket ( option ) {
|
|
||||||
let total = 0;
|
|
||||||
for ( let i in this.data.options.count ) {
|
|
||||||
total += this.data.options.count[ i ];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( total < this.data.options.max ) {
|
interface PopupContent {
|
||||||
this.data.options.count[ option ] += 1;
|
/**
|
||||||
|
* The title shown in big letters at the top of the popup
|
||||||
|
*/
|
||||||
|
title: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (OPTIONAL) The subtitle shown to the user in normal sized letters below title
|
||||||
|
*/
|
||||||
|
subtitle?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (OPTIONAL) The message to show, if the user has not filled out all fields
|
||||||
|
*/
|
||||||
|
incompleteMessage?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of popup (i.e. what it is for)
|
||||||
|
*/
|
||||||
|
popupType: PopupType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (REQUIRED ONLY when popupType === 'input') The input fields to show
|
||||||
|
*/
|
||||||
|
data?: PopupData[];
|
||||||
}
|
}
|
||||||
},
|
|
||||||
deselectTicket ( option ) {
|
interface Data {
|
||||||
if ( this.data.options.count[ option ] > 0 ) {
|
[key: string]: any;
|
||||||
this.data.options.count[ option ] -= 1;
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
submitTicket () {
|
import "@melloware/coloris/dist/coloris.css";
|
||||||
// eslint-disable-next-line no-undef
|
import { ref, type Ref } from 'vue';
|
||||||
$( '#popup-backdrop' ).fadeOut( 300 );
|
import Coloris from '@melloware/coloris';
|
||||||
this.$emit( 'ticket', { 'data': this.data.options.count, 'component': this.data.options.id } );
|
|
||||||
},
|
Coloris.init();
|
||||||
closePopupAdvanced ( message, data ) {
|
|
||||||
this.data[ 'selected' ] = data;
|
const isShowingPopup = ref( false );
|
||||||
this.closePopup( message );
|
const transformOriginVertical = ref( '50% 50%' );
|
||||||
},
|
const data: Ref<Data> = ref( {} );
|
||||||
submitSettings () {
|
const isShowingIncomplete = ref( false );
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
$( '#popup-backdrop' ).fadeOut( 300 );
|
const popupContent: Ref<PopupContent> = ref( {
|
||||||
const dat = this.data.options;
|
title: 'Undefined popup title',
|
||||||
let ret = {};
|
popupType: 'information',
|
||||||
for ( let setting in dat ) {
|
subtitle: 'This popup was not configured correctly during development. Please send a bug-report at <a href="https://support.janishutz.com/index.php?a=add&category=7" target="_blank">support.janishutz.com</a> and inform us about where exactly you encountered this popup! We are sorry for the inconvenience'
|
||||||
if ( dat[ setting ][ 'type' ] !== 'link' ) {
|
|
||||||
ret[ setting ] = dat[ setting ][ 'value' ];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.$emit( 'data', { 'data': ret, 'status': 'settings' } );
|
|
||||||
},
|
|
||||||
openPopup ( message, options, dataType, selected ) {
|
|
||||||
this.data = {
|
|
||||||
'message': message ?? 'No message defined on method call!!',
|
|
||||||
'options': options ?? { '1': { 'value': 'undefined', 'displayName': 'No options specified in call' } },
|
|
||||||
'selected': selected ?? ''
|
|
||||||
};
|
|
||||||
this.contentType = dataType ?? 'string';
|
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
$( '#popup-backdrop' ).fadeIn( 300 );
|
|
||||||
if ( dataType === 'code' ) {
|
|
||||||
if ( options.lang === 'json' ) {
|
|
||||||
this.data.options.code = beautify( options.code, null, 2, 50 );
|
|
||||||
}
|
|
||||||
setTimeout( () => {
|
|
||||||
hljs.highlightAll();
|
|
||||||
}, 200 );
|
|
||||||
} else if ( dataType === 'editor' ) {
|
|
||||||
setTimeout( () => {
|
|
||||||
if ( !document.getElementById( 'quill-editor' ).classList.contains( 'ql-container' ) ) {
|
|
||||||
this.editor = new Quill( '#quill-editor', {
|
|
||||||
modules: { toolbar: '#quill-toolbar' },
|
|
||||||
theme: 'snow',
|
|
||||||
} );
|
} );
|
||||||
if ( this.data.selected === '' ) {
|
|
||||||
this.data.selected = {};
|
const closePopup = () => {
|
||||||
|
isShowingPopup.value = false;
|
||||||
|
Coloris.close();
|
||||||
}
|
}
|
||||||
setTimeout( () => {
|
|
||||||
if ( selected.message ) {
|
const closePopupReturn = () => {
|
||||||
console.log( selected.message );
|
for ( let el in popupContent.value.data ) {
|
||||||
document.getElementsByClassName( 'ql-editor' )[ 0 ].innerHTML = selected.message;
|
if ( !data.value[ popupContent.value.data[ parseInt( el ) ].id ] ) {
|
||||||
|
isShowingIncomplete.value = true;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}, 500 );
|
|
||||||
}
|
}
|
||||||
}, 200 );
|
closePopup();
|
||||||
|
if ( popupContent.value.popupType === 'confirmation' ) {
|
||||||
|
emit( 'update', true );
|
||||||
|
} else {
|
||||||
|
emit( 'update', data.value );
|
||||||
}
|
}
|
||||||
},
|
|
||||||
copy() {
|
|
||||||
const codeCopy = document.getElementById( 'code-copy' )
|
|
||||||
codeCopy.innerHTML = 'Copied!';
|
|
||||||
navigator.clipboard.writeText( this.data.options.code );
|
|
||||||
setTimeout( () => {
|
|
||||||
codeCopy.innerHTML = 'Copy';
|
|
||||||
}, 2000 );
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
};
|
const openPopup = ( popupConfig: PopupContent, transformOrigin?: string ) => {
|
||||||
|
if ( transformOrigin ) {
|
||||||
|
transformOriginVertical.value = transformOrigin;
|
||||||
|
} else {
|
||||||
|
transformOriginVertical.value = '50% 50%';
|
||||||
|
}
|
||||||
|
data.value = {};
|
||||||
|
for ( let el in popupConfig.data ) {
|
||||||
|
if ( !popupConfig.data[ parseInt( el ) ].id ) {
|
||||||
|
console.warn( '[ popup ] Missing ID for input with name "' + popupConfig.data[ parseInt( el ) ].name + '"!' );
|
||||||
|
} else if ( popupConfig.data[ parseInt( el ) ].dataType === 'colour' ) {
|
||||||
|
Coloris( { el: '#colour-' + popupConfig.data[ parseInt( el ) ].id } );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isShowingPopup.value = true;
|
||||||
|
popupContent.value = popupConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose( {
|
||||||
|
openPopup,
|
||||||
|
} );
|
||||||
|
|
||||||
|
const emit = defineEmits( [ 'update' ] );
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.message-iframe {
|
.popup-backdrop {
|
||||||
width: 100%;
|
|
||||||
height: 50vh;
|
|
||||||
margin-top: 1%;
|
|
||||||
}
|
|
||||||
|
|
||||||
pre {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
code {
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
#popup-backdrop {
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
z-index: 10;
|
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
background-color: rgba( 0, 0, 0, 0.6 );
|
position: fixed;
|
||||||
display: none;
|
background-color: var( --overlay-color );
|
||||||
}
|
top: 0;
|
||||||
|
left: 0;
|
||||||
.popup-container {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex-direction: column;
|
overflow: hidden;
|
||||||
|
transition: all 0.5s;
|
||||||
|
transform: scale(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#text-input {
|
.incomplete-message {
|
||||||
width: 90%;
|
color: red;
|
||||||
resize: vertical;
|
font-weight: 300;
|
||||||
|
font-style: italic;
|
||||||
|
margin-top: 0;
|
||||||
|
font-size: 0.8rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button-wrapper {
|
.hidden {
|
||||||
width: 100%;
|
transform: scale(0);
|
||||||
margin-top: 3%;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
flex-direction: row;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.close-wrapper {
|
.popup-main {
|
||||||
width: 100%;
|
width: 40%;
|
||||||
height: 5%;
|
height: 50%;
|
||||||
display: flex;
|
background-color: var( --secondary-color );
|
||||||
justify-content: center;
|
padding: 2.5%;
|
||||||
align-items: flex-end;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.close-button {
|
|
||||||
margin-right: 1vw;
|
|
||||||
margin-top: 2vw;
|
|
||||||
font-size: 200%;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.popup {
|
|
||||||
border: none;
|
|
||||||
border-radius: 20px;
|
border-radius: 20px;
|
||||||
background-color: white;
|
position: relative;
|
||||||
width: 90vw;
|
overflow: scroll;
|
||||||
height: 80vh;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.popup-iframe {
|
.close-icon {
|
||||||
width: 100%;
|
position: absolute;
|
||||||
height: 100%;
|
top: 20px;
|
||||||
|
right: 20px;
|
||||||
|
font-size: 2rem;
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.iframe-wrapper {
|
.popup-content {
|
||||||
height: 100%;
|
position: unset;
|
||||||
}
|
height: 60%;
|
||||||
|
|
||||||
.message-container {
|
|
||||||
height: 90%;
|
|
||||||
width: 90%;
|
|
||||||
margin-left: 5%;
|
|
||||||
overflow: scroll;
|
overflow: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
.options {
|
.textarea {
|
||||||
display: flex;
|
width: 80%;
|
||||||
justify-content: center;
|
resize: vertical;
|
||||||
align-items: center;
|
min-height: 30px;
|
||||||
flex-direction: column;
|
border-radius: 10px;
|
||||||
overflow: visible;
|
|
||||||
min-height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.options .buttons {
|
|
||||||
padding: 1% 2%;
|
|
||||||
margin: 5px;
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.options .buttons:hover {
|
|
||||||
background-color: darkgreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
.select-button-wrapper {
|
|
||||||
width: 100%;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.select-button {
|
|
||||||
background-color: rgba( 0, 0, 0, 0 ) !important;
|
|
||||||
color: black !important;
|
|
||||||
padding: 3vh 2vw !important;
|
|
||||||
border: solid black 1px;
|
|
||||||
border-radius: 5px;
|
|
||||||
transition: all 0.5s ease-in-out;
|
|
||||||
margin-bottom: 1vh;
|
|
||||||
width: 90%;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.select-button:hover {
|
|
||||||
background-color: gray !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.controls {
|
|
||||||
user-select: none;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 100%;
|
|
||||||
font-weight: bold;
|
|
||||||
border: solid var( --primary-color ) 1px;
|
border: solid var( --primary-color ) 1px;
|
||||||
border-radius: 100%;
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media only screen and (min-width: 999px) {
|
.input {
|
||||||
.small {
|
padding: 5px;
|
||||||
width: 40%;
|
border-radius: 10px;
|
||||||
height: 40%;
|
border: solid var( --primary-color ) 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.normal {
|
.popup-content-wrapper {
|
||||||
width: 50%;
|
margin-bottom: 10px;
|
||||||
height: 50%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.big {
|
|
||||||
width: 60%;
|
|
||||||
height: 60%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bigger {
|
|
||||||
width: 70%;
|
|
||||||
height: 70%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.huge {
|
|
||||||
width: 80%;
|
|
||||||
height: 80%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#quill-editor, #quill-toolbar {
|
|
||||||
width: 90%;
|
|
||||||
}
|
|
||||||
|
|
||||||
#quill-editor {
|
|
||||||
min-height: 20vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editor-options {
|
|
||||||
width: 80%;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
/* https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_switch */
|
||||||
|
.switch {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
width: 60px;
|
||||||
|
height: 34px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch input {
|
||||||
|
opacity: 0;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slider {
|
||||||
|
position: absolute;
|
||||||
|
cursor: pointer;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background-color: #ccc;
|
||||||
|
-webkit-transition: .4s;
|
||||||
|
transition: .4s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slider:before {
|
||||||
|
position: absolute;
|
||||||
|
content: "";
|
||||||
|
height: 26px;
|
||||||
|
width: 26px;
|
||||||
|
left: 4px;
|
||||||
|
bottom: 4px;
|
||||||
|
background-color: white;
|
||||||
|
-webkit-transition: .4s;
|
||||||
|
transition: .4s;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:checked + .slider {
|
||||||
|
background-color: #2196F3;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:focus + .slider {
|
||||||
|
box-shadow: 0 0 1px #2196F3;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:checked + .slider:before {
|
||||||
|
-webkit-transform: translateX(26px);
|
||||||
|
-ms-transform: translateX(26px);
|
||||||
|
transform: translateX(26px);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Rounded sliders */
|
||||||
|
.slider.round {
|
||||||
|
border-radius: 34px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slider.round:before {
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -136,7 +136,7 @@
|
|||||||
width: 100vw;
|
width: 100vw;
|
||||||
left: 0;
|
left: 0;
|
||||||
transition: all 1s;
|
transition: all 1s;
|
||||||
z-index: 2;
|
z-index: 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
#search-bar.search-shown {
|
#search-bar.search-shown {
|
||||||
|
|||||||
@@ -9,6 +9,6 @@ const app = createApp(App)
|
|||||||
app.use(createPinia())
|
app.use(createPinia())
|
||||||
app.use(router)
|
app.use(router)
|
||||||
|
|
||||||
localStorage.setItem( 'url', 'http://localhost:8081' );
|
localStorage.setItem( 'url', 'http://localhost:8082' );
|
||||||
|
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { createRouter, createWebHistory } from 'vue-router';
|
import { createRouter, createWebHistory } from 'vue-router';
|
||||||
import HomeView from '@/views/HomeView.vue';
|
import HomeView from '@/views/HomeView.vue';
|
||||||
|
import { useUserStore } from '@/stores/userStore';
|
||||||
|
|
||||||
const router = createRouter( {
|
const router = createRouter( {
|
||||||
history: createWebHistory( import.meta.env.BASE_URL ),
|
history: createWebHistory( import.meta.env.BASE_URL ),
|
||||||
@@ -18,7 +19,7 @@ const router = createRouter( {
|
|||||||
name: 'app',
|
name: 'app',
|
||||||
component: () => import( '../views/AppView.vue' ),
|
component: () => import( '../views/AppView.vue' ),
|
||||||
meta: {
|
meta: {
|
||||||
'authRequired': false,
|
'authRequired': true,
|
||||||
'title': 'App'
|
'title': 'App'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -41,30 +42,14 @@ const router = createRouter( {
|
|||||||
// next();
|
// next();
|
||||||
// } );
|
// } );
|
||||||
|
|
||||||
// router.beforeEach( ( to ) => {
|
router.beforeEach( ( to ) => {
|
||||||
// const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
// const isUserAuthenticated = userStore.getUserAuthenticated;
|
const isUserAuthenticated = userStore.getUserAuthenticated;
|
||||||
// const isAdminAuthenticated = userStore.getAdminAuthenticated;
|
if ( !isUserAuthenticated && to.meta.authRequired ) {
|
||||||
|
localStorage.setItem( 'redirect', to.fullPath );
|
||||||
// if ( to.meta.adminAuthRequired && !isAdminAuthenticated ) {
|
return { name: 'home' };
|
||||||
// return { name: 'adminLogin' };
|
}
|
||||||
// } else if ( to.name === 'adminLogin' && isAdminAuthenticated ) {
|
} );
|
||||||
// return { name: 'admin' };
|
|
||||||
// }
|
|
||||||
// // else if ( isUserAuthenticated && to.name === 'login' ) {
|
|
||||||
// // return { name: 'account' };
|
|
||||||
// // }
|
|
||||||
// else if ( !isUserAuthenticated && to.name === 'checkout' ) {
|
|
||||||
// localStorage.setItem( 'redirect', '/checkout' );
|
|
||||||
// return { name: 'login' };
|
|
||||||
// } else if ( !isUserAuthenticated && to.meta.authRequired ) {
|
|
||||||
// localStorage.setItem( 'redirect', to.fullPath );
|
|
||||||
// return { name: 'login' };
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // TODO: Make titles adapt to languages as well
|
|
||||||
// // TODO: Make multi-lang
|
|
||||||
// } );
|
|
||||||
|
|
||||||
router.afterEach( ( to ) => {
|
router.afterEach( ( to ) => {
|
||||||
window.scrollTo( { top: 0, behavior: 'smooth' } );
|
window.scrollTo( { top: 0, behavior: 'smooth' } );
|
||||||
|
|||||||
@@ -13,11 +13,15 @@ import { io, type Socket } from "socket.io-client"
|
|||||||
|
|
||||||
class NotificationHandler {
|
class NotificationHandler {
|
||||||
socket: Socket;
|
socket: Socket;
|
||||||
|
roomName: string;
|
||||||
|
roomToken: string;
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
this.socket = io( localStorage.getItem( 'url' ) ?? '', {
|
this.socket = io( localStorage.getItem( 'url' ) ?? '', {
|
||||||
autoConnect: false,
|
autoConnect: false,
|
||||||
} );
|
} );
|
||||||
|
this.roomName = '';
|
||||||
|
this.roomToken = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,19 +29,36 @@ class NotificationHandler {
|
|||||||
* @param {string} roomName
|
* @param {string} roomName
|
||||||
* @returns {Promise<string>}
|
* @returns {Promise<string>}
|
||||||
*/
|
*/
|
||||||
connect ( roomName: string ): Promise<string> {
|
connect ( roomName: string ): Promise<void> {
|
||||||
fetch( localStorage.getItem( 'url' ) + '/createRoomToken', { credentials: 'include' } ).then( res => {
|
return new Promise( ( resolve, reject ) => {
|
||||||
|
fetch( localStorage.getItem( 'url' ) + '/createRoomToken?roomName=' + roomName, { credentials: 'include' } ).then( res => {
|
||||||
if ( res.status === 200 ) {
|
if ( res.status === 200 ) {
|
||||||
res.json().then( json => {
|
res.text().then( text => {
|
||||||
|
this.roomToken = text;
|
||||||
} );
|
this.roomName = roomName;
|
||||||
|
this.socket.connect();
|
||||||
|
this.socket.emit( 'create-room', {
|
||||||
|
name: this.roomName,
|
||||||
|
token: this.roomToken
|
||||||
|
}, ( res: { status: boolean, msg: string } ) => {
|
||||||
|
if ( res.status === true) {
|
||||||
|
resolve();
|
||||||
|
} else {
|
||||||
|
reject( 'ERR_ROOM_CONNECTING' );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
} );
|
||||||
|
} else if ( res.status === 409 ) {
|
||||||
|
reject( 'ERR_CONFLICT' );
|
||||||
|
} else {
|
||||||
|
reject( 'ERR_ROOM_CREATING' );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description
|
* Emit an event
|
||||||
* @param {string} event The event to emit
|
* @param {string} event The event to emit
|
||||||
* @param {any} data
|
* @param {any} data
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
@@ -46,12 +67,30 @@ class NotificationHandler {
|
|||||||
this.socket.emit( event, data );
|
this.socket.emit( event, data );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a listener function for an event
|
||||||
|
* @param {string} event The event to listen for
|
||||||
|
* @param {( data: any ) => void} cb The callback function / listener function
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
registerListener ( event: string, cb: ( data: any ) => void ): void {
|
registerListener ( event: string, cb: ( data: any ) => void ): void {
|
||||||
this.socket.on( event, cb );
|
this.socket.on( event, cb );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disconnect from the server
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
disconnect (): void {
|
disconnect (): void {
|
||||||
this.socket.disconnect();
|
this.socket.disconnect();
|
||||||
|
this.socket.emit( 'create-room', {
|
||||||
|
name: this.roomName,
|
||||||
|
token: this.roomToken
|
||||||
|
}, ( res: { status: boolean, msg: string } ) => {
|
||||||
|
if ( !res.status ) {
|
||||||
|
alert( 'Unable to delete the room you were just in. The name will be blocked until the next server restart!' );
|
||||||
|
}
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
import playerView from '@/components/playerView.vue';
|
import playerView from '@/components/playerView.vue';
|
||||||
import libraryView from '@/components/libraryView.vue';
|
import libraryView from '@/components/libraryView.vue';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import type { ReadFile } from '@/scripts/song';
|
import type { ReadFile } from '@/scripts/song';
|
||||||
|
|
||||||
const isLoggedIntoAppleMusic = ref( false );
|
const isLoggedIntoAppleMusic = ref( false );
|
||||||
const isReady = ref( false );
|
const isReady = ref( false );
|
||||||
@@ -37,6 +37,7 @@ import type { ReadFile } from '@/scripts/song';
|
|||||||
let loginChecker = 0;
|
let loginChecker = 0;
|
||||||
|
|
||||||
const logIntoAppleMusic = () => {
|
const logIntoAppleMusic = () => {
|
||||||
|
player.value.logIntoAppleMusic();
|
||||||
loginChecker = setInterval( () => {
|
loginChecker = setInterval( () => {
|
||||||
if ( player.value.getAuth()[ 0 ] ) {
|
if ( player.value.getAuth()[ 0 ] ) {
|
||||||
isLoggedIntoAppleMusic.value = true;
|
isLoggedIntoAppleMusic.value = true;
|
||||||
|
|||||||
@@ -1,19 +1,70 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="home-view">
|
<div class="home-view">
|
||||||
<img src="https://github.com/simplePCBuilding/MusicPlayerV2/raw/master/assets/logo.png" alt="MusicPlayer Logo" class="logo">
|
<img src="https://github.com/simplePCBuilding/MusicPlayerV2/raw/master/assets/logo.png" alt="MusicPlayer Logo" class="logo">
|
||||||
<button @click="login()" class="fancy-button">Log in / Sign up</button>
|
<button :class="'fancy-button' + ( isTryingToSignIn ? ' fancy-button-inactive' : '' )" @click="login()"
|
||||||
|
style="margin-top: 5vh;" title="Sign in or sign up with janishutz.com ID" v-if="status"
|
||||||
|
>{{ isTryingToSignIn ? 'Signing you in...' : 'Login / Sign up' }}</button>
|
||||||
|
<p v-else>We are sorry, but we were unable to initialize the login services. Please reload the page if you wish to retry!</p>
|
||||||
<p>MusicPlayer is a browser based Music Player, that allows you to connect other devices, simply with another web-browser, where you can see the current playlist with sleek animations. You can log in using your Apple Music account or load a playlist from your local disk, simply by selecting the songs using a file picker.</p>
|
<p>MusicPlayer is a browser based Music Player, that allows you to connect other devices, simply with another web-browser, where you can see the current playlist with sleek animations. You can log in using your Apple Music account or load a playlist from your local disk, simply by selecting the songs using a file picker.</p>
|
||||||
|
<notificationsModule ref="notifications" location="bottomleft" size="bigger"></notificationsModule>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import router from '@/router';
|
import router from '@/router';
|
||||||
|
import { useUserStore } from '@/stores/userStore';
|
||||||
|
import notificationsModule from '@/components/notificationsModule.vue';
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
const notifications = ref( notificationsModule );
|
||||||
|
const isTryingToSignIn = ref( true );
|
||||||
|
|
||||||
|
interface JanishutzIDSDK {
|
||||||
|
setLoginSDKURL: ( url: string ) => undefined;
|
||||||
|
createSession: () => undefined;
|
||||||
|
verifySession: () => Promise<JHIDSessionStatus>
|
||||||
|
}
|
||||||
|
|
||||||
|
interface JHIDSessionStatus {
|
||||||
|
status: boolean;
|
||||||
|
username: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
let sdk: JanishutzIDSDK;
|
||||||
|
const status = ref( true );
|
||||||
|
|
||||||
|
if ( typeof( JanishutzID ) !== 'undefined' ) {
|
||||||
|
sdk = JanishutzID();
|
||||||
|
sdk.setLoginSDKURL( localStorage.getItem( 'url' ) ?? '' );
|
||||||
|
} else {
|
||||||
|
setTimeout( () => {
|
||||||
|
notifications.value.createNotification( 'Unable to initialize account services!', 5, 'error' );
|
||||||
|
}, 1000 );
|
||||||
|
status.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
const login = () => {
|
const login = () => {
|
||||||
alert( 'Logging in...' );
|
sdk.createSession();
|
||||||
// TODO: Actually implement with sdk, then check if user has subscription for product, if so, have them proceed to /app
|
}
|
||||||
// else: proceed to /purchase where they get linked to https://store.janishutz.com/product/com.janishutz.MusicPlayer
|
|
||||||
router.push( '/app' );
|
const store = useUserStore();
|
||||||
|
|
||||||
|
if ( store.isUserAuth ) {
|
||||||
|
router.push( localStorage.getItem( 'redirect' ) ?? '/app' );
|
||||||
|
localStorage.removeItem( 'redirect' );
|
||||||
|
} else {
|
||||||
|
if ( typeof( sdk ) !== 'undefined' ) {
|
||||||
|
sdk.verifySession().then( res => {
|
||||||
|
if ( res.status ) {
|
||||||
|
store.isUserAuth = true;
|
||||||
|
store.username = res.username;
|
||||||
|
router.push( localStorage.getItem( 'redirect' ) ?? '/app' );
|
||||||
|
localStorage.removeItem( 'redirect' );
|
||||||
|
} else {
|
||||||
|
isTryingToSignIn.value = false;
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
0
MusicPlayerV2-GUI/src/views/RemoteView.vue
Normal file
0
MusicPlayerV2-GUI/src/views/RemoteView.vue
Normal file
@@ -0,0 +1,420 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div class="info">Designed and developed by Janis Hutz <a href="https://janishutz.com" target="_blank" style="text-decoration: none; color: white;">https://janishutz.com</a></div>
|
||||||
|
<div class="content" id="app">
|
||||||
|
<div v-if="hasLoaded" style="width: 100%">
|
||||||
|
<div class="current-song-wrapper">
|
||||||
|
<span class="material-symbols-outlined fancy-view-song-art" v-if="!playingSong.hasCoverArt">music_note</span>
|
||||||
|
<img v-else-if="playingSong.hasCoverArt && playingSong.coverArtOrigin === 'api'" :src="playingSong.coverArtURL" class="fancy-view-song-art" id="current-image" crossorigin="anonymous">
|
||||||
|
<img v-else :src="'/getSongCover?filename=' + playingSong.filename" class="fancy-view-song-art" id="current-image">
|
||||||
|
<div class="current-song">
|
||||||
|
<progress max="1000" id="progress" :value="progressBar"></progress>
|
||||||
|
<h1>{{ playingSong.title }}</h1>
|
||||||
|
<p class="dancing-style" v-if="playingSong.dancingStyle">{{ playingSong.dancingStyle }}</p>
|
||||||
|
<p>{{ playingSong.artist }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mode-selector-wrapper">
|
||||||
|
<select v-model="visualizationSettings" @change="setVisualization()">
|
||||||
|
<option value="mic">Microphone (Mic access required)</option>
|
||||||
|
<option value="bpm">BPM (might not be 100% accurate)</option>
|
||||||
|
<option value="off">No visualization except background</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="song-list-wrapper">
|
||||||
|
<div v-for="song in songQueue" class="song-list">
|
||||||
|
<span class="material-symbols-outlined song-image" v-if="!song.hasCoverArt && ( playingSong.filename !== song.filename || isPlaying )">music_note</span>
|
||||||
|
<img v-else-if="song.hasCoverArt && ( playingSong.filename !== song.filename || isPlaying ) && song.coverArtOrigin === 'api'" :src="song.coverArtURL" class="song-image">
|
||||||
|
<img v-else-if="song.hasCoverArt && ( playingSong.filename !== song.filename || isPlaying ) && song.coverArtOrigin !== 'api'" :src="'/getSongCover?filename=' + song.filename" class="song-image">
|
||||||
|
<div v-if="playingSong.filename === song.filename && isPlaying" class="playing-symbols">
|
||||||
|
<div class="playing-symbols-wrapper">
|
||||||
|
<div class="playing-bar" id="bar-1"></div>
|
||||||
|
<div class="playing-bar" id="bar-2"></div>
|
||||||
|
<div class="playing-bar" id="bar-3"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span class="material-symbols-outlined pause-icon" v-if="!isPlaying && playingSong.filename === song.filename">pause</span>
|
||||||
|
<div class="song-details-wrapper">
|
||||||
|
<h3>{{ song.title }}</h3>
|
||||||
|
<p>{{ song.artist }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="time-until">
|
||||||
|
{{ getTimeUntil( song ) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- <img :src="" alt=""> -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<h1>Loading...</h1>
|
||||||
|
</div>
|
||||||
|
<div class="background" id="background">
|
||||||
|
<div class="beat"></div>
|
||||||
|
<div class="beat-manual"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- TODO: Get ColorThief either from CDN or preferably as NPM module -->
|
||||||
|
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/color-thief/2.3.0/color-thief.umd.js"></script> -->
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type { Song } from '@/scripts/song';
|
||||||
|
import { ref, type Ref } from 'vue';
|
||||||
|
import { ColorThief } from 'colorthief';
|
||||||
|
|
||||||
|
const hasLoaded = ref( false );
|
||||||
|
const songs: Ref<Song[]> = ref( [] );
|
||||||
|
const playingSong = ref( 0 );
|
||||||
|
const isPlaying = ref( false );
|
||||||
|
const pos = ref( 0 );
|
||||||
|
const colourPalette: string[] = [];
|
||||||
|
const progressBar = ref( 0 );
|
||||||
|
const timeTracker = ref( 0 );
|
||||||
|
const visualizationSettings = ref( 'mic' );
|
||||||
|
const micAnalyzer = ref( 0 );
|
||||||
|
const beatDetected = ref( false );
|
||||||
|
colorThief: null,
|
||||||
|
lastDispatch: new Date().getTime() - 5000,
|
||||||
|
isReconnecting: false,
|
||||||
|
computed: {
|
||||||
|
songQueue() {
|
||||||
|
let ret = [];
|
||||||
|
let pos = 0;
|
||||||
|
for ( let song in this.songs ) {
|
||||||
|
if ( pos >= this.queuePos ) {
|
||||||
|
ret.push( this.songs[ song ] );
|
||||||
|
}
|
||||||
|
pos += 1;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
getTimeUntil() {
|
||||||
|
return ( song ) => {
|
||||||
|
let timeRemaining = 0;
|
||||||
|
for ( let i = this.queuePos; i < Object.keys( this.songs ).length - 1; i++ ) {
|
||||||
|
if ( this.songs[ i ] == song ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
timeRemaining += parseInt( this.songs[ i ].duration );
|
||||||
|
}
|
||||||
|
if ( this.isPlaying ) {
|
||||||
|
if ( timeRemaining === 0 ) {
|
||||||
|
return 'Currently playing';
|
||||||
|
} else {
|
||||||
|
return 'Playing in less than ' + Math.ceil( timeRemaining / 60 - this.pos / 60 ) + 'min';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ( timeRemaining === 0 ) {
|
||||||
|
return 'Plays next';
|
||||||
|
} else {
|
||||||
|
return 'Playing less than ' + Math.ceil( timeRemaining / 60 - this.pos / 60 ) + 'min after starting to play';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
startTimeTracker () {
|
||||||
|
this.timeTracker = setInterval( () => {
|
||||||
|
this.pos = ( new Date().getTime() - this.playingSong.startTime ) / 1000 + this.oldPos;
|
||||||
|
this.progressBar = ( this.pos / this.playingSong.duration ) * 1000;
|
||||||
|
if ( isNaN( this.progressBar ) ) {
|
||||||
|
this.progressBar = 0;
|
||||||
|
}
|
||||||
|
}, 100 );
|
||||||
|
},
|
||||||
|
stopTimeTracker () {
|
||||||
|
clearInterval( this.timeTracker );
|
||||||
|
this.oldPos = this.pos;
|
||||||
|
},
|
||||||
|
getImageData() {
|
||||||
|
return new Promise( ( resolve, reject ) => {
|
||||||
|
if ( this.playingSong.hasCoverArt ) {
|
||||||
|
setTimeout( () => {
|
||||||
|
const img = document.getElementById( 'current-image' );
|
||||||
|
if ( img.complete ) {
|
||||||
|
resolve( this.colorThief.getPalette( img ) );
|
||||||
|
} else {
|
||||||
|
img.addEventListener( 'load', () => {
|
||||||
|
resolve( this.colorThief.getPalette( img ) );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
}, 500 );
|
||||||
|
} else {
|
||||||
|
reject( 'no image' );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
connect() {
|
||||||
|
this.colorThief = new ColorThief();
|
||||||
|
let source = new EventSource( '/clientDisplayNotifier', { withCredentials: true } );
|
||||||
|
source.onmessage = ( e ) => {
|
||||||
|
let data;
|
||||||
|
try {
|
||||||
|
data = JSON.parse( e.data );
|
||||||
|
} catch ( err ) {
|
||||||
|
data = { 'type': e.data };
|
||||||
|
}
|
||||||
|
if ( data.type === 'basics' ) {
|
||||||
|
this.isPlaying = data.data.isPlaying ?? false;
|
||||||
|
this.playingSong = data.data.playingSong ?? {};
|
||||||
|
this.songs = data.data.songQueue ?? [];
|
||||||
|
this.pos = data.data.pos ?? 0;
|
||||||
|
this.oldPos = data.data.pos ?? 0;
|
||||||
|
this.progressBar = this.pos / this.playingSong.duration * 1000;
|
||||||
|
this.queuePos = data.data.queuePos ?? 0;
|
||||||
|
this.getImageData().then( palette => {
|
||||||
|
this.colourPalette = palette;
|
||||||
|
this.handleBackground();
|
||||||
|
} ).catch( () => {
|
||||||
|
this.colourPalette = [ { 'r': 255, 'g': 0, 'b': 0 }, { 'r': 0, 'g': 255, 'b': 0 }, { 'r': 0, 'g': 0, 'b': 255 } ];
|
||||||
|
this.handleBackground();
|
||||||
|
} );
|
||||||
|
} else if ( data.type === 'pos' ) {
|
||||||
|
this.pos = data.data;
|
||||||
|
this.oldPos = data.data;
|
||||||
|
this.progressBar = data.data / this.playingSong.duration * 1000;
|
||||||
|
} else if ( data.type === 'isPlaying' ) {
|
||||||
|
this.isPlaying = data.data;
|
||||||
|
this.handleBackground();
|
||||||
|
} else if ( data.type === 'songQueue' ) {
|
||||||
|
this.songs = data.data;
|
||||||
|
} else if ( data.type === 'playingSong' ) {
|
||||||
|
this.playingSong = data.data;
|
||||||
|
this.getImageData().then( palette => {
|
||||||
|
this.colourPalette = palette;
|
||||||
|
this.handleBackground();
|
||||||
|
} ).catch( () => {
|
||||||
|
this.colourPalette = [ [ 255, 0, 0 ], [ 0, 255, 0 ], [ 0, 0, 255 ] ];
|
||||||
|
this.handleBackground();
|
||||||
|
} );
|
||||||
|
} else if ( data.type === 'queuePos' ) {
|
||||||
|
this.queuePos = data.data;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
source.onopen = () => {
|
||||||
|
this.isReconnecting = false;
|
||||||
|
this.hasLoaded = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
let self = this;
|
||||||
|
|
||||||
|
source.addEventListener( 'error', function( e ) {
|
||||||
|
if ( e.eventPhase == EventSource.CLOSED ) source.close();
|
||||||
|
|
||||||
|
if ( e.target.readyState == EventSource.CLOSED ) {
|
||||||
|
console.log( 'disconnected' );
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Notify about disconnect
|
||||||
|
setTimeout( () => {
|
||||||
|
if ( !self.isReconnecting ) {
|
||||||
|
self.isReconnecting = true;
|
||||||
|
self.tryReconnect();
|
||||||
|
}
|
||||||
|
}, 1000 );
|
||||||
|
}, false );
|
||||||
|
},
|
||||||
|
tryReconnect() {
|
||||||
|
const int = setInterval( () => {
|
||||||
|
if ( !this.isReconnecting ) {
|
||||||
|
clearInterval( int );
|
||||||
|
} else {
|
||||||
|
connectToSSESource();
|
||||||
|
}
|
||||||
|
}, 1000 );
|
||||||
|
},
|
||||||
|
handleBackground() {
|
||||||
|
let colourDetails = [];
|
||||||
|
let colours = [];
|
||||||
|
let differentEnough = true;
|
||||||
|
if ( this.colourPalette[ 0 ] ) {
|
||||||
|
for ( let i in this.colourPalette ) {
|
||||||
|
for ( let colour in colourDetails ) {
|
||||||
|
const colourDiff = ( Math.abs( colourDetails[ colour ][ 0 ] - this.colourPalette[ i ][ 0 ] ) / 255
|
||||||
|
+ Math.abs( colourDetails[ colour ][ 1 ] - this.colourPalette[ i ][ 1 ] ) / 255
|
||||||
|
+ Math.abs( colourDetails[ colour ][ 2 ] - this.colourPalette[ i ][ 2 ] ) / 255 ) / 3 * 100;
|
||||||
|
if ( colourDiff > 15 ) {
|
||||||
|
differentEnough = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( differentEnough ) {
|
||||||
|
colourDetails.push( this.colourPalette[ i ] );
|
||||||
|
colours.push( 'rgb(' + this.colourPalette[ i ][ 0 ] + ',' + this.colourPalette[ i ][ 1 ] + ',' + this.colourPalette[ i ][ 2 ] + ')' );
|
||||||
|
}
|
||||||
|
differentEnough = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let outColours = 'conic-gradient(';
|
||||||
|
if ( colours.length < 3 ) {
|
||||||
|
for ( let i = 0; i < 3; i++ ) {
|
||||||
|
if ( colours[ i ] ) {
|
||||||
|
outColours += colours[ i ] + ',';
|
||||||
|
} else {
|
||||||
|
if ( i === 0 ) {
|
||||||
|
outColours += 'blue,';
|
||||||
|
} else if ( i === 1 ) {
|
||||||
|
outColours += 'green,';
|
||||||
|
} else if ( i === 2 ) {
|
||||||
|
outColours += 'red,';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ( colours.length < 11 ) {
|
||||||
|
for ( let i in colours ) {
|
||||||
|
outColours += colours[ i ] + ',';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for ( let i = 0; i < 10; i++ ) {
|
||||||
|
outColours += colours[ i ] + ',';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outColours += colours[ 0 ] ?? 'blue' + ')';
|
||||||
|
|
||||||
|
$( '#background' ).css( 'background', outColours );
|
||||||
|
this.setVisualization();
|
||||||
|
},
|
||||||
|
setVisualization () {
|
||||||
|
if ( Object.keys( this.playingSong ).length > 0 ) {
|
||||||
|
if ( this.visualizationSettings === 'bpm' ) {
|
||||||
|
if ( this.playingSong.bpm && this.isPlaying ) {
|
||||||
|
$( '.beat' ).show();
|
||||||
|
$( '.beat' ).css( 'animation-duration', 60 / this.playingSong.bpm );
|
||||||
|
$( '.beat' ).css( 'animation-delay', this.pos % ( 60 / this.playingSong.bpm * this.pos ) + this.playingSong.bpmOffset - ( 60 / this.playingSong.bpm * this.pos / 2 ) );
|
||||||
|
} else {
|
||||||
|
$( '.beat' ).hide();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
clearInterval( this.micAnalyzer );
|
||||||
|
} catch ( err ) {}
|
||||||
|
} else if ( this.visualizationSettings === 'off' ) {
|
||||||
|
$( '.beat' ).hide();
|
||||||
|
try {
|
||||||
|
clearInterval( this.micAnalyzer );
|
||||||
|
} catch ( err ) {}
|
||||||
|
} else if ( this.visualizationSettings === 'mic' ) {
|
||||||
|
$( '.beat-manual' ).hide();
|
||||||
|
try {
|
||||||
|
clearInterval( this.micAnalyzer );
|
||||||
|
} catch ( err ) {}
|
||||||
|
this.micAudioHandler();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log( 'not playing yet' );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
micAudioHandler () {
|
||||||
|
const audioContext = new ( window.AudioContext || window.webkitAudioContext )();
|
||||||
|
const analyser = audioContext.createAnalyser();
|
||||||
|
analyser.fftSize = 256;
|
||||||
|
const bufferLength = analyser.frequencyBinCount;
|
||||||
|
const dataArray = new Uint8Array( bufferLength );
|
||||||
|
|
||||||
|
navigator.mediaDevices.getUserMedia( { audio: true } ).then( ( stream ) => {
|
||||||
|
const mic = audioContext.createMediaStreamSource( stream );
|
||||||
|
mic.connect( analyser );
|
||||||
|
analyser.getByteFrequencyData( dataArray );
|
||||||
|
let prevSpectrum = null;
|
||||||
|
let threshold = 10; // Adjust as needed
|
||||||
|
this.beatDetected = false;
|
||||||
|
this.micAnalyzer = setInterval( () => {
|
||||||
|
analyser.getByteFrequencyData( dataArray );
|
||||||
|
// Convert the frequency data to a numeric array
|
||||||
|
const currentSpectrum = Array.from( dataArray );
|
||||||
|
|
||||||
|
if ( prevSpectrum ) {
|
||||||
|
// Calculate the spectral flux
|
||||||
|
const flux = this.calculateSpectralFlux( prevSpectrum, currentSpectrum );
|
||||||
|
|
||||||
|
if ( flux > threshold && !this.beatDetected ) {
|
||||||
|
// Beat detected
|
||||||
|
this.beatDetected = true;
|
||||||
|
this.animateBeat();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
prevSpectrum = currentSpectrum;
|
||||||
|
}, 20 );
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
animateBeat () {
|
||||||
|
$( '.beat-manual' ).stop();
|
||||||
|
const duration = Math.ceil( 60 / ( this.playingSong.bpm ?? 180 ) * 500 ) - 50;
|
||||||
|
$( '.beat-manual' ).fadeIn( 50 );
|
||||||
|
setTimeout( () => {
|
||||||
|
$( '.beat-manual' ).fadeOut( duration );
|
||||||
|
setTimeout( () => {
|
||||||
|
$( '.beat-manual' ).stop();
|
||||||
|
this.beatDetected = false;
|
||||||
|
}, duration );
|
||||||
|
}, 50 );
|
||||||
|
},
|
||||||
|
calculateSpectralFlux( prevSpectrum, currentSpectrum ) {
|
||||||
|
let flux = 0;
|
||||||
|
|
||||||
|
for ( let i = 0; i < prevSpectrum.length; i++ ) {
|
||||||
|
const diff = currentSpectrum[ i ] - prevSpectrum[ i ];
|
||||||
|
flux += Math.max( 0, diff );
|
||||||
|
}
|
||||||
|
|
||||||
|
return flux;
|
||||||
|
},
|
||||||
|
notifier() {
|
||||||
|
if ( parseInt( this.lastDispatch ) + 5000 < new Date().getTime() ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
Notification.requestPermission();
|
||||||
|
|
||||||
|
console.warn( '[ notifier ]: Status is now enabled \n\n-> Any leaving or tampering with the website will send a notification to the host' );
|
||||||
|
// Detect if window is currently in focus
|
||||||
|
window.onblur = () => {
|
||||||
|
this.sendNotification( 'blur' );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detect if browser window becomes hidden (also with blur event)
|
||||||
|
document.onvisibilitychange = () => {
|
||||||
|
if ( document.visibilityState === 'hidden' ) {
|
||||||
|
this.sendNotification( 'visibility' );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
sendNotification( notification ) {
|
||||||
|
let fetchOptions = {
|
||||||
|
method: 'post',
|
||||||
|
body: JSON.stringify( { 'type': notification } ),
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'charset': 'utf-8'
|
||||||
|
},
|
||||||
|
};
|
||||||
|
fetch( '/clientStatusUpdate', fetchOptions ).catch( err => {
|
||||||
|
console.error( err );
|
||||||
|
} );
|
||||||
|
|
||||||
|
new Notification( 'YOU ARE UNDER SURVEILLANCE', {
|
||||||
|
body: 'Please return to the original webpage immediately!',
|
||||||
|
requireInteraction: true,
|
||||||
|
} )
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.connect();
|
||||||
|
this.notifier();
|
||||||
|
// if ( this.visualizationSettings === 'mic' ) {
|
||||||
|
// this.micAudioHandler();
|
||||||
|
// }
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
isPlaying( value ) {
|
||||||
|
if ( value ) {
|
||||||
|
this.startTimeTracker();
|
||||||
|
} else {
|
||||||
|
this.stopTimeTracker();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} ).mount( '#app' );
|
||||||
|
|
||||||
|
</script>
|
||||||
@@ -27,6 +27,6 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
port: 8080
|
port: 8081
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,5 +2,6 @@
|
|||||||
"token": "phafowegoväbwpb$weapvbpvfwcvfäawef39'ü0wtäqgpt5^ü62q'ẗ9wäa3g",
|
"token": "phafowegoväbwpb$weapvbpvfwcvfäawef39'ü0wtäqgpt5^ü62q'ẗ9wäa3g",
|
||||||
"name": "localhost:8082",
|
"name": "localhost:8082",
|
||||||
"client": "localhost:8081",
|
"client": "localhost:8081",
|
||||||
"backendURL": "http://localhost:8080"
|
"backendURL": "http://localhost:8080",
|
||||||
|
"failReturnURL": "http://localhost:8081"
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,23 @@ const run = () => {
|
|||||||
cb( {
|
cb( {
|
||||||
status: true,
|
status: true,
|
||||||
msg: 'ADDED_TO_ROOM'
|
msg: 'ADDED_TO_ROOM'
|
||||||
} )
|
} );
|
||||||
|
} else {
|
||||||
|
cb( {
|
||||||
|
status: false,
|
||||||
|
msg: 'ERR_TOKEN_INVALID'
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
socket.on( 'delete-room', ( room: { name: string, token: string }, cb: ( res: { status: boolean, msg: string } ) => void ) => {
|
||||||
|
if ( room.token === socketData[ room.name ].roomToken ) {
|
||||||
|
socket.leave( room.name );
|
||||||
|
socketData[ room.name ] = undefined;
|
||||||
|
cb( {
|
||||||
|
status: true,
|
||||||
|
msg: 'ROOM_DELETED'
|
||||||
|
} );
|
||||||
} else {
|
} else {
|
||||||
cb( {
|
cb( {
|
||||||
status: false,
|
status: false,
|
||||||
@@ -193,7 +209,7 @@ const run = () => {
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
const PORT = process.env.PORT || 8081;
|
const PORT = process.env.PORT || 8082;
|
||||||
httpServer.listen( PORT );
|
httpServer.listen( PORT );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user