4 <title>JSONEditor</title>
7 href="https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/5.28.2/jsoneditor.min.css"
8 integrity="sha256-0g5yJEEhhjj7b+OT+tOn8IBly2P/5+UyU1g1/W5VZfI="
9 crossorigin="anonymous" />
11 <script src="https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/5.28.2/jsoneditor.min.js"
12 integrity="sha256-0fFVLa/33uSRXl/lUXolxF9IdLB/WC3DRP1JGXmTJyM="
13 crossorigin="anonymous"></script>
15 <style type="text/css">
24 Modify json and click submit.
27 <form action="" method="post">
28 <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
29 <button id="submit" name="submit" value="{{ TheJson }}">Submit result</button>
32<div id="jsoneditor"></div>
36 var container = document.getElementById('jsoneditor');
38 var editor = new JSONEditor(container, options);
41 var InJson = {{ TheJson|safe }};
45 document.getElementById('submit').onclick = function () {
46 var OutJson = editor.get();
47 document.getElementById('submit').value=JSON.stringify(OutJson); //, null, 2
50 stra=JSON.stringify(editor.get());
51 prefix="tiledviz_editor";
52 var sessionDate = new Date();
53 var strDate=sessionDate.toLocaleDateString({day: "2-digit", month: "2-digit"}).replace(/\//g, "-") + "_" + sessionDate.toLocaleTimeString("fr-FR").replace(/:/g, "-");
54 var fileName = prefix + "_" + strDate + ".json";
55 //var file = new File([stra], fileName, {type: "text/plain;charset=utf-8"},{ autoBom: false });
58 var a = document.createElement("a");
59 var file = new Blob([stra], {type: "text/plain;charset=utf-8"});
60 a.href = URL.createObjectURL(file);
61 a.download = fileName;
62 var button = document.createElement('button');
63 button.setAttribute('class',"btn btn-primary btn-lg");
64 button.innerText="Save";
65 button.onclick=function(){ a.click(); URL.revokeObjectURL(a.href) };
66 a.appendChild(button);
67 document.body.appendChild(a);