diff --git a/_includes/app.js b/_includes/app.js index 9bf88ee..66a7e94 100644 --- a/_includes/app.js +++ b/_includes/app.js @@ -40,4 +40,30 @@ document.addEventListener('DOMContentLoaded', function () { detailsElement.classList.add('viewed'); } }); + + // Set highlight words + if(hw = document.getElementById('highlight-words')) { + hw.value = (JSON.parse(localStorage.getItem("highlightWords"))||[]).join("\n"); + } + + // Save settings + if(document.getElementById('btn-settings-save')) { + document.getElementById('btn-settings-save').addEventListener('click', function (e) { + val = document.getElementById('highlight-words').value.split("\n").map(function(x){return x.trim()}); + localStorage.setItem('highlightWords', JSON.stringify(val)); + return false; + }); + } + + // Enable highlighting + if(words = localStorage.getItem('highlightWords')) { + var scriptTag = document.createElement('script'); + scriptTag.setAttribute('src','/assets/mark.min.js'); + scriptTag.async=scriptTag.defer = true; + document.body.appendChild(scriptTag); + scriptTag.onload = function() { + var markInstance = new Mark(document.querySelector("main")); + markInstance.mark(JSON.parse(words), {}); + } + } }); diff --git a/_includes/footer.html b/_includes/footer.html index f0bf875..5de6762 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -13,6 +13,7 @@
diff --git a/_includes/style.css b/_includes/style.css index 9f463e1..337baeb 100644 --- a/_includes/style.css +++ b/_includes/style.css @@ -9,7 +9,6 @@ body { max-width: 550px; margin: 0 auto; font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif; - } main { @@ -76,7 +75,7 @@ h2 { } .button:link, -.button:visited { +.button:visited, button, input[type=button] { background-color: #660033; color: white; border: 1px solid #660033; @@ -127,4 +126,10 @@ details .trigger-warning { } details[open] .trigger-warning { display: none; +} + +mark { + background: #ff0; + padding: 0px 2px; + color: #000; } \ No newline at end of file diff --git a/_layouts/default.html b/_layouts/default.html index ea75113..784e563 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -10,7 +10,7 @@ @@ -20,6 +20,6 @@ {% include_cached footer.html %} - +