summaryrefslogtreecommitdiff
path: root/plugins/Comet/CometPlugin.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-04-26 15:08:49 -0400
committerEvan Prodromou <evan@controlyourself.ca>2009-04-26 15:08:49 -0400
commitccf45d454c68f7f667d07e0db608569e049ec285 (patch)
treeebfa90bc4676f5e0e0dbb65944f47405789c067c /plugins/Comet/CometPlugin.php
parent262dbeac787ad3aecb28c470484eb3fc8d036d93 (diff)
Lots of tweaking to make things work
Did some tweaking and maneuvering to make things work. This version will now show a "notice received" alert box -- lots of progress! Had to test with Java server, not Python server.
Diffstat (limited to 'plugins/Comet/CometPlugin.php')
-rw-r--r--plugins/Comet/CometPlugin.php22
1 files changed, 11 insertions, 11 deletions
diff --git a/plugins/Comet/CometPlugin.php b/plugins/Comet/CometPlugin.php
index 10f8c198c..f60d40075 100644
--- a/plugins/Comet/CometPlugin.php
+++ b/plugins/Comet/CometPlugin.php
@@ -56,6 +56,8 @@ class CometPlugin extends Plugin
{
$timeline = null;
+ $this->log(LOG_DEBUG, 'got action ' . $action->trimmed('action'));
+
switch ($action->trimmed('action')) {
case 'public':
$timeline = '/timelines/public';
@@ -64,16 +66,18 @@ class CometPlugin extends Plugin
return true;
}
- $action->element('script', array('type' => 'text/javascript',
- 'src' => common_path('plugins/Comet/jquery.comet.js')),
+ $scripts = array('jquery.comet.js', 'json2.js', 'updatetimeline.js');
+
+ foreach ($scripts as $script) {
+ $action->element('script', array('type' => 'text/javascript',
+ 'src' => common_path('plugins/Comet/'.$script)),
' ');
+ }
+
$action->elementStart('script', array('type' => 'text/javascript'));
- $action->raw("var _timelineServer = \"$this->server\"; ".
- "var _timeline = \"$timeline\";");
+ $action->raw("$(document).ready(function() { updater.init(\"$this->server\", \"$timeline\");});");
$action->elementEnd('script');
- $action->element('script', array('type' => 'text/javascript',
- 'src' => common_path('plugins/Comet/updatetimeline.js')),
- ' ');
+
return true;
}
@@ -96,21 +100,17 @@ class CometPlugin extends Plugin
$json = $this->noticeAsJson($notice);
- $this->log(LOG_DEBUG, "JSON = '$json'");
-
// Bayeux? Comet? Huh? These terms confuse me
$bay = new Bayeux($this->server);
foreach ($timelines as $timeline) {
$this->log(LOG_INFO, "Posting notice $notice->id to '$timeline'.");
$bay->publish($timeline, $json);
- $this->log(LOG_DEBUG, "Done posting notice $notice->id to '$timeline'.");
}
$bay = NULL;
}
- $this->log(LOG_DEBUG, "All done.");
return true;
}