umap-project 2.4.2__py3-none-any.whl → 2.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. umap/__init__.py +1 -1
  2. umap/locale/el/LC_MESSAGES/django.mo +0 -0
  3. umap/locale/eu/LC_MESSAGES/django.mo +0 -0
  4. umap/locale/hu/LC_MESSAGES/django.mo +0 -0
  5. umap/locale/hu/LC_MESSAGES/django.po +100 -50
  6. umap/static/umap/base.css +4 -1
  7. umap/static/umap/css/contextmenu.css +11 -0
  8. umap/static/umap/css/dialog.css +24 -3
  9. umap/static/umap/css/panel.css +4 -2
  10. umap/static/umap/css/slideshow.css +69 -0
  11. umap/static/umap/css/tableeditor.css +69 -0
  12. umap/static/umap/css/tooltip.css +3 -3
  13. umap/static/umap/img/16-white.svg +4 -0
  14. umap/static/umap/img/source/16-white.svg +5 -1
  15. umap/static/umap/js/components/alerts/alert.css +10 -10
  16. umap/static/umap/js/modules/autocomplete.js +23 -1
  17. umap/static/umap/js/modules/browser.js +14 -8
  18. umap/static/umap/js/modules/facets.js +40 -10
  19. umap/static/umap/js/modules/formatter.js +153 -0
  20. umap/static/umap/js/modules/global.js +10 -1
  21. umap/static/umap/js/modules/help.js +25 -25
  22. umap/static/umap/js/modules/importer.js +4 -4
  23. umap/static/umap/js/modules/importers/communesfr.js +3 -1
  24. umap/static/umap/js/modules/importers/datasets.js +8 -6
  25. umap/static/umap/js/modules/importers/geodatamine.js +10 -10
  26. umap/static/umap/js/modules/importers/overpass.js +18 -14
  27. umap/static/umap/js/modules/rules.js +13 -1
  28. umap/static/umap/js/modules/schema.js +16 -12
  29. umap/static/umap/js/{umap.share.js → modules/share.js} +60 -99
  30. umap/static/umap/js/modules/slideshow.js +141 -0
  31. umap/static/umap/js/modules/tableeditor.js +329 -0
  32. umap/static/umap/js/modules/ui/base.js +93 -0
  33. umap/static/umap/js/modules/ui/contextmenu.js +50 -0
  34. umap/static/umap/js/modules/ui/dialog.js +169 -31
  35. umap/static/umap/js/modules/ui/panel.js +6 -4
  36. umap/static/umap/js/modules/ui/tooltip.js +5 -75
  37. umap/static/umap/js/modules/utils.js +20 -0
  38. umap/static/umap/js/umap.controls.js +1 -1
  39. umap/static/umap/js/umap.features.js +22 -14
  40. umap/static/umap/js/umap.forms.js +157 -154
  41. umap/static/umap/js/umap.js +48 -34
  42. umap/static/umap/js/umap.layer.js +232 -164
  43. umap/static/umap/js/umap.permissions.js +1 -1
  44. umap/static/umap/js/umap.popup.js +1 -1
  45. umap/static/umap/locale/am_ET.js +22 -5
  46. umap/static/umap/locale/am_ET.json +19 -5
  47. umap/static/umap/locale/ar.js +22 -5
  48. umap/static/umap/locale/ar.json +19 -5
  49. umap/static/umap/locale/ast.js +22 -5
  50. umap/static/umap/locale/ast.json +19 -5
  51. umap/static/umap/locale/bg.js +22 -5
  52. umap/static/umap/locale/bg.json +19 -5
  53. umap/static/umap/locale/br.js +22 -5
  54. umap/static/umap/locale/br.json +19 -5
  55. umap/static/umap/locale/ca.js +56 -39
  56. umap/static/umap/locale/ca.json +53 -39
  57. umap/static/umap/locale/cs_CZ.js +22 -5
  58. umap/static/umap/locale/cs_CZ.json +19 -5
  59. umap/static/umap/locale/da.js +22 -5
  60. umap/static/umap/locale/da.json +19 -5
  61. umap/static/umap/locale/de.js +22 -5
  62. umap/static/umap/locale/de.json +19 -5
  63. umap/static/umap/locale/el.js +27 -10
  64. umap/static/umap/locale/el.json +19 -5
  65. umap/static/umap/locale/en.js +22 -6
  66. umap/static/umap/locale/en.json +19 -5
  67. umap/static/umap/locale/en_US.json +19 -5
  68. umap/static/umap/locale/es.js +22 -6
  69. umap/static/umap/locale/es.json +19 -5
  70. umap/static/umap/locale/et.js +22 -5
  71. umap/static/umap/locale/et.json +19 -5
  72. umap/static/umap/locale/eu.js +167 -150
  73. umap/static/umap/locale/eu.json +167 -150
  74. umap/static/umap/locale/fa_IR.js +22 -5
  75. umap/static/umap/locale/fa_IR.json +19 -5
  76. umap/static/umap/locale/fi.js +22 -5
  77. umap/static/umap/locale/fi.json +19 -5
  78. umap/static/umap/locale/fr.js +22 -6
  79. umap/static/umap/locale/fr.json +19 -5
  80. umap/static/umap/locale/gl.js +22 -5
  81. umap/static/umap/locale/gl.json +19 -5
  82. umap/static/umap/locale/he.js +22 -5
  83. umap/static/umap/locale/he.json +19 -5
  84. umap/static/umap/locale/hr.js +22 -5
  85. umap/static/umap/locale/hr.json +19 -5
  86. umap/static/umap/locale/hu.js +89 -72
  87. umap/static/umap/locale/hu.json +89 -75
  88. umap/static/umap/locale/id.js +22 -5
  89. umap/static/umap/locale/id.json +19 -5
  90. umap/static/umap/locale/is.js +22 -5
  91. umap/static/umap/locale/is.json +19 -5
  92. umap/static/umap/locale/it.js +22 -5
  93. umap/static/umap/locale/it.json +19 -5
  94. umap/static/umap/locale/ja.js +22 -5
  95. umap/static/umap/locale/ja.json +19 -5
  96. umap/static/umap/locale/ko.js +22 -5
  97. umap/static/umap/locale/ko.json +19 -5
  98. umap/static/umap/locale/lt.js +22 -5
  99. umap/static/umap/locale/lt.json +19 -5
  100. umap/static/umap/locale/ms.js +22 -5
  101. umap/static/umap/locale/ms.json +19 -5
  102. umap/static/umap/locale/nl.js +22 -5
  103. umap/static/umap/locale/nl.json +19 -5
  104. umap/static/umap/locale/no.js +22 -5
  105. umap/static/umap/locale/no.json +19 -5
  106. umap/static/umap/locale/pl.js +22 -5
  107. umap/static/umap/locale/pl.json +19 -5
  108. umap/static/umap/locale/pl_PL.json +19 -5
  109. umap/static/umap/locale/pt.js +22 -6
  110. umap/static/umap/locale/pt.json +21 -7
  111. umap/static/umap/locale/pt_BR.js +22 -5
  112. umap/static/umap/locale/pt_BR.json +19 -5
  113. umap/static/umap/locale/pt_PT.js +22 -5
  114. umap/static/umap/locale/pt_PT.json +19 -5
  115. umap/static/umap/locale/ro.js +22 -5
  116. umap/static/umap/locale/ro.json +19 -5
  117. umap/static/umap/locale/ru.js +22 -5
  118. umap/static/umap/locale/ru.json +19 -5
  119. umap/static/umap/locale/sk_SK.js +22 -5
  120. umap/static/umap/locale/sk_SK.json +19 -5
  121. umap/static/umap/locale/sl.js +22 -5
  122. umap/static/umap/locale/sl.json +19 -5
  123. umap/static/umap/locale/sr.js +22 -5
  124. umap/static/umap/locale/sr.json +19 -5
  125. umap/static/umap/locale/sv.js +22 -5
  126. umap/static/umap/locale/sv.json +19 -5
  127. umap/static/umap/locale/th_TH.js +22 -5
  128. umap/static/umap/locale/th_TH.json +19 -5
  129. umap/static/umap/locale/tr.js +22 -5
  130. umap/static/umap/locale/tr.json +19 -5
  131. umap/static/umap/locale/uk_UA.js +22 -5
  132. umap/static/umap/locale/uk_UA.json +19 -5
  133. umap/static/umap/locale/vi.js +22 -5
  134. umap/static/umap/locale/vi.json +19 -5
  135. umap/static/umap/locale/vi_VN.json +19 -5
  136. umap/static/umap/locale/zh.js +22 -5
  137. umap/static/umap/locale/zh.json +19 -5
  138. umap/static/umap/locale/zh_CN.json +19 -5
  139. umap/static/umap/locale/zh_TW.Big5.json +19 -5
  140. umap/static/umap/locale/zh_TW.js +22 -5
  141. umap/static/umap/locale/zh_TW.json +19 -5
  142. umap/static/umap/map.css +2 -145
  143. umap/static/umap/vars.css +5 -0
  144. umap/static/umap/vendors/formbuilder/Leaflet.FormBuilder.js +410 -428
  145. umap/static/umap/vendors/geojson-to-gpx/index.js +155 -0
  146. umap/static/umap/vendors/osmtogeojson/osmtogeojson.js +1 -2
  147. umap/static/umap/vendors/togeojson/togeojson.es.js +1109 -0
  148. umap/static/umap/vendors/togeojson/{togeojson.umd.js.map → togeojson.es.mjs.map} +1 -1
  149. umap/static/umap/vendors/tokml/tokml.es.js +895 -0
  150. umap/static/umap/vendors/tokml/tokml.es.mjs.map +1 -0
  151. umap/storage.py +5 -1
  152. umap/templates/umap/components/alerts/alert.html +3 -3
  153. umap/templates/umap/css.html +3 -0
  154. umap/templates/umap/js.html +0 -6
  155. umap/tests/fixtures/categorized_highway.geojson +1 -0
  156. umap/tests/fixtures/test_import_osm_relation.json +130 -0
  157. umap/tests/integration/conftest.py +8 -1
  158. umap/tests/integration/test_browser.py +3 -2
  159. umap/tests/integration/test_categorized_layer.py +141 -0
  160. umap/tests/integration/test_conditional_rules.py +21 -0
  161. umap/tests/integration/test_datalayer.py +9 -4
  162. umap/tests/integration/test_edit_datalayer.py +1 -0
  163. umap/tests/integration/test_edit_polygon.py +1 -1
  164. umap/tests/integration/test_export_map.py +2 -3
  165. umap/tests/integration/test_import.py +22 -0
  166. umap/tests/integration/test_tableeditor.py +158 -4
  167. umap/tests/integration/test_websocket_sync.py +2 -2
  168. {umap_project-2.4.2.dist-info → umap_project-2.5.0.dist-info}/METADATA +8 -8
  169. {umap_project-2.4.2.dist-info → umap_project-2.5.0.dist-info}/RECORD +172 -162
  170. umap/static/umap/js/umap.slideshow.js +0 -163
  171. umap/static/umap/js/umap.tableeditor.js +0 -118
  172. umap/static/umap/vendors/togeojson/togeojson.umd.js +0 -2
  173. umap/static/umap/vendors/togpx/togpx.js +0 -547
  174. umap/static/umap/vendors/tokml/tokml.js +0 -343
  175. {umap_project-2.4.2.dist-info → umap_project-2.5.0.dist-info}/WHEEL +0 -0
  176. {umap_project-2.4.2.dist-info → umap_project-2.5.0.dist-info}/entry_points.txt +0 -0
  177. {umap_project-2.4.2.dist-info → umap_project-2.5.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,547 +0,0 @@
1
- (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.togpx = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
- var JXON = require("jxon");
3
- JXON.config({attrPrefix: '@'});
4
-
5
- function togpx( geojson, options ) {
6
- options = (function (defaults, options) {
7
- for (var k in defaults) {
8
- if (options.hasOwnProperty(k))
9
- defaults[k] = options[k];
10
- }
11
- return defaults;
12
- })({
13
- creator: "togpx",
14
- metadata: undefined,
15
- featureTitle: get_feature_title,
16
- featureDescription: get_feature_description,
17
- featureLink: undefined,
18
- featureCoordTimes: get_feature_coord_times,
19
- }, options || {});
20
-
21
- // is featureCoordTimes is a string -> look for the specified property
22
- if (typeof options.featureCoordTimes === 'string') {
23
- var customTimesFieldKey = options.featureCoordTimes;
24
- options.featureCoordTimes = function (feature) {
25
- return feature.properties[customTimesFieldKey];
26
- }
27
- }
28
-
29
- function get_feature_title(props) {
30
- // a simple default heuristic to determine a title for a given feature
31
- // uses a nested `tags` object or the feature's `properties` if present
32
- // and then searchs for the following properties to construct a title:
33
- // `name`, `ref`, `id`
34
- if (!props) return "";
35
- if (typeof props.tags === "object") {
36
- var tags_title = get_feature_title(props.tags);
37
- if (tags_title !== "")
38
- return tags_title;
39
- }
40
- if (props.name)
41
- return props.name;
42
- if (props.ref)
43
- return props.ref;
44
- if (props.id)
45
- return props.id;
46
- return "";
47
- }
48
- function get_feature_description(props) {
49
- // constructs a description for a given feature
50
- // uses a nested `tags` object or the feature's `properties` if present
51
- // and then concatenates all properties to construct a description.
52
- if (!props) return "";
53
- if (typeof props.tags === "object")
54
- return get_feature_description(props.tags);
55
- var res = "";
56
- for (var k in props) {
57
- if (typeof props[k] === "object")
58
- continue;
59
- res += k+"="+props[k]+"\n";
60
- }
61
- return res.substr(0,res.length-1);
62
- }
63
- function get_feature_coord_times(feature) {
64
- if (!feature.properties) return null;
65
- return feature.properties.times || feature.properties.coordTimes || null;
66
- }
67
- function add_feature_link(o, f) {
68
- if (options.featureLink)
69
- o.link = { "@href": options.featureLink(f.properties) }
70
- }
71
- // make gpx object
72
- var gpx = {"gpx": {
73
- "@xmlns":"http://www.topografix.com/GPX/1/1",
74
- "@xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance",
75
- "@xsi:schemaLocation":"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd",
76
- "@version":"1.1",
77
- "metadata": null,
78
- "wpt": [],
79
- "trk": [],
80
- }};
81
- if (options.creator)
82
- gpx.gpx["@creator"] = options.creator;
83
- if (options.metadata)
84
- gpx.gpx["metadata"] = options.metadata;
85
- else
86
- delete options.metadata;
87
-
88
- var features;
89
- if (geojson.type === "FeatureCollection")
90
- features = geojson.features;
91
- else if (geojson.type === "Feature")
92
- features = [geojson];
93
- else
94
- features = [{type:"Feature", properties: {}, geometry: geojson}];
95
- features.forEach(function mapFeature(f) {
96
- switch (f.geometry.type) {
97
- // POIs
98
- case "Point":
99
- case "MultiPoint":
100
- var coords = f.geometry.coordinates;
101
- if (f.geometry.type == "Point") coords = [coords];
102
- coords.forEach(function (coordinates) {
103
- o = {
104
- "@lat": coordinates[1],
105
- "@lon": coordinates[0],
106
- "name": options.featureTitle(f.properties),
107
- "desc": options.featureDescription(f.properties)
108
- };
109
- if (coordinates[2] !== undefined) {
110
- o.ele = coordinates[2];
111
- }
112
- add_feature_link(o,f);
113
- gpx.gpx.wpt.push(o);
114
- });
115
- break;
116
- // LineStrings
117
- case "LineString":
118
- case "MultiLineString":
119
- var coords = f.geometry.coordinates;
120
- var times = options.featureCoordTimes(f);
121
- if (f.geometry.type == "LineString") coords = [coords];
122
- o = {
123
- "name": options.featureTitle(f.properties),
124
- "desc": options.featureDescription(f.properties)
125
- };
126
- add_feature_link(o,f);
127
- o.trkseg = [];
128
- coords.forEach(function(coordinates) {
129
- var seg = {trkpt: []};
130
- coordinates.forEach(function(c, i) {
131
- var o = {
132
- "@lat": c[1],
133
- "@lon":c[0]
134
- };
135
- if (c[2] !== undefined) {
136
- o.ele = c[2];
137
- }
138
- if (times && times[i]) {
139
- o.time = times[i];
140
- }
141
- seg.trkpt.push(o);
142
- });
143
- o.trkseg.push(seg);
144
- });
145
- gpx.gpx.trk.push(o);
146
- break;
147
- // Polygons / Multipolygons
148
- case "Polygon":
149
- case "MultiPolygon":
150
- o = {
151
- "name": options.featureTitle(f.properties),
152
- "desc": options.featureDescription(f.properties)
153
- };
154
- add_feature_link(o,f);
155
- o.trkseg = [];
156
- var coords = f.geometry.coordinates;
157
- var times = options.featureCoordTimes(f);
158
- if (f.geometry.type == "Polygon") coords = [coords];
159
- coords.forEach(function(poly) {
160
- poly.forEach(function(ring) {
161
- var seg = {trkpt: []};
162
- var i = 0;
163
- ring.forEach(function(c) {
164
- var o = {
165
- "@lat": c[1],
166
- "@lon":c[0]
167
- };
168
- if (c[2] !== undefined) {
169
- o.ele = c[2];
170
- }
171
- if (times && times[i]) {
172
- o.time = times[i];
173
- }
174
- i++;
175
- seg.trkpt.push(o);
176
- });
177
- o.trkseg.push(seg);
178
- });
179
- });
180
- gpx.gpx.trk.push(o);
181
- break;
182
- case "GeometryCollection":
183
- f.geometry.geometries.forEach(function (geometry) {
184
- var pseudo_feature = {
185
- "properties": f.properties,
186
- "geometry": geometry
187
- };
188
- mapFeature(pseudo_feature);
189
- });
190
- break;
191
- default:
192
- console.log("warning: unsupported geometry type: "+f.geometry.type);
193
- }
194
- });
195
- gpx_str = JXON.stringify(gpx);
196
- return gpx_str;
197
- };
198
-
199
- module.exports = togpx;
200
-
201
- },{"jxon":2}],2:[function(require,module,exports){
202
- /*
203
- * JXON framework - Copyleft 2011 by Mozilla Developer Network
204
- *
205
- * Revision #1 - September 5, 2014
206
- *
207
- * https://developer.mozilla.org/en-US/docs/JXON
208
- *
209
- * This framework is released under the GNU Public License, version 3 or later.
210
- * http://www.gnu.org/licenses/gpl-3.0-standalone.html
211
- *
212
- * small modifications performed by the iD project:
213
- * https://github.com/openstreetmap/iD/commits/18aa33ba97b52cacf454e95c65d154000e052a1f/js/lib/jxon.js
214
- *
215
- * small modifications performed by user @bugreport0
216
- * https://github.com/tyrasd/JXON/pull/2/commits
217
- *
218
- * some additions and modifications by user @igord
219
- * https://github.com/tyrasd/JXON/pull/5/commits
220
- *
221
- * bugfixes and code cleanup by user @laubstein
222
- * https://github.com/tyrasd/jxon/pull/32
223
- *
224
- * adapted for nodejs and npm by @tyrasd (Martin Raifer <tyr.asd@gmail.com>)
225
- */
226
-
227
- (function(root, factory) {
228
- if (typeof define === 'function' && define.amd) {
229
- // AMD. Register as an anonymous module.
230
- define([], factory(window));
231
- } else if (typeof exports === 'object') {
232
- if (typeof window === 'object' && window.DOMImplementation && window.XMLSerializer && window.DOMParser) {
233
- // Browserify. hardcode usage of browser's own XMLDom implementation
234
- // see https://github.com/tyrasd/jxon/issues/18
235
-
236
- module.exports = factory(window);
237
- } else {
238
- // Node. Does not work with strict CommonJS, but
239
- // only CommonJS-like environments that support module.exports,
240
- // like Node.
241
-
242
- module.exports = factory(require('xmldom'), true);
243
- }
244
- } else {
245
- // Browser globals (root is window)
246
-
247
- root.JXON = factory(window);
248
- }
249
- }(this, function(xmlDom, isNodeJs) {
250
- var opts = {
251
- valueKey: '_',
252
- attrKey: '$',
253
- attrPrefix: '$',
254
- lowerCaseTags: false,
255
- trueIsEmpty: false,
256
- autoDate: false,
257
- ignorePrefixedNodes: false,
258
- parseValues: false
259
- };
260
- var aCache = [];
261
- var rIsNull = /^\s*$/;
262
- var rIsBool = /^(?:true|false)$/i;
263
- var DOMParser;
264
-
265
- return new (function() {
266
-
267
- this.config = function(cfg) {
268
- for (var k in cfg) {
269
-
270
- opts[k] = cfg[k];
271
- }
272
- if (opts.parserErrorHandler) {
273
- DOMParser = new xmlDom.DOMParser({
274
- errorHandler: opts.parserErrorHandler,
275
- locator: {}
276
- });
277
- }
278
- };
279
-
280
- function parseText(sValue) {
281
- if (!opts.parseValues) {
282
- return sValue;
283
- }
284
-
285
- if (rIsNull.test(sValue)) {
286
- return null;
287
- }
288
-
289
- if (rIsBool.test(sValue)) {
290
- return sValue.toLowerCase() === 'true';
291
- }
292
-
293
- if (isFinite(sValue)) {
294
- return parseFloat(sValue);
295
- }
296
-
297
- if (opts.autoDate && isFinite(Date.parse(sValue))) {
298
- return new Date(sValue);
299
- }
300
-
301
- return sValue;
302
- }
303
- function EmptyTree() {
304
- }
305
- EmptyTree.prototype.toString = function() {
306
- return 'null';
307
- };
308
-
309
- EmptyTree.prototype.valueOf = function() {
310
- return null;
311
- };
312
-
313
- function objectify(vValue) {
314
- return vValue === null ? new EmptyTree() : vValue instanceof Object ? vValue : new vValue.constructor(vValue);
315
- }
316
-
317
- function createObjTree(oParentNode, nVerb, bFreeze, bNesteAttr) {
318
- var CDATA = 4,
319
- TEXT = 3,
320
- ELEMENT = 1,
321
- nLevelStart = aCache.length,
322
- bChildren = oParentNode.hasChildNodes(),
323
- bAttributes = oParentNode.nodeType === oParentNode.ELEMENT_NODE && oParentNode.hasAttributes(),
324
- bHighVerb = Boolean(nVerb & 2),
325
- nLength = 0,
326
- sCollectedTxt = '',
327
- vResult = bHighVerb ? {} : /* put here the default value for empty nodes: */ (opts.trueIsEmpty ? true : ''),
328
- sProp,
329
- vContent;
330
-
331
- if (bChildren) {
332
- for (var oNode, nItem = 0; nItem < oParentNode.childNodes.length; nItem++) {
333
-
334
- oNode = oParentNode.childNodes.item(nItem);
335
- if (oNode.nodeType === CDATA) {
336
- sCollectedTxt += oNode.nodeValue;
337
- } /* nodeType is "CDATASection" (4) */
338
- else if (oNode.nodeType === TEXT) {
339
- sCollectedTxt += oNode.nodeValue.trim();
340
- } /* nodeType is "Text" (3) */
341
- else if (oNode.nodeType === ELEMENT && !(opts.ignorePrefixedNodes && oNode.prefix)) {
342
- aCache.push(oNode);
343
- }
344
- /* nodeType is "Element" (1) */
345
- }
346
- }
347
-
348
- var nLevelEnd = aCache.length,
349
- vBuiltVal = parseText(sCollectedTxt);
350
-
351
- if (!bHighVerb && (bChildren || bAttributes)) {
352
- vResult = nVerb === 0 ? objectify(vBuiltVal) : {};
353
- }
354
-
355
- for (var nElId = nLevelStart; nElId < nLevelEnd; nElId++) {
356
-
357
- sProp = aCache[nElId].nodeName;
358
- if (opts.lowerCaseTags) {
359
- sProp = sProp.toLowerCase();
360
- }
361
-
362
- vContent = createObjTree(aCache[nElId], nVerb, bFreeze, bNesteAttr);
363
- if (vResult.hasOwnProperty(sProp)) {
364
- if (vResult[sProp].constructor !== Array) {
365
- vResult[sProp] = [vResult[sProp]];
366
- }
367
-
368
- vResult[sProp].push(vContent);
369
- } else {
370
- vResult[sProp] = vContent;
371
-
372
- nLength++;
373
- }
374
- }
375
-
376
- if (bAttributes) {
377
- var nAttrLen = oParentNode.attributes.length,
378
- sAPrefix = bNesteAttr ? '' : opts.attrPrefix,
379
- oAttrParent = bNesteAttr ? {} : vResult;
380
-
381
- for (var oAttrib, oAttribName, nAttrib = 0; nAttrib < nAttrLen; nLength++, nAttrib++) {
382
-
383
- oAttrib = oParentNode.attributes.item(nAttrib);
384
-
385
- oAttribName = oAttrib.name;
386
- if (opts.lowerCaseTags) {
387
- oAttribName = oAttribName.toLowerCase();
388
- }
389
-
390
- oAttrParent[sAPrefix + oAttribName] = parseText(oAttrib.value.trim());
391
- }
392
-
393
- if (bNesteAttr) {
394
- if (bFreeze) {
395
- Object.freeze(oAttrParent);
396
- }
397
-
398
- vResult[opts.attrKey] = oAttrParent;
399
-
400
- nLength -= nAttrLen - 1;
401
- }
402
-
403
- }
404
-
405
- if (nVerb === 3 || (nVerb === 2 || nVerb === 1 && nLength > 0) && sCollectedTxt) {
406
- vResult[opts.valueKey] = vBuiltVal;
407
- } else if (!bHighVerb && nLength === 0 && sCollectedTxt) {
408
- vResult = vBuiltVal;
409
- }
410
- if (bFreeze && (bHighVerb || nLength > 0)) {
411
- Object.freeze(vResult);
412
- }
413
-
414
- aCache.length = nLevelStart;
415
-
416
- return vResult;
417
- }
418
- function loadObjTree(oXMLDoc, oParentEl, oParentObj) {
419
- var vValue,
420
- oChild,
421
- elementNS;
422
-
423
- if (oParentObj.constructor === String || oParentObj.constructor === Number || oParentObj.constructor === Boolean) {
424
- oParentEl.appendChild(oXMLDoc.createTextNode(oParentObj.toString())); /* verbosity level is 0 or 1 */
425
- if (oParentObj === oParentObj.valueOf()) {
426
- return;
427
- }
428
-
429
- } else if (oParentObj.constructor === Date) {
430
- oParentEl.appendChild(oXMLDoc.createTextNode(oParentObj.toISOString()));
431
- }
432
- for (var sName in oParentObj) {
433
-
434
- vValue = oParentObj[sName];
435
- if ( vValue === undefined ) {
436
- continue;
437
- }
438
- if ( vValue === null ) {
439
- vValue = {};
440
- }
441
-
442
- if (isFinite(sName) || vValue instanceof Function) {
443
- continue;
444
- }
445
-
446
- /* verbosity level is 0 */
447
- if (sName === opts.valueKey) {
448
- if (vValue !== null && vValue !== true) {
449
- oParentEl.appendChild(oXMLDoc.createTextNode(vValue.constructor === Date ? vValue.toISOString() : String(vValue)));
450
- }
451
-
452
- } else if (sName === opts.attrKey) { /* verbosity level is 3 */
453
- for (var sAttrib in vValue) {
454
- oParentEl.setAttribute(sAttrib, vValue[sAttrib]);
455
- }
456
- } else if (sName === opts.attrPrefix + 'xmlns') {
457
- if (isNodeJs) {
458
- oParentEl.setAttribute(sName.slice(1), vValue);
459
- }
460
- // do nothing: special handling of xml namespaces is done via createElementNS()
461
- } else if (sName.charAt(0) === opts.attrPrefix) {
462
- oParentEl.setAttribute(sName.slice(1), vValue);
463
- } else if (vValue.constructor === Array) {
464
- for (var nItem in vValue) {
465
- if (!vValue.hasOwnProperty(nItem)) continue;
466
- elementNS = (vValue[nItem] && vValue[nItem][opts.attrPrefix + 'xmlns']) || oParentEl.namespaceURI;
467
- if (elementNS) {
468
- oChild = oXMLDoc.createElementNS(elementNS, sName);
469
- } else {
470
- oChild = oXMLDoc.createElement(sName);
471
- }
472
-
473
- loadObjTree(oXMLDoc, oChild, vValue[nItem] || {});
474
- oParentEl.appendChild(oChild);
475
- }
476
- } else {
477
- elementNS = (vValue || {})[opts.attrPrefix + 'xmlns'] || oParentEl.namespaceURI;
478
- if (elementNS) {
479
- oChild = oXMLDoc.createElementNS(elementNS, sName);
480
- } else {
481
- oChild = oXMLDoc.createElement(sName);
482
- }
483
- if (vValue instanceof Object) {
484
- loadObjTree(oXMLDoc, oChild, vValue);
485
- } else if (vValue !== null && (vValue !== true || !opts.trueIsEmpty)) {
486
- oChild.appendChild(oXMLDoc.createTextNode(vValue.toString()));
487
- }
488
- oParentEl.appendChild(oChild);
489
- }
490
- }
491
- }
492
- this.xmlToJs = this.build = function(oXMLParent, nVerbosity /* optional */ , bFreeze /* optional */ , bNesteAttributes /* optional */ ) {
493
- var _nVerb = arguments.length > 1 && typeof nVerbosity === 'number' ? nVerbosity & 3 : /* put here the default verbosity level: */ 1;
494
- return createObjTree(oXMLParent, _nVerb, bFreeze || false, arguments.length > 3 ? bNesteAttributes : _nVerb === 3);
495
- };
496
-
497
- this.jsToXml = this.unbuild = function(oObjTree, sNamespaceURI /* optional */ , sQualifiedName /* optional */ , oDocumentType /* optional */ ) {
498
- var documentImplementation = xmlDom.document && xmlDom.document.implementation || new xmlDom.DOMImplementation();
499
- var oNewDoc = documentImplementation.createDocument(sNamespaceURI || null, sQualifiedName || '', oDocumentType || null);
500
- loadObjTree(oNewDoc, oNewDoc.documentElement || oNewDoc, oObjTree);
501
- return oNewDoc;
502
- };
503
-
504
- this.stringToXml = function(xmlStr) {
505
- if (!DOMParser) {
506
- DOMParser = new xmlDom.DOMParser();
507
- }
508
-
509
- return DOMParser.parseFromString(xmlStr, 'application/xml');
510
- };
511
-
512
- this.xmlToString = function(xmlObj) {
513
- if (typeof xmlObj.xml !== 'undefined') {
514
- return xmlObj.xml;
515
- } else {
516
- return (new xmlDom.XMLSerializer()).serializeToString(xmlObj);
517
- }
518
- };
519
-
520
- this.stringToJs = function(str) {
521
- var xmlObj = this.stringToXml(str);
522
- return this.xmlToJs(xmlObj);
523
- };
524
-
525
- this.jsToString = this.stringify = function(oObjTree, sNamespaceURI /* optional */ , sQualifiedName /* optional */ , oDocumentType /* optional */ ) {
526
- return this.xmlToString(
527
- this.jsToXml(oObjTree, sNamespaceURI, sQualifiedName, oDocumentType)
528
- );
529
- };
530
-
531
- this.each = function(arr, func, thisArg) {
532
- if (arr instanceof Array) {
533
- arr.forEach(func, thisArg);
534
- } else {
535
- [arr].forEach(func, thisArg);
536
- }
537
- };
538
- })();
539
-
540
- }
541
-
542
- ));
543
-
544
- },{"xmldom":3}],3:[function(require,module,exports){
545
-
546
- },{}]},{},[1])(1)
547
- });