From 7af3b0fb39f674f5c68e765699d0c4c57731e924 Mon Sep 17 00:00:00 2001 From: Alexander Cobleigh Date: Thu, 17 Nov 2016 20:37:45 +0100 Subject: [PATCH] new command ~, toggles commander to always show. also patch mousedown + add .gitignore --- .gitignore | 2 ++ scripts/commander.js | 14 ++++++++++++-- scripts/init.js | 10 ++++++---- 3 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3819313 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.swp +*.swo diff --git a/scripts/commander.js b/scripts/commander.js index ae6cf4d..1f23198 100644 --- a/scripts/commander.js +++ b/scripts/commander.js @@ -5,16 +5,23 @@ function Commander(element,element_input) this.cmd = null; this.storage = []; this.storage_index = 0; + this.always_show = false; this.show = function() { this.element.setAttribute('class','visible'); this.element_input.focus(); } + + this.always = function() { + this.always_show = !this.always_show; + } this.hide = function() { - this.element.setAttribute('class','hidden'); + if (!this.always_show) { + this.element.setAttribute('class','hidden'); + } this.element_input.value = ""; } @@ -45,6 +52,9 @@ function Commander(element,element_input) var cmd = new Command(content); switch(key) { + case "~": + this.always(); + break; case "@": ronin.canvas.active(cmd); break; @@ -127,4 +137,4 @@ function Commander(element,element_input) break; } } -} \ No newline at end of file +} diff --git a/scripts/init.js b/scripts/init.js index 73ffcf0..4e4ca3e 100644 --- a/scripts/init.js +++ b/scripts/init.js @@ -7,9 +7,11 @@ var commander = new Commander(document.getElementById("commander"),document.getE // Interactive -document.addEventListener('mousemove', function(e) { ronin.brush.draw(e); }, false); -document.addEventListener('mousedown', function(e) { if(e.which != 1){ return; } ronin.brush.draw_start(e); }, false); -document.addEventListener('mouseup', function(e) { ronin.brush.draw_stop(e); }, false); +document.addEventListener('mousemove', function(e) { ronin.brush.draw(e); ; +}, false); +document.addEventListener('mousedown', function(e) { if(e.which != 1){ return; } ronin.brush.draw_start(e); ronin.brush.draw(e) }, false); +document.addEventListener('mouseup', function(e) { ronin.brush.draw_stop(e); document.getElementById("commander_input").focus();}, false); + var keyboard = new Keyboard(); -document.onkeyup = function myFunction(){ keyboard.listen(event); }; \ No newline at end of file +document.onkeyup = function myFunction(){ keyboard.listen(event); };