Fixed up json import.

Started JavaScript framework.
Started implementing Service Management.
This commit is contained in:
Raoul Snyman 2010-05-30 00:28:28 +02:00
parent 0b8d8b8832
commit 7c47e24cf0
5 changed files with 206 additions and 3 deletions

View File

@ -116,7 +116,7 @@ function new_response(eventname, text){
var table = $("<table>");
for (row in data)
{
var trow = $("<tr>").click("send_event('servicemanager_set_item', '" + row + "')");
var trow = $("<tr>").click("send_event");
if (data[row]['selected'])
{
trow.attr("style", "font-weight: bold");

View File

@ -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();
});

View File

@ -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;
}
});

View File

@ -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 = $("<tr>")
.attr("id", "item-" + item.id)
.addClass("item")
.append($("<td>").text(item.tag))
.append($("<td>").text(item.tag.replace(/\n/g, "<br />")));
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);
});

View File

@ -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))