A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
27
></v-button>28
</div>29
<v-button30
:text="state.account.name"30
:text="state.account?.name"31
icon="user"32
:title="$lang('global.account')"33
:active="state.tab === 'account'"
29
<dialog ref="dialog" class="z-40 fixed w-full h-full bg-black/80">30
<div class="flex flex-col fixed left-[50%] top-[50%] -translate-y-[50%] -translate-x-[50%] rounded-lg sm:rounded-md bg-zinc-900 w-[500px] max-w-[85vw] p-6 sm:p-8 pt-10 sm:pt-8">31
<h3 class="text-white text-[24px] font-bold pb-4 text-center sm:text-left">{{title}}</h3>32
<p class="text-md text-gray-400 text-center sm:text-left">{{description}}</p>33
<v-button34
v-for="action in actions"35
:icon="action.icon"36
:title="action.title"37
class="self-end"38
@click="action.handle"39
></v-button>32
<p class="text-md text-gray-400 text-center sm:text-left" v-html="description"></p>33
<div class="flex gap-2 w-full justify-end">34
<v-button35
v-for="action in actions"36
:icon="action.icon"37
:title="action.title"38
@click="action.handle"39
></v-button>40
</div>41
</div>42
</dialog>43
`
9
export const state = {10
app: null,11
tab: 'search',12
account: {13
username: '',14
language: 'en'15
},16
station: null12
account: null,13
station: null,14
authenticated: false15
};17
(async () => {
37
},38
methods: {39
async init() {42
window.app = this;43
state.account = await http`get::/api/account`();40
try {41
state.account = await http`get::/api/account`();42
}43
catch(error) {44
// ignore45
}46
if(state.account === null) {47
// TODO: create account or authenticate48
return;49
}50
state.authenticated = true;51
document.addEventListener('scroll', this.onScroll);52
document.addEventListener('wheel', this.onScroll);53
if('serviceWorker' in navigator) {
55
navigator.serviceWorker.addEventListener('controllerchange', this.updated);56
}57
},58
showError(error) {59
this.$refs.popup.open({60
title: $lang('global.error'),61
description: $lang('global.error.message', error),62
actions: [63
{64
title: $lang('global.report'),65
icon: 'message-report',66
handle: () => window.open('https://github.com/typable/verbal/issues')67
},68
{69
title: $lang('global.continue'),70
icon: 'arrow-right',71
handle: () => this.$refs.popup.close()72
}73
]74
});75
},76
updated() {77
this.$refs.popup.open({78
title: $lang('global.update'),
99
template: `100
<div class="px-4 sm:px-10 pb-8 sm:pb-[100px] max-w-[1200px] mx-auto flex flex-col">101
<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>102
<v-player v-if="state.authenticated" :station="state.station"></v-player>103
<v-search v-if="state.authenticated" ref="search" :state="state"></v-search>104
<v-favorites v-if="state.authenticated" ref="favorites" :state="state"></v-favorites>105
<v-account v-if"state.authenticated" :state="state"></v-account>106
<v-popup ref="popup"></v-popup>107
</div>108
`
78
}80
export function $lang(id) {81
return state.locale[state.account?.language ?? 'en'][id];80
export function $lang(id, ...args) {81
let message = state.locale[state.account?.language ?? 'en'][id];82
for(const i in args) {83
message = message.replaceAll(`{${i}}`, args[i]);84
}85
return message;86
}
18
"global.playback-history": "Playback History",19
"global.update": "Update installed",20
"global.continue": "Continue",21
"global.report": "Report issue",22
"global.error": "Error",23
"global.error.message": "An error occured! Please try again later. If the error persists feel free to let us know.<br><br>Message: {0}",24
"player.loading": "Loading...",25
"player.no-song-title": "- No song title available -",26
"search.input.placeholder": "Search for stations",
56
"global.playback-history": "Wiedergabeverlauf",57
"global.update": "Update wurde installiert",58
"global.continue": "Fortfahren",59
"global.report": "Fehler melden",60
"global.error": "Fehler",61
"global.error.message": "Ein Fehler ist aufgetreten! Bitte versuche es später erneut. Wenn der Fehler weiterhin besteht, fühle dich frei dies uns mitzuteilen.<br><br>Nachricht: {0}",62
"player.loading": "Laden...",63
"player.no-song-title": "- Song Titel nicht verfügbar -",64
"search.input.placeholder": "Suche nach Sender",