-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* created textarea for code * load/save state with local storage
- Loading branch information
Showing
3 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,31 @@ | ||
'use strict'; | ||
|
||
const STORAGE_ID = 'js8080sim'; | ||
|
||
|
||
loadState(); | ||
|
||
document.querySelector("#run").addEventListener("mousedown", runCode); | ||
|
||
// Expects the global js8080sim to be available. | ||
let asm = new js8080sim.Assembler(); | ||
|
||
let st = document.querySelector("#status"); | ||
st.textContent = "SUCCESS"; | ||
st.style.color = "green"; | ||
|
||
function loadState() { | ||
let state = JSON.parse(localStorage.getItem(STORAGE_ID)); | ||
if (state) { | ||
document.querySelector("#codetext").value = state['codetext']; | ||
} | ||
} | ||
|
||
function saveState() { | ||
let state = {'codetext': document.querySelector('#codetext').value}; | ||
localStorage.setItem(STORAGE_ID, JSON.stringify(state)); | ||
} | ||
|
||
function runCode() { | ||
saveState(); | ||
} |