| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <head> |
| 3 <meta charset="utf-8"> |
| 4 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></sc
ript> |
| 5 <link rel="stylesheet" href="/common.css"></link> |
| 6 <title>Crash Configuration</title> |
| 7 <script> |
| 8 var crash = {}; |
| 9 crash.fracas = {{ fracas | tojson | safe }}; |
| 10 |
| 11 function getJsonOfTextarea(textId) { |
| 12 return JSON.parse($('#' + textId).val()); |
| 13 } |
| 14 |
| 15 function getStringFromJson(json) { |
| 16 return JSON.stringify(json, null, ' '); |
| 17 } |
| 18 |
| 19 function save(e) { |
| 20 var newConfig = { |
| 21 'fracas': getJsonOfTextarea('fracas'), |
| 22 }; |
| 23 $.post('/crash/config', { data: JSON.stringify(newConfig) }).done(function
() { |
| 24 window.location.reload(); // Reload after successful saving. |
| 25 }).fail(function(xhr) { |
| 26 // Replace the whole page with errors from server side. |
| 27 document.body.outerHTML = xhr.responseText; |
| 28 }); |
| 29 e.preventDefault(); |
| 30 } |
| 31 |
| 32 $(document).ready(function() { |
| 33 $('#save-button').click(save); |
| 34 $('#fracas').val(getStringFromJson(crash.fracas)); |
| 35 }); |
| 36 </script> |
| 37 </head> |
| 38 <body> |
| 39 <h3>Crash Configuration</h3> |
| 40 <div> |
| 41 Settings for Fracas:<br> |
| 42 <textarea id="fracas" rows="20" cols="80"></textarea> |
| 43 </div> |
| 44 <button type="submit" id="save-button">Save</button> |
| 45 </body> |
| OLD | NEW |