diff options
-rw-r--r-- | css/codeq.css | 22 | ||||
-rw-r--r-- | index.html | 6 | ||||
-rw-r--r-- | js/codeq/core.js | 10 | ||||
-rw-r--r-- | js/codeq/prolog.js | 6 | ||||
-rw-r--r-- | js/codeq/python.js | 6 |
5 files changed, 44 insertions, 6 deletions
diff --git a/css/codeq.css b/css/codeq.css index 28870c9..56a086b 100644 --- a/css/codeq.css +++ b/css/codeq.css @@ -106,6 +106,28 @@ button.navbar-toggle > span.glyphicon { margin: 0; } +/* system message */ +div#message { + position: fixed; + bottom: 0; + left: 0; + right: 0; + padding: 0.25em 0.5em; + z-index: 999; +} +div#message.error { + background-color: #ffbfbf; + border-top: 1px solid #ff4040; +} +div#message > span.close { + font-weight: normal; + opacity: 0.5; + text-shadow: none; +} +div#message > span.close:hover { + opacity: 0.75; +} + /* misc */ form { margin-bottom: 0; @@ -53,6 +53,12 @@ </script> </head> <body> + <!-- message box for alerts --> + <div id="message" style="display: none;"> + <span class="close glyphicon glyphicon-remove-sign"></span> + <span class="text"></span> + </div> + <!-- the status bar at the top of each page --> <div class="navbar navbar-inverse navbar-fixed-top" id="topbar"> <div class="container-fluid"> diff --git a/js/codeq/core.js b/js/codeq/core.js index b1d4a5c..fd58781 100644 --- a/js/codeq/core.js +++ b/js/codeq/core.js @@ -243,6 +243,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ }; }; + // replace window.alert with custom message box (only used for app errors) + var jqMessage = $('div#message'); + jqMessage.find('.close').click(function () { + jqMessage.slideUp('fast'); + }); + window.alert = function (message, type) { + jqMessage.find('.text').text(message); + jqMessage.removeClass().addClass(type || 'error').slideDown('fast'); + }; + window.codeq = { 'jsonize': jsonize, diff --git a/js/codeq/prolog.js b/js/codeq/prolog.js index c361b03..62effd1 100644 --- a/js/codeq/prolog.js +++ b/js/codeq/prolog.js @@ -86,7 +86,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ promptMode = !t.have_more; } else { - terminal.append(data.message, 'error'); + alert(data.message); promptMode = true; } if (promptMode) { @@ -95,9 +95,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ } }, tcf = function terminalCommandFailed (error) { + alert(error); promptMode = true; terminal.setLineBuffered(); - terminal.append(error + '\n', 'error'); terminal.append('?- ', 'output'); }; @@ -241,7 +241,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ hinter.handle(data.hints); } else { - terminal.append(data.message + '\n', 'error'); + alert(data.message); } }) .fail(alert) diff --git a/js/codeq/python.js b/js/codeq/python.js index ada3954..3bc7ab5 100644 --- a/js/codeq/python.js +++ b/js/codeq/python.js @@ -72,11 +72,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ }), tcs = function terminalCommandSuccess (data) { if (data.code !== 0) { - terminal.append(data.message, 'error'); + alert(data.message); } }, tcf = function terminalCommandFailed (error) { - terminal.append(error + '\n', 'error'); + alert(error); }; terminal.onInput = function (text) { @@ -170,7 +170,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ hinter.handle(data.hints); } else { - terminal.append('error: ' + data.message); + alert(data.message); } }) .fail(alert) |