mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-03 13:01:10 +02:00
Merge pull request #13580 from SimonWalton-HiFi/avatar-settings-validate
Validate user-supplied avatar height range before accepting
This commit is contained in:
commit
071a11ce93
2 changed files with 48 additions and 5 deletions
|
@ -1223,7 +1223,7 @@
|
||||||
"name": "max_avatar_height",
|
"name": "max_avatar_height",
|
||||||
"type": "double",
|
"type": "double",
|
||||||
"label": "Maximum Avatar Height (meters)",
|
"label": "Maximum Avatar Height (meters)",
|
||||||
"help": "Limits the scale of avatars in your domain. Cannot be greater than 1755.",
|
"help": "Limits the height of avatars in your domain. Cannot be greater than 1755.",
|
||||||
"placeholder": 5.2,
|
"placeholder": 5.2,
|
||||||
"default": 5.2
|
"default": 5.2
|
||||||
},
|
},
|
||||||
|
|
|
@ -58,7 +58,11 @@ $(document).ready(function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings.handlePostSettings = function(formJSON) {
|
Settings.handlePostSettings = function(formJSON) {
|
||||||
|
|
||||||
|
if (!verifyAvatarHeights()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// check if we've set the basic http password
|
// check if we've set the basic http password
|
||||||
if (formJSON["security"]) {
|
if (formJSON["security"]) {
|
||||||
|
|
||||||
|
@ -207,7 +211,7 @@ $(document).ready(function(){
|
||||||
swal({
|
swal({
|
||||||
title: '',
|
title: '',
|
||||||
type: 'error',
|
type: 'error',
|
||||||
text: "There was a problem retreiving domain information from High Fidelity API.",
|
text: "There was a problem retrieving domain information from High Fidelity API.",
|
||||||
confirmButtonText: 'Try again',
|
confirmButtonText: 'Try again',
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
closeOnConfirm: false
|
closeOnConfirm: false
|
||||||
|
@ -288,7 +292,7 @@ $(document).ready(function(){
|
||||||
swal({
|
swal({
|
||||||
title: 'Create new domain ID',
|
title: 'Create new domain ID',
|
||||||
type: 'input',
|
type: 'input',
|
||||||
text: 'Enter a label this machine.</br></br>This will help you identify which domain ID belongs to which machine.</br></br>',
|
text: 'Enter a label for this machine.</br></br>This will help you identify which domain ID belongs to which machine.</br></br>',
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
confirmButtonText: "Create",
|
confirmButtonText: "Create",
|
||||||
closeOnConfirm: false,
|
closeOnConfirm: false,
|
||||||
|
@ -669,7 +673,7 @@ $(document).ready(function(){
|
||||||
var spinner = createDomainSpinner();
|
var spinner = createDomainSpinner();
|
||||||
$('#' + Settings.PLACES_TABLE_ID).after($(spinner));
|
$('#' + Settings.PLACES_TABLE_ID).after($(spinner));
|
||||||
|
|
||||||
var errorEl = createDomainLoadingError("There was an error retreiving your places.");
|
var errorEl = createDomainLoadingError("There was an error retrieving your places.");
|
||||||
$("#" + Settings.PLACES_TABLE_ID).after(errorEl);
|
$("#" + Settings.PLACES_TABLE_ID).after(errorEl);
|
||||||
|
|
||||||
// do we have a domain ID?
|
// do we have a domain ID?
|
||||||
|
@ -1091,4 +1095,43 @@ $(document).ready(function(){
|
||||||
|
|
||||||
$('#settings_backup .panel-body').html(html);
|
$('#settings_backup .panel-body').html(html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function verifyAvatarHeights() {
|
||||||
|
var errorString = '';
|
||||||
|
var minAllowedHeight = 0.009;
|
||||||
|
var maxAllowedHeight = 1755;
|
||||||
|
var alertCss = { backgroundColor: '#ffa0a0' };
|
||||||
|
var minHeightElement = $('input[name="avatars.min_avatar_height"]');
|
||||||
|
var maxHeightElement = $('input[name="avatars.max_avatar_height"]');
|
||||||
|
|
||||||
|
var minHeight = Number(minHeightElement.val());
|
||||||
|
var maxHeight = Number(maxHeightElement.val());
|
||||||
|
|
||||||
|
if (maxHeight < minHeight) {
|
||||||
|
errorString = 'Maximum avatar height must not be less than minimum avatar height<br>';
|
||||||
|
minHeightElement.css(alertCss);
|
||||||
|
maxHeightElement.css(alertCss);
|
||||||
|
};
|
||||||
|
if (minHeight < minAllowedHeight) {
|
||||||
|
errorString += 'Minimum avatar height must not be less than ' + minAllowedHeight + '<br>';
|
||||||
|
minHeightElement.css(alertCss);
|
||||||
|
}
|
||||||
|
if (maxHeight > maxAllowedHeight) {
|
||||||
|
errorString += 'Maximum avatar height must not be greater than ' + maxAllowedHeight + '<br>';
|
||||||
|
maxHeightElement.css(alertCss);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errorString.length > 0) {
|
||||||
|
swal({
|
||||||
|
type: 'error',
|
||||||
|
title: '',
|
||||||
|
text: errorString,
|
||||||
|
html: true
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue