Chromium Code Reviews| Index: appengine/findit/templates/crash/crash_config.html |
| diff --git a/appengine/findit/templates/crash/crash_config.html b/appengine/findit/templates/crash/crash_config.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6b6dad9e0aaa9d450a56aec60ba2c4a1e3b5487c |
| --- /dev/null |
| +++ b/appengine/findit/templates/crash/crash_config.html |
| @@ -0,0 +1,45 @@ |
| +<!DOCTYPE html> |
| +<head> |
| + <meta charset="utf-8"> |
| + <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> |
|
mimee
2016/04/07 23:43:09
This might just be a sample internal page, but jqu
stgao
2016/04/08 01:14:08
We prefer jquery over native javascript functions
mimee
2016/04/08 15:36:03
The alternative is to put script on bottom because
stgao
2016/04/11 20:32:19
Ah, I see. But if we move all scripts to the end o
|
| + <link rel="stylesheet" href="/common.css"></link> |
| + <title>Crash Configuration</title> |
| + <script> |
| + var crash = {}; |
| + crash.fracas = {{ fracas | tojson | safe }}; |
| + |
| + function getJsonOfTextarea(textId) { |
| + return JSON.parse($('#' + textId).val()); |
| + } |
| + |
| + function getStringFromJson(json) { |
| + return JSON.stringify(json, null, ' '); |
| + } |
| + |
| + function save(e) { |
| + var newConfig = { |
| + 'fracas': getJsonOfTextarea('fracas'), |
| + }; |
| + $.post('/crash/config', { data: JSON.stringify(newConfig) }).done(function() { |
| + window.location.reload(); // Reload after successful saving. |
| + }).fail(function(xhr) { |
| + // Replace the whole page with errors from server side. |
| + document.body.outerHTML = xhr.responseText; |
| + }); |
| + e.preventDefault(); |
| + } |
| + |
| + $(document).ready(function() { |
| + $('#save-button').click(save); |
| + $('#fracas').val(getStringFromJson(crash.fracas)); |
| + }); |
| + </script> |
| +</head> |
| +<body> |
| + <h3>Crash Configuration</h3> |
| + <div> |
| + Settings for Fracas:<br> |
| + <textarea id="fracas" rows="20" cols="80"></textarea> |
| + </div> |
| + <button type="submit" id="save-button">Save</button> |
| +</body> |