aboutsummaryrefslogtreecommitdiff
path: root/demo/src/utils/editor-history.util.ts
diff options
context:
space:
mode:
authorlironh2020-03-21 21:47:31 +0200
committerlironh2020-03-21 21:47:31 +0200
commitee5708e0babd08e3ed4fffbf9a24d7cd5755a782 (patch)
tree2bc475dd7ba9d5f0363f5af9fece4a1527683485 /demo/src/utils/editor-history.util.ts
parentMerge pull request #19 from gfeun/main-execute-loop-optimization (diff)
downloadavr8js-ee5708e0babd08e3ed4fffbf9a24d7cd5755a782.tar.gz
avr8js-ee5708e0babd08e3ed4fffbf9a24d7cd5755a782.tar.bz2
avr8js-ee5708e0babd08e3ed4fffbf9a24d7cd5755a782.zip
feat(demo): saving user history
Diffstat (limited to 'demo/src/utils/editor-history.util.ts')
-rw-r--r--demo/src/utils/editor-history.util.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/demo/src/utils/editor-history.util.ts b/demo/src/utils/editor-history.util.ts
new file mode 100644
index 0000000..33d1916
--- /dev/null
+++ b/demo/src/utils/editor-history.util.ts
@@ -0,0 +1,17 @@
+const AVRJS8_EDITOR_HISTORY = 'AVRJS8_EDITOR_HISTORY';
+
+export class EditorHistoryUtil {
+ static storeSnippet(codeSnippet: string) {
+ if (window.localStorage) {
+ window.localStorage.setItem(AVRJS8_EDITOR_HISTORY, codeSnippet);
+ } else throw new Error('no localStorage support');
+ }
+
+ static clearSnippet() {
+ localStorage.removeItem(AVRJS8_EDITOR_HISTORY);
+ }
+
+ static getValue() {
+ return localStorage.getItem(AVRJS8_EDITOR_HISTORY);
+ }
+}