summaryrefslogtreecommitdiff
path: root/static/player.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/player.js')
-rw-r--r--static/player.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/static/player.js b/static/player.js
index 3f98dce..b120fe1 100644
--- a/static/player.js
+++ b/static/player.js
@@ -145,6 +145,35 @@ function list(root) {
xmlhttp.send();
}
+function do_search(e) {
+ if(e.keyCode != 13)
+ return;
+
+ var xmlhttp = new XMLHttpRequest();
+ xmlhttp.onreadystatechange = function() {
+ if(xmlhttp.readyState == 4) {
+ var json = JSON.parse(xmlhttp.responseText);
+ document.getElementById('song-links').innerHTML = '';
+ output_link(new MusicListing('dir', '/', 'Go to root directory'));
+ for(var i = 0; i < json.length; i++) {
+ var type = json[i]["type"];
+ var path = json[i]["name"];
+ var track = json[i]["track"];
+ var name = path.substring(path.lastIndexOf('/')+1);
+ var cached = type == "file" ? json[i]["cached"] : false;
+ var metadata = json[i]["metadata"];
+ var l = new MusicListing(type, path, name, track, metadata, cached);
+ output_link(l);
+ }
+ }
+ }
+
+ var query = document.getElementById('search-query').value;
+ var path = '/search?query=' + encodeURIComponent(query);
+ xmlhttp.open('GET', path);
+ xmlhttp.send();
+}
+
function add_directory() {
var songs = document.getElementById('song-links').getElementsByTagName('a');
for(var i = 0; i < songs.length; i++) {