]> git.wh0rd.org - chrome-ext/music-player-client.git/blobdiff - main.js
tcp-client: allow caller to force pulling of more data
[chrome-ext/music-player-client.git] / main.js
diff --git a/main.js b/main.js
index 1de6b6a4c18e8f254be18dbcc6acb6971c9220ef..b83e0a219739a85ff931f8129635815c3eb3b533 100644 (file)
--- a/main.js
+++ b/main.js
@@ -11,6 +11,9 @@ function TcpClientSender(tcpclient) {
 TcpClientSender.prototype.send = function(data, cb) {
        this.tcpclient.sendMessage(data, cb);
 }
+TcpClientSender.prototype.poll = function() {
+       this.tcpclient.poll();
+}
 
 function tramp_mpc_recv(data) {
        mpc.recv(data);
@@ -237,8 +240,7 @@ function update_ui(state, cmd) {
 
        if ('file' in state) {
                // Hack: should be a real object.
-               ui_mpc_metadata.innerText = state['file'];
-               return;
+               ui_mpc_metadata.innerText = state.file;
        }
 
        var time;
@@ -247,10 +249,14 @@ function update_ui(state, cmd) {
                time = state.time.split(':');
        else
                time = [0, 0];
-       window['ui_mpc_seekcur'].max = time[1];
-       window['ui_mpc_seekcur'].value = time[0];
+       window.ui_mpc_seekcur.max = time[1];
+       window.ui_mpc_seekcur.value = time[0];
+       percent = Math.floor((0.0 + time[0]) * 100 / (0.0 + time[1]));
+       window.ui_mpc_seekcur.title = 'seekcur (' + percent + '%)';
+
+       window.ui_mpc_setvol.value = state.volume;
+       window.ui_mpc_setvol.title = 'setvol (' + state.volume + '%)';
 
-       window['ui_mpc_setvol'].value = state.volume;
        [
                'consume', 'random', 'repeat', 'single',
        ].forEach(function(id) {