-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_creator.html
92 lines (79 loc) · 3.22 KB
/
data_creator.html
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>JSON Data Editor</title>
<script src="https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/jsoneditor.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/spectre.css@latest/dist/spectre.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/spectre.css@latest/dist/spectre-exp.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@latest/css/font-awesome.min.css">
</head>
<body>
<h1>JSON Data Editor</h1>
<p>Générateur de fichier jeu de données pour le code XFV :</p>
<ul>
<li>Cocher les différentes propriétés à ajouter.</li>
<li>Remplir le formulaire avec les données souhaitées.</li>
<li>Vérifier la validité du formulaire.</li>
<li>Afficher le fichier json généré en cliquant sur <code>Edit JSON</code> de la rubrique <code>Data</code>.</li>
<li>Extraire (copier-coller) le résultat dans un fichier DATA.json et placer le fichier créé dans le répertoire du cas.</li>
</ul>
<p> Il est recommandé de remplir le formulaire en s'appuyant sur la <a class="reference internal" href="doc_keywords.html"> documentation des mots clés</a>.</p>
<button id='restore'>Restore to Default</button>
<button id='enable_disable'>Disable/Enable Form</button>
<span id='valid_indicator'></span>
<div id='editor_holder'></div>
<script>
// Initialize the editor with a JSON schema
var editor = new JSONEditor(document.getElementById('editor_holder'),{
// Enable fetching schemas via ajax
ajax: true,
// Disable legends :
compact: true,
// Disable not required options
show_opt_in: true,
// Additional properties = false unless specified in json schema
no_additional_properties: true,
// The schema for the editor
schema: {
$ref: "./json-editor_docs/xvof_types/complete-schema.json",
title: "Data",
theme: "spectre",
iconlib: "spectre"
}
});
// Hook up the Restore to Default button
document.getElementById('restore').addEventListener('click',function() {
editor.setValue(starting_value);
});
// Hook up the enable/disable button
document.getElementById('enable_disable').addEventListener('click',function() {
// Enable form
if(!editor.isEnabled()) {
editor.enable();
}
// Disable form
else {
editor.disable();
}
});
// Hook up the validation indicator to update its
// status whenever the editor changes
editor.on('change',function() {
// Get an array of errors from the validator
var errors = editor.validate();
var indicator = document.getElementById('valid_indicator');
// Not valid
if(errors.length) {
indicator.style.color = 'red';
indicator.textContent = "not valid";
}
// Valid
else {
indicator.style.color = 'green';
indicator.textContent = "valid";
}
});
</script>
</body>
</html>