[TASK] Optimize code

This commit is contained in:
Xaver Maierhofer 2018-08-03 20:08:08 +02:00
parent e1aa152055
commit 9c596531e2
No known key found for this signature in database
GPG Key ID: 7FDCE23FD2EC9FE8
4 changed files with 15 additions and 23 deletions

View File

@ -97,8 +97,7 @@ define(['filters/nodefilter'], function (NodeFilter) {
setData: setData, setData: setData,
addFilter: addFilter, addFilter: addFilter,
removeFilter: removeFilter, removeFilter: removeFilter,
watchFilters: watchFilters, watchFilters: watchFilters
refresh: refresh
}; };
}; };
}); });

View File

@ -27,29 +27,25 @@ define(['map/clientlayer', 'map/labellayer', 'map/button', 'leaflet', 'map/activ
document.querySelector('.leaflet-control-layers').classList.add('leaflet-control-layers-expanded'); document.querySelector('.leaflet-control-layers').classList.add('leaflet-control-layers-expanded');
} }
function mapActiveArea() {
map.setActiveArea({
position: 'absolute',
left: sidebar.getWidth() + 'px',
right: 0,
top: 0,
bottom: 0
});
}
function setActiveArea() { function setActiveArea() {
setTimeout(function () { setTimeout(mapActiveArea, 300);
map.setActiveArea({
position: 'absolute',
left: sidebar.getWidth() + 'px',
right: 0,
top: 0,
bottom: 0
});
}, 300);
} }
var el = document.createElement('div'); var el = document.createElement('div');
el.classList.add('map'); el.classList.add('map');
map = L.map(el, options); map = L.map(el, options);
map.setActiveArea({ mapActiveArea();
position: 'absolute',
left: sidebar.getWidth() + 'px',
right: 0,
top: 0,
bottom: 0
});
var now = new Date(); var now = new Date();
config.mapLayers.forEach(function (item, i) { config.mapLayers.forEach(function (item, i) {

View File

@ -22,7 +22,7 @@ define(['polyglot', 'moment', 'helper'], function (Polyglot, moment, helper) {
} }
function getLocale(input) { function getLocale(input) {
var language = input || navigator.languages && navigator.languages[0] || navigator.language || navigator.userLanguage; var language = input || navigator.languages && navigator.languages[0] || navigator.language;
var locale = config.supportedLocale[0]; var locale = config.supportedLocale[0];
config.supportedLocale.some(function (item) { config.supportedLocale.some(function (item) {
if (language.indexOf(item) !== -1) { if (language.indexOf(item) !== -1) {

View File

@ -50,10 +50,7 @@ define(function () {
var ca = a.split(''); var ca = a.split('');
var cb = b.split(''); var cb = b.split('');
var diff = this.findIndex(ca, function (c, index) { var diff = this.findIndex(ca, function (c, index) {
if (cb[index] && c === cb[index]) { return !(cb[index] && c === cb[index]);
return false;
}
return true;
}); });
if (diff === -1) { if (diff === -1) {
if (cb.length > ca.length) { if (cb.length > ca.length) {