-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Étienne ANDRÉ
committed
Mar 1, 2018
1 parent
2e53416
commit f7feed0
Showing
13 changed files
with
215 additions
and
459 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
CONFIG = { | ||
"secret_key": "", | ||
"mpc_host": "localhost", | ||
"mpc_port": "6600", | ||
"youtube_key": "", | ||
"spotify-clientid": "", | ||
"spotify-secret": "", | ||
"listen_addr": "0.0.0.0", | ||
"listen_port": 8080, | ||
"search_providers": [ | ||
# "spotify", | ||
"youtube" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
function template(html, d) { | ||
var r = html; | ||
for (i in d) { | ||
r=r.replace("{"+i+"}", d[i]); | ||
} | ||
r=r.replace(/{\w+}/g, "") | ||
return r; | ||
} | ||
|
||
function generate_track_html(t) { | ||
track_html = document.createElement("div") | ||
track_html.innerHTML = template(track_template, t) | ||
$(track_html).children().data("track", t); | ||
return track_html | ||
} | ||
|
||
track_template = ` | ||
<li class="list-group-item {active}"> | ||
<div class="row"> | ||
<div class="col-4 centered"> | ||
<img class="albumart" src="{albumart_url}"> | ||
</div> | ||
<div class="col track-info centered"> | ||
<span class="track-title">{title}</span> | ||
<span class="track-artist">{artist}</span> | ||
<span class="track-duration">{duration} s.</span> | ||
</div> | ||
<div class="col-1 centered"> | ||
<img class="icon btn-remove" src="/static/images/icons/x.svg"> | ||
</div> | ||
</div> | ||
</li> | ||
` | ||
update_search = function() { | ||
$.get("/sync", function (data) { | ||
// console.log(data); | ||
$('#playlist').html(""); | ||
for (i in data.playlist) { | ||
var t = data.playlist[i]; | ||
if (i == 0) { | ||
t.active = "active"; | ||
} | ||
$('#playlist').append(generate_track_html(t)) | ||
$('#playlist li:last .btn-remove').click(function() { | ||
$.post("/remove", $(this).parents("li").data("track")); | ||
$(this).parents("li").hide(); | ||
}); | ||
} | ||
}); | ||
window.setTimeout(arguments.callee, 5000); | ||
}(); | ||
|
||
var delay = (function(){ | ||
var timer = 0; | ||
return function(callback, ms){ | ||
clearTimeout (timer); | ||
timer = setTimeout(callback, ms); | ||
}; | ||
})(); | ||
|
||
$('#query').keyup(function() { | ||
if ($('#query').val() == "") { | ||
$("#search_results").html(""); | ||
$("#search_results").hide(); | ||
return; | ||
} | ||
delay(function() { | ||
console.log("searching "+$('#query').val()); | ||
$.get("/search/"+$('#query').val(), function(data) { | ||
$("#search_results").html("") | ||
console.log(data); | ||
for (i in data) { | ||
var t = data[i]; | ||
$('#search_results').append(generate_track_html(data[i])) | ||
$('#search_results li:last').click(function() { | ||
$.post("/add", $(this).data("track")); | ||
$('#search_results').hide(); | ||
}); | ||
} | ||
$("#search_results").show() | ||
}, dataType="json"); | ||
},150); | ||
}); | ||
$('#query').focus(function () { | ||
if ($('#query').val() != "") | ||
$('#search_results').show(); | ||
}); | ||
|
||
$('#search_results').hide(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
.icon { | ||
height: 20px; | ||
display: block; | ||
} | ||
|
||
#search_results .btn-skip { | ||
display: none; | ||
} | ||
#search_results li { | ||
cursor: pointer; | ||
} | ||
|
||
.albumart { | ||
width: 100% | ||
} | ||
|
||
.track-title { | ||
display: block; | ||
font-size: x-large; | ||
} | ||
.track-artist { | ||
display: block; | ||
} | ||
|
||
.btn-remove { | ||
cursor:pointer | ||
} | ||
.centered { | ||
margin: auto | ||
} | ||
.track-duration { | ||
color: #aaa; | ||
} |
Oops, something went wrong.