szurubooru/client/js/models/settings.js
rr- 702ec3e6fe client/settings: increase default post count to 42
Since on big resolutions the posts use 7 columns, it makes sense to use
a multiple of that.
2016-08-27 22:19:01 +02:00

43 lines
986 B
JavaScript

'use strict';
const events = require('../events.js');
const defaultSettings = {
listPosts: {
safe: true,
sketchy: true,
unsafe: false,
},
upscaleSmallPosts: false,
endlessScroll: false,
keyboardShortcuts: true,
transparencyGrid: true,
fitMode: 'fit-both',
tagSuggestions: true,
postsPerPage: 42,
};
class Settings extends events.EventTarget {
save(newSettings, silent) {
localStorage.setItem('settings', JSON.stringify(newSettings));
if (silent !== true) {
this.dispatchEvent(new CustomEvent('change', {
detail: {
settings: this.get(),
},
}));
}
}
get() {
let ret = {};
Object.assign(ret, defaultSettings);
try {
Object.assign(ret, JSON.parse(localStorage.getItem('settings')));
} catch (e) {
}
return ret;
}
};
module.exports = new Settings();