diff options
author | Matthew Somerville <matthew@mysociety.org> | 2016-01-20 15:35:31 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2016-01-20 15:41:36 +0000 |
commit | 47d534a2ac59335474be97fbb9fa9fc39f0464c7 (patch) | |
tree | 62aa3d9b09bc1c2e79d1bad8472661d5f5c86c98 | |
parent | 9232c62b050f5b9371b3c74dfe57e87ad186b9c9 (diff) |
Make sure data variable is defined before use.
e.g. if you had skipped the map there is no fixmystreet variable on the
resulting page, so we need to create it and check it.
-rw-r--r-- | templates/web/base/questionnaire/index.html | 1 | ||||
-rw-r--r-- | templates/web/base/report/new/fill_in_details_form.html | 1 | ||||
-rw-r--r-- | templates/web/base/report/update-form.html | 1 | ||||
-rw-r--r-- | templates/web/bromley/report/display.html | 1 | ||||
-rw-r--r-- | templates/web/bromley/report/new/fill_in_details_form.html | 1 | ||||
-rw-r--r-- | templates/web/eastsussex/report/update-form.html | 1 | ||||
-rw-r--r-- | templates/web/zurich/report/new/fill_in_details_form.html | 1 | ||||
-rw-r--r-- | web/cobrands/fixmystreet/fixmystreet.js | 16 |
8 files changed, 16 insertions, 7 deletions
diff --git a/templates/web/base/questionnaire/index.html b/templates/web/base/questionnaire/index.html index 82f0534f4..2c7761d5d 100644 --- a/templates/web/base/questionnaire/index.html +++ b/templates/web/base/questionnaire/index.html @@ -81,6 +81,7 @@ <div id="form_photos"> [% IF upload_fileid %] <script> + var fixmystreet = fixmystreet || {}; fixmystreet.uploaded_files = "[% upload_fileid %]".split(','); </script> <p>[% loc('You have already attached photos to this update. Note that you can attach a maximum of 3 to this update (if you try to upload more, the oldest will be removed).') %]</p> diff --git a/templates/web/base/report/new/fill_in_details_form.html b/templates/web/base/report/new/fill_in_details_form.html index ae5586127..9c42f4696 100644 --- a/templates/web/base/report/new/fill_in_details_form.html +++ b/templates/web/base/report/new/fill_in_details_form.html @@ -60,6 +60,7 @@ <div id="form_photos"> [% IF upload_fileid %] <script> + var fixmystreet = fixmystreet || {}; fixmystreet.uploaded_files = "[% upload_fileid %]".split(','); </script> <p>[% loc('You have already attached photos to this report. Note that you can attach a maximum of 3 to this report (if you try to upload more, the oldest will be removed).') %]</p> diff --git a/templates/web/base/report/update-form.html b/templates/web/base/report/update-form.html index 8c812cd08..adf1130bf 100644 --- a/templates/web/base/report/update-form.html +++ b/templates/web/base/report/update-form.html @@ -27,6 +27,7 @@ <div id="form_photos"> [% IF upload_fileid %] <script> + var fixmystreet = fixmystreet || {}; fixmystreet.uploaded_files = "[% upload_fileid %]".split(','); </script> <p>[% loc('You have already attached photos to this update. Note that you can attach a maximum of 3 to this update (if you try to upload more, the oldest will be removed).') %]</p> diff --git a/templates/web/bromley/report/display.html b/templates/web/bromley/report/display.html index c9b0e9847..569275841 100644 --- a/templates/web/bromley/report/display.html +++ b/templates/web/bromley/report/display.html @@ -71,6 +71,7 @@ <div id="form_photos"> [% IF upload_fileid %] <script> + var fixmystreet = fixmystreet || {}; fixmystreet.uploaded_files = "[% upload_fileid %]".split(','); </script> <p>[% loc('You have already attached photos to this update. Note that you can attach a maximum of 3 to this update (if you try to upload more, the oldest will be removed).') %]</p> diff --git a/templates/web/bromley/report/new/fill_in_details_form.html b/templates/web/bromley/report/new/fill_in_details_form.html index 09e695278..2f853b506 100644 --- a/templates/web/bromley/report/new/fill_in_details_form.html +++ b/templates/web/bromley/report/new/fill_in_details_form.html @@ -59,6 +59,7 @@ <div id="form_photos"> [% IF upload_fileid %] <script> + var fixmystreet = fixmystreet || {}; fixmystreet.uploaded_files = "[% upload_fileid %]".split(','); </script> <p>[% loc('You have already attached photos to this report. Note that you can attach a maximum of 3 to this report (if you try to upload more, the oldest will be removed).') %]</p> diff --git a/templates/web/eastsussex/report/update-form.html b/templates/web/eastsussex/report/update-form.html index 55d79a930..8c15db904 100644 --- a/templates/web/eastsussex/report/update-form.html +++ b/templates/web/eastsussex/report/update-form.html @@ -71,6 +71,7 @@ <div id="form_photos"> [% IF upload_fileid %] <script> + var fixmystreet = fixmystreet || {}; fixmystreet.uploaded_files = "[% upload_fileid %]".split(','); </script> <p>[% loc('You have already attached photos to this update. Note that you can attach a maximum of 3 to this update (if you try to upload more, the oldest will be removed).') %]</p> diff --git a/templates/web/zurich/report/new/fill_in_details_form.html b/templates/web/zurich/report/new/fill_in_details_form.html index 7a487f902..1e036c087 100644 --- a/templates/web/zurich/report/new/fill_in_details_form.html +++ b/templates/web/zurich/report/new/fill_in_details_form.html @@ -53,6 +53,7 @@ <div id="form_photos"> [% IF upload_fileid %] <script> + var fixmystreet = fixmystreet || {}; fixmystreet.uploaded_files = "[% upload_fileid %]".split(','); </script> <p>[% loc('You have already attached photos to this report. Note that you can attach a maximum of 3 to this report (if you try to upload more, the oldest will be removed).') %]</p> diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js index 3b81ad144..975a8e227 100644 --- a/web/cobrands/fixmystreet/fixmystreet.js +++ b/web/cobrands/fixmystreet/fixmystreet.js @@ -246,13 +246,15 @@ $(function(){ } }); - $.each(fixmystreet.uploaded_files || [], function(i, f) { - var mockFile = { name: f, server_id: f }; - photodrop.emit("addedfile", mockFile); - photodrop.createThumbnailFromUrl(mockFile, '/photo/' + f + '.temp.jpeg'); - photodrop.emit("complete", mockFile); - photodrop.options.maxFiles -= 1; - }); + if (typeof fixmystreet !== 'undefined') { + $.each(fixmystreet.uploaded_files || [], function(i, f) { + var mockFile = { name: f, server_id: f }; + photodrop.emit("addedfile", mockFile); + photodrop.createThumbnailFromUrl(mockFile, '/photo/' + f + '.temp.jpeg'); + photodrop.emit("complete", mockFile); + photodrop.options.maxFiles -= 1; + }); + } } /* |