mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
IPC GUI Update Nr.4 (#750)
* Removed horizontal scrollbar in log and command * Renamed "Only show" to "Hide bots" on bots page * Nightmode update * Added basic key redeemer button on bots page * Misc * Cleanup * Fix * Added basic config generator for bots * Let user specify delimeter for GamesToRedeemInBackground * Nightmode update * Misc * Added ASF.json to config generator
This commit is contained in:
committed by
Łukasz Domeradzki
parent
37564d0cfe
commit
3af53d55be
2
ArchiSteamFarm/www/css/_nightmode.min.css
vendored
2
ArchiSteamFarm/www/css/_nightmode.min.css
vendored
File diff suppressed because one or more lines are too long
@@ -10,7 +10,8 @@
|
||||
border-color: rgb(221, 221, 221);
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
overflow: auto;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.box-content-command {
|
||||
@@ -21,7 +22,8 @@
|
||||
border-color: rgb(221, 221, 221);
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
overflow: auto;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
font-family: monospace, monospace;
|
||||
color: rgb(255, 255, 255);
|
||||
font-size: 14px;
|
||||
@@ -173,3 +175,9 @@ button.bot-resumed:hover {
|
||||
background: #F39814;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#gamesToRedeemInBackground {
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
@@ -19,26 +19,26 @@ function store(name, val) {
|
||||
|
||||
function getIPCPassword() {
|
||||
swal({
|
||||
title: "IPC password required",
|
||||
text: "Please enter the correct IPC password:",
|
||||
type: "input",
|
||||
title: 'IPC password required',
|
||||
text: 'Please enter the correct IPC password:',
|
||||
type: 'input',
|
||||
showCancelButton: true,
|
||||
closeOnConfirm: false,
|
||||
inputPlaceholder: "Type your password",
|
||||
inputType: "password"
|
||||
inputPlaceholder: 'Type your password',
|
||||
inputType: 'password'
|
||||
}, function (typedPassword) {
|
||||
if (typedPassword === false) return false;
|
||||
|
||||
if (typedPassword === "") {
|
||||
swal.showInputError("You need to enter a valid password!");
|
||||
if (typedPassword === '') {
|
||||
swal.showInputError('You need to enter a valid password!');
|
||||
return false;
|
||||
}
|
||||
|
||||
store('IPCPassword', typedPassword);
|
||||
swal({
|
||||
title: "Success!",
|
||||
text: "Your IPC password has been saved.",
|
||||
type: "success"
|
||||
title: 'Success!',
|
||||
text: 'Your IPC password has been saved.',
|
||||
type: 'success'
|
||||
}, function () { location.reload(); });
|
||||
});
|
||||
}
|
||||
@@ -50,14 +50,14 @@ if (IPCPassword) $.ajaxSetup({ beforeSend: function (jqXHR) { jqXHR.setRequestHe
|
||||
//#region Footer
|
||||
$('.main-footer').ready(function () {
|
||||
$.ajax({
|
||||
url: "/Api/ASF",
|
||||
type: "GET",
|
||||
url: '/Api/ASF',
|
||||
type: 'GET',
|
||||
statusCode: { 401: function () { getIPCPassword(); } },
|
||||
success: function (data) {
|
||||
var obj = data["Result"].Version,
|
||||
var obj = data['Result'].Version,
|
||||
version = obj.Major + '.' + obj.Minor + '.' + obj.Build + '.' + obj.Revision;
|
||||
|
||||
$("#version").html('<b>Version</b> ' + version);
|
||||
$('#version').html('<b>Version</b> ' + version);
|
||||
$('#changelog').attr('href', 'https://github.com/JustArchi/ArchiSteamFarm/releases/tag/' + version);
|
||||
}
|
||||
});
|
||||
@@ -72,10 +72,10 @@ $('.bot-status').ready(function () {
|
||||
offlineBots = 0;
|
||||
|
||||
$.ajax({
|
||||
url: "/Api/Bot/ASF",
|
||||
type: "GET",
|
||||
url: '/Api/Bot/ASF',
|
||||
type: 'GET',
|
||||
success: function (data) {
|
||||
var json = data["Result"];
|
||||
var json = data['Result'];
|
||||
|
||||
for (var i = 0; i < json.length; i++) {
|
||||
var obj = json[i],
|
||||
@@ -85,7 +85,7 @@ $('.bot-status').ready(function () {
|
||||
if (KeepRunning === false) {
|
||||
offlineBots++;
|
||||
} else {
|
||||
if (TimeRemaining === "00:00:00") {
|
||||
if (TimeRemaining === '00:00:00') {
|
||||
idleBots++;
|
||||
} else {
|
||||
activeBots++;
|
||||
@@ -93,9 +93,9 @@ $('.bot-status').ready(function () {
|
||||
}
|
||||
}
|
||||
|
||||
$("#offlineBots").text(offlineBots);
|
||||
$("#idleBots").text(idleBots);
|
||||
$("#activeBots").text(activeBots);
|
||||
$('#offlineBots').text(offlineBots);
|
||||
$('#idleBots').text(idleBots);
|
||||
$('#activeBots').text(activeBots);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -109,9 +109,9 @@ $('.bot-status').ready(function () {
|
||||
$('.info-overview').ready(function () {
|
||||
function displayRAMUsage() {
|
||||
$.ajax({
|
||||
url: "/Api/ASF",
|
||||
type: "GET",
|
||||
success: function (data) { $("#ramUsage").html((data["Result"].MemoryUsage / 1024).toFixed(2) + " MB"); }
|
||||
url: '/Api/ASF',
|
||||
type: 'GET',
|
||||
success: function (data) { $('#ramUsage').html((data['Result'].MemoryUsage / 1024).toFixed(2) + ' MB'); }
|
||||
});
|
||||
}
|
||||
|
||||
@@ -120,9 +120,9 @@ $('.info-overview').ready(function () {
|
||||
|
||||
function displayUptime() {
|
||||
$.ajax({
|
||||
url: "/Api/ASF",
|
||||
type: "GET",
|
||||
success: function (data) { $("#uptime").html(uptimeToString(data["Result"].ProcessStartTime)); }
|
||||
url: '/Api/ASF',
|
||||
type: 'GET',
|
||||
success: function (data) { $('#uptime').html(uptimeToString(data['Result'].ProcessStartTime)); }
|
||||
});
|
||||
}
|
||||
|
||||
@@ -146,22 +146,22 @@ function uptimeToString(startTime) {
|
||||
hours = (hours < 10 ? '0' : '') + hours;
|
||||
mins = (mins < 10 ? '0' : '') + mins;
|
||||
|
||||
return days + "d " + hours + "h " + mins + "m";
|
||||
return days + 'd ' + hours + 'h ' + mins + 'm';
|
||||
}
|
||||
//#endregion ASF Information
|
||||
|
||||
//#region Command Page
|
||||
var $cmdInput = $('#commandInput');
|
||||
function fillCommand(cmd) { $cmdInput.val(cmd); }
|
||||
function fillBots(bot) { $cmdInput.val($cmdInput.val() + ' ' + bot); }
|
||||
function fillCommand(cmd) { $cmdInput.val(cmd + ' '); }
|
||||
function fillBots(bot) { $cmdInput.val($cmdInput.val() + bot); }
|
||||
|
||||
function getDateAndTime() {
|
||||
var currentdate = new Date();
|
||||
return ('0' + currentdate.getDate()).slice(-2) + '.'
|
||||
+ ('0' + (currentdate.getMonth() + 1)).slice(-2) + '.'
|
||||
+ currentdate.getFullYear() + " @ "
|
||||
+ ('0' + currentdate.getHours()).slice(-2) + ":"
|
||||
+ ('0' + currentdate.getMinutes()).slice(-2) + ":"
|
||||
+ currentdate.getFullYear() + ' @ '
|
||||
+ ('0' + currentdate.getHours()).slice(-2) + ':'
|
||||
+ ('0' + currentdate.getMinutes()).slice(-2) + ':'
|
||||
+ ('0' + currentdate.getSeconds()).slice(-2);
|
||||
}
|
||||
|
||||
@@ -169,41 +169,41 @@ function logCommand(state, cmd) {
|
||||
var tmpAutoClear = get('autoClear');
|
||||
|
||||
if (state) {
|
||||
$("#commandSent").val(getDateAndTime() + ' Command sent: ' + cmd);
|
||||
$('#commandSent').val(getDateAndTime() + ' Command sent: ' + cmd);
|
||||
} else {
|
||||
if (tmpAutoClear === 'false') {
|
||||
$(".box-content-command").append('\n' + getDateAndTime() + ' Response received: ' + cmd + '\n');
|
||||
$('.box-content-command').append('\n' + getDateAndTime() + ' Response received: ' + cmd + '\n');
|
||||
} else {
|
||||
$(".box-content-command").text(getDateAndTime() + ' Response received: ' + cmd);
|
||||
$('.box-content-command').text(getDateAndTime() + ' Response received: ' + cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function sendCommand() {
|
||||
var command = $cmdInput.val(),
|
||||
requestURL = "/Api/Command/" + command,
|
||||
requestURL = '/Api/Command/' + command,
|
||||
tmpAutoClear = get('autoClear');
|
||||
|
||||
if (command === "") return;
|
||||
if (command === '') return;
|
||||
|
||||
logCommand(true, command);
|
||||
|
||||
if (tmpAutoClear === 'false') {
|
||||
if ($(".box-content-command").text() === '') {
|
||||
$(".box-content-command").append(getDateAndTime() + ' Waiting for response...' + '\n');
|
||||
if ($('.box-content-command').text() === '') {
|
||||
$('.box-content-command').append(getDateAndTime() + ' Waiting for response...' + '\n');
|
||||
} else {
|
||||
$(".box-content-command").append('\n' + getDateAndTime() + ' Waiting for response...' + '\n');
|
||||
$('.box-content-command').append('\n' + getDateAndTime() + ' Waiting for response...' + '\n');
|
||||
}
|
||||
|
||||
} else {
|
||||
$(".box-content-command").text(getDateAndTime() + ' Waiting for response...');
|
||||
$('.box-content-command').text(getDateAndTime() + ' Waiting for response...');
|
||||
}
|
||||
|
||||
$(".box-content-command").append('<div class="overlay"><i class="fas fa-sync fa-spin" style="color:white"></i></div>');
|
||||
$('.box-content-command').append('<div class="overlay"><i class="fas fa-sync fa-spin" style="color:white"></i></div>');
|
||||
|
||||
$.ajax({
|
||||
url: requestURL,
|
||||
type: "GET",
|
||||
type: 'GET',
|
||||
success: function (data) {
|
||||
$('.overlay').remove();
|
||||
logCommand(false, data['Result']);
|
||||
@@ -218,7 +218,7 @@ function sendCommand() {
|
||||
}
|
||||
//#endregion Command Page
|
||||
|
||||
//#region Config Changer Page
|
||||
//#region Config Page
|
||||
|
||||
//#region New stuff
|
||||
//const cachedTypeDefinitions = new Map();
|
||||
@@ -328,14 +328,20 @@ function sendCommand() {
|
||||
//}
|
||||
//#endregion New stuff
|
||||
|
||||
function generateConfigChangerHTML() {
|
||||
var globalBotConfig = {},
|
||||
globalDefaultConfig = {};
|
||||
|
||||
function generateConfigHTML(prefix) {
|
||||
$('#config' + prefix + 'Tab').empty(); // Clear page content first
|
||||
|
||||
$.ajax({
|
||||
url: "/Api/Type/ArchiSteamFarm.BotConfig",
|
||||
type: "GET",
|
||||
url: '/Api/Type/ArchiSteamFarm.BotConfig',
|
||||
type: 'GET',
|
||||
success: function (data) {
|
||||
var obj = data["Result"],
|
||||
objBody = obj["Body"],
|
||||
boxBodyHTML = "",
|
||||
var obj = data['Result'],
|
||||
objBody = obj['Body'],
|
||||
boxHeaderHTML = '',
|
||||
boxBodyHTML = '',
|
||||
textBoxes = '',
|
||||
checkBoxes = '',
|
||||
numberBoxes = '',
|
||||
@@ -351,32 +357,32 @@ function generateConfigChangerHTML() {
|
||||
switch (value) {
|
||||
case 'System.Boolean':
|
||||
checkBoxes += '<div class="">'
|
||||
+ '<button title="Toggle ' + key + '" type="button" data-type="' + value + '" class="btn btn-box-tool text-grey" id="' + key + '"><i id="ico' + key + '" class="fas fa-toggle-on fa-2x fa-fw fa-rotate-180"></i></button>'
|
||||
+ '<button title="Toggle ' + key + '" type="button" data-type="' + value + '" class="btn btn-box-tool text-grey" id="' + prefix + key + '"><i id="ico' + prefix + key + '" class="fas fa-toggle-on fa-2x fa-fw fa-rotate-180"></i></button>'
|
||||
+ readableKey
|
||||
+ '</div>';
|
||||
break;
|
||||
case 'System.String':
|
||||
textBoxes += '<div class="form-group-config">'
|
||||
+ '<label for="' + key + '">' + readableKey + '</label>'
|
||||
+ '<input type="text" id="' + key + '" class="form-control" data-type="' + value + '">'
|
||||
+ '<label for="' + prefix + key + '">' + readableKey + '</label>'
|
||||
+ '<input type="text" id="' + prefix + key + '" class="form-control" data-type="' + value + '">'
|
||||
+ '</div>';
|
||||
break;
|
||||
case 'System.Byte':
|
||||
numberBoxes += '<div class="form-group-config">'
|
||||
+ '<label for="' + key + '">' + readableKey + '</label>'
|
||||
+ '<input type="number" id="' + key + '" class="form-control" data-type="' + value + '">'
|
||||
+ '<label for="' + prefix + key + '">' + readableKey + '</label>'
|
||||
+ '<input type="number" id="' + prefix + key + '" class="form-control" data-type="' + value + '">'
|
||||
+ '</div>';
|
||||
break;
|
||||
case 'System.Collections.Generic.Dictionary`2[System.UInt64][ArchiSteamFarm.BotConfig+EPermission]':
|
||||
textAreas += '<div class="form-group-config">'
|
||||
+ '<label for="' + key + '">' + readableKey + '</label>'
|
||||
+ '<textarea id="' + key + '" class="form-control" data-type="' + value + '" rows="3"></textarea>'
|
||||
+ '<label for="' + prefix + key + '">' + readableKey + '</label>'
|
||||
+ '<textarea id="' + prefix + key + '" class="form-control" data-type="' + value + '" rows="3"></textarea>'
|
||||
+ '</div>';
|
||||
break;
|
||||
default:
|
||||
defaultBoxes += '<div class="form-group-config">'
|
||||
+ '<label for="' + key + '">' + readableKey + '</label>'
|
||||
+ '<input type="text" id="' + key + '" class="form-control" data-type="' + value + '">'
|
||||
+ '<label for="' + prefix + key + '">' + readableKey + '</label>'
|
||||
+ '<input type="text" id="' + prefix + key + '" class="form-control" data-type="' + value + '">'
|
||||
+ '</div>';
|
||||
}
|
||||
}
|
||||
@@ -386,22 +392,131 @@ function generateConfigChangerHTML() {
|
||||
+ '<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">' + checkBoxes + textAreas + '</div>';
|
||||
}
|
||||
|
||||
$('#configChangerTab').html('<div class="box-header with-border">'
|
||||
+ '<h3 class="box-title"></h3>'
|
||||
+ '<div class="box-tools pull-right">'
|
||||
+ '<div class="btn-group">'
|
||||
+ '<button type="button" class="btn btn-box-tool dropdown-toggle" data-toggle="dropdown" aria-expanded="false">'
|
||||
+ 'Change Bot '
|
||||
+ '<span class="fas fa-caret-down"></span>'
|
||||
+ '</button>'
|
||||
+ '<ul class="dropdown-menu scrollable-menu" role="menu" id="botsDropDown"></ul>'
|
||||
+ '</div>'
|
||||
+ '</div>'
|
||||
+ '</div>'
|
||||
+ '<div class="box-body">'
|
||||
+ boxBodyHTML
|
||||
+ '</div>');
|
||||
|
||||
if (prefix === 'Changer') {
|
||||
boxHeaderHTML = '<div class="box-header with-border">'
|
||||
+ '<h3 class="box-title"></h3>'
|
||||
+ '<div class="box-tools pull-right">'
|
||||
+ '<div class="btn-group">'
|
||||
+ '<button type="button" class="btn btn-box-tool dropdown-toggle" data-toggle="dropdown" aria-expanded="false">'
|
||||
+ 'Change bot '
|
||||
+ '<span class="fas fa-caret-down"></span>'
|
||||
+ '</button>'
|
||||
+ '<ul class="dropdown-menu scrollable-menu" role="menu" id="botsDropDown"></ul>'
|
||||
+ '</div>'
|
||||
+ '</div>'
|
||||
+ '</div>';
|
||||
} else if (prefix === 'Generator') {
|
||||
boxHeaderHTML = '<div class="box-header with-border">'
|
||||
+ '<h3 class="box-title"></h3>'
|
||||
+ '<div class="box-tools pull-right">'
|
||||
+ '<div class="btn-group">'
|
||||
+ '<button type="button" class="btn btn-box-tool dropdown-toggle" data-toggle="dropdown" aria-expanded="false">'
|
||||
+ 'Change mode '
|
||||
+ '<span class="fas fa-caret-down"></span>'
|
||||
+ '</button>'
|
||||
+ '<ul class="dropdown-menu scrollable-menu" role="menu" id="modeDropDown"></ul>'
|
||||
+ '</div>'
|
||||
+ '</div>'
|
||||
+ '</div>';
|
||||
}
|
||||
|
||||
$('#config' + prefix + 'Tab').html(boxHeaderHTML + '<div class="box-body">' + boxBodyHTML + '</div>');
|
||||
|
||||
createClickFunction();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function generateASFConfigHTML(prefix) {
|
||||
$('#config' + prefix + 'Tab').empty(); // Clear page content first
|
||||
|
||||
$.ajax({
|
||||
url: '/Api/Type/ArchiSteamFarm.GlobalConfig',
|
||||
type: 'GET',
|
||||
success: function (data) {
|
||||
var obj = data['Result'],
|
||||
objBody = obj['Body'],
|
||||
boxHeaderHTML = '',
|
||||
boxBodyHTML = '',
|
||||
textBoxes = '',
|
||||
checkBoxes = '',
|
||||
numberBoxes = '',
|
||||
defaultBoxes = '',
|
||||
textAreas = '';
|
||||
|
||||
for (var key in objBody) {
|
||||
if (objBody.hasOwnProperty(key)) {
|
||||
var value = objBody[key],
|
||||
noSpaceKey = key.replace(/([A-Z])/g, ' $1').trim(),
|
||||
readableKey = noSpaceKey.replace(/([A-Z])\s(?=[A-Z])/g, '$1');
|
||||
|
||||
switch (value) {
|
||||
case 'System.Boolean':
|
||||
checkBoxes += '<div class="">'
|
||||
+ '<button title="Toggle ' + key + '" type="button" data-type="' + value + '" class="btn btn-box-tool text-grey" id="' + prefix + key + '"><i id="ico' + prefix + key + '" class="fas fa-toggle-on fa-2x fa-fw fa-rotate-180"></i></button>'
|
||||
+ readableKey
|
||||
+ '</div>';
|
||||
break;
|
||||
case 'System.String':
|
||||
textBoxes += '<div class="form-group-config">'
|
||||
+ '<label for="' + prefix + key + '">' + readableKey + '</label>'
|
||||
+ '<input type="text" id="' + prefix + key + '" class="form-control" data-type="' + value + '">'
|
||||
+ '</div>';
|
||||
break;
|
||||
case 'System.Byte':
|
||||
numberBoxes += '<div class="form-group-config">'
|
||||
+ '<label for="' + prefix + key + '">' + readableKey + '</label>'
|
||||
+ '<input type="number" id="' + prefix + key + '" class="form-control" data-type="' + value + '">'
|
||||
+ '</div>';
|
||||
break;
|
||||
case 'System.Collections.Generic.HashSet`1[System.String]':
|
||||
textAreas += '<div class="form-group-config">'
|
||||
+ '<label for="' + prefix + key + '">' + readableKey + '</label>'
|
||||
+ '<textarea id="' + prefix + key + '" class="form-control" data-type="' + value + '" rows="3"></textarea>'
|
||||
+ '</div>';
|
||||
break;
|
||||
default:
|
||||
defaultBoxes += '<div class="form-group-config">'
|
||||
+ '<label for="' + prefix + key + '">' + readableKey + '</label>'
|
||||
+ '<input type="text" id="' + prefix + key + '" class="form-control" data-type="' + value + '">'
|
||||
+ '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
boxBodyHTML = '<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">' + numberBoxes + '</div>'
|
||||
+ '<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">' + checkBoxes + defaultBoxes + textBoxes + textAreas + '</div>';
|
||||
}
|
||||
|
||||
if (prefix === 'Changer') {
|
||||
boxHeaderHTML = '<div class="box-header with-border">'
|
||||
+ '<h3 class="box-title"></h3>'
|
||||
+ '<div class="box-tools pull-right">'
|
||||
+ '<div class="btn-group">'
|
||||
+ '<button type="button" class="btn btn-box-tool dropdown-toggle" data-toggle="dropdown" aria-expanded="false">'
|
||||
+ 'Change bot '
|
||||
+ '<span class="fas fa-caret-down"></span>'
|
||||
+ '</button>'
|
||||
+ '<ul class="dropdown-menu scrollable-menu" role="menu" id="botsDropDown"></ul>'
|
||||
+ '</div>'
|
||||
+ '</div>'
|
||||
+ '</div>';
|
||||
} else if (prefix === 'Generator') {
|
||||
boxHeaderHTML = '<div class="box-header with-border">'
|
||||
+ '<h3 class="box-title"></h3>'
|
||||
+ '<div class="box-tools pull-right">'
|
||||
+ '<div class="btn-group">'
|
||||
+ '<button type="button" class="btn btn-box-tool dropdown-toggle" data-toggle="dropdown" aria-expanded="false">'
|
||||
+ 'Change mode '
|
||||
+ '<span class="fas fa-caret-down"></span>'
|
||||
+ '</button>'
|
||||
+ '<ul class="dropdown-menu scrollable-menu" role="menu" id="modeDropDown"></ul>'
|
||||
+ '</div>'
|
||||
+ '</div>'
|
||||
+ '</div>';
|
||||
}
|
||||
|
||||
$('#config' + prefix + 'Tab').html(boxHeaderHTML + '<div class="box-body">' + boxBodyHTML + '</div>');
|
||||
|
||||
createClickFunction();
|
||||
}
|
||||
});
|
||||
@@ -413,7 +528,7 @@ function createClickFunction() {
|
||||
for (i = 0; i < myNodeList.length; i++) {
|
||||
var myID = myNodeList[i].id;
|
||||
|
||||
$('#' + myID).bind("click", function () {
|
||||
$('#' + myID).bind('click', function () {
|
||||
var $key = $('#' + this.id);
|
||||
|
||||
if ($key.hasClass('text-grey')) {
|
||||
@@ -431,14 +546,12 @@ function createClickFunction() {
|
||||
}
|
||||
}
|
||||
|
||||
var globalBotConfig = {};
|
||||
|
||||
function loadConfigValuesForBot(botName) {
|
||||
$.ajax({
|
||||
url: "/Api/Bot/" + encodeURIComponent(botName),
|
||||
type: "GET",
|
||||
url: '/Api/Bot/' + encodeURIComponent(botName),
|
||||
type: 'GET',
|
||||
success: function (data) {
|
||||
var obj = data["Result"],
|
||||
var obj = data['Result'],
|
||||
objBot = obj[0],
|
||||
BotConfig = objBot.BotConfig;
|
||||
|
||||
@@ -447,7 +560,7 @@ function loadConfigValuesForBot(botName) {
|
||||
for (var key in BotConfig) {
|
||||
if (BotConfig.hasOwnProperty(key)) {
|
||||
var value = BotConfig[key],
|
||||
$key = $('#' + key),
|
||||
$key = $('#Changer' + key),
|
||||
keyObj = $key[0];
|
||||
|
||||
if (typeof keyObj === 'undefined') continue;
|
||||
@@ -459,11 +572,11 @@ function loadConfigValuesForBot(botName) {
|
||||
if (value) {
|
||||
$key.removeClass('text-grey');
|
||||
$key.addClass('text-olive');
|
||||
$('#ico' + key).removeClass('fa-rotate-180');
|
||||
$('#icoChanger' + key).removeClass('fa-rotate-180');
|
||||
} else {
|
||||
$key.removeClass('text-olive');
|
||||
$key.addClass('text-grey');
|
||||
$('#ico' + key).addClass('fa-rotate-180');
|
||||
$('#icoChanger' + key).addClass('fa-rotate-180');
|
||||
}
|
||||
break;
|
||||
case 'System.UInt64':
|
||||
@@ -487,14 +600,68 @@ function loadConfigValuesForBot(botName) {
|
||||
});
|
||||
}
|
||||
|
||||
function loadDefaultConfigValues(mode) {
|
||||
var namespace = mode === 'ASF' ? 'ArchiSteamFarm.GlobalConfig' : 'ArchiSteamFarm.BotConfig';
|
||||
|
||||
$.ajax({
|
||||
url: '/Api/Structure/' + namespace,
|
||||
type: 'GET',
|
||||
success: function (data) {
|
||||
var BotConfig = data['Result'];
|
||||
|
||||
globalDefaultConfig = BotConfig;
|
||||
|
||||
for (var key in BotConfig) {
|
||||
if (BotConfig.hasOwnProperty(key)) {
|
||||
var value = BotConfig[key],
|
||||
$key = $('#Generator' + key),
|
||||
keyObj = $key[0];
|
||||
|
||||
if (typeof keyObj === 'undefined') continue;
|
||||
|
||||
var inputType = keyObj.dataset.type;
|
||||
|
||||
switch (inputType) {
|
||||
case 'System.Boolean':
|
||||
if (value) {
|
||||
$key.removeClass('text-grey');
|
||||
$key.addClass('text-olive');
|
||||
$('#icoGenerator' + key).removeClass('fa-rotate-180');
|
||||
} else {
|
||||
$key.removeClass('text-olive');
|
||||
$key.addClass('text-grey');
|
||||
$('#icoGenerator' + key).addClass('fa-rotate-180');
|
||||
}
|
||||
break;
|
||||
case 'System.UInt64':
|
||||
$key.val(BotConfig['s_' + key]);
|
||||
break;
|
||||
case 'System.Collections.Generic.Dictionary`2[System.UInt64][ArchiSteamFarm.BotConfig+EPermission]':
|
||||
$key.text(''); // Reset textarea before filling
|
||||
|
||||
for (var steamID64 in value) {
|
||||
if (value.hasOwnProperty(steamID64)) $key.append(steamID64 + ':' + value[steamID64] + '\n');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$key.val(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loadModeDropDown(mode);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function prepareBotConfigForSaving() {
|
||||
var botName = $("#saveButton").data("BotName"),
|
||||
var botName = $('#saveButton').data('BotName'),
|
||||
BotConfig = globalBotConfig;
|
||||
|
||||
for (var key in BotConfig) {
|
||||
if (BotConfig.hasOwnProperty(key)) {
|
||||
var value = BotConfig[key],
|
||||
$key = $('#' + key),
|
||||
$key = $('#Changer' + key),
|
||||
keyObj = $key[0];
|
||||
|
||||
if (typeof keyObj === 'undefined') continue;
|
||||
@@ -504,7 +671,7 @@ function prepareBotConfigForSaving() {
|
||||
|
||||
switch (inputType) {
|
||||
case 'System.Boolean':
|
||||
var $keyState = $('#ico' + key).hasClass('fa-rotate-180') ? false : true;
|
||||
var $keyState = $('#icoChanger' + key).hasClass('fa-rotate-180') ? false : true;
|
||||
if ($keyState !== value) BotConfig[key] = $keyState;
|
||||
break;
|
||||
|
||||
@@ -519,6 +686,7 @@ function prepareBotConfigForSaving() {
|
||||
}
|
||||
break;
|
||||
case 'System.Collections.Generic.HashSet`1[System.UInt32]':
|
||||
if ($keyValue === '') continue;
|
||||
var items = $keyValue.split(',');
|
||||
if (items.map(Number) !== value) BotConfig[key] = items.map(Number);
|
||||
break;
|
||||
@@ -557,24 +725,179 @@ function prepareBotConfigForSaving() {
|
||||
saveConfig(botName, { BotConfig });
|
||||
}
|
||||
|
||||
function prepareGeneratorConfigForSaving() {
|
||||
var botName = $('#GeneratorName').val(),
|
||||
BotConfig = globalDefaultConfig;
|
||||
|
||||
if (botName === '') {
|
||||
swal({
|
||||
title: 'Error!',
|
||||
text: 'You need to enter a name',
|
||||
type: 'error'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var key in BotConfig) {
|
||||
if (BotConfig.hasOwnProperty(key)) {
|
||||
var value = BotConfig[key],
|
||||
$key = $('#Generator' + key),
|
||||
keyObj = $key[0];
|
||||
|
||||
if (typeof keyObj === 'undefined') continue;
|
||||
|
||||
var inputType = keyObj.dataset.type,
|
||||
$keyValue = $key.val();
|
||||
|
||||
switch (inputType) {
|
||||
case 'System.Boolean':
|
||||
var $keyState = $('#icoGenerator' + key).hasClass('fa-rotate-180') ? false : true;
|
||||
if ($keyState !== value) BotConfig[key] = $keyState;
|
||||
break;
|
||||
|
||||
case 'System.String':
|
||||
if ($keyValue === '') $keyValue = null;
|
||||
if ($keyValue !== value) BotConfig[key] = $keyValue;
|
||||
break;
|
||||
case 'System.UInt64':
|
||||
if ($keyValue !== BotConfig['s_' + key]) {
|
||||
delete BotConfig[key];
|
||||
BotConfig['s_' + key] = $keyValue;
|
||||
}
|
||||
break;
|
||||
case 'System.Collections.Generic.HashSet`1[System.UInt32]':
|
||||
if ($keyValue === '') continue;
|
||||
var items = $keyValue.split(',');
|
||||
if (items.map(Number) !== value) BotConfig[key] = items.map(Number);
|
||||
break;
|
||||
|
||||
case 'System.Collections.Generic.Dictionary`2[System.UInt64][ArchiSteamFarm.BotConfig+EPermission]':
|
||||
var steamUserPermissions = {},
|
||||
permissions = [],
|
||||
lines = $key.val().split('\n');
|
||||
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
if (lines[i] !== '') permissions.push(lines[i].split(':'));
|
||||
}
|
||||
|
||||
for (var j = 0; j < permissions.length; j++) {
|
||||
var obj = permissions[j];
|
||||
steamUserPermissions[obj[0]] = parseInt(obj[1]);
|
||||
}
|
||||
|
||||
if (steamUserPermissions !== value) BotConfig[key] = steamUserPermissions;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (typeof value === 'object') {
|
||||
var objItems = $keyValue.split(',');
|
||||
if (objItems.map(Number) !== value) BotConfig[key] = objItems.map(Number);
|
||||
} else if (typeof value === 'number') {
|
||||
var number = Number($keyValue);
|
||||
if (number !== value) BotConfig[key] = number;
|
||||
} else {
|
||||
if ($keyValue !== value) BotConfig[key] = $keyValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
downloadObjectAsJson(botName, BotConfig);
|
||||
$('#GeneratorName').val('');
|
||||
}
|
||||
|
||||
function prepareGeneratorASFConfigForSaving() {
|
||||
var botName = $('#GeneratorName').val(),
|
||||
BotConfig = globalDefaultConfig;
|
||||
|
||||
for (var key in BotConfig) {
|
||||
if (BotConfig.hasOwnProperty(key)) {
|
||||
var value = BotConfig[key],
|
||||
$key = $('#Generator' + key),
|
||||
keyObj = $key[0];
|
||||
|
||||
if (typeof keyObj === 'undefined') continue;
|
||||
|
||||
var inputType = keyObj.dataset.type,
|
||||
$keyValue = $key.val();
|
||||
|
||||
switch (inputType) {
|
||||
case 'System.Boolean':
|
||||
var $keyState = $('#icoGenerator' + key).hasClass('fa-rotate-180') ? false : true;
|
||||
if ($keyState !== value) BotConfig[key] = $keyState;
|
||||
break;
|
||||
|
||||
case 'System.String':
|
||||
if ($keyValue === '') $keyValue = null;
|
||||
if ($keyValue !== value) BotConfig[key] = $keyValue;
|
||||
break;
|
||||
case 'System.UInt64':
|
||||
if ($keyValue !== BotConfig['s_' + key]) {
|
||||
delete BotConfig[key];
|
||||
BotConfig['s_' + key] = $keyValue;
|
||||
}
|
||||
break;
|
||||
case 'System.Collections.Generic.HashSet`1[System.UInt32]':
|
||||
if ($keyValue === '') continue;
|
||||
var items = $keyValue.split(',');
|
||||
if (items.map(Number) !== value) BotConfig[key] = items.map(Number);
|
||||
break;
|
||||
|
||||
case 'System.Collections.Generic.HashSet`1[System.String]':
|
||||
var ipcprefix = [],
|
||||
lines = $key.val().split('\n');
|
||||
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
if (lines[i] !== '') ipcprefix.push(lines[i]);
|
||||
}
|
||||
|
||||
if (ipcprefix !== value) BotConfig[key] = ipcprefix;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (typeof value === 'object') {
|
||||
var objItems = $keyValue.split(',');
|
||||
if (objItems.map(Number) !== value) BotConfig[key] = objItems.map(Number);
|
||||
} else if (typeof value === 'number') {
|
||||
var number = Number($keyValue);
|
||||
if (number !== value) BotConfig[key] = number;
|
||||
} else {
|
||||
if ($keyValue !== value) BotConfig[key] = $keyValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
downloadObjectAsJson(botName, BotConfig);
|
||||
}
|
||||
|
||||
function downloadObjectAsJson(exportName, exportObj) {
|
||||
var dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(exportObj));
|
||||
var downloadAnchorNode = document.createElement('a');
|
||||
downloadAnchorNode.setAttribute("href", dataStr);
|
||||
downloadAnchorNode.setAttribute("download", exportName + ".json");
|
||||
downloadAnchorNode.click();
|
||||
downloadAnchorNode.remove();
|
||||
}
|
||||
|
||||
function saveConfig(botName, config) {
|
||||
$.ajax({
|
||||
url: "/Api/Bot/" + encodeURIComponent(botName),
|
||||
type: "POST",
|
||||
url: '/Api/Bot/' + encodeURIComponent(botName),
|
||||
type: 'POST',
|
||||
data: JSON.stringify(config),
|
||||
contentType: "application/json",
|
||||
contentType: 'application/json',
|
||||
success: function (data) {
|
||||
swal({
|
||||
title: "Success!",
|
||||
text: "<" + botName + "> and its config file got updated.",
|
||||
type: "success"
|
||||
title: 'Success!',
|
||||
text: '<' + botName + '> and its config file got updated.',
|
||||
type: 'success'
|
||||
}, function () { location.reload(); });
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
swal({
|
||||
title: "Error!",
|
||||
title: 'Error!',
|
||||
text: jqXHR.status + ' - ' + errorThrown,
|
||||
type: "error"
|
||||
type: 'error'
|
||||
}, function () { location.reload(); });
|
||||
}
|
||||
});
|
||||
@@ -584,10 +907,10 @@ function loadBotsDropDown(botName) {
|
||||
var botsDropDownHTML = '';
|
||||
|
||||
$.ajax({
|
||||
url: "/Api/Bot/ASF",
|
||||
type: "GET",
|
||||
url: '/Api/Bot/ASF',
|
||||
type: 'GET',
|
||||
success: function (data) {
|
||||
var obj = data["Result"];
|
||||
var obj = data['Result'];
|
||||
|
||||
for (var i = 0; i < obj.length; i++) {
|
||||
var currentBot = obj[i],
|
||||
@@ -598,13 +921,49 @@ function loadBotsDropDown(botName) {
|
||||
botsDropDownHTML += '<li><a href="javascript:void(0)" onclick="loadConfigValuesForBot(\'' + currentBotName + '\')">' + currentBotName + '</a></li>';
|
||||
}
|
||||
|
||||
$(".box-title").html("Currently editing: <b>" + botName + "</b>");
|
||||
$("#saveButton").data("BotName", botName);
|
||||
$("#botsDropDown").html(botsDropDownHTML);
|
||||
$('.box-title').html('Currently editing: <b>' + botName + '</b>');
|
||||
$('#saveButton').data('BotName', botName);
|
||||
$('#botsDropDown').html(botsDropDownHTML);
|
||||
}
|
||||
});
|
||||
}
|
||||
//#endregion Config Changer Page
|
||||
|
||||
function loadModeDropDown(mode) {
|
||||
var botsDropDownHTML = '';
|
||||
|
||||
if (mode === 'ASF') {
|
||||
botsDropDownHTML = '<li><a href="javascript:void(0)" onclick="loadPageContentGenerator(\'Bot\');">Bot</a></li>';
|
||||
} else if (mode === 'Bot') {
|
||||
botsDropDownHTML = '<li><a href="javascript:void(0)" onclick="loadPageContentGenerator(\'ASF\');">ASF</a></li>';
|
||||
}
|
||||
|
||||
$('.box-title').html('Current mode: <b>' + mode + '</b>');
|
||||
$('#modeDropDown').html(botsDropDownHTML);
|
||||
}
|
||||
|
||||
function loadPageContentGenerator(namespace) {
|
||||
if (namespace === 'Bot') {
|
||||
generateConfigHTML('Generator');
|
||||
$('#GeneratorName').prop('disabled', false);
|
||||
$('#GeneratorName').prop('value', '');
|
||||
$("#downloadButton").unbind();
|
||||
$("#downloadButton").click(function () { prepareGeneratorConfigForSaving(); });
|
||||
} else if (namespace === 'ASF') {
|
||||
generateASFConfigHTML('Generator');
|
||||
$('#GeneratorName').prop('disabled', true);
|
||||
$('#GeneratorName').prop('value', 'ASF');
|
||||
$("#downloadButton").unbind();
|
||||
$("#downloadButton").click(function () { prepareGeneratorASFConfigForSaving(); });
|
||||
}
|
||||
|
||||
$('#configGeneratorTab').ready(function () {
|
||||
loadDefaultConfigValues(namespace);
|
||||
});
|
||||
$('#downloadButton').show();
|
||||
$('#downloadDiv').show();
|
||||
$('#saveButton').hide();
|
||||
}
|
||||
//#endregion Config Page
|
||||
|
||||
//#region Layout
|
||||
$(function () {
|
||||
@@ -634,19 +993,19 @@ $(function () {
|
||||
|
||||
function changeSetting() {
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "Your IPC password will be reset!",
|
||||
type: "warning",
|
||||
title: 'Are you sure?',
|
||||
text: 'Your IPC password will be reset!',
|
||||
type: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonClass: "btn-danger",
|
||||
confirmButtonText: "Yes, reset it!",
|
||||
confirmButtonClass: 'btn-danger',
|
||||
confirmButtonText: 'Yes, reset it!',
|
||||
closeOnConfirm: false
|
||||
}, function () {
|
||||
store('IPCPassword', "");
|
||||
store('IPCPassword', '');
|
||||
swal({
|
||||
title: "Success!",
|
||||
text: "Your IPC password has been reset.",
|
||||
type: "success"
|
||||
title: 'Success!',
|
||||
text: 'Your IPC password has been reset.',
|
||||
type: 'success'
|
||||
}, function () { location.reload(); });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -106,11 +106,11 @@
|
||||
<div class="box-tools pull-right">
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-box-tool dropdown-toggle" data-toggle="dropdown">
|
||||
Only show <span class="fas fa-caret-down"></span>
|
||||
Hide bots <span class="fas fa-caret-down"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><button title="Toggle online bots" type="button" class="btn btn-box-tool text-olive" id="chkShowOnlineBots"><i id="iconShowOnlineBots" class="fas fa-toggle-on fa-2x"></i></button>Online bots</li>
|
||||
<li><button title="Toggle offline bots" type="button" class="btn btn-box-tool text-olive" id="chkShowOfflineBots"><i id="iconShowOfflineBots" class="fas fa-toggle-on fa-2x"></i></button>Offline bots</li>
|
||||
<li><button title="Toggle online bots" type="button" class="btn btn-box-tool text-grey" id="chkHideOnlineBots"><i id="iconHideOnlineBots" class="fas fa-toggle-on fa-2x fa-rotate-180"></i></button>Online bots</li>
|
||||
<li><button title="Toggle offline bots" type="button" class="btn btn-box-tool text-grey" id="chkHideOfflineBots"><i id="iconHideOfflineBots" class="fas fa-toggle-on fa-2x fa-rotate-180"></i></button>Offline bots</li>
|
||||
</ul>
|
||||
</div>
|
||||
<button title="Toggle multi select" type="button" class="btn btn-box-tool" id="chkMultiSelect" data-widget="collapse"><i id="iconMultiSelect" class="far fa-square"></i></button>
|
||||
@@ -120,6 +120,7 @@
|
||||
<i class="fas fa-wrench"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><button title="Toggle key button" type="button" class="btn btn-box-tool text-grey" id="chkShowKeyButton"><i id="iconShowKeyButton" class="fas fa-toggle-on fa-2x fa-rotate-180"></i></button>Show key button</li>
|
||||
<li><button title="Toggle delete button" type="button" class="btn btn-box-tool text-grey" id="chkShowDeleteButton"><i id="iconShowDeleteButton" class="fas fa-toggle-on fa-2x fa-rotate-180"></i></button>Show delete button</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -166,33 +167,39 @@
|
||||
$(function () {
|
||||
'use strict';
|
||||
|
||||
var tmpShowOnlineBots = get('showOnlineBots'),
|
||||
tmpShowOfflineBots = get('showOfflineBots'),
|
||||
var tmpHideOnlineBots = get('hideOnlineBots'),
|
||||
tmpHideOfflineBots = get('hideOfflineBots'),
|
||||
tmpShowDeleteButton = get('showDeleteButton'),
|
||||
tmpShowKeyButton = get('showKeyButton'),
|
||||
tmpMultiSelect = get('multiSelect'),
|
||||
currentlySelectedBots = [];
|
||||
|
||||
// Load state of checkboxes
|
||||
$('.box-tools').ready(function () {
|
||||
if (tmpShowOnlineBots === 'false') {
|
||||
$('#chkShowOnlineBots').removeClass('text-olive');
|
||||
$('#chkShowOnlineBots').addClass('text-grey');
|
||||
$('#iconShowOnlineBots').addClass('fa-rotate-180');
|
||||
|
||||
$('.box-tools').ready(function () { // Load state of checkboxes
|
||||
if (tmpHideOnlineBots === 'true') {
|
||||
$('#chkHideOnlineBots').removeClass('text-grey');
|
||||
$('#chkHideOnlineBots').addClass('text-olive');
|
||||
$('#iconHideOnlineBots').removeClass('fa-rotate-180');
|
||||
}
|
||||
|
||||
if (tmpShowOfflineBots === 'false') {
|
||||
$('#chkShowOfflineBots').removeClass('text-olive');
|
||||
$('#chkShowOfflineBots').addClass('text-grey');
|
||||
$('#iconShowOfflineBots').addClass('fa-rotate-180');
|
||||
if (tmpHideOfflineBots === 'true') {
|
||||
$('#chkHideOfflineBots').removeClass('text-grey');
|
||||
$('#chkHideOfflineBots').addClass('text-olive');
|
||||
$('#iconHideOfflineBots').removeClass('fa-rotate-180');
|
||||
}
|
||||
|
||||
if (tmpHideOnlineBots !== 'true' || tmpHideOfflineBots !== 'true') loadPageContent();
|
||||
|
||||
if (tmpShowDeleteButton === 'true') {
|
||||
$('#chkShowDeleteButton').removeClass('text-grey');
|
||||
$('#chkShowDeleteButton').addClass('text-olive');
|
||||
$('#iconShowDeleteButton').removeClass('fa-rotate-180');
|
||||
}
|
||||
|
||||
if (tmpShowOnlineBots !== 'false' || tmpShowOfflineBots !== 'false') loadPageContent();
|
||||
if (tmpShowKeyButton === 'true') {
|
||||
$('#chkShowKeyButton').removeClass('text-grey');
|
||||
$('#chkShowKeyButton').addClass('text-olive');
|
||||
$('#iconShowKeyButton').removeClass('fa-rotate-180');
|
||||
}
|
||||
|
||||
if (tmpMultiSelect === 'true') {
|
||||
$('#iconMultiSelect').removeClass('fa-square');
|
||||
@@ -222,32 +229,32 @@
|
||||
}
|
||||
});
|
||||
|
||||
$('#chkShowOnlineBots').click(function () {
|
||||
if ($('#iconShowOnlineBots').hasClass('fa-rotate-180')) {
|
||||
$('#iconShowOnlineBots').removeClass('fa-rotate-180');
|
||||
$('#chkShowOnlineBots').removeClass('text-grey');
|
||||
$('#chkShowOnlineBots').addClass('text-olive');
|
||||
store('showOnlineBots', true);
|
||||
$('#chkHideOnlineBots').click(function () {
|
||||
if ($('#iconHideOnlineBots').hasClass('fa-rotate-180')) {
|
||||
$('#iconHideOnlineBots').removeClass('fa-rotate-180');
|
||||
$('#chkHideOnlineBots').removeClass('text-grey');
|
||||
$('#chkHideOnlineBots').addClass('text-olive');
|
||||
store('hideOnlineBots', true);
|
||||
} else {
|
||||
$('#iconShowOnlineBots').addClass('fa-rotate-180');
|
||||
$('#chkShowOnlineBots').removeClass('text-olive');
|
||||
$('#chkShowOnlineBots').addClass('text-grey');
|
||||
store('showOnlineBots', false);
|
||||
$('#iconHideOnlineBots').addClass('fa-rotate-180');
|
||||
$('#chkHideOnlineBots').removeClass('text-olive');
|
||||
$('#chkHideOnlineBots').addClass('text-grey');
|
||||
store('hideOnlineBots', false);
|
||||
}
|
||||
loadPageContent();
|
||||
});
|
||||
|
||||
$('#chkShowOfflineBots').click(function () {
|
||||
if ($('#iconShowOfflineBots').hasClass('fa-rotate-180')) {
|
||||
$('#iconShowOfflineBots').removeClass('fa-rotate-180');
|
||||
$('#chkShowOfflineBots').removeClass('text-grey');
|
||||
$('#chkShowOfflineBots').addClass('text-olive');
|
||||
store('showOfflineBots', true);
|
||||
$('#chkHideOfflineBots').click(function () {
|
||||
if ($('#iconHideOfflineBots').hasClass('fa-rotate-180')) {
|
||||
$('#iconHideOfflineBots').removeClass('fa-rotate-180');
|
||||
$('#chkHideOfflineBots').removeClass('text-grey');
|
||||
$('#chkHideOfflineBots').addClass('text-olive');
|
||||
store('hideOfflineBots', true);
|
||||
} else {
|
||||
$('#iconShowOfflineBots').addClass('fa-rotate-180');
|
||||
$('#chkShowOfflineBots').removeClass('text-olive');
|
||||
$('#chkShowOfflineBots').addClass('text-grey');
|
||||
store('showOfflineBots', false);
|
||||
$('#iconHideOfflineBots').addClass('fa-rotate-180');
|
||||
$('#chkHideOfflineBots').removeClass('text-olive');
|
||||
$('#chkHideOfflineBots').addClass('text-grey');
|
||||
store('hideOfflineBots', false);
|
||||
}
|
||||
loadPageContent();
|
||||
});
|
||||
@@ -299,29 +306,44 @@
|
||||
loadPageContent();
|
||||
});
|
||||
|
||||
function loadPageContent() {
|
||||
var tmpShowOnlineBots = get('showOnlineBots'),
|
||||
tmpShowOfflineBots = get('showOfflineBots'),
|
||||
tmpShowDeleteButton = get('showDeleteButton');
|
||||
$('#chkShowKeyButton').click(function () {
|
||||
if ($('#iconShowKeyButton').hasClass('fa-rotate-180')) {
|
||||
$('#iconShowKeyButton').removeClass('fa-rotate-180');
|
||||
$('#chkShowKeyButton').removeClass('text-grey');
|
||||
$('#chkShowKeyButton').addClass('text-olive');
|
||||
store('showKeyButton', true);
|
||||
} else {
|
||||
$('#iconShowKeyButton').addClass('fa-rotate-180');
|
||||
$('#chkShowKeyButton').removeClass('text-olive');
|
||||
$('#chkShowKeyButton').addClass('text-grey');
|
||||
store('showKeyButton', false);
|
||||
}
|
||||
loadPageContent();
|
||||
});
|
||||
|
||||
// Clear page content first
|
||||
$("#totalBotOverview").empty();
|
||||
$("#botRow").empty();
|
||||
function loadPageContent() {
|
||||
var tmpHideOnlineBots = get('hideOnlineBots'),
|
||||
tmpHideOfflineBots = get('hideOfflineBots'),
|
||||
tmpShowDeleteButton = get('showDeleteButton'),
|
||||
tmpShowKeyButton = get('showKeyButton');
|
||||
|
||||
$('#totalBotOverview').empty(); // Clear page content
|
||||
$('#botRow').empty(); // Clear page content
|
||||
|
||||
$.ajax({
|
||||
url: "/Api/Bot/ASF",
|
||||
type: "GET",
|
||||
url: '/Api/Bot/ASF',
|
||||
type: 'GET',
|
||||
success: function (data) {
|
||||
var json = data["Result"],
|
||||
steamAvatarBaseURL = "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/",
|
||||
steamGameBaseURL = "http://cdn.edgecast.steamstatic.com/steam/apps/",
|
||||
deleteBotHTML = "",
|
||||
var json = data['Result'],
|
||||
steamAvatarBaseURL = 'https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/',
|
||||
steamGameBaseURL = 'http://cdn.edgecast.steamstatic.com/steam/apps/',
|
||||
totalGamesRemaining = 0,
|
||||
totalTimeRemaining = "00:00:00",
|
||||
totalTimeRemaining = '00:00:00',
|
||||
totalCardsRemaining = 0,
|
||||
farmingIsActive = false;
|
||||
|
||||
if (tmpShowDeleteButton === 'true') deleteBotHTML = '<button title="Delete this bot" type="button" class="btn btn-box-tool" data-command="deleteBot"><i class="far fa-trash-alt"></i></button>';
|
||||
var deleteBotHTML = tmpShowDeleteButton === 'true' ? '<button title="Delete this bot" type="button" class="btn btn-box-tool" data-command="deleteBot"><i class="far fa-trash-alt"></i></button>' : '';
|
||||
var redeemGamesHTML = tmpShowKeyButton === 'true' ? '<button title="Add keys to GamesToRedeemInBackground" type="button" class="btn btn-box-tool" data-command="redeemGames"><i class="fas fa-key"></i></button>' : '';
|
||||
|
||||
for (var i = 0; i < json.length; i++) {
|
||||
var obj = json[i],
|
||||
@@ -331,44 +353,44 @@
|
||||
KeepRunning = obj.KeepRunning,
|
||||
SteamID = obj.SteamID,
|
||||
Paused = obj.CardsFarmer.Paused,
|
||||
boxColorHTML = "",
|
||||
avatarHTML = "",
|
||||
startOrStopHTML = "",
|
||||
pauseOrResumeHTML = "",
|
||||
expandBoxHTML = "",
|
||||
allGamesHTML = "",
|
||||
boxBodyHTML = "";
|
||||
boxColorHTML = '',
|
||||
avatarHTML = '',
|
||||
startOrStopHTML = '',
|
||||
pauseOrResumeHTML = '',
|
||||
expandBoxHTML = '',
|
||||
allGamesHTML = '',
|
||||
boxBodyHTML = '';
|
||||
|
||||
if (AvatarHash) {
|
||||
var folder = AvatarHash.substring(0, 2);
|
||||
avatarHTML = steamAvatarBaseURL + folder + "/" + AvatarHash + ".jpg";
|
||||
avatarHTML = steamAvatarBaseURL + folder + '/' + AvatarHash + '.jpg';
|
||||
} else {
|
||||
avatarHTML = steamAvatarBaseURL + "fe/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb.jpg";
|
||||
avatarHTML = steamAvatarBaseURL + 'fe/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb.jpg';
|
||||
}
|
||||
|
||||
if (KeepRunning === false) { // Bot is offline
|
||||
if (tmpShowOfflineBots === 'false') continue;
|
||||
boxColorHTML = "box-gray";
|
||||
if (tmpHideOfflineBots === 'true') continue;
|
||||
boxColorHTML = 'box-gray';
|
||||
startOrStopHTML = '<button title="Start <' + BotName + '>" type="button" class="btn btn-box-tool bot-stopped" data-command="startBot"><i class="fas fa-power-off"></i></button>';
|
||||
} else { // Bot is idling
|
||||
if (tmpShowOnlineBots === 'false') continue;
|
||||
boxColorHTML = "box-warning";
|
||||
if (tmpHideOnlineBots === 'true') continue;
|
||||
boxColorHTML = 'box-warning';
|
||||
startOrStopHTML = '<button title="Stop <' + BotName + '>" type="button" class="btn btn-box-tool bot-started" data-command="stopBot"><i class="fas fa-power-off"></i></button>';
|
||||
|
||||
var TimeRemaining = obj.CardsFarmer.TimeRemaining;
|
||||
|
||||
if (SteamID === 0) { // Bot is not connected to steam
|
||||
boxColorHTML = "box-danger";
|
||||
boxColorHTML = 'box-danger';
|
||||
} else { // Bot is connected to steam
|
||||
if (TimeRemaining !== "00:00:00") { // Bot is farming
|
||||
if (TimeRemaining !== '00:00:00') { // Bot is farming
|
||||
var GamesToFarm = obj.CardsFarmer.GamesToFarm,
|
||||
CurrentGamesFarming = obj.CardsFarmer.CurrentGamesFarming,
|
||||
allGamesRemainingName = [],
|
||||
allGamesFarmingAppID = [],
|
||||
allCardsRemaining = 0;
|
||||
|
||||
farmingIsActive = true; //at least one bot is farming
|
||||
boxColorHTML = "box-success";
|
||||
farmingIsActive = true; // At least one bot is farming
|
||||
boxColorHTML = 'box-success';
|
||||
|
||||
for (var j = 0; j < GamesToFarm.length; j++) {
|
||||
totalCardsRemaining = totalCardsRemaining + GamesToFarm[j].CardsRemaining;
|
||||
@@ -392,13 +414,13 @@
|
||||
} else {
|
||||
if (allGamesFarmingAppID.length === 1) {
|
||||
var value = allGamesFarmingAppID;
|
||||
allGamesHTML = '<img src="' + steamGameBaseURL + value[0] + '/header.jpg" alt="" class="img-responsive">'; // fill alt="" with gameName
|
||||
} else { // Multiple game farming
|
||||
allGamesHTML = '<img src="' + steamGameBaseURL + value[0] + '/header.jpg" alt="" class="img-responsive">'; // ToDo: Fill alt="" with gameName
|
||||
} else { // Multiple game farming is active
|
||||
allGamesHTML = '<div class="games-carousel-' + BotName + '">';
|
||||
|
||||
for (var appID in allGamesFarmingAppID) {
|
||||
var value = allGamesFarmingAppID[appID];
|
||||
allGamesHTML += '<div class="game-box" style="max-height: 215px;"><img src="' + steamGameBaseURL + value + '/header.jpg" alt="" class="img-responsive"></div>'; // fill alt="" with gameName
|
||||
allGamesHTML += '<div class="game-box" style="max-height: 215px;"><img src="' + steamGameBaseURL + value + '/header.jpg" alt="" class="img-responsive"></div>'; // ToDo: Fill alt="" with gameName
|
||||
}
|
||||
|
||||
allGamesHTML += '</div>';
|
||||
@@ -408,7 +430,7 @@
|
||||
allGamesHTML = '<p class="text-center no-margin">Bot is currently being used.</p>';
|
||||
}
|
||||
|
||||
TimeRemaining = new Date("1970-01-01T" + TimeRemaining + "Z").getTime();
|
||||
TimeRemaining = new Date('1970-01-01T' + TimeRemaining + 'Z').getTime();
|
||||
|
||||
boxBodyHTML = '<div class="box-body" id="' + BotName + '">'
|
||||
+ '<div class="row">'
|
||||
@@ -431,7 +453,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
$("#botRow").append('<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">'
|
||||
$('#botRow').append('<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">'
|
||||
+ '<div class="box ' + boxColorHTML + ' collapsed-box" id="bot-box-' + BotName + '">'
|
||||
+ '<div class="box-header with-border botHeader ui-widget-content">'
|
||||
+ '<img src="' + avatarHTML + '">'
|
||||
@@ -439,6 +461,7 @@
|
||||
+ '<div class="box-tools pull-right botTools" id="' + BotName + '">'
|
||||
+ startOrStopHTML
|
||||
+ pauseOrResumeHTML
|
||||
+ redeemGamesHTML
|
||||
+ deleteBotHTML
|
||||
+ expandBoxHTML
|
||||
+ '</div>'
|
||||
@@ -456,13 +479,11 @@
|
||||
.on('expanded.boxwidget', function (BotName) {
|
||||
var botCarousel = $('.games-carousel-' + BotName);
|
||||
|
||||
// Checks if Slick was already initialized...
|
||||
if ($(botCarousel).hasClass('slick-initialized')) {
|
||||
// Slick is set up, so just resume the animation.
|
||||
$(botCarousel).slick('slickPlay');
|
||||
|
||||
if ($(botCarousel).hasClass('slick-initialized')) { // Check if Slick was already initialized
|
||||
$(botCarousel).slick('slickPlay'); // Slick is set up, so just resume the animation
|
||||
} else {
|
||||
// Sets up Slick for the first time.
|
||||
$(botCarousel).slick({
|
||||
$(botCarousel).slick({ // Set up Slick for the first time.
|
||||
slidesToShow: 1,
|
||||
draggable: true,
|
||||
autoplay: true,
|
||||
@@ -473,8 +494,7 @@
|
||||
}
|
||||
}.bind(null, BotName))
|
||||
.on('collapsed.boxwidget', function (BotName) {
|
||||
// Just pause Slick's animation and collapse the menu.
|
||||
$('.games-carousel-' + BotName).slick('slickPause');
|
||||
$('.games-carousel-' + BotName).slick('slickPause'); // Pause Slick's animation and collapse the menu
|
||||
}.bind(null, BotName)
|
||||
);
|
||||
|
||||
@@ -487,29 +507,30 @@
|
||||
case 'startBot':
|
||||
$botBox.append('<div class="overlay bot-box-loading"><i class="fas fa-sync fa-spin"></i></div>');
|
||||
$.ajax({
|
||||
url: "/Api/Command/start " + encodeURIComponent(BotName),
|
||||
type: "GET",
|
||||
url: '/Api/Command/start ' + encodeURIComponent(BotName),
|
||||
type: 'GET',
|
||||
success: function (data) {
|
||||
$('.overlay').remove();
|
||||
swal({
|
||||
title: "Success!",
|
||||
text: "<" + BotName + "> has been started.",
|
||||
type: "success"
|
||||
title: 'Success!',
|
||||
text: '<' + BotName + '> has been started.',
|
||||
type: 'success'
|
||||
}, function () { location.reload(); });
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case 'stopBot':
|
||||
$botBox.append('<div class="overlay bot-box-loading"><i class="fas fa-sync fa-spin"></i></div>');
|
||||
$.ajax({
|
||||
url: "/Api/Command/stop " + encodeURIComponent(BotName),
|
||||
type: "GET",
|
||||
url: '/Api/Command/stop ' + encodeURIComponent(BotName),
|
||||
type: 'GET',
|
||||
success: function (data) {
|
||||
$('.overlay').remove();
|
||||
swal({
|
||||
title: "Success!",
|
||||
text: "<" + BotName + "> has been stopped.",
|
||||
type: "success"
|
||||
title: 'Success!',
|
||||
text: '<' + BotName + '> has been stopped.',
|
||||
type: 'success'
|
||||
}, function () { location.reload(); });
|
||||
}
|
||||
});
|
||||
@@ -518,14 +539,14 @@
|
||||
case 'pauseBot':
|
||||
$botBox.append('<div class="overlay bot-box-loading"><i class="fas fa-sync fa-spin"></i></div>');
|
||||
$.ajax({
|
||||
url: "/Api/Command/pause " + encodeURIComponent(BotName),
|
||||
type: "GET",
|
||||
url: '/Api/Command/pause ' + encodeURIComponent(BotName),
|
||||
type: 'GET',
|
||||
success: function (data) {
|
||||
$('.overlay').remove();
|
||||
swal({
|
||||
title: "Success!",
|
||||
text: "<" + BotName + "> has been paused.",
|
||||
type: "success"
|
||||
title: 'Success!',
|
||||
text: '<' + BotName + '> has been paused.',
|
||||
type: 'success'
|
||||
}, function () { location.reload(); });
|
||||
}
|
||||
});
|
||||
@@ -534,14 +555,14 @@
|
||||
case 'resumeBot':
|
||||
$botBox.append('<div class="overlay bot-box-loading"><i class="fas fa-sync fa-spin"></i></div>');
|
||||
$.ajax({
|
||||
url: "/Api/Command/resume " + encodeURIComponent(BotName),
|
||||
type: "GET",
|
||||
url: '/Api/Command/resume ' + encodeURIComponent(BotName),
|
||||
type: 'GET',
|
||||
success: function (data) {
|
||||
$('.overlay').remove();
|
||||
swal({
|
||||
title: "Success!",
|
||||
text: "<" + BotName + "> has been resumed.",
|
||||
type: "success"
|
||||
title: 'Success!',
|
||||
text: '<' + BotName + '> has been resumed.',
|
||||
type: 'success'
|
||||
}, function () { location.reload(); });
|
||||
}
|
||||
});
|
||||
@@ -550,25 +571,25 @@
|
||||
case 'deleteBot':
|
||||
$botBox.append('<div class="overlay bot-box-loading"><i class="fas fa-sync fa-spin"></i></div>');
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "You will not be able to recover any bot files!",
|
||||
type: "warning",
|
||||
title: 'Are you sure?',
|
||||
text: 'You will not be able to recover any bot files!',
|
||||
type: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonClass: "btn-danger",
|
||||
confirmButtonText: "Yes, delete bot!",
|
||||
confirmButtonClass: 'btn-danger',
|
||||
confirmButtonText: 'Yes, delete bot!',
|
||||
closeOnConfirm: false,
|
||||
showLoaderOnConfirm: true
|
||||
}, function (isConfirm) {
|
||||
if (isConfirm) {
|
||||
$.ajax({
|
||||
url: "/Api/Bot/" + encodeURIComponent(BotName),
|
||||
type: "DELETE",
|
||||
url: '/Api/Bot/' + encodeURIComponent(BotName),
|
||||
type: 'DELETE',
|
||||
success: function (data) {
|
||||
$('.overlay').remove();
|
||||
swal({
|
||||
title: "Success!",
|
||||
text: "<" + BotName + "> and all related files have been deleted.",
|
||||
type: "success"
|
||||
title: 'Success!',
|
||||
text: '<' + BotName + '> and all related files have been deleted.',
|
||||
type: 'success'
|
||||
}, function () { location.reload(); });
|
||||
}
|
||||
});
|
||||
@@ -577,13 +598,77 @@
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case 'redeemGames':
|
||||
$botBox.append('<div class="overlay bot-box-loading"><i class="fas fa-sync fa-spin"></i></div>');
|
||||
swal({
|
||||
title: 'Enter keys!',
|
||||
text: '<p class="lead text-muted" style="display: block;">Syntax: gameName{Delimeter}cd-key</p>'
|
||||
+ '<textarea id="gamesToRedeemInBackground"></textarea>'
|
||||
+ '<div class="input-group">'
|
||||
+ '<span class="input-group-addon" id="delimeter-text">Delimeter</span>'
|
||||
+ '<input type="text" class="form-control" id="delimeter" value="\t" aria-describedby="delimeter-text">'
|
||||
+ '</div>',
|
||||
html: true,
|
||||
showCancelButton: true,
|
||||
confirmButtonClass: 'btn-success',
|
||||
confirmButtonText: 'Add keys!',
|
||||
closeOnConfirm: false,
|
||||
showLoaderOnConfirm: true
|
||||
}, function (isConfirm) {
|
||||
if (isConfirm === false) {
|
||||
$('.overlay').remove();
|
||||
return false;
|
||||
}
|
||||
var val = $('#gamesToRedeemInBackground').val();
|
||||
if (val === '') return false;
|
||||
|
||||
$('.overlay').remove();
|
||||
|
||||
var _gamesToRedeemInBackground = {},
|
||||
gamesAndKeys = [],
|
||||
lines = val.split('\n'),
|
||||
delimeter = $('#delimeter').val();
|
||||
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
if (lines[i] !== '') gamesAndKeys.push(lines[i].split(delimeter));
|
||||
}
|
||||
|
||||
for (var j = 0; j < gamesAndKeys.length; j++) {
|
||||
var obj = gamesAndKeys[j];
|
||||
_gamesToRedeemInBackground[obj[0]] = obj[1];
|
||||
}
|
||||
|
||||
var ajaxData = { GamesToRedeemInBackground: _gamesToRedeemInBackground};
|
||||
|
||||
$.ajax({
|
||||
url: '/Api/GamesToRedeemInBackground/' + encodeURIComponent(BotName),
|
||||
type: 'POST',
|
||||
data: JSON.stringify(ajaxData),
|
||||
contentType: 'application/json',
|
||||
success: function (data) {
|
||||
swal({
|
||||
title: 'Success!',
|
||||
text: lines.length + ' Keys have been added to <' + BotName + '> background redeemer.',
|
||||
type: 'success'
|
||||
}, function () { location.reload(); });
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
swal({
|
||||
title: 'Error!',
|
||||
text: jqXHR.status + ' - ' + errorThrown,
|
||||
type: 'error'
|
||||
}, function () { location.reload(); });
|
||||
}
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// add info boxes if at least one bot is farming
|
||||
if (farmingIsActive) {
|
||||
$("#totalBotOverview").html('<div class="col-md-4 col-sm-4 col-xs-12">'
|
||||
|
||||
if (farmingIsActive) { // Add info boxes if at least one bot is farming
|
||||
$('#totalBotOverview').html('<div class="col-md-4 col-sm-4 col-xs-12">'
|
||||
+ '<div class="info-box bot-info-box">'
|
||||
+ '<span class="info-box-icon bg-purple bots-info-box-icon"><i class="fas fa-gamepad"></i></span>'
|
||||
+ '<div class="info-box-content bot-info-box-content">'
|
||||
@@ -611,11 +696,11 @@
|
||||
+ '</div>'
|
||||
+ '</div>');
|
||||
|
||||
totalTimeRemaining = new Date("1970-01-01T" + totalTimeRemaining + "Z").getTime();
|
||||
totalTimeRemaining = new Date('1970-01-01T' + totalTimeRemaining + 'Z').getTime();
|
||||
|
||||
$("#totalGamesRemaining").text(totalGamesRemaining);
|
||||
$("#totalTimeRemaining").text(humanizeDuration(totalTimeRemaining));
|
||||
$("#totalCardsRemaining").text(totalCardsRemaining);
|
||||
$('#totalGamesRemaining').text(totalGamesRemaining);
|
||||
$('#totalTimeRemaining').text(humanizeDuration(totalTimeRemaining));
|
||||
$('#totalCardsRemaining').text(totalCardsRemaining);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -201,11 +201,11 @@
|
||||
|
||||
$commandInput.focus();
|
||||
|
||||
$("#sendCommand").click(function (e) {
|
||||
$('#sendCommand').click(function (e) {
|
||||
var cmd = $commandInput.val();
|
||||
keyCount = 0;
|
||||
|
||||
if (typeof prevCommand[prevCommand.length - 1] === "undefined") {
|
||||
if (typeof prevCommand[prevCommand.length - 1] === 'undefined') {
|
||||
prevCommand.push(cmd);
|
||||
} else if (prevCommand[prevCommand.length - 1] !== cmd) {
|
||||
prevCommand.push(cmd);
|
||||
@@ -219,11 +219,11 @@
|
||||
});
|
||||
|
||||
$(document).keydown(function (e) {
|
||||
if (e.which == 38 && $commandInput.is(":focus")) {
|
||||
if (e.which == 38 && $commandInput.is(':focus')) {
|
||||
if (prevCommand.length > keyCount) keyCount++;
|
||||
var index = prevCommand.length - keyCount;
|
||||
$commandInput.val(prevCommand[index]);
|
||||
} else if (e.which == 40 && $commandInput.is(":focus")) {
|
||||
} else if (e.which == 40 && $commandInput.is(':focus')) {
|
||||
if (keyCount > 0) keyCount--;
|
||||
var index = prevCommand.length - keyCount;
|
||||
$commandInput.val(prevCommand[index]);
|
||||
@@ -231,7 +231,7 @@
|
||||
});
|
||||
|
||||
$(document).keypress(function (e) {
|
||||
if (e.which == 13 && $cmdInput.val() !== "") $("#sendCommand").click();
|
||||
if (e.which == 13 && $cmdInput.val() !== "") $('#sendCommand').click();
|
||||
});
|
||||
|
||||
$('.box-tools').ready(function () {
|
||||
@@ -325,10 +325,10 @@
|
||||
|
||||
$('.box-footer').ready(function () {
|
||||
$.ajax({ // Fill drop down with all bots + ASF
|
||||
url: "/Api/Bot/ASF",
|
||||
type: "GET",
|
||||
url: '/Api/Bot/ASF',
|
||||
type: 'GET',
|
||||
success: function (data) {
|
||||
var json = data["Result"];
|
||||
var json = data['Result'];
|
||||
|
||||
$botsDropDown.append('<li><a href="javascript:void(0)" onclick="fillBots(\'ASF\')">ASF</a></li><li class="divider"></li>');
|
||||
|
||||
@@ -347,7 +347,7 @@
|
||||
|
||||
$('#' + cmd)
|
||||
.mouseenter(function () {
|
||||
$commandInput.attr('placeholder', myCommands[this.id]); // Find a better solution for where to display description.
|
||||
$commandInput.attr('placeholder', myCommands[this.id]); // ToDo: Find a better solution for where to display description
|
||||
})
|
||||
.mouseleave(function () {
|
||||
$commandInput.attr('placeholder', 'Type command...');
|
||||
|
||||
@@ -104,17 +104,19 @@
|
||||
</ul>
|
||||
<div class="tab-content no-padding">
|
||||
<div class="tab-pane active" id="configChangerTab"></div>
|
||||
<div class="tab-pane" id="configGeneratorTab">
|
||||
<div class="callout callout-info margin">
|
||||
<h4><i class="icon fas fa-info"></i> Not implemented</h4>
|
||||
<p>This feature has not been implemented yet.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="configGeneratorTab"></div>
|
||||
</div>
|
||||
|
||||
<div class="box-footer">
|
||||
<button type="submit" class="btn btn-default pull-right" id="saveButton"><i class="far fa-save"></i> Save</button>
|
||||
<button type="submit" class="btn btn-default pull-right" id="downloadButton" disabled><i class="fas fa-cloud-download-alt"></i> Download</button>
|
||||
<div class="input-group pull-right">
|
||||
<button class="btn btn-default" id="saveButton"><i class="far fa-save"></i> Save</button>
|
||||
<div class ="input-group pull-right" id="downloadDiv">
|
||||
<input type="text" class="form-control" placeholder="Name" id="GeneratorName">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" type="button" id="downloadButton"><i class="fas fa-cloud-download-alt"></i> Download</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -150,44 +152,64 @@
|
||||
|
||||
$('#configChangerTab').ready(function () {
|
||||
$('#downloadButton').hide();
|
||||
generateConfigChangerHTML();
|
||||
$('#downloadDiv').hide();
|
||||
|
||||
generateConfigHTML('Changer');
|
||||
|
||||
$.ajax({
|
||||
url: "/Api/Bot/ASF",
|
||||
type: "GET",
|
||||
url: '/Api/Bot/ASF',
|
||||
type: 'GET',
|
||||
success: function (data) {
|
||||
var json = data["Result"];
|
||||
var json = data['Result'];
|
||||
loadConfigValuesForBot(json[0].BotName);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#generatorTabButton').click(function (e) {
|
||||
$('#downloadButton').show();
|
||||
$('#saveButton').hide();
|
||||
loadPageContentGenerator('Bot');
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$('#changerTabButton').click(function (e) {
|
||||
generateConfigHTML('Changer');
|
||||
$('#configChangerTab').ready(function () {
|
||||
$.ajax({
|
||||
url: '/Api/Bot/ASF',
|
||||
type: 'GET',
|
||||
success: function (data) {
|
||||
var json = data['Result'];
|
||||
loadConfigValuesForBot(json[0].BotName);
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#downloadButton').hide();
|
||||
$('#downloadDiv').hide();
|
||||
$('#saveButton').show();
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$("#saveButton").click(function (e) {
|
||||
$('#saveButton').click(function (e) {
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "The config will be updated and the bot will be restarted!",
|
||||
type: "warning",
|
||||
title: 'Are you sure?',
|
||||
text: 'The config will be updated and the bot will be restarted!',
|
||||
type: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonClass: "btn-danger",
|
||||
confirmButtonText: "Yes, update config!",
|
||||
confirmButtonClass: 'btn-danger',
|
||||
confirmButtonText: 'Yes, update config!',
|
||||
closeOnConfirm: false,
|
||||
showLoaderOnConfirm: true
|
||||
}, function () { prepareBotConfigForSaving(); });
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$('#downloadButton').click(function (e) {
|
||||
prepareGeneratorConfigForSaving();
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -150,29 +150,28 @@
|
||||
startWebSocket();
|
||||
|
||||
function startWebSocket() {
|
||||
if (!"WebSocket" in window) window.alert('Please use a modern browser to properly view ASF GUI!')
|
||||
if (!'WebSocket' in window) window.alert('Please use a modern browser to properly view ASF GUI!')
|
||||
|
||||
var loc = window.location,
|
||||
new_uri = (loc.protocol === "https:") ? "wss:" : "ws:";
|
||||
new_uri = (loc.protocol === 'https:') ? 'wss:' : 'ws:';
|
||||
|
||||
new_uri += "//" + loc.host + "/Api/Log?password=" + encodeURIComponent(IPCPassword);
|
||||
new_uri += '//' + loc.host + '/Api/Log?password=' + encodeURIComponent(IPCPassword);
|
||||
ws = new WebSocket(new_uri);
|
||||
$('.overlay').remove();
|
||||
$('.box-content-log').text(""); //Clear log
|
||||
$('.box-content-log').text(''); // Clear log
|
||||
|
||||
ws.onmessage = function (evt) {
|
||||
var msg = JSON.parse(evt.data)["Result"] + "\n";
|
||||
var msg = JSON.parse(evt.data)['Result'] + '\n';
|
||||
$('.box-content-log').append(msg);
|
||||
$(".box-content-log").stop().animate({ scrollTop: $(".box-content-log")[0].scrollHeight }, 1000);
|
||||
$('.box-content-log').stop().animate({ scrollTop: $('.box-content-log')[0].scrollHeight }, 1000);
|
||||
};
|
||||
|
||||
ws.onclose = function (event) {
|
||||
if (event.code !== 1000) {
|
||||
// code 1000 means that the connection was closed normally
|
||||
if (event.code !== 1000) { // Code 1000 means that the connection was closed normally
|
||||
swal({
|
||||
title: "Error!",
|
||||
title: 'Error!',
|
||||
text: event.code + ' - ' + event.reason,
|
||||
type: "error"
|
||||
type: 'error'
|
||||
}, function () { swal.close(); });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user