From 7d446c6043216baf9b46e56df973b197df7607ba Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Tue, 9 Oct 2018 14:02:48 +0100 Subject: [BANES] Add roadworks.org layer Uses same parsing of roadworks messages as Lincs --- perllib/FixMyStreet/Map/BathNES.pm | 2 ++ web/cobrands/bathnes/base.scss | 15 +++++++++++ web/cobrands/bathnes/js.js | 51 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 web/cobrands/bathnes/js.js diff --git a/perllib/FixMyStreet/Map/BathNES.pm b/perllib/FixMyStreet/Map/BathNES.pm index b21ba6ce7..45261a625 100644 --- a/perllib/FixMyStreet/Map/BathNES.pm +++ b/perllib/FixMyStreet/Map/BathNES.pm @@ -11,7 +11,9 @@ sub map_javascript { [ '/vendor/OpenLayers.Projection.OrdnanceSurvey.js', '/js/map-OpenLayers.js', '/js/map-OpenStreetMap.js', + '/cobrands/fixmystreet-uk-councils/roadworks.js', '/cobrands/fixmystreet/assets.js', + '/cobrands/bathnes/js.js', '/cobrands/bathnes/assets.js', ] } diff --git a/web/cobrands/bathnes/base.scss b/web/cobrands/bathnes/base.scss index 934d9ffdd..f84323b1c 100644 --- a/web/cobrands/bathnes/base.scss +++ b/web/cobrands/bathnes/base.scss @@ -76,3 +76,18 @@ a:active, a:hover { color: $link-hover-colour; } color: #fff; } } + +.js-roadworks-message { + margin: 1em -1em; + padding: 1em; + background-color: #00aeef; + color: #fff; + dt { + float: left; + margin-right: 0.25em; + } + + p:last-child { + font-weight: bold; + } +} diff --git a/web/cobrands/bathnes/js.js b/web/cobrands/bathnes/js.js new file mode 100644 index 000000000..06741e10d --- /dev/null +++ b/web/cobrands/bathnes/js.js @@ -0,0 +1,51 @@ +(function(){ + +if (!fixmystreet.maps) { + return; +} + +fixmystreet.roadworks.display_message = function(feature) { + var attr = feature.attributes, + start = new Date(attr.start.replace(/{ts '([^ ]*).*/, '$1')).toDateString(), + end = new Date(attr.end.replace(/{ts '([^ ]*).*/, '$1')).toDateString(), + tooltip = attr.tooltip.replace(/\\n/g, '\n'), + desc = attr.works_desc.replace(/\\n/g, '\n'); + + var $msg = $('

Roadworks are scheduled near this location, so you may not need to report your issue.

'); + var $dl = $("
").appendTo($msg); + $dl.append("
Dates:
"); + $dl.append($("
").text(start + " until " + end)); + $dl.append("
Summary:
"); + var $summary = $("
").appendTo($dl); + tooltip.split("\n").forEach(function(para) { + if (para.match(/^(\d{2}\s+\w{3}\s+(\d{2}:\d{2}\s+)?\d{4}( - )?){2}/)) { + // skip showing the date again + return; + } + if (para.match(/^delays/)) { + // skip showing traffic delay information + return; + } + $summary.append(para).append("
"); + }); + if (desc) { + $dl.append("
Description:
"); + $dl.append($("
").text(desc)); + } + $dl.append($("

If you think this issue needs immediate attention you can continue your report below

")); + + $('.change_location').after($msg); +}; + +var org_id = '114'; +var body = "Bath and North East Somerset Council"; +fixmystreet.assets.add($.extend(true, {}, fixmystreet.roadworks.layer_future, { + http_options: { params: { organisation_id: org_id } }, + body: body +})); +fixmystreet.assets.add($.extend(true, {}, fixmystreet.roadworks.layer_planned, { + http_options: { params: { organisation_id: org_id } }, + body: body +})); + +})(); -- cgit v1.2.3