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