/*
* 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 .
*/
// Function that querys all of the data we need.
$(run = function () {
// Check if the module is enabled.
socket.getDBValues('queue_module', {
tables: ['modules', 'queueSettings'],
keys: ['./systems/queueSystem.js', 'isActive']
}, true, function (e) {
// If the module is off, don't load any data.
if (!helpers.handleModuleLoadUp(['queueModule', 'queueListModule'], e['./systems/queueSystem.js'], 'queueModuleToggle')) {
// Remove the chat.
$('#queue-chat').find('iframe').remove();
return;
} else {
if (location.protocol.toLowerCase().startsWith('https') && !(location.port > 0 && location.port !== 443)) {
// Add Twitch chat.
$('#queue-chat').html($('', {
'frameborder': '0',
'scrolling': 'no',
'style': 'width: 100%; height: 532px;',
'src': 'https://www.twitch.tv/embed/' + getChannelName() + '/chat' + (helpers.isDark ? '?darkpopout&' : '?') + 'parent=' + location.hostname
}));
} else {
$('#queue-chat').html('Due to changes by Twitch, the chat panel can no longer be displayed unless you enable SSL on the PhantomBot Panel and change the baseport to 443. This may not work without root privileges.
Alternatively, you can login using the GitHub version of the panel at PhantomBot - GitHub.io which gets around this issue.
For help setting up SSL, please see this guide.');
$('#queue-chat').addClass('box-body');
}
}
// Update the open button to close if the queue is active.
if (e['isActive'] === 'true') {
$('#open-or-close-queue').html($('', {
'class': 'fa fa-lock'
})).append(' Close').removeClass('btn-success').addClass('btn-warning');
}
// Function that updates the queue list.
helpers.temp.updateQueueList = function () {
// Get queue list.
socket.getDBTableValues('get_queue_list', 'queue', function (results) {
const table = $('#queue-table');
const trim = function (username) {
if (username.length > 15) {
return username.substr(0, 15) + '...';
} else {
return username;
}
};
// Sort.
results.sort(function (a, b) {
return parseInt(JSON.parse(a.value).position) - parseInt(JSON.parse(b.value).position);
});
// Remove current data content.
table.find('tr:gt(0)').remove();
for (let i = 0; i < results.length; i++) {
const json = JSON.parse(results[i].value),
tr = $('