forked from K-Sakanoshita/community_mapmaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
modal_takeout.js
executable file
·183 lines (166 loc) · 7.46 KB
/
modal_takeout.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
class modal_Takeout {
// modal view for Takeout
constructor() {
this.html = ""
var xhr = new XMLHttpRequest();
xhr.open('GET', "./modal_takeout.html", true);
xhr.onerror = function () {
console.log("[error]modal_Takeout:");
console.log(xhr);
};
xhr.onload = function () {
if (xhr.status >= 200 && xhr.status < 400) {
console.log("[success]modal_Takeout:");
this.html = xhr.response;
} else {
console.log("[error]modal_Takeout:");
console.log(xhr);
};
}.bind(this);
xhr.send();
};
make(marker) {
$("#modals").html(this.html);
let osmid = marker.target.mapmaker_id
/*
let popcont;
let id = ev.target.mapmaker_id;
let key = ev.target.mapmaker_key;
let tags = poiCont.get_osmid(id).geojson.properties;
if (key == Conf.osm.wikipedia.tag) { // Wikipedia時のPopUp
let qr_btn = `<button class='btn btn-sm m-2' onclick='cMapmaker.qr_add("wikipedia","${id}")'>${glot.get("qrcode_make")}</button>`;
popcont = tags[Conf.osm.wikipedia.tag] + "<br>" + qr_btn;
} else { // その他
let name = tags.name == undefined ? "" : tags.name;
popcont = (name == '' ? glot.get("marker_noname") : name) + "<br>" + chg_mkr + del_btn;
};
L.responsivePopup({ "keepInView": true }).setContent(popcont).setLatLng(ev.latlng).openOn(map);
ev.target.openPopup();
return false;
*/
let poi = poiCont.get_osmid(osmid);
let tags = poi.geojson.properties;
let date = moment(tags.timestamp);
const osmidOrig = osmid;
osmid = osmid.replace('/', "=");
history.replaceState('', '', location.pathname + "?" + osmid + location.hash);
$("#osmid").html(tags.id);
$("#timestamp").html(date.format("YYYY/MM/DD hh:mm"));
let name = tags.name == null ? "" : tags.name;
if (tags.branch) {
name += " " + tags.branch;
}
$("#name").html(name == null ? "-" : name);
$("#category-icon").attr("src", tags.takeaway_icon);
$("#category").html(poiCont.get_catname(tags));
// opening_hours
let openhour;
if (tags["opening_hours:covid19"] != null) {
openhour = tags["opening_hours:covid19"];
} else {
openhour = tags.opening_hours == null ? "-" : tags.opening_hours;
};
let RegexPTN = [[/\|\|/g, "<br>"], [/;/g, "<br>"]];
Object.keys(Conf.opening_hours).forEach(key => {
RegexPTN.push([new RegExp(key, "g"), Conf.opening_hours[key]]);
});
RegexPTN.forEach(val => { openhour = openhour.replace(val[0], val[1]) });
if (tags["opening_hours:covid19"] != null) { openhour += Conf.category.suffix_covid19 }
$("#opening_hours").html(openhour);
// cuisine
let cuisine = [];
if (tags.cuisine != null) {
cuisine = tags.cuisine.split(";").map(key => {
return Conf.category.cuisine[key] || key;
});
};
// cuisine(diet)
let diet = Object.keys(Conf.category.diet).map(key => {
if (tags[key] != null) {
if (tags[key] !== "no") return Conf.category.diet[key] || key;
}
});
cuisine = cuisine.concat(diet);
cuisine = cuisine.filter(Boolean);
cuisine = cuisine.join(', ');
$("#cuisine").html(cuisine == "" ? "-" : cuisine);
if (Conf.default.bookmark == true) {
/*
let bookmarked = bookmark.isBookmarked(osmidOrig);
const CLASS_BOOKMARK_TRUE = "btn-bookmark-true";
const CLASS_BOOKMARK_FALSE = "btn-bookmark-false";
$("#modal_bookmark").show();
$("#modal_bookmark").removeClass((bookmarked) ? CLASS_BOOKMARK_FALSE : CLASS_BOOKMARK_TRUE);
$("#modal_bookmark").addClass((!bookmarked) ? CLASS_BOOKMARK_FALSE : CLASS_BOOKMARK_TRUE);
$('#modal_bookmark').unbind('click');
$('#modal_bookmark').click(() => {
console.log(name);
bookmarked = !bookmarked;
bookmark.setBookmarkByModal(osmidOrig, bookmarked);
$("#modal_bookmark").removeClass((bookmarked) ? CLASS_BOOKMARK_FALSE : CLASS_BOOKMARK_TRUE);
$("#modal_bookmark").addClass((!bookmarked) ? CLASS_BOOKMARK_FALSE : CLASS_BOOKMARK_TRUE);
});
*/
}
/*
let outseet = YESNO.indexOf(tags.outdoor_seating) < 0 ? "" : tags.outdoor_seating;
if (outseet !== "") {
$("#outdoor_seating").attr("glot-model", "outdoor_seating_" + outseet);
} else {
$("#outdoor_seating").removeAttr("glot-model");
};
*/
// takeout
/*
let takeaway;
if (tags["takeaway:covid19"] != null) {
takeaway = Conf.category.takeaway[tags["takeaway:covid19"]];
takeaway = takeaway == undefined ? "?" : takeaway + Conf.category.suffix_covid19;
} else {
takeaway = tags.takeaway == null ? "-" : Conf.category.takeaway[tags.takeaway];
takeaway = takeaway == undefined ? "?" : takeaway;
}
$("#takeaway").html(takeaway);
*/
// delivery
/*
let delname;
if (tags["delivery:covid19"] != null) {
delname = Conf.category.delivery[tags["delivery:covid19"]];
delname = delname == undefined ? "?" : delname + Conf.category.suffix_covid19;
} else {
delname = tags.delivery == null ? "-" : Conf.category.delivery[tags.delivery];
delname = delname == undefined ? "?" : delname;
}
$("#delivery").html(delname);
if (tags.phone != null) {
$("#phone").html("<a href=\"" + ("tel:" + tags.phone) + "\">" + tags.phone + "</a>");
} else {
$("#phone").html("-");
}
*/
let fld = {};
fld.website = tags["contact:website"] == null ? tags["website"] : tags["contact:website"];
fld.sns_instagram = tags["contact:instagram"] == null ? tags["instagram"] : tags["contact:instagram"];
fld.sns_twitter = tags["contact:twitter"] == null ? tags["twitter"] : tags["contact:twitter"];
fld.sns_facebook = tags["contact:facebook"] == null ? tags["facebook"] : tags["contact:facebook"];
Object.keys(fld).forEach(key => {
if (fld[key] == null) {
$("#" + key).hide();
} else {
$("#" + key).show();
};
});
$("#description").html(tags.description == null ? "-" : tags.description.trim());
glot.render();
$('#modal_poiview').modal({ backdrop: 'static', keyboard: true });
let hidden = e => {
//_status = "";
history.replaceState('', '', location.pathname + location.hash);
$('#modal_poiview').modal('hide');
};
$('#modal_poiview').one('hidePrevented.bs.modal', hidden);
$('#modal_poiview').one('hidden.bs.modal', hidden);
}
}
var modal_takeout = new modal_Takeout();