2020-04-21 20:20:19 +00:00
|
|
|
import { toast } from './toasts.js'
|
|
|
|
import { socket } from './socket.js'
|
|
|
|
|
|
|
|
// Globals
|
|
|
|
window.lastSettings = {}
|
|
|
|
window.lastCredentials = {}
|
|
|
|
|
2020-04-22 20:06:59 +00:00
|
|
|
const SettingsTab = new Vue({
|
2020-04-21 20:20:19 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
settings: { tags: {} },
|
|
|
|
spotifyFeatures: {}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
copyARLtoClipboard() {
|
|
|
|
let copyText = this.$refs.loginInput
|
|
|
|
|
|
|
|
copyText.setAttribute('type', 'text')
|
|
|
|
copyText.select()
|
|
|
|
copyText.setSelectionRange(0, 99999)
|
|
|
|
document.execCommand('copy')
|
|
|
|
copyText.setAttribute('type', 'password')
|
|
|
|
|
|
|
|
toast('ARL copied to clipboard', 'assignment')
|
|
|
|
},
|
|
|
|
saveSettings() {
|
|
|
|
lastSettings = { ...SettingsTab.settings }
|
|
|
|
lastCredentials = { ...SettingsTab.spotifyFeatures }
|
|
|
|
socket.emit('saveSettings', lastSettings, lastCredentials)
|
|
|
|
},
|
|
|
|
login() {
|
|
|
|
let arl = this.$refs.loginInput.value
|
|
|
|
if (arl != '' && arl != localStorage.getItem('arl')) {
|
|
|
|
socket.emit('login', arl, true)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
logout() {
|
|
|
|
socket.emit('logout')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).$mount('#settings_tab')
|
|
|
|
|
|
|
|
socket.on('init_settings', function (settings, credentials) {
|
|
|
|
loadSettings(settings, credentials)
|
|
|
|
toast('Settings loaded!', 'settings')
|
|
|
|
})
|
|
|
|
|
|
|
|
socket.on('updateSettings', function (settings, credentials) {
|
|
|
|
loadSettings(settings, credentials)
|
|
|
|
toast('Settings updated!', 'settings')
|
|
|
|
})
|
|
|
|
|
|
|
|
function loadSettings(settings, spotifyCredentials) {
|
|
|
|
lastSettings = { ...settings }
|
|
|
|
lastCredentials = { ...spotifyCredentials }
|
|
|
|
SettingsTab.settings = settings
|
|
|
|
SettingsTab.spotifyFeatures = spotifyCredentials
|
|
|
|
}
|
2020-04-22 20:06:59 +00:00
|
|
|
|
|
|
|
export default SettingsTab
|