so://phie

verbal

A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal

blob: 8f51623af399ed097579b1b4f6015e84570129f2 (2268 bytes)[doc][blame][raw]

1import {http} from './utils.js';

2import VMenu from './component/menu.js';

3import VPlayer from './component/player.js';

4import VSearch from './page/search.js';

5import VFavorites from './page/favorites.js';

6import VAccount from './page/account.js';

7

8export const state = {

9 app: null,

10 tab: 'account',

11 account: {

12 username: '',

13 language: 'en'

14 },

15 station: null

16};

17

18(async () => {

19 state.locale = await http`get::/asset/json/locale.json`();

20

21 new Vue({

22 el: '#app',

23 data: {

24 state

25 },

26 components: {

27 VMenu,

28 VSearch,

29 VFavorites,

30 VAccount,

31 VPlayer

32 },

33 mounted() {

34 document.body.style.display = '';

35 state.app = this;

36 this.init();

37 },

38 methods: {

39 async init() {

40 window.app = this;

41 state.account = await http`get::/api/account`();

42 // document.addEventListener('keyup', this.onKey);

43 document.addEventListener('scroll', this.onScroll);

44 document.addEventListener('wheel', this.onScroll);

45 },

46 // onKey(event) {

47 // const {code, ctrlKey, shiftKey, altKey} = event;

48 // if(!ctrlKey && !shiftKey && !altKey) {

49 // if(code === 'KeyS') state.tab = 'search';

50 // if(code === 'KeyF') state.tab = 'favorites';

51 // if(code === 'KeyA') state.tab = 'account';

52 // }

53 // },

54 onScroll() {

55 if(window.innerHeight + window.pageYOffset >= document.body.offsetHeight - 200) {

56 this.$refs.search.doSearchMore();

57 }

58 }

59 },

60 template: `

61 <div class="px-4 sm:px-10 pb-8 sm:pb-[100px] max-w-[800px] mx-auto flex flex-col">

62 <v-menu :state="state"></v-menu>

63 <v-player :station="state.station"></v-player>

64 <v-search ref="search" :state="state"></v-search>

65 <v-favorites ref="favorites" :state="state"></v-favorites>

66 <v-account :state="state"></v-account>

67 </div>

68 `

69 });

70})();

71