Skip to content

Commit 4c7197f

Browse files
committed
Persist content to local storage
1 parent 02dd4ce commit 4c7197f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ <h1 class="text-3xl font-semibold mb-2">Bash Script Tools</h1>
9696
<script>
9797
ace.config.set("basePath", "https://cdnjs.cloudflare.com/ajax/libs/ace/1.32.2/");
9898

99+
const STORAGE_KEY = "bash-script-tools-content";
100+
99101
const editor = ace.edit("editor");
100102
editor.session.setMode("ace/mode/sh");
101103
editor.setOptions({
@@ -105,6 +107,17 @@ <h1 class="text-3xl font-semibold mb-2">Bash Script Tools</h1>
105107
highlightGutterLine: true,
106108
});
107109

110+
// Load content from localStorage
111+
const savedContent = localStorage.getItem(STORAGE_KEY);
112+
if (savedContent) {
113+
editor.setValue(savedContent, -1);
114+
}
115+
116+
// Save content to localStorage on change
117+
editor.session.on("change", function () {
118+
localStorage.setItem(STORAGE_KEY, editor.getValue());
119+
});
120+
108121
function setButtonsDisabled(disabled) {
109122
document.getElementById("format-btn").disabled = disabled;
110123
document.getElementById("lint-btn").disabled = disabled;

0 commit comments

Comments
 (0)