aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2018-06-19 21:01:25 +0100
committerDave Arter <davea@mysociety.org>2018-08-17 09:43:09 +0100
commit5a47979bf18cda5cd68bcc49a2b27ed3aa22aea3 (patch)
treed054a2692bbb715413c1b8005bfa55df2f854a6f
parentdfa7f748da1df89abbcf26178bfa117a06962aab (diff)
Make roadworks.org integration more configurable
Allows cobrands to customise message displayed, and includes description in GeoJSON feature properties.
-rw-r--r--web/cobrands/fixmystreet-uk-councils/roadworks.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/web/cobrands/fixmystreet-uk-councils/roadworks.js b/web/cobrands/fixmystreet-uk-councils/roadworks.js
index 24eaa8a54..987055f6d 100644
--- a/web/cobrands/fixmystreet-uk-councils/roadworks.js
+++ b/web/cobrands/fixmystreet-uk-councils/roadworks.js
@@ -59,6 +59,7 @@ OpenLayers.Format.RoadworksForwardPlanning = OpenLayers.Class(OpenLayers.Format.
'tooltip': data.tooltip[i],
'org': data.org_name_disp[i],
'promoter': data.promoter[i],
+ 'works_desc': data.works_desc[i],
'start': data.start_date[i],
'end': data.end_date[i],
}
@@ -169,17 +170,20 @@ fixmystreet.roadworks.show_nearby = function(evt, lonlat) {
feature = layer.getNearestFeature(point, 100);
}
if (feature !== null) {
- // XXX TODO
- var attr = feature.attributes,
- start = attr.start.replace(/{ts '([^ ]*).*/, '$1'),
- end = attr.end.replace(/{ts '([^ ]*).*/, '$1'),
- tooltip = attr.tooltip.replace(/\\n/g, '\n');
- $('.change_location').after('<div class="js-roadworks-message box-warning">Roadworks are scheduled near this location from ' + start + ' to ' + end + ', so you may not need to report your issue: “' + tooltip + '”</div>');
+ fixmystreet.roadworks.display_message(feature);
return true;
}
}
};
+fixmystreet.roadworks.display_message = function(feature) {
+ var attr = feature.attributes,
+ start = attr.start.replace(/{ts '([^ ]*).*/, '$1'),
+ end = attr.end.replace(/{ts '([^ ]*).*/, '$1'),
+ tooltip = attr.tooltip.replace(/\\n/g, '\n');
+ $('.change_location').after('<div class="js-roadworks-message box-warning">Roadworks are scheduled near this location from ' + start + ' to ' + end + ', so you may not need to report your issue: “' + tooltip + '”</div>');
+};
+
$(fixmystreet).on('maps:update_pin', fixmystreet.roadworks.show_nearby);
/* Stop sending a needless header so that no preflight CORS request */