Web server improvements

I want to use the remote control this weekend, so I needed to fix it up.
This commit is contained in:
Bryan Schumaker 2011-12-22 14:16:33 -05:00
parent f8ed8c4483
commit 798134b910
6 changed files with 74 additions and 12 deletions

View File

@ -6,14 +6,14 @@
function set_playing()
{
var button = document.getElementById("button");
button.src = "images/pause.png";
button.src = "pause.png";
button.onclick = pause2;
}
function set_paused()
{
var button = document.getElementById("button");
button.src = "images/play.png";
button.src = "play.png";
button.onclick = play2;
}
@ -33,7 +33,7 @@ function set_play_button()
}
}
}
req.open('GET', "controls.py?a=playing", true);
req.open('GET', "RPC/playing", true);
req.send();
}
@ -72,12 +72,12 @@ function stop2()
<tr><td id="album"></td></tr>
</table>
<table><tr>
<td><img id="button" src="images/play.png" onclick="play2();" /></td>
<td><img src="images/stop.png" onclick="stop2();" /></td>
<td><img src="images/next.png" onclick="next();" /></td>
<td><img id="button" src="play.png" onclick="play2();" /></td>
<td><img src="stop.png" onclick="stop();" /></td>
<td><img src="next.png" onclick="next();" /></td>
</tr><tr>
<td><img src="images/rewind.png" onclick="rewind();" /></td>
<td><img src="images/forward.png" onclick="forward();" /></td>
<td><img src="rewind.png" onclick="rewind();" /></td>
<td><img src="forward.png" onclick="forward();" /></td>
</tr></table>
</body>

View File

@ -6,6 +6,7 @@
<body>
<table>
<tr><td><a href="library.html">Library Browser</a></td></tr>
<tr><td><a href="controls.html">Remote Controls</a></td></tr>
<!--<tr><td><a href="library2.py">Library Browser 2</a></td></tr>
<tr><td><a href="controls.html">Remote Controls</a></td></tr>
<tr><td id="vers"></td><td id="up"></td></tr>-->

View File

@ -11,7 +11,7 @@ function set_attr(attr, id)
}
}
req.open('GET', "controls.py?a=" + attr, true);
req.open('GET', "RPC/" + attr, true);
req.send();
setTimeout("set_attr(\"" + attr + "\", \"" + id + "\")", 3000)
}
@ -26,7 +26,7 @@ function set_attr_once(attr, id)
document.getElementById(id).innerHTML = req.responseText;
}
}
req.open('GET', "controls.py?a=" + attr, true);
req.open('GET', "RPC/" + attr, true);
req.send();
}

View File

@ -10,6 +10,7 @@ docs.update(rpc.docs)
types = {
"html":"text/html",
"js":"text/javascript",
"png":"image/png",
}
def lookup(file):

View File

@ -30,6 +30,27 @@ def library(write):
color = "white"
write("</table></body></html>")
def controls_page(write):
write_file(write, "html/controls.html")
def play_button(write):
write_file(write, "html/images/play.png")
def pause_button(write):
write_file(write, "html/images/pause.png")
def stop_button(write):
write_file(write, "html/images/stop.png")
def next_button(write):
write_file(write, "html/images/next.png")
def rewind_button(write):
write_file(write, "html/images/rewind.png")
def forward_button(write):
write_file(write, "html/images/forward.png")
def controls(write):
write_file(write, "html/controls.js")
@ -39,6 +60,13 @@ def utils(write):
docs = {
"index.html":(index, "html"),
"library.html":(library, "html"),
"controls.html":(controls_page, "html"),
"controls.js":(controls, "js"),
"utils.js":(utils, "js"),
"play.png":(play_button, "png"),
"pause.png":(pause_button, "png"),
"stop.png":(stop_button, "png"),
"next.png":(next_button, "png"),
"forward.png":(rewind_button, "png"),
"rewind.png":(forward_button, "png"),
}

View File

@ -9,12 +9,44 @@ def play(write):
def pause(write):
controls.pause()
def next(write):
controls.next()
def stop(write):
controls.stop()
def forward(write):
controls.seek_forward()
def rewind(write):
controls.seek_backward()
def play_id(write, id):
sources.play_id(long(id[0]))
def title(write):
write(sources.get_attrs("title")[0])
def artist(write):
write(sources.get_attrs("artist")[0])
def album(write):
write(sources.get_attrs("album")[0])
def playing(write):
write(controls.playing())
rpc = {
"play.html":(play, "html"),
"pause.html":(pause, "html"),
"play":(play, "html"),
"pause":(pause, "html"),
"stop":(stop, "html"),
"next":(next, "html"),
"forward":(forward, "html"),
"rewind":(rewind, "html"),
"title":(title, "html"),
"artist":(artist, "html"),
"album":(album, "html"),
"playing":(playing, "html"),
"play_id":(play_id, "html"),
}