aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2016-12-08 10:34:10 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2016-12-16 10:21:56 +0000
commitadf07727ab14468c262759a21dedc1ac84cd32c8 (patch)
treecba74237e07f883745a4f9ef5cc37f6399446dd5
parent2abd85a6d9151f95c82656df9e6b8220e381ca03 (diff)
Add a clear offline data button.
-rw-r--r--templates/web/base/offline/appcache.html2
-rw-r--r--web/cobrands/fixmystreet/offline.js12
2 files changed, 14 insertions, 0 deletions
diff --git a/templates/web/base/offline/appcache.html b/templates/web/base/offline/appcache.html
index 6f701321a..5a8ba1463 100644
--- a/templates/web/base/offline/appcache.html
+++ b/templates/web/base/offline/appcache.html
@@ -7,4 +7,6 @@ page wasn’t found or there was a server error. Please try again later.</p>
<ul class="item-list item-list--reports" id="offline_list"></ul>
+<div id="offline_clear"></div>
+
[% INCLUDE 'footer.html' %]
diff --git a/web/cobrands/fixmystreet/offline.js b/web/cobrands/fixmystreet/offline.js
index c875c9b84..c1a93f738 100644
--- a/web/cobrands/fixmystreet/offline.js
+++ b/web/cobrands/fixmystreet/offline.js
@@ -127,6 +127,11 @@ fixmystreet.offlineData = (function() {
saveData();
fixmystreet.offlineBanner.update();
},
+ clearForms: function(idx) {
+ getData().forms = [];
+ saveData();
+ fixmystreet.offlineBanner.update();
+ },
getCachedUrls: function() {
return Object.keys(getData().cachedReports);
},
@@ -370,6 +375,13 @@ if ($('#offline_list').length) {
$(this).find('h3').prepend('<em>Form data saved</em> ');
}
});
+ $('#offline_clear').html('<button id="js-clear-localStorage">Clear offline data</button>');
+ $('#js-clear-localStorage').click(function() {
+ fixmystreet.offline.removeReports(fixmystreet.offlineData.getCachedUrls());
+ fixmystreet.offlineData.clearForms();
+ localStorage.removeItem('/my/planned');
+ alert('Offline data cleared');
+ });
}
}
fixmystreet.offlineBanner.make(true);