2016-01-20 20:56:40 +00:00
|
|
|
/**
|
2016-01-20 21:05:16 +00:00
|
|
|
* Pterodactyl - Panel
|
2017-01-24 22:57:08 +00:00
|
|
|
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>
|
2016-01-20 20:56:40 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2016-01-10 05:38:16 +00:00
|
|
|
function randomKey(length) {
|
|
|
|
var text = '';
|
|
|
|
var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
|
|
|
|
|
|
for( var i=0; i < length; i++ ) {
|
|
|
|
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
|
|
}
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
2016-01-10 23:57:22 +00:00
|
|
|
function escapeRegExp(str) {
|
|
|
|
return str.replace(/^\/|\/$/g, '');
|
|
|
|
}
|
2016-01-08 23:58:03 +00:00
|
|
|
$(document).ready(function () {
|
|
|
|
$.urlParam=function(name){var results=new RegExp("[\\?&]"+name+"=([^&#]*)").exec(decodeURIComponent(window.location.href));if(results==null){return null}else{return results[1]||0}};function getPageName(url){var index=url.lastIndexOf("/")+1;var filenameWithExtension=url.substr(index);var filename=filenameWithExtension.split(".")[0];return filename}
|
|
|
|
function centerModal(element) {
|
|
|
|
var modal = (element.length > 0) ? element : $('.modal:visible');
|
|
|
|
var clone = modal.clone().css('display', 'block').appendTo('body');
|
|
|
|
var top = Math.round((clone.height() - clone.find('.modal-content').height()) / 3);
|
|
|
|
clone.remove();
|
|
|
|
modal.find('div.modal-content').css('margin-top', top);
|
|
|
|
}
|
|
|
|
$('body').on('show.bs.modal', '.modal', function() {
|
|
|
|
centerModal($(this));
|
|
|
|
});
|
|
|
|
$(window).on('resize', centerModal);
|
2016-11-27 00:56:19 +00:00
|
|
|
|
|
|
|
// Idea code for multiplicators submitted by @Taronyuu on Github
|
|
|
|
// https://github.com/Pterodactyl/Panel/issues/154#issuecomment-257116078
|
|
|
|
$('input[data-multiplicator="true"]').on('change', function () {
|
|
|
|
var value = $(this).val();
|
|
|
|
if (!/^\d+$/.test(value)) {
|
|
|
|
var multiplicator = value.replace(/[0-9]/g, '').toLowerCase();
|
|
|
|
value = value.replace(/\D/g, '');
|
|
|
|
|
|
|
|
if (multiplicator === 't') {
|
|
|
|
value = value * (1024 * 1024);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (multiplicator === 'g') {
|
|
|
|
value = value * 1024;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$(this).val(value);
|
|
|
|
});
|
2016-01-08 23:58:03 +00:00
|
|
|
});
|