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",
"version": "0.1.0-alpha",
"version": "0.1.6",
"homepage": "https://notabug.org/RemixDev/deemix/src/master/README.md",
"repository": {
"type": "git",

View File

@ -313,7 +313,7 @@ <h1>No Playlists found</h1>
<div id="home_tab" class="main_tabcontent">
<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>
<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">
<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" />
<p>You are logged in as <strong id="settings_username"></strong></p>
<button id="settings_btn_logout" @click="logout">Logout</button>

View File

@ -11266,6 +11266,11 @@ function init() {
listEl = document.getElementById('download_list');
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
if ('true' === localStorage.getItem('downloadTabOpen')) {
tabContainerEl.classList.remove('tab_hidden');
@ -11350,8 +11355,8 @@ function addToQueue(queueItem, current = false) {
} else {
if (queue.indexOf(queueItem.uuid) == -1) queue.push(queueItem.uuid);
}
let queueDOM = document.getElementById("download_"+queueItem.uuid);
if (typeof(queueDOM) == 'undefined' || queueDOM == null){
let queueDOM = document.getElementById('download_' + queueItem.uuid);
if (typeof queueDOM == 'undefined' || queueDOM == null) {
jquery(listEl).append(
`<div class="download_object" id="download_${queueItem.uuid}" data-deezerid="${queueItem.id}">
<div class="download_info">
@ -41378,7 +41383,7 @@ const HomeTab = new Vue({
albumView,
playlistView,
openSettings(e) {
document.getElementById("main_settings_tablink").click();
document.getElementById('main_settings_tablink').click();
},
addToQueue(e) {
e.stopPropagation();
@ -41393,6 +41398,10 @@ const HomeTab = new Vue({
}
},
mounted() {
if (localStorage.getItem('arl')) {
this.$refs.notLogged.classList.add('hide');
}
socket.on('init_home', this.initHome);
}
}).$mount('#home_tab');
@ -41600,17 +41609,24 @@ const SettingsTab = new Vue({
}
},
mounted() {
socket.on('init_settings', this.initSettings);
socket.on('updateSettings', this.updateSettings);
this.$refs.loggedInInfo.classList.add('hide');
let spotyUser = localStorage.getItem('spotifyUser');
if (localStorage.getItem('arl')) {
this.$refs.loginInput.value = localStorage.getItem('arl');
}
if ('' !== spotyUser) {
this.lastUser = spotyUser;
this.spotifyUser = spotyUser;
let spotifyUser = localStorage.getItem('spotifyUser');
if (spotifyUser) {
this.lastUser = spotifyUser;
this.spotifyUser = spotifyUser;
socket.emit('update_userSpotifyPlaylists', spotifyUser);
}
this.changeSlimDownloads = 'true' === localStorage.getItem('slimDownloads');
socket.on('init_settings', this.initSettings);
socket.on('updateSettings', this.updateSettings);
}
}).$mount('#settings_tab');
@ -41843,6 +41859,7 @@ function handleSidebarClick(event) {
changeTab(sidebarEl, 'main', 'search_tab');
break
case 'main_home_tablink':
console.log('al laod', sidebarEl);
changeTab(sidebarEl, 'main', 'home_tab');
break
case 'main_charts_tablink':
@ -42002,20 +42019,15 @@ function backTab() {
}
function init$3() {
let selectedTheme = localStorage.getItem('selectedTheme');
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');
}
// Open default tab
changeTab(document.getElementById('main_home_tablink'), 'main', 'home_tab');
linkListeners$2();
}
var Tabs = {
init: init$3,
changeTab,
artistView,
albumView,
playlistView,
@ -42074,6 +42086,39 @@ var Search = {
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 ===== */
// Debug messages for socketio
@ -42144,41 +42189,8 @@ socket.on('logged_out', function () {
jquery('#login_input_arl').val('');
jquery('#open_login_prompt').show();
document.getElementById('logged_in_info').classList.add('hide');
// $('#logged_in_info').hide()
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`);
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

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 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 ===== */
// Debug messages for socketio
@ -77,40 +110,7 @@ socket.on('logged_out', function () {
$('#login_input_arl').val('')
$('#open_login_prompt').show()
document.getElementById('logged_in_info').classList.add('hide')
// $('#logged_in_info').hide()
$('#settings_username').text('Not Logged')
$('#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')
})
/* ===== 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,
playlistView,
openSettings(e) {
document.getElementById("main_settings_tablink").click()
document.getElementById('main_settings_tablink').click()
},
addToQueue(e) {
e.stopPropagation()
@ -33,6 +33,10 @@ const HomeTab = new Vue({
}
},
mounted() {
if (localStorage.getItem('arl')) {
this.$refs.notLogged.classList.add('hide')
}
socket.on('init_home', this.initHome)
}
}).$mount('#home_tab')

View File

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

View File

@ -20,6 +20,11 @@ function init() {
listEl = document.getElementById('download_list')
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
if ('true' === localStorage.getItem('downloadTabOpen')) {
tabContainerEl.classList.remove('tab_hidden')
@ -104,8 +109,8 @@ function addToQueue(queueItem, current = false) {
} else {
if (queue.indexOf(queueItem.uuid) == -1) queue.push(queueItem.uuid)
}
let queueDOM = document.getElementById("download_"+queueItem.uuid)
if (typeof(queueDOM) == 'undefined' || queueDOM == null){
let queueDOM = document.getElementById('download_' + queueItem.uuid)
if (typeof queueDOM == 'undefined' || queueDOM == null) {
$(listEl).append(
`<div class="download_object" id="download_${queueItem.uuid}" data-deezerid="${queueItem.id}">
<div class="download_info">

View File

@ -101,6 +101,7 @@ function handleSidebarClick(event) {
changeTab(sidebarEl, 'main', 'search_tab')
break
case 'main_home_tablink':
console.log('al laod', sidebarEl)
changeTab(sidebarEl, 'main', 'home_tab')
break
case 'main_charts_tablink':
@ -269,20 +270,15 @@ function backTab() {
}
function init() {
let selectedTheme = localStorage.getItem('selectedTheme')
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')
}
// Open default tab
changeTab(document.getElementById('main_home_tablink'), 'main', 'home_tab')
linkListeners()
}
export default {
init,
changeTab,
artistView,
albumView,
playlistView,