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'),
80
actions: [81
{82
title: $lang('global.continue'),58
icon: 'arrow-right',83
icon: 'check',84
handle: () => window.location.reload()85
}86
]
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
`
85
},86
template: `87
<v-tab id="search" :tab="state.tab">88
<div class="flex flex-wrap gap-4">89
<input90
v-model="query.name"91
@change="doSearch"92
type="text"93
:placeholder="$lang('search.input.placeholder')"94
class="flex-1 h-[56px] px-5 text-lg rounded-lg bg-zinc-900 text-white font-medium placeholder:font-normal placeholder:text-gray-500 focus:placeholder:text-gray-600 outline-none"95
spellcheck="false"96
autocomplete="off"97
>98
<div class="flex gap-4 w-full md:w-[300px]">99
<select100
v-model="query.country"101
@change="doSearch"102
class="w-6/12 h-[56px] px-5 text-lg rounded-lg bg-zinc-900 text-white font-medium placeholder:font-normal placeholder:text-gray-500 focus:placeholder:text-gray-600 outline-none cursor-pointer appearance-none"103
>104
<option value="" selected>All</option>105
<option v-for="country in countries" :value="country">{{country}}</option>106
</select>107
<select108
v-model="query.language"88
<div class="flex flex-wrap rounded-md overflow-hidden bg-zinc-900">89
<div class="relative before:absolute before:w-full before:bottom-0 before:border-b md:before:border-none before:border-zinc-800 flex-1">90
<input91
v-model="query.name"92
@change="doSearch"110
class="w-6/12 h-[56px] px-5 text-lg rounded-lg bg-zinc-900 text-white font-medium placeholder:font-normal placeholder:text-gray-500 focus:placeholder:text-gray-600 outline-none cursor-pointer appearance-none"93
type="text"94
:placeholder="$lang('search.input.placeholder')"95
class="w-full h-[56px] px-5 text-lg bg-zinc-900 text-white font-medium placeholder:font-normal placeholder:text-gray-500 focus:placeholder:text-gray-600 outline-none"96
spellcheck="false"97
autocomplete="off"98
>112
<option value="">All</option>113
<option v-for="language in languages" :value="language">{{language}}</option>114
</select>99
</div>100
<div class="flex w-full md:w-[300px]">101
<div class="flex relative before:absolute before:h-[36px] before:top-[10px] before:border-l-none md:before:border-l before:border-zinc-800 w-6/12">102
<v-icon103
id="map-pin"104
size="20px"105
class="text-gray-400 select-none pointer-events-none before:left-[24px] min-w-[0px]"106
>107
</v-icon>108
<select109
v-model="query.country"110
@change="doSearch"111
class="w-full h-[56px] px-5 pl-11 text-lg bg-zinc-900 text-white font-medium placeholder:font-normal placeholder:text-gray-500 focus:placeholder:text-gray-600 outline-none cursor-pointer appearance-none"112
>113
<option value="" selected>All</option>114
<option v-for="country in countries" :value="country">{{country}}</option>115
</select>116
</div>117
<div class="flex relative before:absolute before:h-[36px] before:top-[10px] before:border-l before:border-zinc-800 w-6/12">118
<v-icon119
id="world"120
size="20px"121
class="text-gray-400 select-none pointer-events-none before:left-[24px] min-w-[0px]"122
>123
</v-icon>124
<select125
v-model="query.language"126
@change="doSearch"127
class="w-full h-[56px] px-5 pl-11 text-lg bg-zinc-900 text-white font-medium placeholder:font-normal placeholder:text-gray-500 focus:placeholder:text-gray-600 outline-none cursor-pointer appearance-none"128
>129
<option value="">All</option>130
<option v-for="language in languages" :value="language">{{language}}</option>131
</select>132
</div>133
</div>134
</div>135
<ul v-if="searching" class="flex flex-col">
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",