aboutsummaryrefslogtreecommitdiff
path: root/demo/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'demo/src/utils')
-rw-r--r--demo/src/utils/editor-history.util.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/demo/src/utils/editor-history.util.ts b/demo/src/utils/editor-history.util.ts
index 33d1916..65ca38a 100644
--- a/demo/src/utils/editor-history.util.ts
+++ b/demo/src/utils/editor-history.util.ts
@@ -1,17 +1,20 @@
const AVRJS8_EDITOR_HISTORY = 'AVRJS8_EDITOR_HISTORY';
export class EditorHistoryUtil {
+ static hasLocalStorage: boolean = !!window.localStorage;
+
static storeSnippet(codeSnippet: string) {
- if (window.localStorage) {
- window.localStorage.setItem(AVRJS8_EDITOR_HISTORY, codeSnippet);
- } else throw new Error('no localStorage support');
+ 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.