mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-06 11:21:33 +00:00
Add josm converter and converted, switch to it.
This commit is contained in:
@@ -136,7 +136,7 @@
|
||||
<div id="iD"></div><script>
|
||||
locale.current = 'en';
|
||||
d3.json('keys.json', function(err, keys) {
|
||||
d3.json('presets/presets.json', function(err, presets_data) {
|
||||
d3.json('presets/presets_josm.json', function(err, presets_data) {
|
||||
var id = iD();
|
||||
id.connection().keys(keys)
|
||||
.presetData(iD.presetData().data(presets_data))
|
||||
|
||||
@@ -16,7 +16,7 @@ iD.presetData = function() {
|
||||
|
||||
presets.match = function(entity) {
|
||||
return data.filter(function(d) {
|
||||
return _.contains(d.match.type, entity.type);
|
||||
return _.contains(d.type, entity.type);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ iD.ui.preset = function() {
|
||||
|
||||
function presets(selection) {
|
||||
var sections = selection.selectAll('div.preset-section')
|
||||
.data(preset.form)
|
||||
.data(preset.main)
|
||||
.enter()
|
||||
.append('div')
|
||||
.attr('class', 'preset-section');
|
||||
|
||||
44
presets/convert_josm.py
Normal file
44
presets/convert_josm.py
Normal file
@@ -0,0 +1,44 @@
|
||||
from xml.dom.minidom import parse
|
||||
import os
|
||||
dirr = os.path.dirname(__file__)
|
||||
import json
|
||||
|
||||
def relative(x):
|
||||
return os.path.join(dirr, x)
|
||||
dom1 = parse(relative('./josm.xml'))
|
||||
|
||||
items = dom1.getElementsByTagName('item')
|
||||
|
||||
jsonOutput = []
|
||||
|
||||
for item in items:
|
||||
jitem = {
|
||||
"name": item.getAttribute('name'),
|
||||
"type": item.getAttribute('type').split(','),
|
||||
"main": []
|
||||
}
|
||||
for n in item.childNodes:
|
||||
if n.nodeType != n.TEXT_NODE and n.nodeType != n.COMMENT_NODE:
|
||||
if n.tagName == 'text':
|
||||
jitem['main'].append({
|
||||
'type': 'text',
|
||||
'key': n.getAttribute('key'),
|
||||
'text': n.getAttribute('text')
|
||||
})
|
||||
if n.tagName == 'combo':
|
||||
jitem['main'].append({
|
||||
'type': 'select',
|
||||
'key': n.getAttribute('key'),
|
||||
'text': n.getAttribute('text'),
|
||||
'values': n.getAttribute('values').split(',')
|
||||
})
|
||||
if n.tagName == 'check':
|
||||
jitem['main'].append({
|
||||
'type': 'check',
|
||||
'key': n.getAttribute('key'),
|
||||
'text': n.getAttribute('text'),
|
||||
'default': (n.getAttribute('check') == 'true')
|
||||
})
|
||||
jsonOutput.append(jitem)
|
||||
|
||||
json.dump(jsonOutput, open(relative('presets_josm.json'), 'w'), indent=4)
|
||||
12281
presets/presets_josm.json
Normal file
12281
presets/presets_josm.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user