diff --git a/src/index.html b/src/index.html
index 40947a4..f8d4dc2 100644
--- a/src/index.html
+++ b/src/index.html
@@ -101,7 +101,7 @@
-
@@ -601,6 +604,11 @@
+
+
+
diff --git a/src/screenlog.js b/src/screenlog.js
index 8a23762..8d9d67a 100644
--- a/src/screenlog.js
+++ b/src/screenlog.js
@@ -171,4 +171,13 @@ screenLog.init({
proxyCallback: function () {
window.parent.onMessageFromConsole.apply(null, arguments);
}
-});
\ No newline at end of file
+});
+window._wmEvaluate = function _wmEvaluate(expr) {
+ try {
+ var result = eval(expr);
+ } catch(e) {
+ window.parent.onMessageFromConsole.call(null, e);
+ return;
+ }
+ window.parent.onMessageFromConsole.call(null, result);
+}
\ No newline at end of file
diff --git a/src/script.js b/src/script.js
index de98319..3841336 100644
--- a/src/script.js
+++ b/src/script.js
@@ -92,6 +92,7 @@ runBtn, searchInput, consoleEl, consoleLogEl
scope.cm = {};
scope.consoleCm;
+ scope.frame = frame;
scope.demoFrameDocument = frame.contentDocument || frame.contentWindow.document;
// Check all the code wrap if they are minimized or not
@@ -1304,23 +1305,29 @@ runBtn, searchInput, consoleEl, consoleLogEl
};
scope.toggleConsole = function () {
- consoleEl.classList.toggle('is-open');
+ consoleEl.classList.toggle('is-minimized');
};
scope.clearConsole = function () {
scope.consoleCm.setValue('');
};
-
+ scope.evalConsoleExpr = function (e) {
+ if (e.which === 13) {
+ window.onMessageFromConsole('> ' + e.target.value);
+ frame.contentWindow._wmEvaluate(e.target.value);
+ e.target.value = '';
+ }
+ };
window.onMessageFromConsole = function() {
[...arguments].forEach(function(arg) {
- if (arg.indexOf && arg.indexOf('filesystem:chrome-extension') !== -1) {
+ if (arg && arg.indexOf && arg.indexOf('filesystem:chrome-extension') !== -1) {
arg = arg.replace(/filesystem:chrome-extension.*\.js:(\d+):(\d+)/g, 'script $1:$2');
}
scope.consoleCm.replaceRange('\n' + arg + ((arg + '').match(/\[object \w+\]/) ? JSON.stringify(arg) : '') + ' ', {line: Infinity});
+ scope.consoleCm.scrollTo(0, Infinity);
});
}
function compileNodes() {
-
function attachListenerForEvent(eventName) {
const nodes = $all(`[d-${eventName}]`);
nodes.forEach(function (el) {
@@ -1332,6 +1339,7 @@ runBtn, searchInput, consoleEl, consoleLogEl
attachListenerForEvent('click');
attachListenerForEvent('change');
attachListenerForEvent('input');
+ attachListenerForEvent('keypress');
}
function init () {
diff --git a/src/style.css b/src/style.css
index c02108a..393e9ef 100644
--- a/src/style.css
+++ b/src/style.css
@@ -824,13 +824,13 @@ li.CodeMirror-hint-active {
height: 30vh;
left: 0;
right: 0;
- transform: translateY(calc(100% - 30px));
- transition: transform 0.4s cubic-bezier(0.77,-0.1,0.13,0.9);
-}
-.console.is-open {
transform: translateY(0);
+ transition: transform 0.4s cubic-bezier(0.76, 0.01, 0.13, 0.9);
+}
+.console.is-minimized {
+ transform: translateY(calc(100% - 30px));
}
.console .Codemirror {
height: auto;
- max-height: calc(100% - 50px);
+ max-height: calc(100% - 70px);
}
\ No newline at end of file