Update src/client/old.js
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
366ca8b97f
commit
52b3d98fec
@ -18,14 +18,13 @@ Vue.use(window.VueTextareaAutosize);
|
||||
const app = new Vue({
|
||||
el: "#app",
|
||||
data: {
|
||||
journey_edit:
|
||||
["view", "short"].indexOf(window.location.pathname.split("/")[1]) == -1,
|
||||
edit_active: ["view", "short"].indexOf(window.location.pathname.split("/")[1]) == -1,
|
||||
drawer_active: "hotel",
|
||||
journey: new journey_wrapper(window.location.pathname.split("/").pop() || String.gen_id(16)),
|
||||
map_override: { active: false, center: [0, 0] },
|
||||
|
||||
query: {
|
||||
type: "",
|
||||
act: false,
|
||||
res: [],
|
||||
type: "", res: [],
|
||||
},
|
||||
impexp: "",
|
||||
lang: {
|
||||
@ -112,7 +111,6 @@ const app = new Vue({
|
||||
|
||||
search_nominatim: function (f) {
|
||||
return (q) => {
|
||||
this.query.act = true;
|
||||
this.query.type = f;
|
||||
return api.query_nominatim(q, this.compute_bb(), this.get_filter(f)).catch((_err) => []).then((r) => {
|
||||
r.forEach((rr) => {
|
||||
@ -120,33 +118,66 @@ const app = new Vue({
|
||||
rr.sname = rr.display_name.split(",")[0];
|
||||
});
|
||||
this.query.res = r;
|
||||
this.query.act = false;
|
||||
this.query.type = null;
|
||||
return r
|
||||
});
|
||||
}
|
||||
},
|
||||
search_travel: function (f) {
|
||||
return (q) => {
|
||||
this.query.act = true;
|
||||
this.query.type = f;
|
||||
return api.query_flight(q).then((r) => {
|
||||
r.forEach(el => el.path = getGeoLine(
|
||||
new L.LatLng(el.from_geo.lat, el.from_geo.lon),
|
||||
new L.LatLng(el.to_geo.lat, el.to_geo.lon), { dist: 5_000_000 }).map(v => [v.lat, v.lng]));
|
||||
r.forEach(el => {
|
||||
el.path = getGeoLine(
|
||||
{ lat: el.from_geo.lat, lng: el.from_geo.lon },
|
||||
{ lat: el.to_geo.lat, lng: el.to_geo.lon }, { dist: 5_000_000 }).map(v => [v.lat, v.lng])
|
||||
el.type = "flight";
|
||||
});
|
||||
this.query.res = r;
|
||||
this.query.act = false;
|
||||
this.query.type = null;
|
||||
return r;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
drawer_hover_item: function (item) {
|
||||
if (item) {
|
||||
this.map_override.active = true
|
||||
this.map_override.center = [item.lat, item.lon]
|
||||
} else {
|
||||
this.map_override.active = false
|
||||
}
|
||||
},
|
||||
|
||||
drawer_click_item: function (item) {
|
||||
console.log(item)
|
||||
console.log(this.journey.leg_get())
|
||||
switch (this.drawer_active) {
|
||||
case 'hotel': return this.journey.leg_get().hotel = item;
|
||||
case 'restaurant': return this.journey.leg_get().places.restaurants.push(item);
|
||||
case 'place': return this.journey.leg_get().places.places.push(item);
|
||||
case 'other': return;
|
||||
case 'flight': return this.journey.leg_get().travel.push(item);
|
||||
}
|
||||
},
|
||||
|
||||
search_active: function (q) {
|
||||
const txt = q.target.value
|
||||
switch (this.drawer_active) {
|
||||
case 'hotel': return this.search_hotel(txt);
|
||||
case 'restaurant': return this.search_restaurant(txt);
|
||||
case 'place': return this.search_place(txt);
|
||||
case 'other': return this.search_other(txt);
|
||||
case 'flight': return this.search_flight(txt);
|
||||
}
|
||||
},
|
||||
|
||||
keyboardEvent(e) {
|
||||
if (e.which === 13) {
|
||||
}
|
||||
},
|
||||
},
|
||||
created: function () {
|
||||
|
||||
this.search_hotel = api.throttle(this.search_nominatim("hotel"), 1000)
|
||||
this.search_restaurant = api.throttle(this.search_nominatim("restaurant"), 1000)
|
||||
this.search_place = api.throttle(this.search_nominatim("place"), 1000)
|
||||
@ -155,6 +186,7 @@ const app = new Vue({
|
||||
api.save(this.journey.id, this.journey.data);
|
||||
}, 1000);
|
||||
this.search_flight = api.throttle(this.search_travel("flight"), 2000)
|
||||
this
|
||||
|
||||
window.addEventListener("keydown", (e) => {
|
||||
switch (e.key) {
|
||||
@ -171,9 +203,10 @@ const app = new Vue({
|
||||
|
||||
api.load(this.journey.id).then((r) => (app.journey.data = migrator(r)));
|
||||
|
||||
this.search_travel("flight")("qf1").then(r => {
|
||||
this.polyline.latlngs = r.map(e => e.path)
|
||||
});
|
||||
// this.search_travel("flight")("qf1").then(r => {
|
||||
// // this.polyline.latlngs = r.map(e => e.path)
|
||||
// this.journey.data.main[this.journey.sel_leg].travel = r;
|
||||
// });
|
||||
|
||||
},
|
||||
watch: {
|
||||
@ -185,3 +218,26 @@ const app = new Vue({
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
var scrollInterval = null;
|
||||
var scrollDir = null;
|
||||
document.querySelector('.scroll-content').addEventListener('mousemove', (e) => {
|
||||
const c = document.querySelector('.scroll-content')
|
||||
const newDir =
|
||||
e.pageX < c.offsetWidth * 0.2 ? 'left' :
|
||||
(e.pageX > c.offsetWidth * 0.8 ? 'right' : scrollDir)
|
||||
if (!scrollInterval || scrollDir != newDir) {
|
||||
if (scrollInterval) clearInterval(scrollInterval)
|
||||
sideScroll(c, newDir, 25, 10);
|
||||
}
|
||||
});
|
||||
document.querySelector('.scroll-content').addEventListener('mouseleave', () => {
|
||||
clearInterval(scrollInterval);
|
||||
scrollInterval = null
|
||||
});
|
||||
function sideScroll(element, direction, speed, step) {
|
||||
scrollDir = direction
|
||||
scrollInterval = setInterval(() => {
|
||||
element.scrollLeft += (direction == 'left') ? -step : step;
|
||||
}, speed);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user