diff --git a/public/js/main.js b/public/js/main.js index 0403290..6b3370e 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -78,14 +78,14 @@ const app = new Vue({ el: '#app', data: { journey_id : window.location.pathname.split('/').pop() || gen_id(16), - journey_step: window.location.hash.slice(1)==""?((window.location.pathname.split('/')[1]=='view')?0:-1):parseInt(window.location.hash.slice(1)), + journey_step: window.location.hash.slice(1)==""?((['view','short'].indexOf(window.location.pathname.split('/')[1])!=-1)?0:-1):parseInt(window.location.hash.slice(1)), journey_step_data: {day:-1, section:-1}, journey_data : { name: "New Journey", main:[], step_title:[], }, - view: window.location.pathname.split('/')[1]=='view', + vtp: ['view','short'].indexOf(window.location.pathname.split('/')[1]), query:{hotel:[],flight:[],nominatim:[]}, querying:{hotel:false,flight:false,place:false,food:false}, impexp:"", @@ -113,6 +113,40 @@ const app = new Vue({ window.location.hash = '#' + this.journey_step; }, + nextnext_step: function(){ + let nd = this.journey_step_data; + let ns = this.journey_step; + while((nd.section==this.journey_step_data.section || nd.day>1) + && ns>=0){ + ns+=1; + nd = this.step_convert(ns) + if(nd.section==-1){ + ns-=1; + nd = this.step_convert(ns) + break; + } + } + this.journey_step = ns; + this.journey_step_data = nd; + window.location.hash = '#' + this.journey_step; + }, + prevprev_step: function(){ + let nd = this.journey_step_data; + let ns = this.journey_step; + while((nd.section==this.journey_step_data.section || nd.day>1) + && ns>=0){ + ns-=1; + nd = this.step_convert(ns) + if(ns==-1){ + ns+=1; + nd = this.step_convert(ns) + break; + } + } + this.journey_step = ns; + this.journey_step_data = nd; + window.location.hash = '#' + this.journey_step; + }, first_step: function(){ this.journey_step=-1; this.journey_step_data = {day:-1, section:-1}; @@ -137,6 +171,22 @@ const app = new Vue({ } return {day:-1, section:-1}; }, + active_date: function(){ + if(this.journey_step_data.day < 0) return "?"; + if(!this.journey_data.main[this.journey_step_data.section].dateRange) return "?"; + var date = new Date(this.journey_data.main[this.journey_step_data.section].dateRange[0]); + date.setDate(date.getDate() + this.journey_step_data.day-1); + return this.format_date(date) + }, + format_date: function(d){ + var dt = d.toJSON().slice(0, 10); + return dt.slice(8, 10) + '/' + + dt.slice(5, 7) + '/' + + dt.slice(0, 4) + ' (' + + ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][d.getDay()] + +')'; + }, + rm_section: function(idx){ this.journey_data.main.splice(idx,1); }, diff --git a/public/template/journey.html b/public/template/journey.html index 0842481..db79005 100644 --- a/public/template/journey.html +++ b/public/template/journey.html @@ -18,7 +18,7 @@
-
+
@@ -170,11 +172,14 @@
-
+
+
+
+
@@ -318,19 +323,19 @@
-
+
-
+
{{journey_data.main[journey_step_data.section].title + ': Day ' + journey_step_data.day}}
{{journey_data.step_title[journey_step]}}
-
+
@@ -408,8 +413,69 @@
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
-
diff --git a/server.js b/server.js index ca48c72..c144d9c 100644 --- a/server.js +++ b/server.js @@ -42,6 +42,7 @@ fastify.get('/:id', (req, reply) => { } }); fastify.get('/view/:id', (req, reply) => reply.sendFile('/template/journey.html')); +fastify.get('/short/:id', (req, reply) => reply.sendFile('/template/journey.html'));