-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
98 lines (89 loc) · 3.62 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<html>
<meta charset="UTF-8" />
<head>
<title>🎤 Karaoke requests</title>
<link href="style.css" type="text/css" rel="stylesheet">
<meta name="viewport" content="initial-scale=1">
</head>
<body ng-app="karaoke" ng-controller="index as index">
<header>
<input type="text" ng-model="query" ng-model-options="{ debounce: 300 }" placeholder="Search by artist or title…" ng-change="showQueue = false" />
</header>
<form class="modal ng-cloak" name="request" ng-show="index.confirm" ng-submit="index.request(index.confirm)">
<h1>{{index.confirm.title}}</h1>
<h2>by {{index.confirm.artist}}</h2>
<input type="text" ng-model="index.singer" placeholder="Enter your name…" required />
<br/>
<button ng-disabled="!request.$valid">Request</button>
<p><a ng-click="index.confirm = null">Cancel</a></p>
</form>
<main class="ng-cloak">
<div class="queue" ng-show="index.songs" ng-click="showQueue = !showQueue">
<h4>
<code ng-switch="showQueue">
<span ng-switch-when="true">▾</span>
<span ng-switch-default>▸</span>
</code>
{{index.queue.length}} in queue
</h4>
<ul ng-show="showQueue">
<li ng-repeat="request in index.queue">
<h3>
{{::request.song.title}}
<small>{{::request.song.artist}} <span ng-show="song.duo">👥</span></small>
</h3>
<small>{{::request.singer}}</small>
</li>
</ul>
</div>
<ul>
<li ng-repeat="song in index.songs | filter:{search:query} | limitTo:500" ng-click="index.confirm = song">
<h3>
{{::song.title}}
<small>{{::song.artist}} <span ng-show="song.duo">👥</span></small>
</h3>
<small>{{::song.year}}</small>
</li>
</ul>
<h2 ng-hide="index.songs">🎵 Loading</h2>
</main>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.4/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.4/angular-animate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.4/angular-touch.min.js"></script>
<script src="https://cdn.firebase.com/js/client/2.4.2/firebase.js"></script>
<script src="https://cdn.firebase.com/libs/angularfire/1.2.0/angularfire.min.js"></script>
<script>
(function() {
angular
.module('karaoke', ['ngAnimate', 'ngTouch', 'firebase'])
.controller('index', Index);
function Index($http, $firebaseArray) {
this.singer = localStorage.singer;
this.queue = $firebaseArray(new Firebase('https://wafflejs-karaoke.firebaseio.com/queue'));
var csv = 'a73211324d6fc692c25a99fc165bc240.csv';
$http.get(csv).success(function(data) {
this.songs = data.split('\n').slice(1).map(function(line) {
if (!line) return;
var values = line.split(';'),
title = values[1].replace(/"/g, ''),
artist = values[2].replace(/"/g, '');
return {
search: String([title, artist]),
title: title,
artist: artist,
year: values[3],
duo: values[4] === '1',
};
});
}.bind(this));
}
Index.prototype.request = function(song) {
localStorage.singer = this.singer;
this.queue.$add({ song: song, singer: this.singer });
this.confirm = null;
};
})();
</script>
</body>
</html>