diff options
author | Evan Prodromou <evan@status.net> | 2009-12-04 14:31:19 -0500 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2009-12-04 14:31:19 -0500 |
commit | a92228c713c73b4015766b45eecd4769a57ae232 (patch) | |
tree | ef9307bb35cb201c4b7561c991211fa6ca03516a /plugins/Mapstraction/MapstractionPlugin.php | |
parent | 2c07d4a530e2e8ea6a48f08806f5026df1132152 (diff) |
Update Mapstraction to properly scrape data from notice-list pages
Refactored the JavaScript for Mapstraction use so it scrapes data from
the HTML of the page it's on, if possible, and otherwise generates a
JSON array.
Diffstat (limited to 'plugins/Mapstraction/MapstractionPlugin.php')
-rw-r--r-- | plugins/Mapstraction/MapstractionPlugin.php | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/plugins/Mapstraction/MapstractionPlugin.php b/plugins/Mapstraction/MapstractionPlugin.php index c4f9cd77d..ba7827151 100644 --- a/plugins/Mapstraction/MapstractionPlugin.php +++ b/plugins/Mapstraction/MapstractionPlugin.php @@ -112,6 +112,11 @@ class MapstractionPlugin extends Plugin { $actionName = $action->trimmed('action'); + if (!in_array($actionName, + array('showstream', 'all', 'usermap', 'allmap'))) { + return true; + } + switch ($this->provider) { case 'cloudmade': @@ -143,9 +148,20 @@ class MapstractionPlugin extends Plugin $action->script(common_path('plugins/Mapstraction/usermap.js')); - $action->elementStart('script', array('type' => 'text/javascript')); - $action->raw(sprintf('var _provider = "%s";', $this->provider)); - $action->elementEnd('script'); + $action->inlineScript(sprintf('var _provider = "%s";', $this->provider)); + + // usermap and allmap handle this themselves + + if (in_array($actionName, + array('showstream', 'all'))) { + $action->inlineScript('$(document).ready(function() { '. + ' var user = null; '. + (($actionName == 'showstream') ? ' user = scrapeUser(); ' : '') . + ' var notices = scrapeNotices(user); ' . + ' console.log(notices); ' . + ' showMapstraction($("#map_canvas"), notices); '. + '});'); + } return true; } |