update block and line highlightning

This commit is contained in:
Silver Kuusik
2018-08-18 19:12:05 +02:00
parent 2af99f108b
commit 22adce4b9e
4 changed files with 23 additions and 9 deletions

View File

@@ -2,7 +2,6 @@
//var ROBOT_SERVER = '192.168.2.1:80';
var ROBOT_SERVER = 'ws.achex.ca:4010';
var workspace;
// The sumorobot object
var sumorobot;
// Disable / enable coding mode
@@ -119,6 +118,7 @@ window.addEventListener('load', function() {
}
});
var range_id;
var lines = [];
var foundTrue = false;
// Function to process code and highlight blocks and lines
@@ -153,6 +153,11 @@ window.addEventListener('load', function() {
if (/\d/.test(code)) {
timeout = parseInt(code.replace(/[a-z\.()]/g, ''));
}
if (range_id) {
readOnlyCodingEditor.session.removeMarker(range_id);
}
var range = new Range(index, 0, index, 1);
range_id = readOnlyCodingEditor.session.addMarker(range, "highlight", "fullLine");
// Block ID should always be 20 symbols long
var blockId = temp[1].substring(0, 20);
// Highlight the block
@@ -188,6 +193,9 @@ window.addEventListener('load', function() {
// Stop highlighting blocks and lines
lines = [];
workspace.highlightBlock('');
if (range_id) {
readOnlyCodingEditor.session.removeMarker(range_id);
}
});
// Enter (return) keypress listener on robot ID field