1 {% extends "master.html" %}
3 <meta charset="utf-8" />
4 <title>{% block title %}JSON Editor{% endblock %}</title>
5 <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
6 <meta name="robots" content="noindex, nofollow" />
7 <link rel="shortcut icon" href="{{url_for('static', filename='favicon.png')}}" />
8 <script src="https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/jsoneditor.min.js"></script>
9 <link rel="stylesheet" type="text/css" media="screen" href="{{url_for('static', filename='style.css')}}" />
13 <div id='editor_holder'></div>
14 <button id='submit'>Submit (console.log)</button>
17 JSONEditor.defaults.options = {simplemde: {spellChecker: false}};
18 JSONEditor.defaults.languages.de = {
19 error_notset: 'Eigenschaft ist nicht gesetzt',
20 error_notempty: 'Wert erforderlich',
21 error_enum: 'Wert muss einem der vorgegebenen entsprechen',
22 error_anyOf: 'Wert muss mindestens nach einem der vorgegebenen Schemas gültig sein',
23 error_oneOf: 'Wert muss genau einem der vorgegebenen Schemas entsprechen. Derzeit ist es nach {{0}} Schemas gültig.',
24 error_not: 'Wert darf nach dem vorgegebenen Schema nicht gültig sein',
25 error_type_union: 'Wert muss einer der vorgegebenen Typen entsprechen',
26 error_type: 'Wert muss vom Typ {{0}} sein',
27 error_disallow_union: 'Wert darf nicht einer der vorgegebenen unerlaubten Typen sein',
28 error_disallow: 'Wert darf nicht vom Typ {{0}} sein',
29 error_multipleOf: 'Wert muss das vielfache von {{0}} sein',
30 error_maximum_excl: 'Wert muss kleiner sein als {{0}}',
31 error_maximum_incl: 'Wert darf maximal {{0}} sein',
32 error_minimum_excl: 'Wert muss größer sein als {{0}}',
33 error_minimum_incl: 'Wert muss mindestens {{0}} sein',
34 error_maxLength: 'Wert darf maximal {{0}} Zeichen lang sein',
35 error_minLength: 'Wert muss mindestens {{0}} Zeichen lang sein',
36 error_pattern: 'Wert muss dem vorgegebenen Muster {{0}} entsprechen',
37 error_additionalItems: 'In der Liste sind keine zusätzlichen Einträge erlaubt',
39 * When there are to many items in an array
40 * @variables This key takes one variable: The maximum item count
42 error_maxItems: 'Value must have at most {{0}} items',
44 * When there are not enough items in an array
45 * @variables This key takes one variable: The minimum item count
47 error_minItems: 'Value must have at least {{0}} items',
49 * When an array is supposed to have unique items but has duplicates
51 error_uniqueItems: 'Array must have unique items',
53 * When there are too many properties in an object
54 * @variables This key takes one variable: The maximum property count
56 error_maxProperties: 'Object must have at most {{0}} properties',
58 * When there are not enough properties in an object
59 * @variables This key takes one variable: The minimum property count
61 error_minProperties: 'Object must have at least {{0}} properties',
63 * When a required property is not defined
64 * @variables This key takes one variable: The name of the missing property
66 error_required: "Object is missing the required property '{{0}}'",
68 * When there is an additional property is set whereas there should be none
69 * @variables This key takes one variable: The name of the additional property
71 error_additional_properties: 'No additional properties allowed, but property {{0}} is set',
73 * When there is a propertyName that sets a max length and a property name exceeds the max length
74 * @variables This key takes one variable: The name of the invalid property
76 error_property_names_exceeds_maxlength: 'Property name {{0}} exceeds maxLength',
78 * When there is a propertyName that sets an enum and a property name matches none of the possible enum
79 * @variables This key takes one variable: The name of the invalid property
81 error_property_names_enum_mismatch: 'Property name {{0}} does not match any enum values',
83 * When there is a propertyName that sets a pattern and a property name does not match the pattern
84 * @variables This key takes one variable: The name of the invalid property
86 error_property_names_pattern_mismatch: 'Property name {{0}} does not match pattern',
88 * When the propertyName is set to false and there is at least one property
89 * @variables This key takes one variable: The name of the invalid property
91 error_property_names_false: 'Property name {{0}} fails when propertyName is false',
93 * When the propertyName specifies a maxLength that is not a number
94 * @variables This key takes one variable: The name of the current property
96 error_property_names_maxlength: 'Property name {{0}} cannot match invalid maxLength',
98 * When the propertyName specifies an enum that is not an array
99 * @variables This key takes one variable: The name of the current property
101 error_property_names_enum: 'Property name {{0}} cannot match invalid enum',
103 * When the propertyName specifies a pattern that is not a string
104 * @variables This key takes one variable: The name of the current property
106 error_property_names_pattern: 'Property name {{0}} cannot match invalid pattern',
108 * When the propertyName is unsupported
109 * @variables This key takes one variable: The name of the invalid propertyName
111 error_property_names_unsupported: 'Unsupported propertyName {{0}}',
113 * When a dependency is not resolved
114 * @variables This key takes one variable: The name of the missing property for the dependency
116 error_dependency: 'Must have property {{0}}',
118 * When a date is in incorrect format
119 * @variables This key takes one variable: The valid format
121 error_date: 'Date must be in the format {{0}}',
123 * When a time is in incorrect format
124 * @variables This key takes one variable: The valid format
126 error_time: 'Time must be in the format {{0}}',
128 * When a datetime-local is in incorrect format
129 * @variables This key takes one variable: The valid format
131 error_datetime_local: 'Datetime must be in the format {{0}}',
133 * When a integer date is less than 1 January 1970
135 error_invalid_epoch: 'Date must be greater than 1 January 1970',
137 * When an IPv4 is in incorrect format
139 error_ipv4: 'Value must be a valid IPv4 address in the form of 4 numbers between 0 and 255, separated by dots',
141 * When an IPv6 is in incorrect format
143 error_ipv6: 'Value must be a valid IPv6 address',
145 * When a hostname is in incorrect format
147 error_hostname: 'The hostname has the wrong format',
149 * Text on Delete All buttons
151 button_delete_all: 'All',
153 * Title on Delete All buttons
155 button_delete_all_title: 'Delete All',
157 * Text on Delete Last buttons
158 * @variable This key takes one variable: The title of object to delete
160 button_delete_last: 'Last {{0}}',
162 * Title on Delete Last buttons
163 * @variable This key takes one variable: The title of object to delete
165 button_delete_last_title: 'Delete Last {{0}}',
167 * Title on Add Row buttons
168 * @variable This key takes one variable: The title of object to add
170 button_add_row_title: 'Add {{0}}',
172 * Title on Move Down buttons
174 button_move_down_title: 'Move down',
176 * Title on Move Up buttons
178 button_move_up_title: 'Move up',
180 * Title on Object Properties buttons
182 button_object_properties: 'Object Properties',
184 * Title on Delete Row buttons
185 * @variable This key takes one variable: The title of object to delete
187 button_delete_row_title: '{{0}} löschen',
189 * Title on Delete Row buttons, short version (no parameter with the object title)
191 button_delete_row_title_short: 'Löschen',
193 * Title on Copy Row buttons, short version (no parameter with the object title)
195 button_copy_row_title_short: 'Copy',
197 * Title on Collapse buttons
199 button_collapse: 'Collapse',
201 * Title on Expand buttons
203 button_expand: 'Expand',
205 * Title on Flatpickr toggle buttons
207 flatpickr_toggle_button: 'Toggle',
209 * Title on Flatpickr clear buttons
211 flatpickr_clear_button: 'Clear',
213 * Choices input field placeholder text
215 choices_placeholder_text: 'Start typing to add value',
217 * Default title for array items
219 default_array_item_title: 'item',
221 * Warning when deleting a node
223 button_delete_node_warning: 'Are you sure you want to remove this node?'
230 JSONEditor.defaults.language = "de";
233 // Initialize the editor with a JSON schema
234 var editor = new JSONEditor(document.getElementById('editor_holder'), {
235 // https://www.winterrodeln.org/mediawiki/index.php?title=Winterrodeln:Datenschema/Rodelbahn/V1.json&action=raw
236 schema: {"$ref": "{{schema_url}}"},
241 editor.on('ready',() => {
242 // https://www.winterrodeln.org/mediawiki/index.php?title=Latschenh%C3%BCtte/Rodelbahn.json&action=raw
243 fetch("{{json_url}}").then(
245 return response.json();
248 editor.setValue(data);
250 ).catch(function (err) {
256 // Hook up the submit button to log to the console
257 document.getElementById('submit').addEventListener('click',function() {
258 // Get the value from the editor
259 console.log(editor.getValue());