From 6335ceac900ca5f8971cf1103bb0695b5a36dbef Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 15 Mar 2011 08:46:54 +0200 Subject: [PATCH] Added server-side verse changing. --- openlp/plugins/remotes/html/openlp.js | 20 ++++++++++++++++++++ openlp/plugins/remotes/lib/httpserver.py | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/remotes/html/openlp.js b/openlp/plugins/remotes/html/openlp.js index 5b3121439..a272c1590 100644 --- a/openlp/plugins/remotes/html/openlp.js +++ b/openlp/plugins/remotes/html/openlp.js @@ -106,8 +106,28 @@ window.OpenLP = { $("#slide-controller div[data-role=content] ul[data-role=listview]").listview("refresh"); } ); + }, + updateItem: function () { + $.getJSON( + "/api/poll", + function (data, status) { + var idx; + var len = $("#slide-controller div[data-role=content] ul[data-role=listview] li").length; + for (idx = 0; idx < len; idx++) { + if (idx == data.results.slide) { + $($("#slide-controller div[data-role=content] ul[data-role=listview] li")[idx]).attr("data-theme", "e").removeClass("ui-btn-up-c").addClass("ui-btn-up-e"); + } + else { + $($("#slide-controller div[data-role=content] ul[data-role=listview] li")[idx]).attr("data-theme", "c").removeClass("ui-btn-up-e").addClass("ui-btn-up-c"); + } + } + $("#slide-controller div[data-role=content] ul[data-role=listview]").listview("refresh"); + } + ); } } $("#service-manager").live("pagebeforeshow", OpenLP.loadService); $("#slide-controller").live("pagebeforeshow", OpenLP.loadController); +setInterval("OpenLP.updateItem();", 500); +OpenLP.updateItem(); diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index b52f9d3eb..cf32e2dbb 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -143,7 +143,8 @@ class HttpServer(object): The connection has been closed. Clean up """ log.debug(u'close http connection') - self.connections.remove(connection) + if connection in self.connections: + self.connections.remove(connection) def close(self): """