QB.Phone.Settings = {};
QB.Phone.Settings.Background = "default-QBCore";
QB.Phone.Settings.OpenedTab = null;
QB.Phone.Settings.Backgrounds = {
'default-QBCore': {
label: "Standard QBCore"
}
};
var PressedBackground = null;
var PressedBackgroundObject = null;
var OldBackground = null;
var IsChecked = null;
$(document).on('click', '.settings-app-tab', function(e){
e.preventDefault();
var PressedTab = $(this).data("settingstab");
if (PressedTab == "background") {
QB.Phone.Animations.TopSlideDown(".settings-"+PressedTab+"-tab", 200, 0);
QB.Phone.Settings.OpenedTab = PressedTab;
} else if (PressedTab == "profilepicture") {
QB.Phone.Animations.TopSlideDown(".settings-"+PressedTab+"-tab", 200, 0);
QB.Phone.Settings.OpenedTab = PressedTab;
} else if (PressedTab == "numberrecognition") {
var checkBoxes = $(".numberrec-box");
QB.Phone.Data.AnonymousCall = !checkBoxes.prop("checked");
checkBoxes.prop("checked", QB.Phone.Data.AnonymousCall);
if (!QB.Phone.Data.AnonymousCall) {
$("#numberrecognition > p").html('Off');
} else {
$("#numberrecognition > p").html('On');
}
}
});
$(document).on('click', '#accept-background', function(e){
e.preventDefault();
var hasCustomBackground = QB.Phone.Functions.IsBackgroundCustom();
if (hasCustomBackground === false) {
QB.Phone.Notifications.Add("fas fa-paint-brush", "Settings", QB.Phone.Settings.Backgrounds[QB.Phone.Settings.Background].label+" is set!")
QB.Phone.Animations.TopSlideUp(".settings-"+QB.Phone.Settings.OpenedTab+"-tab", 200, -100);
$(".phone-background").css({"background-image":"url('/html/img/backgrounds/"+QB.Phone.Settings.Background+".png')"})
} else {
QB.Phone.Notifications.Add("fas fa-paint-brush", "Settings", "Personal background set!")
QB.Phone.Animations.TopSlideUp(".settings-"+QB.Phone.Settings.OpenedTab+"-tab", 200, -100);
$(".phone-background").css({"background-image":"url('"+QB.Phone.Settings.Background+"')"});
}
$.post('https://qb-phone/SetBackground', JSON.stringify({
background: QB.Phone.Settings.Background,
}))
});
QB.Phone.Functions.LoadMetaData = function(MetaData) {
if (MetaData.background !== null && MetaData.background !== undefined) {
QB.Phone.Settings.Background = MetaData.background;
} else {
QB.Phone.Settings.Background = "default-QBCore";
}
var hasCustomBackground = QB.Phone.Functions.IsBackgroundCustom();
if (!hasCustomBackground) {
$(".phone-background").css({"background-image":"url('/html/img/backgrounds/"+QB.Phone.Settings.Background+".png')"})
} else {
$(".phone-background").css({"background-image":"url('"+QB.Phone.Settings.Background+"')"});
}
if (MetaData.profilepicture == "default") {
$("[data-settingstab='profilepicture']").find('.settings-tab-icon').html('
');
} else {
$("[data-settingstab='profilepicture']").find('.settings-tab-icon').html('');
}
}
$(document).on('click', '#cancel-background', function(e){
e.preventDefault();
QB.Phone.Animations.TopSlideUp(".settings-"+QB.Phone.Settings.OpenedTab+"-tab", 200, -100);
});
QB.Phone.Functions.IsBackgroundCustom = function() {
var retval = true;
$.each(QB.Phone.Settings.Backgrounds, function(i, background){
if (QB.Phone.Settings.Background == i) {
retval = false;
}
});
return retval
}
$(document).on('click', '.background-option', function(e){
e.preventDefault();
PressedBackground = $(this).data('background');
PressedBackgroundObject = this;
OldBackground = $(this).parent().find('.background-option-current');
IsChecked = $(this).find('.background-option-current');
if (IsChecked.length === 0) {
if (PressedBackground != "custom-background") {
QB.Phone.Settings.Background = PressedBackground;
$(OldBackground).fadeOut(50, function(){
$(OldBackground).remove();
});
$(PressedBackgroundObject).append('
');
} else {
QB.Phone.Notifications.Add("fas fa-paint-brush", "Settings", "Personal avatar set!")
QB.Phone.Animations.TopSlideUp(".settings-"+QB.Phone.Settings.OpenedTab+"-tab", 200, -100);
$("[data-settingstab='profilepicture']").find('.settings-tab-icon').html('