diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/check/script.js b/check/script.js index 738fcea..695832b 100644 --- a/check/script.js +++ b/check/script.js @@ -1,5 +1,5 @@ -var fileContents = new Array(); -var fileNames = new Array(); +var fileContents = []; +var fileNames = []; function handleFileSelect(evt) { evt.stopPropagation(); @@ -46,8 +46,8 @@ function compareFiles(fileContents, fileNames) { } function resetArrays() { - fileNames = new Array(); - fileContents = new Array(); + fileNames = []; + fileContents = []; } function handleDragOver(evt) { diff --git a/index.css b/index.css index 1764d29..8f22e6d 100644 --- a/index.css +++ b/index.css @@ -67,7 +67,7 @@ body { } .scrollcode { - margin: 0px auto; + margin: 0 auto; width: 100%; height: 300px; overflow: scroll; @@ -75,11 +75,10 @@ body { } .scrollresult { - margin: 0px auto; + margin: 0 auto; width: 100%; height: 300px; overflow: scroll; - overflow-x: scroll; } .input_prompt { @@ -126,7 +125,7 @@ body { text-align: center; width: 100%; color: #FF0000; - margin: 0px auto; + margin: 0 auto; } .blur { @@ -137,7 +136,6 @@ body { top: 0; bottom: 0; z-index: 900; - background-color: #000000; opacity: 0.7; visibility: hidden; } diff --git a/index.html b/index.html index 1679de6..9761328 100644 --- a/index.html +++ b/index.html @@ -32,8 +32,7 @@
- {{strings.input_value}} - +
@@ -43,14 +42,19 @@ - + + +
{{strings.project_name}} - -

@@ -62,8 +66,16 @@ - - + +
{{line.line}} + + + +
@@ -125,24 +137,26 @@ - {{strings.interval}} - +
- JVON Web
- {{strings.credits_description}} {{strings.credits_john}}
- {{strings.credits_cromer}}
- Ingeniería Civil en Informática, Universidad del Bío Bío, 2015
- Version android + JVON Web
+ {{strings.credits_description}} {{strings.credits_john}}
+ {{strings.credits_cromer}}
+ Ingeniería Civil en Informática, Universidad del Bío Bío, 2015
+
Version android
diff --git a/js/jvon-angular.js b/js/jvon-angular.js index 25ee013..ed9bdd0 100644 --- a/js/jvon-angular.js +++ b/js/jvon-angular.js @@ -1,4 +1,5 @@ // This is the angular controller and the code pane +//noinspection JSUnresolvedFunction var jvonapp = angular.module("JVON", ["ngTouch", "ngSanitize"]); jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", function ($scope, $timeout ,$interval) { @@ -6,13 +7,13 @@ jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", functio $scope.commands = commands; // The code pane - $scope.code_lines = new Array(); + $scope.code_lines = []; // The result pane - $scope.results = new Array(); + $scope.results = []; // What is displayed on the screen - $scope.screen = new Array(); + $scope.screen = []; $scope.execution_started = false; @@ -67,14 +68,14 @@ jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", functio } else { $interval.cancel($scope.blink_promise); - element = document.getElementById("pause_code"); + var element = document.getElementById("pause_code"); element.style.opacity = 1; - element.style.filter = "alpha(opacity=" + 1 * 100 + ")"; + element.style.filter = "alpha(opacity=100)"; } }; $scope.blink = function () { - element = document.getElementById("pause_code"); + var element = document.getElementById("pause_code"); if ($scope.blink_state == false) { if ($scope.opacity <= 0.1) { $scope.blink_state = true; @@ -177,7 +178,8 @@ jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", functio if ($scope.code_lines.length > 0) { // Find the last highlighted line var highlighted = null; - for (var i = $scope.code_lines.length - 1; i >= 0; i--) { + var i; + for (i = $scope.code_lines.length - 1; i >= 0; i--) { if ($scope.code_lines[i].highlighted == true) { highlighted = i; break; @@ -188,9 +190,9 @@ jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", functio } // Add a line after the last highlighted - var new_code_lines = new Array(); + var new_code_lines = []; var j = 1; - for (var i = 0; i < $scope.code_lines.length; i++) { + for (i = 0; i < $scope.code_lines.length; i++) { if (highlighted == i) { $scope.code_lines[i].line = j.toString(); new_code_lines.push($scope.code_lines[i]); @@ -217,7 +219,7 @@ jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", functio // Delete the highlighted lines $scope.delete_line = function () { - var new_code_lines = new Array(); + var new_code_lines = []; var j = 1; for (var i = 0; i < $scope.code_lines.length; i++) { if (!$scope.code_lines[i].highlighted) { @@ -231,17 +233,18 @@ jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", functio // Delete all code lines $scope.clear_code = function () { - $scope.code_lines = new Array(); + $scope.code_lines = []; }; $scope.select_line = function (line_number, result) { + var line; + // If execution finished remove all highlights if ($scope.finished == true) { $scope.finished = false; for (var i = 0; i < $scope.code_lines.length; i++) { if ($scope.code_lines[i].highlighted == true) { // Unhighlight - var line; line = document.getElementById("line1_" + i.toString()); line.className = line.className.substring(0,line.className.length - 21); line = document.getElementById("line2_" + i.toString()); @@ -256,7 +259,6 @@ jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", functio if ($scope.executing == true && result == true) { if ($scope.code_lines[line_number].highlighted == false) { // Highlight - var line; line = document.getElementById("line1_" + line_number.toString()); line.className += " code_number_selected"; line = document.getElementById("line2_" + line_number.toString()); @@ -267,7 +269,6 @@ jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", functio } else { // Unhighlight - var line; line = document.getElementById("line1_" + line_number.toString()); line.className = line.className.substring(0,line.className.length - 21); line = document.getElementById("line2_" + line_number.toString()); @@ -280,7 +281,6 @@ jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", functio else if ($scope.executing == false && result == false) { if ($scope.code_lines[line_number].highlighted == false) { // Highlight - var line; line = document.getElementById("line1_" + line_number.toString()); line.className += " line_number_selected"; line = document.getElementById("line2_" + line_number.toString()); @@ -291,7 +291,6 @@ jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", functio } else { // Unhighlight - var line; line = document.getElementById("line1_" + line_number.toString()); line.className = line.className.substring(0,line.className.length - 21); line = document.getElementById("line2_" + line_number.toString()); @@ -380,7 +379,7 @@ jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", functio }; // Watch for changes to the code from external sources and update accordingly - $scope.$watch('imported_code',function(newValue, oldValue) { + $scope.$watch('imported_code', function (newValue) { if (newValue) { $scope.code_lines = newValue; $scope.imported_code = false; @@ -417,7 +416,7 @@ jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", functio jvonapp.directive("importFile", function () { return { restrict: "A", - link: function ($scope, element, attributes) { + link: function ($scope, element) { element.bind('change', function (event) { var file = event.target.files[0]; @@ -435,9 +434,9 @@ jvonapp.directive("importFile", function () { $scope.select_line(i, true); } } - $scope.code_lines = new Array(); + $scope.code_lines = []; $scope.$apply(); - } + }; reader.readAsText(file); } diff --git a/js/jvon-interpret.js b/js/jvon-interpret.js index 68ddeca..cf1b77c 100644 --- a/js/jvon-interpret.js +++ b/js/jvon-interpret.js @@ -18,7 +18,7 @@ document.addEventListener('DOMContentLoaded', function () { $scope.finished = false; $scope.ac = ""; - $scope.memory = new Array(); + $scope.memory = []; $scope.memory[0] = null; // 80 $scope.memory[1] = null; // 81 $scope.memory[2] = null; // 82 @@ -39,8 +39,8 @@ document.addEventListener('DOMContentLoaded', function () { $scope.disable_code_buttons(); - $scope.results = new Array(); - $scope.screen = new Array(); + $scope.results = []; + $scope.screen = []; $scope.line_number = 0; $scope.repeater(); } @@ -135,7 +135,7 @@ document.addEventListener('DOMContentLoaded', function () { $scope.pow($scope.code_lines[$scope.line_number].value); break; case "End": - $scope.End($scope.code_lines[$scope.line_number].value); + $scope.End(); break; default: alert($scope.code_lines[$scope.line_number].command.name + " is not implemented yet."); @@ -148,12 +148,13 @@ document.addEventListener('DOMContentLoaded', function () { $scope.check_syntax = function (value) { var result; + var regex; if (value == "") { return {type: "blank", value: ""}; } - var regex = /^(\d+)$/; + regex = /^(\d+)$/; if ((result = regex.exec(value)) !== null) { if (result.index === regex.lastIndex) { regex.lastIndex++; @@ -162,7 +163,7 @@ document.addEventListener('DOMContentLoaded', function () { return {type: "memory", value: result[1]}; } - var regex = /^\[(\d+)\]$/; + regex = /^\[(\d+)]$/; if ((result = regex.exec(value)) !== null) { if (result.index === regex.lastIndex) { regex.lastIndex++; @@ -171,7 +172,7 @@ document.addEventListener('DOMContentLoaded', function () { return {type: "address", value: result[1]}; } - var regex = /^#(-?[0-9]*?\.?[0-9]+)$/; + regex = /^#(-?[0-9]*?\.?[0-9]+)$/; if ((result = regex.exec(value)) !== null) { if (result.index === regex.lastIndex) { regex.lastIndex++; @@ -185,18 +186,12 @@ document.addEventListener('DOMContentLoaded', function () { $scope.check_memory_address = function(value) { value = parseFloat(value); - if (value < 80 || value > 85) { - return false; - } - return true; + return !(value < 80 || value > 85); }; $scope.check_memory_value = function(value) { value = parseFloat(value) - 80; - if ($scope.memory[value] == null) { - return false; - } - return true; + return $scope.memory[value] != null; }; $scope.rda = function (value) { @@ -223,9 +218,8 @@ document.addEventListener('DOMContentLoaded', function () { var new_memory = $scope.memory[syntax.value]; var regex = /^\d+$/; - var result; - if ((result = regex.exec(new_memory)) !== null && $scope.check_memory_address(new_memory) == true) { + if (regex.exec(new_memory) !== null && $scope.check_memory_address(new_memory) == true) { $scope.rda_value = new_memory; $scope.show_input_prompt(); } @@ -245,9 +239,8 @@ document.addEventListener('DOMContentLoaded', function () { var value = document.getElementById("rda").value; var regex = /^-?[0-9]*?\.?[0-9]+$/; - var result; - if ((result = regex.exec(value)) !== null) { + if (regex.exec(value) !== null) { value = parseFloat(value); $scope.rda_value = parseFloat($scope.rda_value); @@ -329,7 +322,7 @@ document.addEventListener('DOMContentLoaded', function () { } else if (syntax.type == "memory") { if ($scope.check_memory_address(value) == true) { - new_value = parseFloat(value) - 80; + var new_value = parseFloat(value) - 80; $scope.memory[new_value] = $scope.ac; $scope.create_result($scope.line_number, parseFloat(value), $scope.ac); @@ -350,9 +343,8 @@ document.addEventListener('DOMContentLoaded', function () { var new_memory = $scope.memory[syntax.value]; var regex = /^\d+$/; - var result; - if ((result = regex.exec(new_memory)) !== null && $scope.check_memory_address(new_memory) == true) { + if (regex.exec(new_memory) !== null && $scope.check_memory_address(new_memory) == true) { new_memory = parseFloat(new_memory) - 80; $scope.memory[new_memory] = $scope.ac; @@ -519,13 +511,13 @@ document.addEventListener('DOMContentLoaded', function () { $scope.div = function (value) { var syntax = $scope.check_syntax(value); + var regex; if (syntax.type == "number") { $scope.ac = parseFloat($scope.ac) / parseFloat(syntax.value); - var regex = /^-?[0-9]*\.?[0-9]+$/; - var result; + regex = /^-?[0-9]*\.?[0-9]+$/; - if ((result = regex.exec($scope.ac)) !== null) { + if (regex.exec($scope.ac) !== null) { $scope.create_result($scope.line_number, "ac", $scope.ac); $scope.line_number++; $scope.repeater(); @@ -540,10 +532,9 @@ document.addEventListener('DOMContentLoaded', function () { value = $scope.memory[value - 80]; $scope.ac = parseFloat($scope.ac) / parseFloat(value); - var regex = /^-?[0-9]*\.?[0-9]+$/; - var result; + regex = /^-?[0-9]*\.?[0-9]+$/; - if ((result = regex.exec($scope.ac)) !== null) { + if (regex.exec($scope.ac) !== null) { $scope.create_result($scope.line_number, "ac", $scope.ac); $scope.line_number++; $scope.repeater(); @@ -564,10 +555,9 @@ document.addEventListener('DOMContentLoaded', function () { value = parseFloat($scope.memory[temp_value - 80]); $scope.ac = parseFloat($scope.ac) / value; - var regex = /^-?[0-9]*\.?[0-9]+$/; - var result; + regex = /^-?[0-9]*\.?[0-9]+$/; - if ((result = regex.exec($scope.ac)) !== null) { + if (regex.exec($scope.ac) !== null) { $scope.create_result($scope.line_number, "ac", $scope.ac); $scope.line_number++; $scope.repeater(); @@ -686,13 +676,14 @@ document.addEventListener('DOMContentLoaded', function () { $scope.sqr = function (value) { var syntax = $scope.check_syntax(value); + var sqr; if (syntax.type == "blank") { if ($scope.ac == "") { alert($scope.strings.error_ac); $scope.stop_code(); } else { - var sqr = Math.sqrt(parseFloat($scope.ac)); + sqr = Math.sqrt(parseFloat($scope.ac)); if (sqr == "NaN") { alert($scope.strings.error_math); $scope.stop_code(); @@ -706,7 +697,7 @@ document.addEventListener('DOMContentLoaded', function () { } } else if (syntax.type == "number") { - var sqr = Math.sqrt(syntax.value); + sqr = Math.sqrt(parseFloat(syntax.value)); if (sqr == "NaN") { alert($scope.strings.error_math); $scope.stop_code(); @@ -721,7 +712,7 @@ document.addEventListener('DOMContentLoaded', function () { else if (syntax.type == "memory") { if ($scope.check_memory_address(value) == true && $scope.check_memory_value(value) == true) { value = parseFloat($scope.memory[value - 80]); - var sqr = Math.sqrt(value); + sqr = Math.sqrt(value); if (sqr == "NaN") { alert($scope.strings.error_math); $scope.stop_code(); @@ -742,7 +733,7 @@ document.addEventListener('DOMContentLoaded', function () { var temp_value = $scope.memory[syntax.value - 80]; if ($scope.check_memory_address(temp_value) == true && $scope.check_memory_value(temp_value) == true) { value = parseFloat($scope.memory[temp_value - 80]); - var sqr = Math.sqrt(value); + sqr = Math.sqrt(value); if (sqr == "NaN") { alert($scope.strings.error_math); $scope.stop_code(); @@ -767,9 +758,9 @@ document.addEventListener('DOMContentLoaded', function () { $scope.pow = function (value) { var syntax = $scope.check_syntax(value); + var new_value; if (syntax.type == "number") { if ($scope.ac != "" || $scope.ac == 0) { - var new_value; value = parseFloat(syntax.value); if (value < 0) { // The exponent is negative @@ -793,7 +784,6 @@ document.addEventListener('DOMContentLoaded', function () { else if (syntax.type == "memory") { if ($scope.check_memory_address(value) == true) { value = parseFloat($scope.memory[value - 80]); - var new_value; if (value < 0) { // The exponent is negative value = Math.abs(parseFloat(value)); @@ -817,7 +807,6 @@ document.addEventListener('DOMContentLoaded', function () { var temp_value = $scope.memory[syntax.value - 80]; if ($scope.check_memory_address(temp_value) == true) { value = parseFloat($scope.memory[temp_value - 80]); - var new_value; if (value < 0) { // The exponent is negative value = Math.abs(parseFloat(value)); @@ -850,9 +839,9 @@ document.addEventListener('DOMContentLoaded', function () { else { return base * $scope.pow_repeat(exponent -1, base); } - } + }; - $scope.End = function (value) { + $scope.End = function () { // Rap-up everything $scope.stop_code(); };