mapserver/server/static/js/search/SearchStore.js

41 lines
651 B
JavaScript
Raw Normal View History

var SearchStore = {
2019-04-14 20:51:31 +03:00
query: "",
2019-04-14 22:35:59 +03:00
result: [],
2019-04-14 20:51:31 +03:00
search: function(q){
this.query = q;
this.fetchData();
},
fetchData: debounce(function(){
2019-04-14 22:35:59 +03:00
var self = this;
this.result = [];
2019-04-14 20:51:31 +03:00
if (!this.query){
return;
}
api.getMapObjects({
pos1: { x:-2048, y:-2048, z:-2048 },
pos2: { x:2048, y:2048, z:2048 },
2019-04-14 22:35:59 +03:00
type: "shop",
attributelike: {
key: "out_item",
value: "%" + this.query + "%"
}
2019-04-14 20:51:31 +03:00
})
.then(function(result){
2019-04-14 22:35:59 +03:00
self.result = result;
console.log(result); //XXX
2019-04-14 20:51:31 +03:00
});
}, 400),
clear: function(){
this.query = "";
2019-04-14 22:35:59 +03:00
this.result = [];
2019-04-14 20:51:31 +03:00
}
};