fixed bugs and cleanup
This commit is contained in:
parent
0a7f973068
commit
78a6c2e6fa
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -1,5 +1,5 @@
|
|||||||
var fileContents = new Array();
|
var fileContents = [];
|
||||||
var fileNames = new Array();
|
var fileNames = [];
|
||||||
|
|
||||||
function handleFileSelect(evt) {
|
function handleFileSelect(evt) {
|
||||||
evt.stopPropagation();
|
evt.stopPropagation();
|
||||||
@ -46,8 +46,8 @@ function compareFiles(fileContents, fileNames) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function resetArrays() {
|
function resetArrays() {
|
||||||
fileNames = new Array();
|
fileNames = [];
|
||||||
fileContents = new Array();
|
fileContents = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDragOver(evt) {
|
function handleDragOver(evt) {
|
||||||
|
@ -67,7 +67,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.scrollcode {
|
.scrollcode {
|
||||||
margin: 0px auto;
|
margin: 0 auto;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 300px;
|
height: 300px;
|
||||||
overflow: scroll;
|
overflow: scroll;
|
||||||
@ -75,11 +75,10 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.scrollresult {
|
.scrollresult {
|
||||||
margin: 0px auto;
|
margin: 0 auto;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 300px;
|
height: 300px;
|
||||||
overflow: scroll;
|
overflow: scroll;
|
||||||
overflow-x: scroll;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.input_prompt {
|
.input_prompt {
|
||||||
@ -126,7 +125,7 @@ body {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
color: #FF0000;
|
color: #FF0000;
|
||||||
margin: 0px auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.blur {
|
.blur {
|
||||||
@ -137,7 +136,6 @@ body {
|
|||||||
top: 0;
|
top: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
z-index: 900;
|
z-index: 900;
|
||||||
background-color: #000000;
|
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
|
26
index.html
26
index.html
@ -32,8 +32,7 @@
|
|||||||
|
|
||||||
<div id="input_prompt" class="input_prompt">
|
<div id="input_prompt" class="input_prompt">
|
||||||
<span class="input_prompt_vertical">
|
<span class="input_prompt_vertical">
|
||||||
{{strings.input_value}}
|
<label for="rda">{{strings.input_value}}</label><input autocomplete="off" type="text" name="rda" id="rda"/>
|
||||||
<input autocomplete="off" type="text" name="rda" id="rda" />
|
|
||||||
<input ng-click="rda_value_received();" type="button" value="Ingresar" />
|
<input ng-click="rda_value_received();" type="button" value="Ingresar" />
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@ -43,13 +42,18 @@
|
|||||||
<table class="title_table">
|
<table class="title_table">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="blank_title_cell"><img src="ubblogo.png" /></td>
|
<td class="blank_title_cell"><img src="ubblogo.png" /></td>
|
||||||
<td class="project_name">{{strings.project_name}} <input type="text" id="project_name" name="project_name" value="" /></td>
|
<td class="project_name"><label for="project_name">{{strings.project_name}} </label><input type="text"
|
||||||
|
id="project_name"
|
||||||
|
name="project_name"
|
||||||
|
value=""/></td>
|
||||||
<td class="options">
|
<td class="options">
|
||||||
<input ng-click="show_help();" type="button" value="{{strings.help}}" />
|
<input ng-click="show_help();" type="button" value="{{strings.help}}" />
|
||||||
|
<label>
|
||||||
<select ng-change="change_language();" ng-model="language">
|
<select ng-change="change_language();" ng-model="language">
|
||||||
<option value="0">{{strings.spanish}}</option>
|
<option value="0">{{strings.spanish}}</option>
|
||||||
<option value="1">{{strings.english}}</option>
|
<option value="1">{{strings.english}}</option>
|
||||||
</select>
|
</select>
|
||||||
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@ -62,8 +66,16 @@
|
|||||||
<table align="center" class="table_background">
|
<table align="center" class="table_background">
|
||||||
<tr ng-repeat="(key, line) in code_lines">
|
<tr ng-repeat="(key, line) in code_lines">
|
||||||
<td id="line1_{{key}}" ng-click="select_line(key, false);" class="table_cell line_number_td" >{{line.line}}</td>
|
<td id="line1_{{key}}" ng-click="select_line(key, false);" class="table_cell line_number_td" >{{line.line}}</td>
|
||||||
<td id="line2_{{key}}" class="table_cell"><select ng-model="line.command" ng-options="command.name for command in commands"></select></td>
|
<td id="line2_{{key}}" class="table_cell">
|
||||||
<td id="line3_{{key}}" class="table_cell"><input type="text" ng-model="line.value" /></td>
|
<label>
|
||||||
|
<select ng-model="line.command" ng-options="command.name for command in commands"></select>
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
<td id="line3_{{key}}" class="table_cell">
|
||||||
|
<label>
|
||||||
|
<input type="text" ng-model="line.value"/>
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -125,6 +137,7 @@
|
|||||||
<input ng-click="execute_code();" id="execute_code" type="button" value="{{strings.execute_code}}" />
|
<input ng-click="execute_code();" id="execute_code" type="button" value="{{strings.execute_code}}" />
|
||||||
<input ng-click="pause_code();" id="pause_code" type="button" value="{{strings.pause_code}}" disabled="disabled" />
|
<input ng-click="pause_code();" id="pause_code" type="button" value="{{strings.pause_code}}" disabled="disabled" />
|
||||||
<input ng-click="stop_code();" id="stop_code" type="button" value="{{strings.stop_code}}" disabled="disabled" />
|
<input ng-click="stop_code();" id="stop_code" type="button" value="{{strings.stop_code}}" disabled="disabled" />
|
||||||
|
<label>
|
||||||
{{strings.interval}}
|
{{strings.interval}}
|
||||||
<select ng-change="change_speed();" ng-model="speed">
|
<select ng-change="change_speed();" ng-model="speed">
|
||||||
<option value="0">0</option>
|
<option value="0">0</option>
|
||||||
@ -134,6 +147,7 @@
|
|||||||
<option value="4">4</option>
|
<option value="4">4</option>
|
||||||
<option value="5">5</option>
|
<option value="5">5</option>
|
||||||
</select>
|
</select>
|
||||||
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@ -142,7 +156,7 @@
|
|||||||
{{strings.credits_description}} <b>{{strings.credits_john}}</b><br/>
|
{{strings.credits_description}} <b>{{strings.credits_john}}</b><br/>
|
||||||
{{strings.credits_cromer}}<br/>
|
{{strings.credits_cromer}}<br/>
|
||||||
Ingeniería Civil en Informática, Universidad del Bío Bío, 2015<br/>
|
Ingeniería Civil en Informática, Universidad del Bío Bío, 2015<br/>
|
||||||
<a target="_blank" href="jvon-1.0.0.0.apk">Version android</href>
|
<a target="_blank" href="jvon-1.0.0.0.apk">Version android</a>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// This is the angular controller and the code pane
|
// This is the angular controller and the code pane
|
||||||
|
//noinspection JSUnresolvedFunction
|
||||||
var jvonapp = angular.module("JVON", ["ngTouch", "ngSanitize"]);
|
var jvonapp = angular.module("JVON", ["ngTouch", "ngSanitize"]);
|
||||||
|
|
||||||
jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", function ($scope, $timeout ,$interval) {
|
jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", function ($scope, $timeout ,$interval) {
|
||||||
@ -6,13 +7,13 @@ jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", functio
|
|||||||
$scope.commands = commands;
|
$scope.commands = commands;
|
||||||
|
|
||||||
// The code pane
|
// The code pane
|
||||||
$scope.code_lines = new Array();
|
$scope.code_lines = [];
|
||||||
|
|
||||||
// The result pane
|
// The result pane
|
||||||
$scope.results = new Array();
|
$scope.results = [];
|
||||||
|
|
||||||
// What is displayed on the screen
|
// What is displayed on the screen
|
||||||
$scope.screen = new Array();
|
$scope.screen = [];
|
||||||
|
|
||||||
$scope.execution_started = false;
|
$scope.execution_started = false;
|
||||||
|
|
||||||
@ -67,14 +68,14 @@ jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", functio
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$interval.cancel($scope.blink_promise);
|
$interval.cancel($scope.blink_promise);
|
||||||
element = document.getElementById("pause_code");
|
var element = document.getElementById("pause_code");
|
||||||
element.style.opacity = 1;
|
element.style.opacity = 1;
|
||||||
element.style.filter = "alpha(opacity=" + 1 * 100 + ")";
|
element.style.filter = "alpha(opacity=100)";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.blink = function () {
|
$scope.blink = function () {
|
||||||
element = document.getElementById("pause_code");
|
var element = document.getElementById("pause_code");
|
||||||
if ($scope.blink_state == false) {
|
if ($scope.blink_state == false) {
|
||||||
if ($scope.opacity <= 0.1) {
|
if ($scope.opacity <= 0.1) {
|
||||||
$scope.blink_state = true;
|
$scope.blink_state = true;
|
||||||
@ -177,7 +178,8 @@ jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", functio
|
|||||||
if ($scope.code_lines.length > 0) {
|
if ($scope.code_lines.length > 0) {
|
||||||
// Find the last highlighted line
|
// Find the last highlighted line
|
||||||
var highlighted = null;
|
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) {
|
if ($scope.code_lines[i].highlighted == true) {
|
||||||
highlighted = i;
|
highlighted = i;
|
||||||
break;
|
break;
|
||||||
@ -188,9 +190,9 @@ jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", functio
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add a line after the last highlighted
|
// Add a line after the last highlighted
|
||||||
var new_code_lines = new Array();
|
var new_code_lines = [];
|
||||||
var j = 1;
|
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) {
|
if (highlighted == i) {
|
||||||
$scope.code_lines[i].line = j.toString();
|
$scope.code_lines[i].line = j.toString();
|
||||||
new_code_lines.push($scope.code_lines[i]);
|
new_code_lines.push($scope.code_lines[i]);
|
||||||
@ -217,7 +219,7 @@ jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", functio
|
|||||||
|
|
||||||
// Delete the highlighted lines
|
// Delete the highlighted lines
|
||||||
$scope.delete_line = function () {
|
$scope.delete_line = function () {
|
||||||
var new_code_lines = new Array();
|
var new_code_lines = [];
|
||||||
var j = 1;
|
var j = 1;
|
||||||
for (var i = 0; i < $scope.code_lines.length; i++) {
|
for (var i = 0; i < $scope.code_lines.length; i++) {
|
||||||
if (!$scope.code_lines[i].highlighted) {
|
if (!$scope.code_lines[i].highlighted) {
|
||||||
@ -231,17 +233,18 @@ jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", functio
|
|||||||
|
|
||||||
// Delete all code lines
|
// Delete all code lines
|
||||||
$scope.clear_code = function () {
|
$scope.clear_code = function () {
|
||||||
$scope.code_lines = new Array();
|
$scope.code_lines = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.select_line = function (line_number, result) {
|
$scope.select_line = function (line_number, result) {
|
||||||
|
var line;
|
||||||
|
|
||||||
// If execution finished remove all highlights
|
// If execution finished remove all highlights
|
||||||
if ($scope.finished == true) {
|
if ($scope.finished == true) {
|
||||||
$scope.finished = false;
|
$scope.finished = false;
|
||||||
for (var i = 0; i < $scope.code_lines.length; i++) {
|
for (var i = 0; i < $scope.code_lines.length; i++) {
|
||||||
if ($scope.code_lines[i].highlighted == true) {
|
if ($scope.code_lines[i].highlighted == true) {
|
||||||
// Unhighlight
|
// Unhighlight
|
||||||
var line;
|
|
||||||
line = document.getElementById("line1_" + i.toString());
|
line = document.getElementById("line1_" + i.toString());
|
||||||
line.className = line.className.substring(0,line.className.length - 21);
|
line.className = line.className.substring(0,line.className.length - 21);
|
||||||
line = document.getElementById("line2_" + i.toString());
|
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.executing == true && result == true) {
|
||||||
if ($scope.code_lines[line_number].highlighted == false) {
|
if ($scope.code_lines[line_number].highlighted == false) {
|
||||||
// Highlight
|
// Highlight
|
||||||
var line;
|
|
||||||
line = document.getElementById("line1_" + line_number.toString());
|
line = document.getElementById("line1_" + line_number.toString());
|
||||||
line.className += " code_number_selected";
|
line.className += " code_number_selected";
|
||||||
line = document.getElementById("line2_" + line_number.toString());
|
line = document.getElementById("line2_" + line_number.toString());
|
||||||
@ -267,7 +269,6 @@ jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", functio
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Unhighlight
|
// Unhighlight
|
||||||
var line;
|
|
||||||
line = document.getElementById("line1_" + line_number.toString());
|
line = document.getElementById("line1_" + line_number.toString());
|
||||||
line.className = line.className.substring(0,line.className.length - 21);
|
line.className = line.className.substring(0,line.className.length - 21);
|
||||||
line = document.getElementById("line2_" + line_number.toString());
|
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) {
|
else if ($scope.executing == false && result == false) {
|
||||||
if ($scope.code_lines[line_number].highlighted == false) {
|
if ($scope.code_lines[line_number].highlighted == false) {
|
||||||
// Highlight
|
// Highlight
|
||||||
var line;
|
|
||||||
line = document.getElementById("line1_" + line_number.toString());
|
line = document.getElementById("line1_" + line_number.toString());
|
||||||
line.className += " line_number_selected";
|
line.className += " line_number_selected";
|
||||||
line = document.getElementById("line2_" + line_number.toString());
|
line = document.getElementById("line2_" + line_number.toString());
|
||||||
@ -291,7 +291,6 @@ jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", functio
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Unhighlight
|
// Unhighlight
|
||||||
var line;
|
|
||||||
line = document.getElementById("line1_" + line_number.toString());
|
line = document.getElementById("line1_" + line_number.toString());
|
||||||
line.className = line.className.substring(0,line.className.length - 21);
|
line.className = line.className.substring(0,line.className.length - 21);
|
||||||
line = document.getElementById("line2_" + line_number.toString());
|
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
|
// 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) {
|
if (newValue) {
|
||||||
$scope.code_lines = newValue;
|
$scope.code_lines = newValue;
|
||||||
$scope.imported_code = false;
|
$scope.imported_code = false;
|
||||||
@ -417,7 +416,7 @@ jvonapp.controller('JVONController', ["$scope", "$timeout", "$interval", functio
|
|||||||
jvonapp.directive("importFile", function () {
|
jvonapp.directive("importFile", function () {
|
||||||
return {
|
return {
|
||||||
restrict: "A",
|
restrict: "A",
|
||||||
link: function ($scope, element, attributes) {
|
link: function ($scope, element) {
|
||||||
element.bind('change', function (event) {
|
element.bind('change', function (event) {
|
||||||
var file = event.target.files[0];
|
var file = event.target.files[0];
|
||||||
|
|
||||||
@ -435,9 +434,9 @@ jvonapp.directive("importFile", function () {
|
|||||||
$scope.select_line(i, true);
|
$scope.select_line(i, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$scope.code_lines = new Array();
|
$scope.code_lines = [];
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
}
|
};
|
||||||
|
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
$scope.finished = false;
|
$scope.finished = false;
|
||||||
|
|
||||||
$scope.ac = "";
|
$scope.ac = "";
|
||||||
$scope.memory = new Array();
|
$scope.memory = [];
|
||||||
$scope.memory[0] = null; // 80
|
$scope.memory[0] = null; // 80
|
||||||
$scope.memory[1] = null; // 81
|
$scope.memory[1] = null; // 81
|
||||||
$scope.memory[2] = null; // 82
|
$scope.memory[2] = null; // 82
|
||||||
@ -39,8 +39,8 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
|
|
||||||
$scope.disable_code_buttons();
|
$scope.disable_code_buttons();
|
||||||
|
|
||||||
$scope.results = new Array();
|
$scope.results = [];
|
||||||
$scope.screen = new Array();
|
$scope.screen = [];
|
||||||
$scope.line_number = 0;
|
$scope.line_number = 0;
|
||||||
$scope.repeater();
|
$scope.repeater();
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
$scope.pow($scope.code_lines[$scope.line_number].value);
|
$scope.pow($scope.code_lines[$scope.line_number].value);
|
||||||
break;
|
break;
|
||||||
case "End":
|
case "End":
|
||||||
$scope.End($scope.code_lines[$scope.line_number].value);
|
$scope.End();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
alert($scope.code_lines[$scope.line_number].command.name + " is not implemented yet.");
|
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) {
|
$scope.check_syntax = function (value) {
|
||||||
var result;
|
var result;
|
||||||
|
var regex;
|
||||||
|
|
||||||
if (value == "") {
|
if (value == "") {
|
||||||
return {type: "blank", value: ""};
|
return {type: "blank", value: ""};
|
||||||
}
|
}
|
||||||
|
|
||||||
var regex = /^(\d+)$/;
|
regex = /^(\d+)$/;
|
||||||
if ((result = regex.exec(value)) !== null) {
|
if ((result = regex.exec(value)) !== null) {
|
||||||
if (result.index === regex.lastIndex) {
|
if (result.index === regex.lastIndex) {
|
||||||
regex.lastIndex++;
|
regex.lastIndex++;
|
||||||
@ -162,7 +163,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
return {type: "memory", value: result[1]};
|
return {type: "memory", value: result[1]};
|
||||||
}
|
}
|
||||||
|
|
||||||
var regex = /^\[(\d+)\]$/;
|
regex = /^\[(\d+)]$/;
|
||||||
if ((result = regex.exec(value)) !== null) {
|
if ((result = regex.exec(value)) !== null) {
|
||||||
if (result.index === regex.lastIndex) {
|
if (result.index === regex.lastIndex) {
|
||||||
regex.lastIndex++;
|
regex.lastIndex++;
|
||||||
@ -171,7 +172,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
return {type: "address", value: result[1]};
|
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 = regex.exec(value)) !== null) {
|
||||||
if (result.index === regex.lastIndex) {
|
if (result.index === regex.lastIndex) {
|
||||||
regex.lastIndex++;
|
regex.lastIndex++;
|
||||||
@ -185,18 +186,12 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
|
|
||||||
$scope.check_memory_address = function(value) {
|
$scope.check_memory_address = function(value) {
|
||||||
value = parseFloat(value);
|
value = parseFloat(value);
|
||||||
if (value < 80 || value > 85) {
|
return !(value < 80 || value > 85);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.check_memory_value = function(value) {
|
$scope.check_memory_value = function(value) {
|
||||||
value = parseFloat(value) - 80;
|
value = parseFloat(value) - 80;
|
||||||
if ($scope.memory[value] == null) {
|
return $scope.memory[value] != null;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.rda = function (value) {
|
$scope.rda = function (value) {
|
||||||
@ -223,9 +218,8 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
var new_memory = $scope.memory[syntax.value];
|
var new_memory = $scope.memory[syntax.value];
|
||||||
|
|
||||||
var regex = /^\d+$/;
|
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.rda_value = new_memory;
|
||||||
$scope.show_input_prompt();
|
$scope.show_input_prompt();
|
||||||
}
|
}
|
||||||
@ -245,9 +239,8 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
var value = document.getElementById("rda").value;
|
var value = document.getElementById("rda").value;
|
||||||
|
|
||||||
var regex = /^-?[0-9]*?\.?[0-9]+$/;
|
var regex = /^-?[0-9]*?\.?[0-9]+$/;
|
||||||
var result;
|
|
||||||
|
|
||||||
if ((result = regex.exec(value)) !== null) {
|
if (regex.exec(value) !== null) {
|
||||||
value = parseFloat(value);
|
value = parseFloat(value);
|
||||||
$scope.rda_value = parseFloat($scope.rda_value);
|
$scope.rda_value = parseFloat($scope.rda_value);
|
||||||
|
|
||||||
@ -329,7 +322,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
}
|
}
|
||||||
else if (syntax.type == "memory") {
|
else if (syntax.type == "memory") {
|
||||||
if ($scope.check_memory_address(value) == true) {
|
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.memory[new_value] = $scope.ac;
|
||||||
|
|
||||||
$scope.create_result($scope.line_number, parseFloat(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 new_memory = $scope.memory[syntax.value];
|
||||||
|
|
||||||
var regex = /^\d+$/;
|
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;
|
new_memory = parseFloat(new_memory) - 80;
|
||||||
$scope.memory[new_memory] = $scope.ac;
|
$scope.memory[new_memory] = $scope.ac;
|
||||||
|
|
||||||
@ -519,13 +511,13 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
|
|
||||||
$scope.div = function (value) {
|
$scope.div = function (value) {
|
||||||
var syntax = $scope.check_syntax(value);
|
var syntax = $scope.check_syntax(value);
|
||||||
|
var regex;
|
||||||
if (syntax.type == "number") {
|
if (syntax.type == "number") {
|
||||||
$scope.ac = parseFloat($scope.ac) / parseFloat(syntax.value);
|
$scope.ac = parseFloat($scope.ac) / parseFloat(syntax.value);
|
||||||
|
|
||||||
var regex = /^-?[0-9]*\.?[0-9]+$/;
|
regex = /^-?[0-9]*\.?[0-9]+$/;
|
||||||
var result;
|
|
||||||
|
|
||||||
if ((result = regex.exec($scope.ac)) !== null) {
|
if (regex.exec($scope.ac) !== null) {
|
||||||
$scope.create_result($scope.line_number, "ac", $scope.ac);
|
$scope.create_result($scope.line_number, "ac", $scope.ac);
|
||||||
$scope.line_number++;
|
$scope.line_number++;
|
||||||
$scope.repeater();
|
$scope.repeater();
|
||||||
@ -540,10 +532,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
value = $scope.memory[value - 80];
|
value = $scope.memory[value - 80];
|
||||||
$scope.ac = parseFloat($scope.ac) / parseFloat(value);
|
$scope.ac = parseFloat($scope.ac) / parseFloat(value);
|
||||||
|
|
||||||
var regex = /^-?[0-9]*\.?[0-9]+$/;
|
regex = /^-?[0-9]*\.?[0-9]+$/;
|
||||||
var result;
|
|
||||||
|
|
||||||
if ((result = regex.exec($scope.ac)) !== null) {
|
if (regex.exec($scope.ac) !== null) {
|
||||||
$scope.create_result($scope.line_number, "ac", $scope.ac);
|
$scope.create_result($scope.line_number, "ac", $scope.ac);
|
||||||
$scope.line_number++;
|
$scope.line_number++;
|
||||||
$scope.repeater();
|
$scope.repeater();
|
||||||
@ -564,10 +555,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
value = parseFloat($scope.memory[temp_value - 80]);
|
value = parseFloat($scope.memory[temp_value - 80]);
|
||||||
$scope.ac = parseFloat($scope.ac) / value;
|
$scope.ac = parseFloat($scope.ac) / value;
|
||||||
|
|
||||||
var regex = /^-?[0-9]*\.?[0-9]+$/;
|
regex = /^-?[0-9]*\.?[0-9]+$/;
|
||||||
var result;
|
|
||||||
|
|
||||||
if ((result = regex.exec($scope.ac)) !== null) {
|
if (regex.exec($scope.ac) !== null) {
|
||||||
$scope.create_result($scope.line_number, "ac", $scope.ac);
|
$scope.create_result($scope.line_number, "ac", $scope.ac);
|
||||||
$scope.line_number++;
|
$scope.line_number++;
|
||||||
$scope.repeater();
|
$scope.repeater();
|
||||||
@ -686,13 +676,14 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
|
|
||||||
$scope.sqr = function (value) {
|
$scope.sqr = function (value) {
|
||||||
var syntax = $scope.check_syntax(value);
|
var syntax = $scope.check_syntax(value);
|
||||||
|
var sqr;
|
||||||
if (syntax.type == "blank") {
|
if (syntax.type == "blank") {
|
||||||
if ($scope.ac == "") {
|
if ($scope.ac == "") {
|
||||||
alert($scope.strings.error_ac);
|
alert($scope.strings.error_ac);
|
||||||
$scope.stop_code();
|
$scope.stop_code();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var sqr = Math.sqrt(parseFloat($scope.ac));
|
sqr = Math.sqrt(parseFloat($scope.ac));
|
||||||
if (sqr == "NaN") {
|
if (sqr == "NaN") {
|
||||||
alert($scope.strings.error_math);
|
alert($scope.strings.error_math);
|
||||||
$scope.stop_code();
|
$scope.stop_code();
|
||||||
@ -706,7 +697,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (syntax.type == "number") {
|
else if (syntax.type == "number") {
|
||||||
var sqr = Math.sqrt(syntax.value);
|
sqr = Math.sqrt(parseFloat(syntax.value));
|
||||||
if (sqr == "NaN") {
|
if (sqr == "NaN") {
|
||||||
alert($scope.strings.error_math);
|
alert($scope.strings.error_math);
|
||||||
$scope.stop_code();
|
$scope.stop_code();
|
||||||
@ -721,7 +712,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
else if (syntax.type == "memory") {
|
else if (syntax.type == "memory") {
|
||||||
if ($scope.check_memory_address(value) == true && $scope.check_memory_value(value) == true) {
|
if ($scope.check_memory_address(value) == true && $scope.check_memory_value(value) == true) {
|
||||||
value = parseFloat($scope.memory[value - 80]);
|
value = parseFloat($scope.memory[value - 80]);
|
||||||
var sqr = Math.sqrt(value);
|
sqr = Math.sqrt(value);
|
||||||
if (sqr == "NaN") {
|
if (sqr == "NaN") {
|
||||||
alert($scope.strings.error_math);
|
alert($scope.strings.error_math);
|
||||||
$scope.stop_code();
|
$scope.stop_code();
|
||||||
@ -742,7 +733,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
var temp_value = $scope.memory[syntax.value - 80];
|
var temp_value = $scope.memory[syntax.value - 80];
|
||||||
if ($scope.check_memory_address(temp_value) == true && $scope.check_memory_value(temp_value) == true) {
|
if ($scope.check_memory_address(temp_value) == true && $scope.check_memory_value(temp_value) == true) {
|
||||||
value = parseFloat($scope.memory[temp_value - 80]);
|
value = parseFloat($scope.memory[temp_value - 80]);
|
||||||
var sqr = Math.sqrt(value);
|
sqr = Math.sqrt(value);
|
||||||
if (sqr == "NaN") {
|
if (sqr == "NaN") {
|
||||||
alert($scope.strings.error_math);
|
alert($scope.strings.error_math);
|
||||||
$scope.stop_code();
|
$scope.stop_code();
|
||||||
@ -767,9 +758,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
|
|
||||||
$scope.pow = function (value) {
|
$scope.pow = function (value) {
|
||||||
var syntax = $scope.check_syntax(value);
|
var syntax = $scope.check_syntax(value);
|
||||||
|
var new_value;
|
||||||
if (syntax.type == "number") {
|
if (syntax.type == "number") {
|
||||||
if ($scope.ac != "" || $scope.ac == 0) {
|
if ($scope.ac != "" || $scope.ac == 0) {
|
||||||
var new_value;
|
|
||||||
value = parseFloat(syntax.value);
|
value = parseFloat(syntax.value);
|
||||||
if (value < 0) {
|
if (value < 0) {
|
||||||
// The exponent is negative
|
// The exponent is negative
|
||||||
@ -793,7 +784,6 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
else if (syntax.type == "memory") {
|
else if (syntax.type == "memory") {
|
||||||
if ($scope.check_memory_address(value) == true) {
|
if ($scope.check_memory_address(value) == true) {
|
||||||
value = parseFloat($scope.memory[value - 80]);
|
value = parseFloat($scope.memory[value - 80]);
|
||||||
var new_value;
|
|
||||||
if (value < 0) {
|
if (value < 0) {
|
||||||
// The exponent is negative
|
// The exponent is negative
|
||||||
value = Math.abs(parseFloat(value));
|
value = Math.abs(parseFloat(value));
|
||||||
@ -817,7 +807,6 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
var temp_value = $scope.memory[syntax.value - 80];
|
var temp_value = $scope.memory[syntax.value - 80];
|
||||||
if ($scope.check_memory_address(temp_value) == true) {
|
if ($scope.check_memory_address(temp_value) == true) {
|
||||||
value = parseFloat($scope.memory[temp_value - 80]);
|
value = parseFloat($scope.memory[temp_value - 80]);
|
||||||
var new_value;
|
|
||||||
if (value < 0) {
|
if (value < 0) {
|
||||||
// The exponent is negative
|
// The exponent is negative
|
||||||
value = Math.abs(parseFloat(value));
|
value = Math.abs(parseFloat(value));
|
||||||
@ -850,9 +839,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
else {
|
else {
|
||||||
return base * $scope.pow_repeat(exponent -1, base);
|
return base * $scope.pow_repeat(exponent -1, base);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
$scope.End = function (value) {
|
$scope.End = function () {
|
||||||
// Rap-up everything
|
// Rap-up everything
|
||||||
$scope.stop_code();
|
$scope.stop_code();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user