/* * Copyright (C) 2016-2020 phantombot.github.io/PhantomBot * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ // If we can sroll the event log or not. var canScroll = true; // Function that querys all of the data we need. $(function() { // Query our panel settings first. socket.getDBValues('panel_get_settings', { tables: ['panelData', 'panelData', 'modules'], keys: ['isDark', 'isReverseSortEvents', './systems/commercialSystem.js'] }, true, function(e) { helpers.isDark = e.isDark === 'true'; helpers.isReverseSortEvents = e.isReverseSortEvents === 'true'; // Handle the dark mode skins. helpers.handleDarkMode(helpers.isDark, true); // Handle the dark mode toggle. $('#dark-mode-toggle').prop('checked', helpers.isDark); // Update event toggle. $('#toggle-reverse-events').prop('checked', helpers.isReverseSortEvents); // Disable isntant commercials if the module is disabled if (e['./systems/commercialSystem.js'] !== 'true') { $('#grp-instant-commercial').addClass('hidden'); } else { $('#instant-commercial-length').select2({ placeholder: 'Commercial length, in seconds.', width: '100%' }).tooltip('disable'); } // Query recent events. socket.getDBValue('dashboard_get_events', 'panelData', 'data', function(e) { if (e.panelData !== null && e.panelData.length > 0) { let events = JSON.parse(e.panelData); // This should never be null unless the user removes the DB table. if (events !== null) { // Sort events if needed. if (helpers.isReverseSortEvents) { events.sort(function(a, b) { return b.date - a.date; }); } else { events.sort(function(a, b) { return a.date - b.date; }); } let htmlEvents = $('