+ self.getNightMode = function() {
+ night_mode = window.localStorage.getItem('View.night_mode');
+ if (night_mode === undefined)
+ return false;
+ else
+ return !!night_mode;
+ };
+
+ self.checkNightMode = function() {
+ night_mode = self.getNightMode();
+ if (night_mode) {
+ document.body.setAttribute("class", "night-mode");
+ }
+ else {
+ document.body.setAttribute("class", "");
+ }
+ };
+
+ self.setNightMode = function(night_mode) {
+ night_mode = night_mode ? "1" : "";
+ window.localStorage.setItem('View.night_mode', night_mode);
+ self.checkNightMode();
+ };
+
+ self.toggleNightMode = function(night_mode) {
+ self.setNightMode(!self.getNightMode());
+ };