console.log();
let php_conf = JSON.parse('{{mod.confs_php|json_encode|raw}}');
let initial_conf = JSON.parse('{{mod.tab|json_encode|raw}}');
let timezone_data = JSON.parse('{{mod.timezone_data|json_encode|raw}}');
let editor_one = null;
let uchip = null;
function disableConf(elem){
let id = $(elem).data('line');
let st = $(elem).data('status');
let fa_icon = 'fa-check';
let new_icon = 'fa-ban';
let css_class = 'btn-success';
let new_css_class = 'btn-warning';
let msg = '{{langmod.PHPINIDISABLED}}';
let new_st = 0;
if(st == 0){
msg = '{{langmod.PHPINIENABLED}}';
fa_icon = 'fa-ban';
new_icon = 'fa-check';
css_class = 'btn-warning';
new_css_class = 'btn-success';
new_st = 1;
}
uchip.handleButton(elem, fa_icon);
uchip.call('module=phpini_editor&acc=changestconf', {
data:"id=" + id + "&file=" + Base64.encode($("#hfilename").val()),
callback: function(response){
uchip.handleButton(elem, new_icon, true);
$(elem).removeClass(css_class);
$(elem).addClass(new_css_class);
noti_bubble(msg,'{{langmod.PHPINISUCCESS}}','success',true,false,'3000',true);
$(elem).data('status', new_st);
updateEditor();
}
});
}
function updateEditor(){
let content = '';
$('.conf_item').each(function(){
let tag = $(this).find('.conf_item_tag').val();
let value = $(this).find('.conf_item_value').val().replaceAll('"','"');
let st = $(this).find('.item_status_button').data('status') != 1 && tag.substring(0, 2) != ';;' ? ';;' : '';
content += st + tag.replaceAll('__','.') + '=' + value + '\n';
});
editor_one.setValue(content);
}
String.prototype.replaceAll = function(search, replacement) {
var target = this;
return target.split(search).join(replacement);
};
function updatePHPConf(elem){
let confs = [];
let content = '';
$('.conf_item').each(function(){
let tag = $(this).find('.conf_item_tag').val();
let value = $(this).find('.conf_item_value').val();
confs.push({
tag : tag,
value : value
});
let st = $(this).find('.item_status_button').data('status') != 1 && tag.substring(0, 2) != ';;' ? ';;' : '';
content += st + tag.replaceAll('__','.') + '=' + value + '\n';
});
// console.log(JSON.stringify(confs).replaceAll('&', '{AMPERSAND}'));
let config_options = Base64.encode(JSON.stringify(confs).replaceAll('&', '{AMPERSAND}').replaceAll('__', '.'));
config_options = encodeURIComponent(config_options);
// console.log(Base64.decode(mamasita));
// return;
uchip.handleButton(elem, 'fa-floppy-o');
uchip.call('module=phpini_editor&acc=updateconf', {
data: 'data_conf=' + config_options + '&file=' + Base64.encode($('#hfilename').val()),
callback: function(response){
if(response.result == 'success'){
noti_bubble('{{langmod.PHPEXIT}}','{{langmod.PHPINISUCCESS}}','success',true,false,'3000',true);
editor_one.setValue(content);
}else if(response.result == 'warning'){
noti_bubble('{{langmod.PHPINVALIDINPUT2}}
' + response.errors.join(': {{langmod.PHPINVALIDINPUT}}
') + ': {{langmod.PHPINVALIDINPUT}}','{{langmod.PHPINISUCCESS}}','warning',true,false,'6000',true);
// editor_one.setValue(content);
response.errors.forEach(function(tagerror){
tagerror = tagerror.replaceAll(';;','').replaceAll('__','.');
$('#tag_value_' + tagerror).val('');
});
let content = '';
$('.conf_item').each(function(){
let tag = $(this).find('.conf_item_tag').val();
let value = $(this).find('.conf_item_value').val();
let st = $(this).find('.item_status_button').data('status') != 1 && tag.substring(0, 2) != ';;' ? ';;' : '';
content += st + tag.replaceAll('__','.') + '=' + value + '\n';
});
editor_one.setValue(content);
}else if(response.result == 'error'){
noti_bubble('{{langmod.ERRORINI}}','{{langmod.ERROR1}}','error',true,false,'3000',true);
}
uchip.handleButton(elem, 'fa-floppy-o', true);
}
});
}
function checkSideBar(){
let scroll = $(window).scrollTop();
let sidebar = $('#sidebar_phpini');
let phpini_table = $('#phpini_table');
let table_position = phpini_table.offset();
let table_height = phpini_table.height();
let table_bottom = table_height + table_position.top;
let sidebar_position = sidebar.offset();
let sidebar_bottom = sidebar.height() + sidebar_position.top;
if(sidebar_bottom > table_bottom){
let new_top = table_bottom - table_position.top - sidebar.height();
sidebar.animate({top:new_top}, 200);
}
}
function saveFromEditor(elem){
// console.log(editor_one.getValue());
uchip.handleButton('.save-from-editor', 'fa-floppy-o');
let conf_data = Base64.encode(editor_one.getValue().replaceAll('&', '{AMPERSAND}'));
conf_data = encodeURIComponent(conf_data);
uchip.call('module=phpini_editor&acc=updatefromeditor', {
data: 'data_conf=' + conf_data + '&file=' + Base64.encode($('#hfilename').val()),
callback: function(response){
if(response.result == 'success'){
noti_bubble('{{langmod.PHPEXIT}}','{{langmod.PHPINISUCCESS}}','success',true,false,'3000',true);
listConfiguration(response.list);
}else{
noti_bubble('{{langmod.ERRORINI}}','{{langmod.ERROR1}}','error',true,false,'3000',true);
}
uchip.handleButton('.save-from-editor', 'fa-floppy-o', true);
}
});
}
$(function () {
uchip = {% if mod.isie == 1 %} new $.Uchip(); {% else %} new Uchip(); {% endif %}
editor_one = CodeMirror.fromTextArea(document.getElementById("code1"), {
lineNumbers: true,
matchBrackets: true,
styleActiveLine: true,
theme: "ambiance"
});
editor_one.on('change', function (cMirror) {
code1hiden.value = cMirror.getValue();
});
$(window).scroll(function () {
let scroll = $(window).scrollTop();
let sidebar = $('#sidebar_phpini');
let phpini_table = $('#phpini_table');
let table_position = phpini_table.offset();
let table_bottom = phpini_table.height() + table_position.top;
let sidebar_position = sidebar.offset();
let sidebar_bottom = sidebar.height() + sidebar_position.top;
if (scroll > table_position.top) {
let new_top = scroll - table_position.top;
if (scroll < sidebar_position.top || sidebar_bottom < table_bottom) {
sidebar.css('top', new_top);
}
} else if (scroll < table_position.top) {
sidebar.css('top', 0);
}
});
});
function addNewRecord(elem){
let is_custom = $('#custom_conf').is(':visible');
let is_valid = true;
if(is_custom && $('#custom_conf').val() == ''){
$('#custom_conf').addClass('error');
is_valid = false;
}else if(!is_custom && $('#addnew_sel').val() == ''){
$('#addnew_sel').addClass('error');
is_valid = false;
}
if($('#addvalue').val() == ''){
$('#addvalue').addClass('error');
is_valid = false;
}
if(!is_valid){
noti_bubble('{{langmod.PHPINIREQFILEDS}}','{{langmod.ERROR1}}','error',true,false,'3000',true);
return;
}else{
uchip.handleButton(elem,'fa-plus');
let label = is_custom ? $('#custom_conf').val() : $('#addnew_sel').val();
uchip.call('module=phpini_editor&acc=addlabelphpini', {
data: 'label=' + Base64.encode(label)+'&value=' + Base64.encode($('#addvalue').val().replaceAll('&', '{AMPERSAND}')) + '&file=' + Base64.encode($('#hfilename').val()),
callback: function(response){
if(response.result == 'success'){
noti_bubble('{{langmod.EXIST}}','{{langmod.EXITO}}','success',true,false,'3000',true);
if(!is_custom){
$("#addnew_sel option[value='" + response.conf.label + "']").remove();
}
// conf_value.replaceAll('{DQ_CWP}','"')
let val_new = response.conf.value.replaceAll('{SQ_CWP}',"'").replaceAll('{DQ_CWP}','"');
let row_conf = '
{{langmod.SETTING}} | ' + '{{langmod.VALUE}} | ' + 'Actions | ' + '
---|
{{ langmod.ALERTDELETE }} ' + name.replaceAll(';;','').replaceAll('__','.') + ' {{ langmod.ALERTDELETE2 }}
'; var varfooter=' '; $("#deletemodal .modal-header").html(varheader); $("#deletemodal .modal-body").html(varbody); $("#deletemodal .modal-footer").html(varfooter); $("#deletemodal").modal('toggle'); }else if(st==1){ uchip.handleButton('#pc_button_delete_' + id, 'fa-trash'); $('#phpconf_line_' + id).addClass('deleting_tr'); $("#deletemodal").modal('hide'); uchip.call('module=phpini_editor&acc=deletephpini', { data: 'id=' + id + '&file=' + Base64.encode($('#hfilename').val()), callback: function(response){ noti_bubble('{{langmod.PHPINIDELSUCC}}','{{langmod.PHPINISUCCESS}}','success',true,false,'3000',true); $('#phpconf_line_' + id).slideUp('fast', function(){ $(this).remove(); updateEditor(); if($('#conteditphp tr').length < 1){ $('#phpini_table_container').slideUp('fast', function(){ $(this).html(conf_table_empty); $(this).slideDown('fast'); }); } }); let label = $('#pc_item_' + id).val().replaceAll('__','.'); $('#addnew_sel').append(''); } }); } return false; } selectConfs(initial_conf); $('.typeahead_3').typeahead({ source: timezone_data, }); function cancelNewRecord(){ $('#addnew_sel').val(''); $('#addvalue').val(''); $('#custom_conf').val(''); $('#control_new').slideUp('fast'); if($('#custom_conf').is(':visible')){ $('#custom_conf').fadeOut('fast', function(){ $('#addnew_sel').fadeIn('fast'); }); } } function changeFileConf(elem){ let container = $('#phpini_table_container'); container.parent().find('.col-md-3').hide(); container.removeClass('col-md-9'); container.addClass('col-md-12'); container.html('