diff options
Diffstat (limited to 'static/js/db.js')
| -rw-r--r-- | static/js/db.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/static/js/db.js b/static/js/db.js new file mode 100644 index 00000000..2cffa80c --- /dev/null +++ b/static/js/db.js @@ -0,0 +1,20 @@ +function savePageToDB(entirePage, path) { + window.sessionStorage.setItem(path, entirePage); + // db.collection('pages').doc(path).set({ path: path, page: entirePage }); +} + +const lang = localStorage.getItem("lang"); +const path = window.location.pathname; + +const storedPage = window.sessionStorage.getItem(path); + +if (lang === "ja" && storedPage) { + console.log("Page already translated"); + document.getElementById('wrap').innerHTML = storedPage; +} else { + const script = document.createElement("script"); + script.type = "text/javascript"; + script.src = + "//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"; + document.getElementById("tl_block").appendChild(script); +} |
