-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
244 lines (202 loc) · 10.9 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<!DOCTYPE html>
<html>
<head>
<title>Fox 91.4 Desktop Client</title>
<link rel="stylesheet" href="libs/animate/animate.css">
<link rel="stylesheet" type="text/css" href="libs/loader/loader.css">
<link rel="stylesheet" type="text/css" href="libs/fox-desktop/site.css">
<link rel="stylesheet" type="text/css" href="node_modules/toastr/build/toastr.css">
</head>
<body class="body_background">
<div class="heading">
<h1 id="heading" align="center">Fox 91.4</h1>
</div>
<audio id="audio">
<source src="" type="audio/mpeg" />
</audio>
<div id="container_button">
<div id="hole">
<div id="button">
<div id="triangle"></div>
<div id="lighter_triangle"></div>
<div id="darker_triangle"></div>
</div>
</div>
</div>
<div class="menu">
<div id="aboutMenu" class="menuItem" title="Author"><img src="images/developer.png" width="80px" height="80px"></div>
<div class="menuSeparator"></div>
<div id="sourceMenu" class="menuItem" title="Project Website / Download Latest Version"><img src="images/github.png" width="20px" height="20px"></div>
<div class="menuSeparator"></div>
<div id="reportBugMenu" class="menuItem" title="Report a Bug"><img src="images/bug.png" width="20px" height="20px"></div>
<div class="menuSeparator"></div>
<div id="licenseMenu" class="menuItem" title="Read License"><img src="images/license.png" width="20px" height="20px"></div>
<div class="menuSeparator"></div>
<div id="likeMenu" class="menuItem" title="Like on Facebook"><img src="images/fblike.png" width="50px" height="20px"></div>
<div class="menuSeparator"></div>
<div id="fbShareMenu" class="menuItem" title="Share on Facebook"><img src="images/facebook.png" width="20px" height="20px"></div>
<div class="menuSeparator"></div>
<div id="twitterShareMenu" class="menuItem" title="Share on Twitter"><img src="images/twitter.png" width="20px" height="20px"></div>
<div class="menuSeparator"></div>
<div id="gplusShareMenu" class="menuItem" title="Share on Google Plus"><img src="images/gplus.png" width="20px" height="20px"></div>
<div class="menuSeparator"></div>
<div id="linkedShareMenu" class="menuItem" title="Share on LinkedIn"><img src="images/linkedin.png" width="20px" height="20px"></div>
</div>
<script type="application/javascript">
var Loader = require('./libs/loader/loader.js');
var loader = new Loader('loader');
loader.show();
var $ = require('jquery');
var jQuery = $;
$(document).ready(function () {
var toastr = require('toastr');
toastr.options.preventDuplicates = true;
toastr.options.positionClass = "toast-bottom-right";
var btnPlay = document.getElementById('button');
var audio = document.getElementById('audio');
var heading = document.getElementById("heading");
var aboutMenu = document.getElementById("aboutMenu");
var sourceMenu = document.getElementById("sourceMenu");
var reportBugMenu = document.getElementById("reportBugMenu");
var licenseMenu = document.getElementById("licenseMenu");
var likeMenu = document.getElementById("likeMenu");
var fbShareMenu = document.getElementById("fbShareMenu");
var twitterShareMenu = document.getElementById("twitterShareMenu");
var gplusShareMenu = document.getElementById("gplusShareMenu");
var linkedShareMenu = document.getElementById("linkedShareMenu");
var q = require('q');
var open = null;
var merge = null;
var restClient = null;
var config = null
var controlTipsShown = false;
q.Promise(function(resolve, reject){
localConfig = require('./local-config.js');
restClient = require('simple-get');
toastr["info"]("Retrieving remote configuration...");
restClient.concat(localConfig.remoteConfigUrl, function (err, res, data) {
try{
if (typeof err === 'undefined' || err === null) {
let remoteConfig = JSON.parse(data.toString('utf8'));
if(typeof remoteConfig !== 'undefined' && remoteConfig !== null){
resolve(remoteConfig);
return;
}
}
resolve(null);
}
catch(e){
resolve(null);
}
});
}).then(function (remoteConfig) {
open = require('opn');
merge = require('merge');
if(remoteConfig !== null){
config = merge.recursive(true, localConfig, remoteConfig);
}
else{
config = localConfig;
toastr["warning"]("Unable to retrieve remote configuration. Please check your internet. Falling back to local configuration instead...");
}
$.fn.extend({
animateCss: function (animationName, loop) {
var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
if(loop){
$(this).addClass('animated ' + animationName);
}
else{
$(this).addClass('animated ' + animationName).one(animationEnd, function() {
$(this).removeClass('animated ' + animationName);
});
}
}
});
var stop = function(){
heading.className = '';
audio.pause();
audio.currentTime = 0;
audio.src = '';
};
var backgroundChangeHandle = null;
var bgImageNumber = 2;
btnPlay.addEventListener('click', function() {
if(audio.src !== config.streamUrl){
audio.src = config.streamUrl;
audio.load();
audio.play();
}
else{
stop();
clearInterval(backgroundChangeHandle);
document.body.style.backgroundImage = '';
if(!controlTipsShown){
toastr["info"]("You could always hit that button again you know...");
controlTipsShown = true;
}
}
}, false);
audio.addEventListener('play', function(){
$(heading).animateCss('pulse', true);
});
audio.addEventListener('playing', function(){
if(!controlTipsShown){
toastr["info"]("Hit the button again to pause. But why would you even...");
}
$(heading).animateCss('tada', true);
document.body.style.backgroundImage = 'url("images/visuals/' + bgImageNumber + '.gif")';
backgroundChangeHandle = setInterval(function (){
if(bgImageNumber > 14){
bgImageNumber = 1;
}
document.body.style.backgroundImage = 'url("images/visuals/' + bgImageNumber + '.gif")';
bgImageNumber += 1;
}, 60000);
});
audio.addEventListener('error', function(){
if(audio.src === config.streamUrl){
stop();
toastr["error"]("Oops! Unable to connect. Please check whether you are properly connected to the internet. If you are, then you may be behind a firewall which is blocking the Fox 91.4 audio stream. That's not cool man. Not cool at all.");
}
});
aboutMenu.addEventListener('mouseover', function(){
var aboutMessage = '<u>Fox Desktop v' + config.version + '</u><br/>An unofficial cross platform streaming desktop client for Sri Lanka\'s Fox 91.4 FM Radio. This program is free software licensed and distributed under GNU GPL v3 with absolutely no warranties.<br/></br>Developed by <a target="_blank" href="https://www.linkedin.com/in/harindaka">Hemal Harindaka</a>';
toastr["info"](aboutMessage);
});
aboutMenu.addEventListener('click', function(){
open(config.authorUrl);
});
sourceMenu.addEventListener('click', function(){
open(config.projectUrl);
});
reportBugMenu.addEventListener('click', function(){
open(config.issuesUrl);
});
licenseMenu.addEventListener('click', function(){
open(config.licenseUrl);
});
likeMenu.addEventListener('click', function(){
open(config.fbPageUrl);
});
fbShareMenu.addEventListener('click', function(){
open(config.fbShareUrl);
});
twitterShareMenu.addEventListener('click', function(){
open(config.twitterShareUrl);
});
gplusShareMenu.addEventListener('click', function(){
open(config.gplusShareUrl);
});
linkedShareMenu.addEventListener('click', function(){
open(config.linkedInShareUrl);
});
loader.close();
toastr["info"]("Hit the button to start streaming awesomeness...");
}).catch(function(e){
loader.close();
toastr["error"]("Oops! An unhandled error occurred. You may need to restart the application for it to behave as intended. Error details: " + e.message);
}).done();
});
</script>
</body>
</html>