made startApp function cleaner, updated package name to 0.1.6 because of alpha 5 release , updated README.md

This commit is contained in:
Roberto Tonino 2020-05-15 22:21:31 +02:00
parent f371aa157a
commit cf3331d94b
9 changed files with 130 additions and 106 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "deemix", "name": "deemix",
"version": "0.1.0-alpha", "version": "0.1.6",
"homepage": "https://notabug.org/RemixDev/deemix/src/master/README.md", "homepage": "https://notabug.org/RemixDev/deemix/src/master/README.md",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -313,7 +313,7 @@ <h1>No Playlists found</h1>
<div id="home_tab" class="main_tabcontent"> <div id="home_tab" class="main_tabcontent">
<h2 class="page_heading">Welcome to deemix</h2> <h2 class="page_heading">Welcome to deemix</h2>
<section id="home_not_logged_in" class="home_section"> <section id="home_not_logged_in" class="home_section" ref="notLogged">
<p id="home_not_logged_text">You need to log into your deezer account before you can start downloading. <p id="home_not_logged_text">You need to log into your deezer account before you can start downloading.
</p> </p>
<button type="button" name="button" @click="openSettings">Open Settings</button> <button type="button" name="button" @click="openSettings">Open Settings</button>
@ -575,7 +575,7 @@ <h2 v-else-if="type == 'album'">by <span class="clickable" @click="artistView"
<div id="settings_tab" class="main_tabcontent fixed_footer"> <div id="settings_tab" class="main_tabcontent fixed_footer">
<h2 class="page_heading">Settings</h2> <h2 class="page_heading">Settings</h2>
<div id="logged_in_info"> <div id="logged_in_info" ref="loggedInInfo">
<img id="settings_picture" src="" alt="Profile Picture" class="circle" /> <img id="settings_picture" src="" alt="Profile Picture" class="circle" />
<p>You are logged in as <strong id="settings_username"></strong></p> <p>You are logged in as <strong id="settings_username"></strong></p>
<button id="settings_btn_logout" @click="logout">Logout</button> <button id="settings_btn_logout" @click="logout">Logout</button>

View File

@ -11266,6 +11266,11 @@ function init() {
listEl = document.getElementById('download_list'); listEl = document.getElementById('download_list');
dragHandlerEl = document.getElementById('download_tab_drag_handler'); dragHandlerEl = document.getElementById('download_tab_drag_handler');
// Check if download tab has slim entries
if ('true' === localStorage.getItem('slimDownloads')) {
listEl.classList.add('slim');
}
// Check if download tab should be open // Check if download tab should be open
if ('true' === localStorage.getItem('downloadTabOpen')) { if ('true' === localStorage.getItem('downloadTabOpen')) {
tabContainerEl.classList.remove('tab_hidden'); tabContainerEl.classList.remove('tab_hidden');
@ -11350,8 +11355,8 @@ function addToQueue(queueItem, current = false) {
} else { } else {
if (queue.indexOf(queueItem.uuid) == -1) queue.push(queueItem.uuid); if (queue.indexOf(queueItem.uuid) == -1) queue.push(queueItem.uuid);
} }
let queueDOM = document.getElementById("download_"+queueItem.uuid); let queueDOM = document.getElementById('download_' + queueItem.uuid);
if (typeof(queueDOM) == 'undefined' || queueDOM == null){ if (typeof queueDOM == 'undefined' || queueDOM == null) {
jquery(listEl).append( jquery(listEl).append(
`<div class="download_object" id="download_${queueItem.uuid}" data-deezerid="${queueItem.id}"> `<div class="download_object" id="download_${queueItem.uuid}" data-deezerid="${queueItem.id}">
<div class="download_info"> <div class="download_info">
@ -41378,7 +41383,7 @@ const HomeTab = new Vue({
albumView, albumView,
playlistView, playlistView,
openSettings(e) { openSettings(e) {
document.getElementById("main_settings_tablink").click(); document.getElementById('main_settings_tablink').click();
}, },
addToQueue(e) { addToQueue(e) {
e.stopPropagation(); e.stopPropagation();
@ -41393,6 +41398,10 @@ const HomeTab = new Vue({
} }
}, },
mounted() { mounted() {
if (localStorage.getItem('arl')) {
this.$refs.notLogged.classList.add('hide');
}
socket.on('init_home', this.initHome); socket.on('init_home', this.initHome);
} }
}).$mount('#home_tab'); }).$mount('#home_tab');
@ -41600,17 +41609,24 @@ const SettingsTab = new Vue({
} }
}, },
mounted() { mounted() {
socket.on('init_settings', this.initSettings); this.$refs.loggedInInfo.classList.add('hide');
socket.on('updateSettings', this.updateSettings);
let spotyUser = localStorage.getItem('spotifyUser'); if (localStorage.getItem('arl')) {
this.$refs.loginInput.value = localStorage.getItem('arl');
}
if ('' !== spotyUser) { let spotifyUser = localStorage.getItem('spotifyUser');
this.lastUser = spotyUser;
this.spotifyUser = spotyUser; if (spotifyUser) {
this.lastUser = spotifyUser;
this.spotifyUser = spotifyUser;
socket.emit('update_userSpotifyPlaylists', spotifyUser);
} }
this.changeSlimDownloads = 'true' === localStorage.getItem('slimDownloads'); this.changeSlimDownloads = 'true' === localStorage.getItem('slimDownloads');
socket.on('init_settings', this.initSettings);
socket.on('updateSettings', this.updateSettings);
} }
}).$mount('#settings_tab'); }).$mount('#settings_tab');
@ -41843,6 +41859,7 @@ function handleSidebarClick(event) {
changeTab(sidebarEl, 'main', 'search_tab'); changeTab(sidebarEl, 'main', 'search_tab');
break break
case 'main_home_tablink': case 'main_home_tablink':
console.log('al laod', sidebarEl);
changeTab(sidebarEl, 'main', 'home_tab'); changeTab(sidebarEl, 'main', 'home_tab');
break break
case 'main_charts_tablink': case 'main_charts_tablink':
@ -42002,20 +42019,15 @@ function backTab() {
} }
function init$3() { function init$3() {
let selectedTheme = localStorage.getItem('selectedTheme'); // Open default tab
changeTab(document.getElementById('main_home_tablink'), 'main', 'home_tab');
if (selectedTheme) {
document.querySelector('.theme_toggler--active').classList.remove('theme_toggler--active');
document
.querySelector(`.theme_toggler[data-theme-variant="${selectedTheme}"]`)
.classList.add('theme_toggler--active');
}
linkListeners$2(); linkListeners$2();
} }
var Tabs = { var Tabs = {
init: init$3, init: init$3,
changeTab,
artistView, artistView,
albumView, albumView,
playlistView, playlistView,
@ -42074,6 +42086,39 @@ var Search = {
linkListeners: linkListeners$3 linkListeners: linkListeners$3
}; };
/* ===== App initialization ===== */
function startApp() {
// Setting current theme
setUserTheme();
Downloads.init();
QualityModal$1.init();
Tabs.init();
Search.linkListeners();
TrackPreview.init();
}
document.addEventListener('DOMContentLoaded', startApp);
/* ===== General functions ===== */
/**
* Sets the current theme according to
* the localStorage saved theme.
* @since 0.1.6
*/
function setUserTheme() {
let selectedTheme = localStorage.getItem('selectedTheme');
if (selectedTheme) {
let activeClass = 'theme_toggler--active';
document.querySelector(`.${activeClass}`).classList.remove(activeClass);
document.querySelector(`.theme_toggler[data-theme-variant="${selectedTheme}"]`).classList.add(activeClass);
}
}
/* ===== Socketio listeners ===== */ /* ===== Socketio listeners ===== */
// Debug messages for socketio // Debug messages for socketio
@ -42144,41 +42189,8 @@ socket.on('logged_out', function () {
jquery('#login_input_arl').val(''); jquery('#login_input_arl').val('');
jquery('#open_login_prompt').show(); jquery('#open_login_prompt').show();
document.getElementById('logged_in_info').classList.add('hide'); document.getElementById('logged_in_info').classList.add('hide');
// $('#logged_in_info').hide()
jquery('#settings_username').text('Not Logged'); jquery('#settings_username').text('Not Logged');
jquery('#settings_picture').attr('src', `https://e-cdns-images.dzcdn.net/images/user/125x125-000000-80-0-0.jpg`); jquery('#settings_picture').attr('src', `https://e-cdns-images.dzcdn.net/images/user/125x125-000000-80-0-0.jpg`);
document.getElementById('home_not_logged_in').classList.remove('hide'); document.getElementById('home_not_logged_in').classList.remove('hide');
}); });
/* ===== App initialization ===== */
function startApp() {
Downloads.init();
QualityModal$1.init();
Tabs.init();
Search.linkListeners();
TrackPreview.init();
document.getElementById('logged_in_info').classList.add('hide');
if (localStorage.getItem('arl')) {
let arl = localStorage.getItem('arl');
jquery('#login_input_arl').val(arl);
document.getElementById('home_not_logged_in').classList.add('hide');
}
if ('true' === localStorage.getItem('slimDownloads')) {
document.getElementById('download_list').classList.add('slim');
}
let spotifyUser = localStorage.getItem('spotifyUser');
if (spotifyUser != '') {
socket.emit('update_userSpotifyPlaylists', spotifyUser);
}
// Open default tab
document.getElementById('main_home_tablink').click();
}
document.addEventListener('DOMContentLoaded', startApp);
//# sourceMappingURL=bundle.js.map //# sourceMappingURL=bundle.js.map

File diff suppressed because one or more lines are too long

View File

@ -7,6 +7,39 @@ import Tabs from './modules/tabs.js'
import Search from './modules/search.js' import Search from './modules/search.js'
import TrackPreview from './modules/track-preview.js' import TrackPreview from './modules/track-preview.js'
/* ===== App initialization ===== */
function startApp() {
// Setting current theme
setUserTheme()
Downloads.init()
QualityModal.init()
Tabs.init()
Search.linkListeners()
TrackPreview.init()
}
document.addEventListener('DOMContentLoaded', startApp)
/* ===== General functions ===== */
/**
* Sets the current theme according to
* the localStorage saved theme.
* @since 0.1.6
*/
function setUserTheme() {
let selectedTheme = localStorage.getItem('selectedTheme')
if (selectedTheme) {
let activeClass = 'theme_toggler--active'
document.querySelector(`.${activeClass}`).classList.remove(activeClass)
document.querySelector(`.theme_toggler[data-theme-variant="${selectedTheme}"]`).classList.add(activeClass)
}
}
/* ===== Socketio listeners ===== */ /* ===== Socketio listeners ===== */
// Debug messages for socketio // Debug messages for socketio
@ -77,40 +110,7 @@ socket.on('logged_out', function () {
$('#login_input_arl').val('') $('#login_input_arl').val('')
$('#open_login_prompt').show() $('#open_login_prompt').show()
document.getElementById('logged_in_info').classList.add('hide') document.getElementById('logged_in_info').classList.add('hide')
// $('#logged_in_info').hide()
$('#settings_username').text('Not Logged') $('#settings_username').text('Not Logged')
$('#settings_picture').attr('src', `https://e-cdns-images.dzcdn.net/images/user/125x125-000000-80-0-0.jpg`) $('#settings_picture').attr('src', `https://e-cdns-images.dzcdn.net/images/user/125x125-000000-80-0-0.jpg`)
document.getElementById('home_not_logged_in').classList.remove('hide') document.getElementById('home_not_logged_in').classList.remove('hide')
}) })
/* ===== App initialization ===== */
function startApp() {
Downloads.init()
QualityModal.init()
Tabs.init()
Search.linkListeners()
TrackPreview.init()
document.getElementById('logged_in_info').classList.add('hide')
if (localStorage.getItem('arl')) {
let arl = localStorage.getItem('arl')
$('#login_input_arl').val(arl)
document.getElementById('home_not_logged_in').classList.add('hide')
}
if ('true' === localStorage.getItem('slimDownloads')) {
document.getElementById('download_list').classList.add('slim')
}
let spotifyUser = localStorage.getItem('spotifyUser')
if (spotifyUser != '') {
socket.emit('update_userSpotifyPlaylists', spotifyUser)
}
// Open default tab
document.getElementById('main_home_tablink').click()
}
document.addEventListener('DOMContentLoaded', startApp)

View File

@ -18,7 +18,7 @@ const HomeTab = new Vue({
albumView, albumView,
playlistView, playlistView,
openSettings(e) { openSettings(e) {
document.getElementById("main_settings_tablink").click() document.getElementById('main_settings_tablink').click()
}, },
addToQueue(e) { addToQueue(e) {
e.stopPropagation() e.stopPropagation()
@ -33,6 +33,10 @@ const HomeTab = new Vue({
} }
}, },
mounted() { mounted() {
if (localStorage.getItem('arl')) {
this.$refs.notLogged.classList.add('hide')
}
socket.on('init_home', this.initHome) socket.on('init_home', this.initHome)
} }
}).$mount('#home_tab') }).$mount('#home_tab')

View File

@ -82,17 +82,24 @@ const SettingsTab = new Vue({
} }
}, },
mounted() { mounted() {
socket.on('init_settings', this.initSettings) this.$refs.loggedInInfo.classList.add('hide')
socket.on('updateSettings', this.updateSettings)
let spotyUser = localStorage.getItem('spotifyUser') if (localStorage.getItem('arl')) {
this.$refs.loginInput.value = localStorage.getItem('arl')
}
if ('' !== spotyUser) { let spotifyUser = localStorage.getItem('spotifyUser')
this.lastUser = spotyUser
this.spotifyUser = spotyUser if (spotifyUser) {
this.lastUser = spotifyUser
this.spotifyUser = spotifyUser
socket.emit('update_userSpotifyPlaylists', spotifyUser)
} }
this.changeSlimDownloads = 'true' === localStorage.getItem('slimDownloads') this.changeSlimDownloads = 'true' === localStorage.getItem('slimDownloads')
socket.on('init_settings', this.initSettings)
socket.on('updateSettings', this.updateSettings)
} }
}).$mount('#settings_tab') }).$mount('#settings_tab')

View File

@ -20,6 +20,11 @@ function init() {
listEl = document.getElementById('download_list') listEl = document.getElementById('download_list')
dragHandlerEl = document.getElementById('download_tab_drag_handler') dragHandlerEl = document.getElementById('download_tab_drag_handler')
// Check if download tab has slim entries
if ('true' === localStorage.getItem('slimDownloads')) {
listEl.classList.add('slim')
}
// Check if download tab should be open // Check if download tab should be open
if ('true' === localStorage.getItem('downloadTabOpen')) { if ('true' === localStorage.getItem('downloadTabOpen')) {
tabContainerEl.classList.remove('tab_hidden') tabContainerEl.classList.remove('tab_hidden')
@ -104,8 +109,8 @@ function addToQueue(queueItem, current = false) {
} else { } else {
if (queue.indexOf(queueItem.uuid) == -1) queue.push(queueItem.uuid) if (queue.indexOf(queueItem.uuid) == -1) queue.push(queueItem.uuid)
} }
let queueDOM = document.getElementById("download_"+queueItem.uuid) let queueDOM = document.getElementById('download_' + queueItem.uuid)
if (typeof(queueDOM) == 'undefined' || queueDOM == null){ if (typeof queueDOM == 'undefined' || queueDOM == null) {
$(listEl).append( $(listEl).append(
`<div class="download_object" id="download_${queueItem.uuid}" data-deezerid="${queueItem.id}"> `<div class="download_object" id="download_${queueItem.uuid}" data-deezerid="${queueItem.id}">
<div class="download_info"> <div class="download_info">

View File

@ -101,6 +101,7 @@ function handleSidebarClick(event) {
changeTab(sidebarEl, 'main', 'search_tab') changeTab(sidebarEl, 'main', 'search_tab')
break break
case 'main_home_tablink': case 'main_home_tablink':
console.log('al laod', sidebarEl)
changeTab(sidebarEl, 'main', 'home_tab') changeTab(sidebarEl, 'main', 'home_tab')
break break
case 'main_charts_tablink': case 'main_charts_tablink':
@ -269,20 +270,15 @@ function backTab() {
} }
function init() { function init() {
let selectedTheme = localStorage.getItem('selectedTheme') // Open default tab
changeTab(document.getElementById('main_home_tablink'), 'main', 'home_tab')
if (selectedTheme) {
document.querySelector('.theme_toggler--active').classList.remove('theme_toggler--active')
document
.querySelector(`.theme_toggler[data-theme-variant="${selectedTheme}"]`)
.classList.add('theme_toggler--active')
}
linkListeners() linkListeners()
} }
export default { export default {
init, init,
changeTab,
artistView, artistView,
albumView, albumView,
playlistView, playlistView,