Add multiplicators to certain inputs, closes #154
Allows for users to enter `10g` into a memory field and have it converted to 10GB equivalent in MB.
This commit is contained in:
parent
90cd2b677e
commit
e47bb6ef0f
5 changed files with 29 additions and 9 deletions
20
public/js/admin.min.js
vendored
20
public/js/admin.min.js
vendored
|
@ -46,4 +46,24 @@ $(document).ready(function () {
|
|||
centerModal($(this));
|
||||
});
|
||||
$(window).on('resize', centerModal);
|
||||
|
||||
// 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);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue