[TASK] Optimize code
This commit is contained in:
parent
e1aa152055
commit
9c596531e2
@ -97,8 +97,7 @@ define(['filters/nodefilter'], function (NodeFilter) {
|
||||
setData: setData,
|
||||
addFilter: addFilter,
|
||||
removeFilter: removeFilter,
|
||||
watchFilters: watchFilters,
|
||||
refresh: refresh
|
||||
watchFilters: watchFilters
|
||||
};
|
||||
};
|
||||
});
|
||||
|
28
lib/map.js
28
lib/map.js
@ -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');
|
||||
}
|
||||
|
||||
function mapActiveArea() {
|
||||
map.setActiveArea({
|
||||
position: 'absolute',
|
||||
left: sidebar.getWidth() + 'px',
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0
|
||||
});
|
||||
}
|
||||
|
||||
function setActiveArea() {
|
||||
setTimeout(function () {
|
||||
map.setActiveArea({
|
||||
position: 'absolute',
|
||||
left: sidebar.getWidth() + 'px',
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0
|
||||
});
|
||||
}, 300);
|
||||
setTimeout(mapActiveArea, 300);
|
||||
}
|
||||
|
||||
var el = document.createElement('div');
|
||||
el.classList.add('map');
|
||||
|
||||
map = L.map(el, options);
|
||||
map.setActiveArea({
|
||||
position: 'absolute',
|
||||
left: sidebar.getWidth() + 'px',
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0
|
||||
});
|
||||
mapActiveArea();
|
||||
|
||||
var now = new Date();
|
||||
config.mapLayers.forEach(function (item, i) {
|
||||
|
@ -22,7 +22,7 @@ define(['polyglot', 'moment', 'helper'], function (Polyglot, moment, helper) {
|
||||
}
|
||||
|
||||
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];
|
||||
config.supportedLocale.some(function (item) {
|
||||
if (language.indexOf(item) !== -1) {
|
||||
|
@ -50,10 +50,7 @@ define(function () {
|
||||
var ca = a.split('');
|
||||
var cb = b.split('');
|
||||
var diff = this.findIndex(ca, function (c, index) {
|
||||
if (cb[index] && c === cb[index]) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(cb[index] && c === cb[index]);
|
||||
});
|
||||
if (diff === -1) {
|
||||
if (cb.length > ca.length) {
|
||||
|
Loading…
Reference in New Issue
Block a user