A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: 809c02897f42fb2a0160ed48280a98165d969851 (2938 bytes)[doc][blame][raw]
1
import {http, $lang} from './utils.js';2
import VMenu from './component/menu.js';3
import VPlayer from './component/player.js';4
import VPopup from './component/popup.js';5
import VSearch from './page/search.js';6
import VFavorites from './page/favorites.js';7
import VAccount from './page/account.js';9
export const state = {10
app: null,11
tab: 'search',12
account: {13
username: '',14
language: 'en'15
},16
station: null17
};19
(async () => {20
state.locale = await http`get::/asset/json/locale.json`();22
new Vue({23
el: '#app',24
data: {25
state26
},27
components: {28
VMenu,29
VSearch,30
VFavorites,31
VAccount,32
VPlayer,33
VPopup34
},35
mounted() {36
document.body.style.display = '';37
state.app = this;38
this.init();39
},40
methods: {41
async init() {42
window.app = this;43
state.account = await http`get::/api/account`();44
document.addEventListener('scroll', this.onScroll);45
document.addEventListener('wheel', this.onScroll);46
if('serviceWorker' in navigator) {47
navigator.serviceWorker.register('/worker.js');48
navigator.serviceWorker.addEventListener('controllerchange', this.updated);49
}50
},51
updated() {52
this.$refs.popup.open({53
title: $lang('global.update'),54
description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.',55
actions: [56
{57
title: $lang('global.continue'),58
icon: 'arrow-right',59
handle: () => window.location.reload()60
}61
]62
});63
},64
onScroll() {65
if(state.tab === 'search') {66
if(window.innerHeight + window.pageYOffset >= document.body.offsetHeight - 200) {67
if(this.$refs.search.searching) {68
this.$refs.search.doSearchMore();69
}70
}71
}72
}73
},74
template: `75
<div class="px-4 sm:px-10 pb-8 sm:pb-[100px] max-w-[1200px] mx-auto flex flex-col">76
<v-menu :state="state"></v-menu>77
<v-player :station="state.station"></v-player>78
<v-search ref="search" :state="state"></v-search>79
<v-favorites ref="favorites" :state="state"></v-favorites>80
<v-account :state="state"></v-account>81
<v-popup ref="popup"></v-popup>82
</div>83
`84
});85
})();