This repository was archived by the owner on Apr 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidationPlugin.js
More file actions
53 lines (44 loc) · 1.83 KB
/
validationPlugin.js
File metadata and controls
53 lines (44 loc) · 1.83 KB
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
'use strict';
(function () {
'use strict';
window.nsGmx = window.nsGmx || {};
var pluginName = 'crisismap-validation-plugin';
var publicInterface = {
pluginName: pluginName,
afterViewer: function afterViewer(params, map) {
if (window.nsGmx) {
if (params.layers) {
var layers = params.layers.split(', ');
for (var i = 0; i < layers.length; i++) {
var layer = nsGmx.gmxMap.layersByID[layers[i]];
layer.addPopupHook('toponyms', function (properties, div, node, hooksCount) {
var cleared = properties.toponyms.replace(/\\{3}/ig, ''),
parsed = JSON.parse(cleared),
toponyms = parsed.map(function (arr) {
return arr[0];
}),
list = document.createElement('ul');
list.className = 'popup-validation-list'
toponyms.forEach(fillList);
div.appendChild(list);
console.log(toponyms);
function fillList(toponym) {
var elem = document.createElement('li');
elem.innerHTML = toponym;
list.appendChild(elem);
}
});
}
}
}
}
};
if (window.gmxCore) {
window.gmxCore.addModule(pluginName, publicInterface, {
css: './css/main.css',
init: function init(module, path) {}
});
} else {
window.nsGmx[pluginName] = publicInterface;
}
})();