-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
510 lines (412 loc) · 27.8 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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
<!DOCTYPE html>
<html>
<head>
<title>Capture Photo</title>
<meta charset='utf-8'/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" type="text/css"/>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
<script src="js/audioplayer.js"></script>
<!-- <script src="js/myCamera.js"></script> -->
<script src="js/jquery.fileDownload.js"></script>
<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>
<link rel="stylesheet" href="css/main.css" type="text/css" />
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
var pictureSource; // picture source
var destinationType; // sets the format of returned value
// Wait for device API libraries to load
//
document.addEventListener("deviceready",onDeviceReady,false);
// device APIs are available
//
function onDeviceReady() {
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
$('#testbtn2').click({
song_url:'https://api.soundcloud.com/tracks/108623436/download?client_id=707228f02dd69922dbac5f0bb309a07c'},
function (event) {
var fileTransfer = new FileTransfer();
fileTransfer.download('https://api.soundcloud.com/tracks/108623436/download?client_id=707228f02dd69922dbac5f0bb309a07c',
'/sdcard/Download/skelewu.mp3',
function(entry) {
console.log('download complete: ' + entry.fullPath);
alert(entry.toURI());
},
function(error) {
console.log('download error source ' + error.source);
console.log('download error target ' + error.target);
console.log('upload error code' + error.code);
});
alert(event.data.song_url);
});
}
function myDownload(song_url, song_name) {
var fileTransfer = new FileTransfer();
fileTransfer.download(song_url,
'/sdcard/Download/'+song_name,
function(entry) {
console.log('download complete: ' + entry.fullPath);
alert("Downloaded to: "+entry.toURI());
},
function(error) {
console.log('download error source ' + error.source);
console.log('download error target ' + error.target);
console.log('upload error code' + error.code);
});
// alert(song_url);
alert("Downloading "+ song_name+" To /sdcard/Download/");
}
// Called when a photo is successfully retrieved
//
function onPhotoDataSuccess(imageData) {
// Uncomment to view the base64-encoded image data
// console.log(imageData);
// Get image handle
//
var smallImage = document.getElementById('smallImage');
// Unhide image elements
//
smallImage.style.display = 'block';
// Show the captured photo
// The inline CSS rules are used to resize the image
//
smallImage.src = "data:image/jpeg;base64," + imageData;
}
// Called when a photo is successfully retrieved
//
function onPhotoURISuccess(imageURI) {
// Uncomment to view the image file URI
// console.log(imageURI);
// Get image handle
//
var largeImage = document.getElementById('largeImage');
// Unhide image elements
//
largeImage.style.display = 'block';
// Show the captured photo
// The inline CSS rules are used to resize the image
//
largeImage.src = imageURI;
}
// A button will call this function
//
function capturePhoto() {
// Take picture using device camera and retrieve image as base64-encoded string
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
destinationType: destinationType.DATA_URL });
}
// A button will call this function
//
function capturePhotoEdit() {
// Take picture using device camera, allow edit, and retrieve image as base64-encoded string
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 20, allowEdit: true,
destinationType: destinationType.DATA_URL });
}
// A button will call this function
//
function getPhoto(source) {
// Retrieve image file location from specified source
navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50,
destinationType: destinationType.FILE_URI,
sourceType: source });
}
// Called if something bad happens.
//
function onFail(message) {
alert('Failed because: ' + message);
}
////////////////stuff for download
function downloadFile(){
window.requestFileSystem(
LocalFileSystem.PERSISTENT, 0,
function onFileSystemSuccess(fileSystem) {
fileSystem.root.getFile(
"dummy.html", {create: true, exclusive: false},
function gotFileEntry(fileEntry){
var sPath = fileEntry.fullPath.replace("dummy.html","");
var fileTransfer = new FileTransfer();
fileEntry.remove();
fileTransfer.download(
'https://api.soundcloud.com/tracks/108623436/download?client_id=707228f02dd69922dbac5f0bb309a07c',
sPath + "eg.mp3",
function(theFile) {
console.log("download complete: " + theFile.toURI());
showLink(theFile.toURI());
},
function(error) {
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code: " + error.code);
}
);
},
fail);
},
fail);
}
function showLink(url){
alert(url);
var divEl = document.getElementById("ready");
var aElem = document.createElement("a");
aElem.setAttribute("target", "_blank");
aElem.setAttribute("href", url);
aElem.appendChild(document.createTextNode("Ready! Click To Open."))
divEl.appendChild(aElem);
}
function fail(evt) {
console.log(evt.target.error.code);
}
</script>
<script>
///////navigation stuff
// var why = document.getElementById("searchpage");
// alert(why.innerHTML);
$("a[data-role=tab]").each(function () {
var anchor = $(this);
anchor.bind("click", function () {
$.mobile.changePage(anchor.attr("href"), {
transition: "none",
changeHash: false
});
return false;
});
});
$("div[data-role=page]").bind("pagebeforeshow", function (e, data) {
$.mobile.silentScroll(0);
$.mobile.changePage.defaults.transition = 'slide';
});
////////music list generation stuff
var songs = new Array();
//http://designmodo.com/audio-player/
function generateMusicLink(song, index, backLocation){
var artistStr = "";
if(song.artist)
artistStr = song.artist + " - ";
var ret = '<a href="javascript:void(0)" onclick="goToSongDetailPage(\''+ song.title + '\',\'' + song.download_url + '\',\'' + backLocation + '\')"><li id="mylistitem">'+ artistStr + song.title + '</li></a>';
songs[index] = ret;
return ret;
}
var count = 0;
function goToSongDetailPage(songTitle, stream_url, backLocation){
$('.stopBtn')[0].onclick();
var onclickevent = 'onclick="myDownload(\''+ stream_url + '\',\'' + songTitle +'.mp3'+ '\')"';
var musicPage = $("<div data-role='page'id='songDetail' data-url=> <img src='img/testbg.png' class='fullscreen'><div id='onbackground'><div data-role='header'><h1>" + songTitle + "</h1><a href='"+backLocation+"' data-icon='home' data-iconpos='notext' id='backBtn'>search</a></div><br/><br/><br/><br/><div data-role='content'><div id='preview'><p>Preview</p><audio id='previewsong' src='"+stream_url+"' preload='auto' controls></audio></div><a href='#' data-role='button' class='frontPageBtn'><p id='downloadbtn' "+onclickevent+">Download</p></a></div></div><script>var audioElem = $('audio')["+count++ +"];\n$('#backBtn')[0].setAttribute('onclick', 'enableStopBtn()');\n \<\/script\></div>");
var i = 0;
while($('.stopBtn')[i]){
$('.stopBtn')[i++].setAttribute('onclick', 'disableStopBtn()');
}
musicPage.appendTo($.mobile.pageContainer);
$.mobile.changePage( musicPage );
}
function enableStopBtn(){
if(typeof audioElem != 'undefined' ){
if(!audioElem.paused){
var i = 0;
while($('.stopBtn')[i])
$('.stopBtn')[i++].setAttribute('style', 'display:block');
}
}
}
function disableStopBtn(){
if(typeof audioElem != 'undefined' )
audioElem.pause()
/* var i = 0;
while($('.stopBtn')[i])
$('.stopBtn')[i++].setAttribute('style', 'display:none' );*/
}
//http://jsonlint.com/
$.ajax({
type: 'GET',
url: "http://musicnaija-europe.herokuapp.com/api/week_top_ten?callback=?",
async: false,
jsonpCallback: 'jsonCallback',
contentType: "application/json",
dataType: 'jsonp',
success: function(songs){
//Start of with empty list each time to get latest from server
$("#trendList").empty();
//add the song items as List
var j = 0;
$.each(songs, function(i, song){
$('#trendList').append(generateMusicLink(song, j++, "#trendingpage"));
});
//refresh the list view to show the latest changes
$('#trendList').listview('refresh');
console.dir(songs);
},
error: function(e) {
console.log(e.message);
}
});
function searchForSong(songName){
if(songName != ""){
$.ajax({
type: 'GET',
url: "http://musicnaija-europe.herokuapp.com/api?q="+ songName + "&callback=?",
async: false,
jsonpCallback: 'jsonCallback',
contentType: "application/json",
dataType: 'jsonp',
success: function(songs){
//Start of with empty list each time to get latest from server
$("#songList").empty();
//add the movie items as List
var j = 0;
$.each(songs, function(i, song){
$('#songList').append(generateMusicLink(song, j++, "#searchpage"));
});
//refresh the list view to show the latest changes
$('#songList').listview('refresh');
console.dir(songs);
},
error: function(e) {
console.log(e.message);
}
});
}
}
function changeBgPic(newPic){
var i = 0;
while($(".bgpic")[i]){
$(".bgpic")[i++].setAttribute("src", newPic);
}
}
$(document).ready(function(){
$('#mylistitem').css('width', window.innerWidth * .100);
// $('#campic').css('display', 'none');
changeBgPic("img/testbg.png");
// disableStopBtn();
// myCamera.initialize();
$(".change-pic-btn").click(function(event){
event.preventDefault();
if (!navigator.camera) {
alert("Camera API not supported");
return;
}
var options = { quality: 50,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: 1, // 0:Photo Library, 1=Camera, 2=Saved Photo Album
encodingType: 0 // 0=JPG 1=PNG
};
navigator.camera.getPicture(
function(imageData) {
changeBgPic(imageData);
},
function() {
alert('Error taking picture');
},
options);
return false;
});
});
// $( "#mypanel" ).panel( "open" , optionsHash );
</script>
</head>
<body>
<div id="home" data-role="page">
<div data-role="panel" id="mypanel">
some content
</div> <!-- /panel -->
<div data-role="content">
<img class="fullscreen bgpic">
<div id="onbackground">
<br/><br/><br/><br/>
<!-- <img src="" id="campic" style="width:200px; height:200px;"> -->
<h1 id='maintitle'> Music Naija </h1>
<a href="#searchpage" data-role="button" data-shadow="false" data-theme="b" class="frontPageBtn"><p>search</p></a>
<a href="#trendingpage" data-role="button" data-shadow="false" data-theme="b" class="frontPageBtn"><p>trending</p></a>
<!-- <a href="#librarypage" data-role="button" data-shadow="false" data-theme="b" class="frontPageBtn"><p>my library</p></a> -->
<br/><br/><br/><br/><br/><br><br/>
<hr/>
<p style="text-align:center; font-size:15px;"> © 2013 xelaApps </p>
</div>
</div>
</div> <!--page-->
<div id="searchpage" data-role="page">
<img class="fullscreen bgpic">
<!-- <div data-role="panel" id="mypanel">
some content
</div> /panel -->
<div id="onbackground">
<div data-role='header'>
<h1>Find Songs</h1>
<a href="#home" data-icon='grid' data-iconpos='notext'>open panel</a>
<a href="#" onclick="" class="stopBtn"><img src="img/stop.png" alt="Stop" class="ui-li-icon footer-icon2"/></a>
</div>
<article data-role="content">
<input id="searchbar" placeholder="SONG ARTISTS OR ALBUM" data-type="search" class="ui-input-text ui-body-c">
<a href='#' onclick="searchForSong($('#searchbar')[0].value)" class='searchBtn'>SEARCH</a><br/>
<ul data-role="listview" data-inset='true' id='songList'>
</ul>
</article>
</div>
<footer data-role="footer" data-position='fixed'>
<nav data-role="navbar">
<ul>
<li><a href="#home" ><img src="img/home_icon_edit.png" alt="Great Britain" class="ui-li-icon footer-icon2"><br/>Home</a></li>
<li><a href="#searchpage"><img src="img/globe_edit.png" alt="Great Britain" class="ui-li-icon footer-icon2"><br/>Search</a></li>
<li><a href="#trendingpage"><img src="img/headphones_edit.png" alt="Great Britain" class="ui-li-icon footer-icon2"><br/>Trending</a></li>
</ul>
</nav>
</footer>
</div> <!--page-->
<div id="trendingpage" data-role="page">
<img class="fullscreen bgpic"/>
<div id="onbackground">
<div data-role='header'>
<h1>Trending Tracks</h1>
<a href="#home" data-icon='grid' data-iconpos='notext'>open panel</a>
<a href="#" onclick="" class="stopBtn"><img src="img/stop.png" alt="Stop" class="ui-li-icon footer-icon2"/></a>
</div>
<article data-role="content">
<h1 id='maintitle'> Trending Nigerian Music</h1>
<ul data-role="listview" data-inset='true'id='trendList'>
</ul>
</article>
<!-- Unexpected identifier <a href="javascript:void(0)" onclick="goToSongDetailPage('Snoop Dogg & Wiz Khalifa - Smokin' On f. Juicy J (prod. Drumma Boy)','https://api.soundcloud.com/tracks/29840349/download?client_id=707228f02dd69922dbac5f0bb309a07c','#searchpage')"><li id="mylistitem">Snoop Dogg & Wiz Khalifa - Smokin' On f. Juicy J (prod. Drumma Boy)</li></a> -->
</div>
<footer data-role="footer" data-position='fixed'>
<nav data-role="navbar">
<ul>
<li><a href="#home" ><img src="img/home_icon_edit.png" alt="Great Britain" class="ui-li-icon footer-icon2"><br/>Home</a></li>
<li><a href="#searchpage"><img src="img/globe_edit.png" alt="Great Britain" class="ui-li-icon footer-icon2"><br/>Search</a></li>
<li><a href="#trendingpage"><img src="img/headphones_edit.png" alt="Great Britain" class="ui-li-icon footer-icon2"><br/>Trending</a></li>
</ul>
</nav>
</footer>
</div> <!--page-->
<div id="librarypage" data-role="page">
<div data-role='header'>
<h1>Songs</h1>
<!-- <a href="#mypanel" data-icon='home' data-iconpos='notext'>open panel</a> -->
</div>
<article data-role="content">
<img class="fullscreen bgpic">
<div id="onbackground">
<ul data-role="listview" data-filter='true' data-inset='true' data-filter-placeholder="SONG ARTISTS OR ALBUM" id='libraryList'>
</ul>
<a href="#home">temp homescreen</a>
</div>
</article>
<footer data-role="footer" data-position='fixed'>
<nav data-role="navbar">
<ul>
<li><a href="#home" ><img src="img/home_icon_edit.png" alt="Great Britain" class="ui-li-icon footer-icon2"><br/>Home</a></li>
<li><a href="#searchpage"><img src="img/globe_edit.png" alt="Great Britain" class="ui-li-icon footer-icon2"><br/>Search</a></li>
<li><a href="#trendingpage"><img src="img/headphones_edit.png" alt="Great Britain" class="ui-li-icon footer-icon2"><br/>Trending</a></li>
<!-- <li><a href="#librarypage"><img src="img/music-icon_edit.png" alt="Great Britain" class="ui-li-icon footer-icon2"><br/>My Library</a></li>-->
</ul>
</nav>
</footer>
</div> <!--page-->
<!--<li><a href="#"><img src="img/globe.png" alt="Great Britain" class="ui-li-icon">Great Britain</a></li>-->
<script>
$( function()
{
$( 'audio' ).audioPlayer();
});
// $(".bgpic").setAttribute("src", "img/blackbg.jpg");
</script>
</body>
</html>