diff --git a/index.html b/index.html index c04eb8d..55ad581 100644 --- a/index.html +++ b/index.html @@ -96,6 +96,7 @@ recognizer.onresult = (event) => { case speechactions[2] : deleteTarget( latest ) speechCommands.push( speechContent ) + addedContent.pop() break; case speechactions[3] : el = latest.cloneNode(true) // does not work properly, losing some attributes, in particular scale can be problematic @@ -118,8 +119,19 @@ recognizer.onresult = (event) => { speechCommands.push( speechContent ) break; case speechactions[5] : - console.log( "should undo", speechCommands.at(-1) ) - // note that not all commands might be undo-able + if ( speechCommands.at(-1) ){ + let prev_cmd_words = speechCommands.at(-1).split(" ").map( i => i.toLowerCase() ) + switch(prev_cmd_words[0]) { + case speechactions[0]: + console.log( "undoing", speechCommands.at(-1) ) + deleteTarget( latest ) + addedContent.pop() + break; + default: + console.log( "can't undo", speechCommands.at(-1) ) + // note that not all commands might be undo-able + } + } break; default: addedContent.push( addNewNoteAsPostItNote(speechContent, "0 1.2 -.5") ) @@ -499,96 +511,6 @@ setTimeout( _ => { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -