From a92228c713c73b4015766b45eecd4769a57ae232 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 4 Dec 2009 14:31:19 -0500 Subject: 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. --- plugins/Mapstraction/MapstractionPlugin.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'plugins/Mapstraction/MapstractionPlugin.php') 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; } -- cgit v1.2.3-54-g00ecf