| 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.cracas = {{ cracas | tojson | safe }}; |
| 10 crash.component_classifier = {{ component_classifier | tojson | safe }}; | 11 crash.component_classifier = {{ component_classifier | tojson | safe }}; |
| 11 crash.project_classifier = {{ project_classifier | tojson | safe }}; | 12 crash.project_classifier = {{ project_classifier | tojson | safe }}; |
| 12 | 13 |
| 13 function getJsonOfTextarea(textId) { | 14 function getJsonOfTextarea(textId) { |
| 14 return JSON.parse($('#' + textId).val()); | 15 return JSON.parse($('#' + textId).val()); |
| 15 } | 16 } |
| 16 | 17 |
| 17 function getStringFromJson(json) { | 18 function getStringFromJson(json) { |
| 18 return JSON.stringify(json, null, ' '); | 19 return JSON.stringify(json, null, ' '); |
| 19 } | 20 } |
| 20 | 21 |
| 21 function save(e) { | 22 function save(e) { |
| 22 var newConfig = { | 23 var newConfig = { |
| 23 'fracas': getJsonOfTextarea('fracas'), | 24 'fracas': getJsonOfTextarea('fracas'), |
| 25 'cracas': getJsonOfTextarea('cracas'), |
| 24 'component_classifier': getJsonOfTextarea('component-classifier'), | 26 'component_classifier': getJsonOfTextarea('component-classifier'), |
| 25 'project_classifier': getJsonOfTextarea('project-classifier'), | 27 'project_classifier': getJsonOfTextarea('project-classifier'), |
| 26 }; | 28 }; |
| 27 $.post('/crash/config', { data: JSON.stringify(newConfig) }).done(function
() { | 29 $.post('/crash/config', { data: JSON.stringify(newConfig) }).done(function
() { |
| 28 window.location.reload(); // Reload after successful saving. | 30 window.location.reload(); // Reload after successful saving. |
| 29 }).fail(function(xhr) { | 31 }).fail(function(xhr) { |
| 30 // Replace the whole page with errors from server side. | 32 // Replace the whole page with errors from server side. |
| 31 document.body.outerHTML = xhr.responseText; | 33 document.body.outerHTML = xhr.responseText; |
| 32 }); | 34 }); |
| 33 e.preventDefault(); | 35 e.preventDefault(); |
| 34 } | 36 } |
| 35 | 37 |
| 36 $(document).ready(function() { | 38 $(document).ready(function() { |
| 37 $('#save-button').click(save); | 39 $('#save-button').click(save); |
| 38 $('#fracas').val(getStringFromJson(crash.fracas)); | 40 $('#fracas').val(getStringFromJson(crash.fracas)); |
| 41 $('#cracas').val(getStringFromJson(crash.cracas)); |
| 39 $('#component-classifier').val(getStringFromJson(crash.component_classifie
r)); | 42 $('#component-classifier').val(getStringFromJson(crash.component_classifie
r)); |
| 40 $('#project-classifier').val(getStringFromJson(crash.project_classifier)); | 43 $('#project-classifier').val(getStringFromJson(crash.project_classifier)); |
| 41 }); | 44 }); |
| 42 </script> | 45 </script> |
| 43 </head> | 46 </head> |
| 44 <body> | 47 <body> |
| 45 <h3>Crash Configuration</h3> | 48 <h3>Crash Configuration</h3> |
| 46 <div> | 49 <div> |
| 47 Settings for Fracas:<br> | 50 Settings for Fracas:<br> |
| 48 <textarea id="fracas" rows="20" cols="80"></textarea> | 51 <textarea id="fracas" rows="20" cols="80"></textarea> |
| 49 </div> | 52 </div> |
| 50 <div> | 53 <div> |
| 54 Settings for Cracas:<br> |
| 55 <textarea id="cracas" rows="20" cols="80"></textarea> |
| 56 </div> |
| 57 <div> |
| 51 Settings for component classifier:<br> | 58 Settings for component classifier:<br> |
| 52 <textarea id="component-classifier" rows="20" cols="80"></textarea> | 59 <textarea id="component-classifier" rows="20" cols="80"></textarea> |
| 53 </div> | 60 </div> |
| 54 <div> | 61 <div> |
| 55 Settings for project classifier:<br> | 62 Settings for project classifier:<br> |
| 56 <textarea id="project-classifier" rows="20" cols="80"></textarea> | 63 <textarea id="project-classifier" rows="20" cols="80"></textarea> |
| 57 </div> | 64 </div> |
| 58 <button type="submit" id="save-button">Save</button> | 65 <button type="submit" id="save-button">Save</button> |
| 59 </body> | 66 </body> |
| OLD | NEW |