Permalink
Browse files

add timestamps, clean up HTML, fix uri

  • Loading branch information...
1 parent af08d6f commit f86965dede80e4cedebb02c0f5c5bf905f5506ca Luke Closs committed Apr 15, 2008
Showing with 13 additions and 9 deletions.
  1. +3 −2 test-web-view.py
  2. +6 −4 web/index.html
  3. +4 −3 web/xo-code.js
View
@@ -6,6 +6,7 @@
from XOCom import XOCom
# The XOCom object helps us communicate with the browser
+uri = "file:///home/olpc/src/testapp/web/index.html"
xocom = XOCom(uri)
# This is just a simple way to trigger events from python for testing
@@ -27,6 +28,7 @@ def keypress(window, event):
if key == 'q':
quit(None)
+
# Shut down our app
def quit(window):
# hulahop.shutdown()
@@ -38,7 +40,6 @@ def quit(window):
window.connect("destroy", quit)
window.connect("key_press_event", keypress)
-uri = "file:///home/olpc/src/testapp/web/index.html"
-window.add( xocom.create_webview(uri) )
+window.add( xocom.create_webview() )
window.show()
gtk.main()
View
@@ -16,16 +16,18 @@
jQuery('textarea').html(data)
})
XO.register('write', function() {
- return jQuery('textarea').html()
+ var content = jQuery('textarea').val()
+ jQuery('#app-status').html("Writing (" + content + ")")
+ return content
})
setTimeout( function () {
jQuery('#app-status').html("Registered XO Hooks")
}, 50)
</script>
<body>
- XO Status:<div id="xo-status">No status</div><br />
- App Status:<div id="app-status">No status</div><br />
- <textarea rows="30" cols="80">Default text</textarea>
+ XO Status: <span id="xo-status">No status</span><br />
+ App Status: <span id="app-status">No status</span><br />
+ <textarea rows="30" cols="80"></textarea>
</body>
</html>
View
@@ -30,7 +30,8 @@ var XO = window.XO = {
},
observer: {
observe: function(req_obj,topic,command) {
- XO.set_status("Handling " + command)
+ now = new Date().getTime()
+ XO.set_status("(" + now + ") Handling " + command)
try {
// We need access to use the XPCom functions below
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect")
@@ -46,15 +47,15 @@ var XO = window.XO = {
}
// Execute the registered callback method
- return_value = XO.callbacks[command](command_arg)
+ return_value = XO.callbacks[command](command_arg) || ''
// Wrap the return value back into the XPCom object
var result = Components.classes["@mozilla.org/supports-string;1"].createInstance(
Components.interfaces.nsISupportsString)
result.data = return_value
req_obj.clear()
req_obj.appendElement(result, false)
- XO.set_status("Handled " + command)
+ XO.set_status("(" + now + ") Handled " + command + ": (" + return_value + ")")
}
catch (err) {
XO.set_status("Error handling event: " + err)

0 comments on commit f86965d

Please sign in to comment.