Avoid having to repeat whitelisted settings.

This commit is contained in:
JC Brand 2014-11-17 09:50:00 +01:00
parent 1c5b27bae7
commit 2afdcfac80

View File

@ -198,89 +198,53 @@
// Default configuration values // Default configuration values
// ---------------------------- // ----------------------------
this.allow_contact_requests = true; var default_settings = {
this.allow_dragresize = true; allow_contact_requests: true,
this.allow_logout = true; allow_dragresize: true,
this.allow_muc = true; allow_logout: true,
this.allow_otr = true; allow_muc: true,
this.animate = true; allow_otr: true,
this.auto_list_rooms = false; allow_registration: true,
this.auto_reconnect = false; animate: true,
this.auto_subscribe = false; auto_list_rooms: false,
this.bosh_service_url = undefined; // The BOSH connection manager URL. auto_reconnect: false,
this.cache_otr_key = false; auto_subscribe: false,
this.debug = false; bosh_service_url: undefined, // The BOSH connection manager URL.
this.default_box_height = 324; // The default height, in pixels, for the control box, chat boxes and chatrooms. cache_otr_key: false,
this.expose_rid_and_sid = false; debug: false,
this.forward_messages = false; default_box_height: 324, // The default height, in pixels, for the control box, chat boxes and chatrooms.
this.hide_muc_server = false; expose_rid_and_sid: false,
this.hide_offline_users = false; forward_messages: false,
this.i18n = locales.en; hide_muc_server: false,
this.keepalive = false; hide_offline_users: false,
this.message_carbons = false; i18n: locales.en,
this.no_trimming = false; // Set to true for phantomjs tests (where browser apparently has no width) keepalive: false,
this.play_sounds = false; message_carbons: false,
this.prebind = false; no_trimming: false, // Set to true for phantomjs tests (where browser apparently has no width)
this.roster_groups = false; play_sounds: false,
this.show_controlbox_by_default = false; prebind: false,
this.show_only_online_users = false; roster_groups: false,
this.show_toolbar = true; show_controlbox_by_default: false,
this.storage = 'session'; show_only_online_users: false,
this.use_otr_by_default = false; show_toolbar: true,
this.use_vcards = true; storage: 'session',
this.visible_toolbar_buttons = { use_otr_by_default: false,
'emoticons': true, use_vcards: true,
'call': false, visible_toolbar_buttons: {
'clear': true, 'emoticons': true,
'toggle_participants': true 'call': false,
'clear': true,
'toggle_participants': true
},
xhr_custom_status: false,
xhr_custom_status_url: '',
xhr_user_search: false,
xhr_user_search_url: ''
}; };
this.xhr_custom_status = false; _.extend(this, default_settings);
this.xhr_custom_status_url = '';
this.xhr_user_search = false;
this.xhr_user_search_url = '';
// Allow only whitelisted configuration attributes to be overwritten // Allow only whitelisted configuration attributes to be overwritten
_.extend(this, _.pick(settings, [ _.extend(this, _.pick(settings, Object.keys(default_settings)));
'allow_contact_requests',
'allow_dragresize',
'allow_logout',
'allow_muc',
'allow_otr',
'animate',
'auto_list_rooms',
'auto_reconnect',
'auto_subscribe',
'bosh_service_url',
'cache_otr_key',
'connection',
'debug',
'default_box_height',
'expose_rid_and_sid',
'forward_messages',
'fullname',
'hide_muc_server',
'hide_offline_users',
'i18n',
'jid',
'keepalive',
'message_carbons',
'no_trimming',
'play_sounds',
'prebind',
'rid',
'roster_groups',
'show_controlbox_by_default',
'show_only_online_users',
'show_toolbar',
'sid',
'storage',
'use_otr_by_default',
'use_vcards',
'xhr_custom_status',
'xhr_custom_status_url',
'xhr_user_search',
'xhr_user_search_url'
]));
if (settings.visible_toolbar_buttons) { if (settings.visible_toolbar_buttons) {
_.extend( _.extend(
this.visible_toolbar_buttons, this.visible_toolbar_buttons,