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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user