misc_pterodactyl-panel/public/js/plugins/minecraft/eula.js
Dane Everitt aa6e733ba5
Switch filemanager and EULA check to use pure Javascript methods
Removes the need for the javascript to be parsed by Blade template
engine by using a defined javascript variable with the values that are
necessary for checking everything and passing the correct values.

This does make it so that if a user does not have permission to do
something they could theoretically make the option show up in the
context menu, however when they click it, it will simply return an
error by the daemon.
2017-01-03 16:47:33 -05:00

61 lines
2.9 KiB
JavaScript

// Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
$(window).load(function () {
socket.on('console', function (data) {
if (data.line.indexOf('You need to agree to the EULA in order to run the server') > -1) {
swal({
title: 'EULA Acceptance',
text: 'By pressing \'I Accept\' below you are indicating your agreement to the <a href="https://account.mojang.com/documents/minecraft_eula" target="_blank">Mojang EULA</a>.',
type: 'info',
html: true,
showCancelButton: true,
showConfirmButton: true,
cancelButtonText: 'I do not Accept',
confirmButtonText: 'I Accept',
closeOnConfirm: false,
showLoaderOnConfirm: true
}, function () {
$.ajax({
type: 'POST',
url: Pterodactyl.meta.saveFile,
headers: { 'X-CSRF-Token': Pterodactyl.meta.csrfToken, },
data: {
file: 'eula.txt',
contents: 'eula=true'
}
}).done(function (data) {
$('[data-attr="power"][data-action="start"]').trigger('click');
swal({
type: 'success',
title: '',
text: 'The EULA for this server has been accepted, restarting server now.',
});
}).fail(function (jqXHR) {
console.error(jqXHR);
swal({
title: 'Whoops!',
text: 'An error occured while attempting to set the EULA as accepted: ' . jqXHR.responseJSON.error,
type: 'error'
})
});
});
}
});
});