diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-12-08 10:34:10 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-12-16 10:21:56 +0000 |
commit | adf07727ab14468c262759a21dedc1ac84cd32c8 (patch) | |
tree | cba74237e07f883745a4f9ef5cc37f6399446dd5 /web | |
parent | 2abd85a6d9151f95c82656df9e6b8220e381ca03 (diff) |
Add a clear offline data button.
Diffstat (limited to 'web')
-rw-r--r-- | web/cobrands/fixmystreet/offline.js | 12 |
1 files changed, 12 insertions, 0 deletions
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); |