-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhomePage_final.html
122 lines (97 loc) · 3.69 KB
/
homePage_final.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!DOCTYPE html>
<html xml:lang="en" lang="en">
<head>
<title>ARM Simulator</title>
<link rel="stylesheet" href="loadfile.css">
<link rel="stylesheet" href="browse.css">
</head>
<body>
<div id="header"></div><div id="container">
<h1>Online ARM Simulator</h1>
<table>
<tr>
<td><form action="" id="formsubmit" method = "post">
<textarea name = "formContent" id = "formContent" style="display:none;"></textarea>
<input type="submit" name="submit" value="Run" id = "submit" class="btn btn-primary" onClick = "getEditorContent()">
<input type="button" onclick="resetEditor()" id="Reset" class="btn btn-primary" name="Reset" value="Reset">
<td><input id="inputFileNameToSaveAs"></input></td>
<td><input type="button" onclick="saveTextAsFile()" name="Save code to File" value="Save code to file" class="btn btn-primary"></td>
</tr>
<tr>
<td colspan="3">
<div id="inputTextToSave" value="savethistext" style="width:630px;height:450px"></div>
</td>
<td><div><textarea name ="outputText" id ="outputText" style="width:630px;height:325px;border: 2px solid #428bca" placeholder = "Output is shown here..."></textarea><br>
<textarea name="inputs" id="inputs" style="width:630px;height:100px;border: 2px solid #428bca" placeholder = "Input your values here..."></textarea></div></td></form>
</tr>
<tr>
<td><input type="file" class="custom-file-input" id="fileToLoad"></td>
<td><input type ="button" onclick="loadFileAsText()" class="btn btn-primary" name="Load Selected File" value="Load Selected File">
</td>
</tr>
</table>
<script src="ace.js" type="text/javascript" charset="utf-8"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="ajaxscript.js"></script>
<script>
var editor = ace.edit("inputTextToSave");
editor.setTheme("ace/theme/idle_fingers");
editor.getSession().setMode("ace/mode/arm");
</script>
<script type="text/javascript">function getEditorContent(){
document.getElementById("formContent").innerHTML = editor.getValue();}
</script>
<script type='text/javascript'>
function saveTextAsFile()
{
var textToWrite = document.getElementById("formContent").value;
var textFileAsBlob = new Blob([textToWrite], {type:'text/plain'});
var fileNameToSaveAs = document.getElementById("inputFileNameToSaveAs").value;
var downloadLink = document.createElement("a");
downloadLink.download = fileNameToSaveAs;
downloadLink.innerHTML = "Download File";
if (window.webkitURL != null)
{
// Chrome allows the link to be clicked
// without actually adding it to the DOM.
downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob);
}
else
{
// Firefox requires the link to be added to the DOM
// before it can be clicked.
downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
downloadLink.onclick = destroyClickedElement;
downloadLink.style.display = "none";
document.body.appendChild(downloadLink);
}
downloadLink.click();
}
function resetEditor()
{
var editor = ace.edit("inputTextToSave");
editor.getSession().setValue("");
document.getElementById("outputText").value = "";
document.getElementById("inputs").value = "";
}
function destroyClickedElement(event)
{
document.body.removeChild(event.target);
}
function loadFileAsText()
{
var fileToLoad = document.getElementById("fileToLoad").files[0];
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent)
{
inputTextToSave.getSelectedText = function() {
this.session.getTextRange(this.getSelectionRange())
}
var textFromFileLoaded = fileLoadedEvent.target.result;
editor.setValue(textFromFileLoaded);
};
fileReader.readAsText(fileToLoad, "UTF-8");
}
</script>
</body>
</html>