2019-06-11 15:16:41 +03:00
|
|
|
import SearchStore from './SearchStore.js';
|
2019-06-11 16:01:16 +03:00
|
|
|
import layerMgr from '../LayerManager.js';
|
2019-04-15 08:54:11 +03:00
|
|
|
|
2019-06-11 15:16:41 +03:00
|
|
|
export default {
|
2019-04-20 18:59:22 +03:00
|
|
|
view: function(vnode){
|
|
|
|
var map = vnode.attrs.map;
|
2019-04-15 08:54:11 +03:00
|
|
|
|
|
|
|
function getLayer(obj){
|
|
|
|
var layer = layerMgr.getLayerByY(obj.y);
|
|
|
|
return layer ? layer.name : "<unknown>";
|
|
|
|
}
|
|
|
|
|
|
|
|
function getPos(obj){
|
|
|
|
var text = obj.x + "/" + obj.y + "/" + obj.z;
|
|
|
|
|
2019-04-20 18:59:22 +03:00
|
|
|
return m("span", {class:"badge badge-success"}, text);
|
2019-04-15 08:54:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
var rows = SearchStore.result.map(function(obj){
|
2019-04-20 18:59:22 +03:00
|
|
|
|
|
|
|
var row_classes = "";
|
|
|
|
var description = obj.type;
|
|
|
|
var type = obj.type;
|
|
|
|
|
2019-05-14 09:31:35 +03:00
|
|
|
// train-line result
|
2019-04-21 22:51:43 +03:00
|
|
|
if (obj.type == "train"){
|
|
|
|
description = [
|
|
|
|
m("span", obj.attributes.station),
|
|
|
|
" ",
|
|
|
|
m("span", {class:"badge badge-info"}, obj.attributes.line)
|
|
|
|
];
|
|
|
|
|
|
|
|
type = m("i", { class: "fa fa-subway" });
|
|
|
|
}
|
|
|
|
|
2019-05-14 09:31:35 +03:00
|
|
|
// travelnet
|
2019-04-21 22:51:43 +03:00
|
|
|
if (obj.type == "travelnet"){
|
|
|
|
description = m("span", obj.attributes.station_name);
|
|
|
|
type = m("img", { src: "pics/travelnet_inv.png" });
|
|
|
|
}
|
|
|
|
|
2019-05-14 09:31:35 +03:00
|
|
|
// bones
|
|
|
|
if (obj.type == "bones"){
|
|
|
|
description = m("span", obj.attributes.owner);
|
|
|
|
type = m("img", { src: "pics/bones_top.png" });
|
|
|
|
}
|
|
|
|
|
2019-06-11 14:49:23 +03:00
|
|
|
// label
|
|
|
|
if (obj.type == "label"){
|
|
|
|
description = m("span", obj.attributes.text);
|
|
|
|
type = m("img", { src: "pics/mapserver_label.png" });
|
|
|
|
}
|
|
|
|
|
2019-06-11 14:54:58 +03:00
|
|
|
// digiterm
|
|
|
|
if (obj.type == "digiterm"){
|
|
|
|
description = m("span", obj.attributes.display_text);
|
|
|
|
type = m("img", { src: "pics/digiterms_beige_front.png" });
|
|
|
|
}
|
|
|
|
|
|
|
|
// digiline lcd
|
|
|
|
if (obj.type == "digilinelcd"){
|
|
|
|
description = m("span", obj.attributes.text);
|
|
|
|
type = m("img", { src: "pics/lcd_lcd.png" });
|
|
|
|
}
|
|
|
|
|
2019-05-14 10:15:11 +03:00
|
|
|
// locator
|
|
|
|
if (obj.type == "locator"){
|
|
|
|
description = m("span", obj.attributes.name);
|
|
|
|
|
2019-05-14 17:04:42 +03:00
|
|
|
var img = "pics/locator_beacon_level1.png";
|
2019-05-14 10:15:11 +03:00
|
|
|
|
|
|
|
if (obj.attributes.level == "2")
|
|
|
|
img = "pics/locator_beacon_level2.png";
|
|
|
|
else if (obj.attributes.level == "3")
|
|
|
|
img = "pics/locator_beacon_level3.png";
|
|
|
|
|
|
|
|
type = m("img", { src: img });
|
|
|
|
}
|
|
|
|
|
2019-05-14 09:31:35 +03:00
|
|
|
// poi marker
|
2019-04-20 18:59:22 +03:00
|
|
|
if (obj.type == "poi"){
|
|
|
|
description = m("span", obj.attributes.name);
|
2019-05-03 09:20:03 +03:00
|
|
|
|
|
|
|
var color = obj.attributes.color || "blue";
|
|
|
|
var icon = obj.attributes.icon || "home";
|
|
|
|
|
2019-05-03 18:39:53 +03:00
|
|
|
type = m("div", { style: "position: relative", class: "awesome-marker awesome-marker-icon-" + color }, [
|
2019-05-03 09:20:03 +03:00
|
|
|
m("i", { class: "fa fa-" + icon })
|
|
|
|
]);
|
2019-04-20 18:59:22 +03:00
|
|
|
}
|
|
|
|
|
2019-05-14 09:31:35 +03:00
|
|
|
//shop
|
2019-04-20 18:59:22 +03:00
|
|
|
if (obj.type == "shop") {
|
|
|
|
if (obj.attributes.stock == 0){
|
|
|
|
row_classes += "table-warning";
|
|
|
|
type = m("img", { src: "pics/shop_empty.png" });
|
|
|
|
} else {
|
|
|
|
type = m("img", { src: "pics/shop.png" });
|
|
|
|
}
|
|
|
|
|
|
|
|
description = m("span", [
|
|
|
|
"Shop, trading ",
|
|
|
|
m("span", {class:"badge badge-primary"}, obj.attributes.out_count + "x"),
|
|
|
|
m("span", {class:"badge badge-info"}, obj.attributes.out_item),
|
|
|
|
" for ",
|
|
|
|
m("span", {class:"badge badge-primary"}, obj.attributes.in_count + "x"),
|
|
|
|
m("span", {class:"badge badge-info"}, obj.attributes.in_item),
|
|
|
|
" Stock: ",
|
|
|
|
m("span", {class:"badge badge-info"}, obj.attributes.stock)
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onclick(){
|
2019-04-21 22:51:43 +03:00
|
|
|
var layer = layerMgr.getLayerByY(obj.y);
|
|
|
|
|
|
|
|
layerMgr.switchLayer(layer.id);
|
|
|
|
|
2019-04-20 18:59:22 +03:00
|
|
|
map.setView([obj.z, obj.x], 12);
|
2019-04-21 22:51:43 +03:00
|
|
|
SearchStore.show = false;
|
2019-04-20 18:59:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return m("tr", {"class": row_classes}, [
|
|
|
|
m("td", type),
|
2019-04-15 08:54:11 +03:00
|
|
|
m("td", obj.attributes.owner),
|
|
|
|
m("td", getLayer(obj)),
|
|
|
|
m("td", getPos(obj)),
|
2019-04-20 18:59:22 +03:00
|
|
|
m("td", description),
|
|
|
|
m("button[type=button]", {class: "btn btn-secondary", onclick: onclick }, [
|
|
|
|
"Goto ",
|
|
|
|
m("i", { class: "fas fa-play" })
|
|
|
|
])
|
2019-04-15 08:54:11 +03:00
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
2019-04-20 18:59:22 +03:00
|
|
|
return m("table", {class:"table table-striped"}, [
|
2019-04-15 08:54:11 +03:00
|
|
|
m("thead", [
|
|
|
|
m("tr", [
|
|
|
|
m("th", "Type"),
|
|
|
|
m("th", "Owner"),
|
|
|
|
m("th", "Layer"),
|
|
|
|
m("th", "Position"),
|
2019-04-20 18:59:22 +03:00
|
|
|
m("th", "Description"),
|
|
|
|
m("th", "Action")
|
2019-04-15 08:54:11 +03:00
|
|
|
])
|
|
|
|
]),
|
|
|
|
m("tbody", rows)
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
};
|