Files: ff1a418d0029c04d3d05537027bbd381a540dbbe / stores / songs.js
889 bytesRaw
1 | module.exports = store |
2 | |
3 | function store (state,emitter) { |
4 | var songs = require('../songs.json') |
5 | state.songs = songs.songs |
6 | state.currentSong = '' |
7 | state.songList = [] |
8 | |
9 | emitter.on('DOMContentLoaded', function () { |
10 | emitter.on('changeSong', function (song) { |
11 | song = song.replace(/\s+/g, '-').toLowerCase() |
12 | emitter.emit('pushState', '/#songbook/'+song) |
13 | setTimeout("document.getElementById('track').classList.toggle('change-color')", 1500) |
14 | }) |
15 | }) |
16 | emitter.on('DOMContentLoaded', function (){ |
17 | emitter.on('close', function (song) { |
18 | state.lastSong = song |
19 | emitter.emit('pushState', '/#songbook') |
20 | }) |
21 | }) |
22 | emitter.on('DOMContentLoaded', function () { |
23 | var archive = new DatArchive(window.location.host) |
24 | var songFiles = archive.readdir('songs').then(contents => { |
25 | state.songList = contents |
26 | console.log(state.songList) |
27 | }) |
28 | }) |
29 | } |
30 |
Built with git-ssb-web