From a5a5a276ab60d000fe259858585dc5b71eb372d2 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Thu, 31 Mar 2016 16:56:19 +0200 Subject: Replace window.alert with custom message box --- js/codeq/core.js | 10 ++++++++++ js/codeq/prolog.js | 6 +++--- js/codeq/python.js | 6 +++--- 3 files changed, 16 insertions(+), 6 deletions(-) (limited to 'js') 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 . */ }; }; + // 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 . */ 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 . */ } }, 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 . */ 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 . */ }), 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 . */ hinter.handle(data.hints); } else { - terminal.append('error: ' + data.message); + alert(data.message); } }) .fail(alert) -- cgit v1.2.1