diff --git a/openlp/plugins/remotes/html/index.html b/openlp/plugins/remotes/html/index.html index 67621f790..f1499ec4d 100644 --- a/openlp/plugins/remotes/html/index.html +++ b/openlp/plugins/remotes/html/index.html @@ -116,7 +116,7 @@ function new_response(eventname, text){ var table = $(""); for (row in data) { - var trow = $("").click("send_event('servicemanager_set_item', '" + row + "')"); + var trow = $("").click("send_event"); if (data[row]['selected']) { trow.attr("style", "font-weight: bold"); diff --git a/openlp/plugins/remotes/html/init.js b/openlp/plugins/remotes/html/init.js new file mode 100644 index 000000000..6c5f497da --- /dev/null +++ b/openlp/plugins/remotes/html/init.js @@ -0,0 +1,32 @@ +/***************************************************************************** + * OpenLP - Open Source Lyrics Projection * + * ------------------------------------------------------------------------- * + * Copyright (c) 2008-2010 Raoul Snyman * + * Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael * + * Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin * + * Thompson, Jon Tibble, Carsten Tinggaard * + * ------------------------------------------------------------------------- * + * This program is free software; you can redistribute it and/or modify it * + * under the terms of the GNU General Public License as published by the * + * Free Software Foundation; version 2 of the License. * + * * + * This program is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * + * Public License for more details. * + * * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + *****************************************************************************/ + +/** + * init.js - In certain browsers (yes, IE, I'm looking at you!), DocumentReady + * JavaScript functions can only be run very last on the page. This file is the + * last JavaScript file to be included on the page, and provides a work-around + * for this bug in certain browsers. + */ + +$(document).ready(function () { + OpenLP.Events.init(); +}); \ No newline at end of file diff --git a/openlp/plugins/remotes/html/openlp.js b/openlp/plugins/remotes/html/openlp.js new file mode 100644 index 000000000..8172177d7 --- /dev/null +++ b/openlp/plugins/remotes/html/openlp.js @@ -0,0 +1,123 @@ +/***************************************************************************** + * OpenLP - Open Source Lyrics Projection * + * ------------------------------------------------------------------------- * + * Copyright (c) 2008-2010 Raoul Snyman * + * Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael * + * Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin * + * Thompson, Jon Tibble, Carsten Tinggaard * + * ------------------------------------------------------------------------- * + * This program is free software; you can redistribute it and/or modify it * + * under the terms of the GNU General Public License as published by the * + * Free Software Foundation; version 2 of the License. * + * * + * This program is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * + * Public License for more details. * + * * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + *****************************************************************************/ + +window["OpenLP"] = { + Namespace: { + /** + * Create a Javascript namespace. + * Based on: http://code.google.com/p/namespacedotjs/ + * Idea behind this is to created nested namespaces that are not ugly. + */ + create: function (name, attributes) { + var parts = name.split('.'), + ns = window, + i = 0; + // find the deepest part of the namespace + // that is already defined + for(; i < parts.length && parts[i] in ns; i++) + ns = ns[parts[i]]; + // initialize any remaining parts of the namespace + for(; i < parts.length; i++) + ns = ns[parts[i]] = {}; + // copy the attributes into the namespace + for (var attr in attributes) + ns[attr] = attributes[attr]; + }, + exists: function (namespace) { + /** + * Determine the namespace of a page + */ + page_namespace = $ScribeEngine.Namespace.get_page_namespace(); + return (namespace == page_namespace); + }, + get_page_namespace: function () { + return $("#content > h2").attr("id"); + } + } +}; + +Array.prototype.append = function (elem) { + this[this.length] = elem; +} + +OpenLP.Namespace.create("OpenLP.Events", { + // Local variables + onload_functions: Array(), + // Functions + load: function (func) { + this.onload_functions.append(func); + }, + click: function (selector, func) { + $(selector).bind("click", func); + }, + change: function (selector, func) { + $(selector).bind("change", func); + }, + submit: function (selector, func) { + $(selector).bind("submit", func); + }, + blur: function (selector, func) { + $(selector).bind("blur", func); + }, + paste: function (selector, func) { + $(selector).bind("paste", func); + }, + keyup: function (selector, func) { + $(selector).bind("keyup", func); + }, + keydown: function (selector, func) { + $(selector).bind("keydown", func); + }, + keypress: function (selector, func) { + $(selector).bind("keypress", func); + }, + getElement: function(event) { + var targ; + if (!event) { + var event = window.event; + } + if (event.target) { + targ = event.target; + } + else if (event.srcElement) { + targ = event.srcElement; + } + if (targ.nodeType == 3) { + // defeat Safari bug + targ = targ.parentNode; + } + return $(targ); + }, + init: function () { + for (idx in this.onload_functions) { + func = this.onload_functions[idx]; + func(); + } + } +}); + +OpenLP.Namespace.create("OpenLP.Remote", { + sendEvent: function (event_name, event_data) + { + return false; + } +}); \ No newline at end of file diff --git a/openlp/plugins/remotes/html/openlp.service.js b/openlp/plugins/remotes/html/openlp.service.js new file mode 100644 index 000000000..843e6d18f --- /dev/null +++ b/openlp/plugins/remotes/html/openlp.service.js @@ -0,0 +1,44 @@ +/***************************************************************************** + * OpenLP - Open Source Lyrics Projection * + * ------------------------------------------------------------------------- * + * Copyright (c) 2008-2010 Raoul Snyman * + * Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael * + * Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin * + * Thompson, Jon Tibble, Carsten Tinggaard * + * ------------------------------------------------------------------------- * + * This program is free software; you can redistribute it and/or modify it * + * under the terms of the GNU General Public License as published by the * + * Free Software Foundation; version 2 of the License. * + * * + * This program is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * + * Public License for more details. * + * * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + *****************************************************************************/ + +OpenLP.Namespace.create("OpenLP.Service", { + addServiceItem: function (elem, item) + { + var trow = $("") + .attr("id", "item-" + item.id) + .addClass("item") + .append($("
").text(item.tag)) + .append($("").text(item.tag.replace(/\n/g, "
"))); + return false; + }, + sendLive: function (e) + { + var elem = OpenLP.Events.getElement(e); + var row = elem.attr("id").substr(5); + elem.addStyle("font-weight", "bold"); + return false; + } +}); + +OpenLP.Events.load(function (){ + OpenLP.Events.liveClick(".item", OpenLP.Service.sendLive); +}); \ No newline at end of file diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 790a41f3f..2c12eac76 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -25,9 +25,13 @@ import logging import os -import json import urlparse +try: + import json +except ImportError: + import simplejson as json + from PyQt4 import QtCore, QtNetwork from openlp.core.lib import Receiver @@ -185,7 +189,7 @@ class HttpConnection(object): Ultimately for i18n, this could first look for xx/file.html before falling back to file.html... where xx is the language, e.g. 'en' """ - log.debug(u'serve file request %s' % filename) + log.debug(u'serve file request %s' % filename) if not filename: filename = u'index.html' path = os.path.normpath(os.path.join(self.parent.html_dir, filename))