aboutsummaryrefslogtreecommitdiffstats
path: root/www/js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js')
-rw-r--r--www/js/app.js2
-rw-r--r--www/js/router.js6
-rw-r--r--www/js/views/existing.js26
-rw-r--r--www/js/views/home.js2
4 files changed, 35 insertions, 1 deletions
diff --git a/www/js/app.js b/www/js/app.js
index f717da9..e79d7a7 100644
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -38,7 +38,7 @@ var tpl = {
(function (FMS, Backbone, _, $) {
_.extend(FMS, {
templates: [
- 'home', 'around', 'address_search', 'photo', 'details', 'submit', 'submit_email', 'submit_name', 'submit_password', 'sent'
+ 'home', 'around', 'address_search', 'existing', 'photo', 'details', 'submit', 'submit_email', 'submit_name', 'submit_password', 'sent'
],
initialized: 0,
diff --git a/www/js/router.js b/www/js/router.js
index c259c05..f220422 100644
--- a/www/js/router.js
+++ b/www/js/router.js
@@ -8,6 +8,7 @@
'home': 'home',
'around': 'around',
'search': 'search',
+ 'existing': 'existing',
'photo': 'photo',
'details': 'details',
'submit': 'submit',
@@ -42,6 +43,11 @@
this.changeView(searchView);
},
+ existing: function(){
+ var existingView = new FMS.ExistingView({ model: FMS.currentDraft });
+ this.changeView(existingView);
+ },
+
home: function(){
var homeView = new FMS.HomeView({ model: FMS.currentDraft });
this.changeView(homeView);
diff --git a/www/js/views/existing.js b/www/js/views/existing.js
new file mode 100644
index 0000000..b4af574
--- /dev/null
+++ b/www/js/views/existing.js
@@ -0,0 +1,26 @@
+(function (FMS, Backbone, _, $) {
+ _.extend( FMS, {
+ ExistingView: FMS.FMSView.extend({
+ template: 'existing',
+ id: 'existing',
+
+ events: {
+ 'pagehide': 'destroy',
+ 'pageshow': 'afterDisplay',
+ 'click #use_report': 'useReport',
+ 'click #discard': 'discardReport'
+ },
+
+ useReport: function() {
+ localStorage.currentDraftID = FMS.currentDraft.id;
+ this.navigate('around');
+ },
+
+ discardReport: function() {
+ FMS.currentDraft.destroy();
+ FMS.currentDraft = new FMS.Draft();
+ this.navigate('around');
+ }
+ })
+ });
+})(FMS, Backbone, _, $);
diff --git a/www/js/views/home.js b/www/js/views/home.js
index 0a0480f..9c169a9 100644
--- a/www/js/views/home.js
+++ b/www/js/views/home.js
@@ -27,6 +27,8 @@
navigator.connection.type == Connection.UNKNOWN ) ) {
localStorage.offline = 1;
this.navigate( 'no_connection' );
+ } else if ( FMS.currentDraft && FMS.currentDraft.get('lat') ) {
+ this.navigate( 'existing' );
} else {
this.navigate( 'around' );
}