diff options
-rw-r--r-- | js/read.js | 33 | ||||
-rw-r--r-- | read.html | 2 |
2 files changed, 22 insertions, 13 deletions
@@ -141,24 +141,33 @@ function save_and_close() { } } -function invert() { - localStorage["night_mode"] = localStorage["night_mode"] == "0" ? 1 : 0; +function toggle_night_mode() { + localforage.getItem("epube.night_mode").then(function(night) { + night = !night; - apply_night_mode(); + localforage.setItem("epube.night_mode", night).then(function() { + apply_night_mode(); + }); + + }); } function apply_night_mode() { - if (localStorage["night_mode"] == "1") { - window.book.setStyle("background", "black"); - window.book.setStyle("color", "#ccc"); + localforage.getItem("epube.night_mode").then(function(night) { + if (night) { - $("body").css("background", "black"); + window.book.setStyle("background", "black"); + window.book.setStyle("color", "#ccc"); - } else { - window.book.setStyle("background", "white"); - window.book.setStyle("color", "black"); + $("body").css("background", "black"); - $("body").css("background", "white"); + } else { + + window.book.setStyle("background", "white"); + window.book.setStyle("color", "black"); + + $("body").css("background", "white"); + } + }); - } } @@ -126,7 +126,7 @@ <span class="glyphicon glyphicon-wrench" aria-hidden="true"></span> </button> - <button class="btn btn-default btn-xs" onclick="invert()"> + <button class="btn btn-default btn-xs" onclick="toggle_night_mode()"> <span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span> </button> |