From 54bb9dad139b8541588533a0fc8e365d34c54743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Tue, 30 Dec 2014 20:24:33 +0100 Subject: [PATCH] Add default settings again --- js/glowingbear.js | 20 ++++++++++++++++++++ js/settings.js | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/js/glowingbear.js b/js/glowingbear.js index ae4a92a..cc72e6b 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -17,6 +17,26 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $scope.command = ''; $scope.themes = ['dark', 'light']; + + settings.setDefaults({ + 'theme': 'dark', + 'host': 'localhost', + 'port': 9001, + 'ssl': (window.location.protocol === "https:"), + 'savepassword': false, + 'autoconnect': false, + 'nonicklist': utils.isMobileUi(), + 'noembed': utils.isMobileUi(), + 'onlyUnread': false, + 'hotlistsync': true, + 'orderbyserver': true, + 'useFavico': true, + 'showtimestamp': true, + 'showtimestampSeconds': false, + 'fontsize': '14px', + 'fontfamily': (utils.isMobileUi() ? 'sans-serif' : 'Inconsolata, Consolas, Monaco, Ubuntu Mono, monospace'), + 'readlineBindings': false + }); $scope.settings = settings; // From: http://stackoverflow.com/a/18539624 by StackOverflow user "plantian" diff --git a/js/settings.js b/js/settings.js index 3da50d3..8c312fc 100644 --- a/js/settings.js +++ b/js/settings.js @@ -53,6 +53,15 @@ weechat.factory('settings', ['$store', '$rootScope', function($store, $rootScope }, 0); }; + this.setDefaults = function(defaults) { + for (var key in defaults) { + // null means the key isn't set + if ($store.get(key) === null) { + this[key] = defaults[key]; + } + } + }; + return this; }]);