Add a base for renderer settings modal

This commit is contained in:
chylex 2016-11-02 22:59:57 +01:00
parent f1a6345385
commit babdafea01
3 changed files with 32 additions and 2 deletions

View File

@ -19,6 +19,8 @@
<div class="splitter"></div>
<button id="btn-settings">Settings</button>
<div> <!-- needed to stop the select from messing up -->
<select id="opt-messages-per-page">
<option value="50">50 messages per page&nbsp;</option>

View File

@ -20,10 +20,15 @@ var GUI = (function(){
// Modal dialogs
// -------------
var showSettingsModal = function(){
showModal(560, 256, [
].join(""));
};
var showInfoModal = function(){
var linkGH = "https://github.com/chylex/Discord-History-Tracker";
var dialog = showModal(560, 128, [
showModal(560, 128, [
"<p>Discord History Tracker is developed by <a href='https://chylex.com'>chylex</a> as an <a href='"+linkGH+"/blob/master/LICENSE.md'>open source</a> project.</p>",
"<p>Please, report any issues and suggestions to the <a href='"+linkGH+"/issues'>tracker</a>. If you want to support the development, please spread the word and consider <a href='https://www.patreon.com/chylex'>becoming a patron</a>. Any support is appreciated!</p>",
"<p>",
@ -67,6 +72,10 @@ var GUI = (function(){
});
});
DOM.id("btn-settings").addEventListener("click", () => {
showSettingsModal();
});
DOM.id("btn-about").addEventListener("click", () => {
showInfoModal();
});

View File

@ -140,13 +140,32 @@ var STATE = (function(){
currentPage = total;
}
return currentPage;
return currentPage || 1;
};
ROOT.getPageCount = function(){
return !MSGS ? 0 : (!messagesPerPage ? 1 : Math.ceil(MSGS.length/messagesPerPage));
};
// --------
// Settings
// --------
ROOT.settings = {};
var defineSettingProperty = (property, defaultValue) => {
var name = "_"+property;
Object.defineProperty(ROOT.settings, property, {
get: (() => ROOT.settings[name]),
set: (value => {
ROOT.settings[name] = value;
triggerMessagesRefreshed();
})
});
ROOT.settings[name] = defaultValue;
}
// End
return ROOT;
})();