aboutsummaryrefslogtreecommitdiff
path: root/demo/src/utils
diff options
context:
space:
mode:
authorUri Shaked2020-03-22 10:28:31 +0200
committerGitHub2020-03-22 10:28:31 +0200
commit87ef2c22913dbf07bbe4c10c6ea249a6dfa4b42c (patch)
tree7a4e2df1ca890141623353702dc875f850174ba6 /demo/src/utils
parentMerge pull request #19 from gfeun/main-execute-loop-optimization (diff)
parentfeat(demo): saving user history (diff)
downloadavr8js-87ef2c22913dbf07bbe4c10c6ea249a6dfa4b42c.tar.gz
avr8js-87ef2c22913dbf07bbe4c10c6ea249a6dfa4b42c.tar.bz2
avr8js-87ef2c22913dbf07bbe4c10c6ea249a6dfa4b42c.zip
Merge pull request #25 from LironHazan/AVR8JS-24-editor-user-history
feat(demo): saving user history
Diffstat (limited to 'demo/src/utils')
-rw-r--r--demo/src/utils/editor-history.util.ts20
1 files changed, 20 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..65ca38a
--- /dev/null
+++ b/demo/src/utils/editor-history.util.ts
@@ -0,0 +1,20 @@
+const AVRJS8_EDITOR_HISTORY = 'AVRJS8_EDITOR_HISTORY';
+
+export class EditorHistoryUtil {
+ static hasLocalStorage: boolean = !!window.localStorage;
+
+ static storeSnippet(codeSnippet: string) {
+ if (!EditorHistoryUtil.hasLocalStorage) return;
+ window.localStorage.setItem(AVRJS8_EDITOR_HISTORY, codeSnippet);
+ }
+
+ static clearSnippet() {
+ if (!EditorHistoryUtil.hasLocalStorage) return;
+ localStorage.removeItem(AVRJS8_EDITOR_HISTORY);
+ }
+
+ static getValue() {
+ if (!EditorHistoryUtil.hasLocalStorage) return;
+ return localStorage.getItem(AVRJS8_EDITOR_HISTORY);
+ }
+}
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.