Linux lhjmq-records 5.15.0-118-generic #128-Ubuntu SMP Fri Jul 5 09:28:59 UTC 2024 x86_64
Your IP : 18.191.14.104
var typePage = getParameterByName('type');
var idTypePage = getParameterByName('id');
var idSegment=0,idSection=0,idCategorie=0,idSubcategorie=0;
var getKeys = function(obj)
{
var keys = [];
for(var key in obj)
{
keys.push(key+'\n');
}
return keys;
}
switch(typePage)
{
case 'seg': idSegment=idTypePage;
idSection=0;
idCategorie=0;
idSubcategorie=0;
break;
case 'sec': idSection=idTypePage;
idCategorie=0;
idSubcategorie=0;
break;
case 'cat': idCategorie=idTypePage;
idSubcategorie=0;
break;
case 'scat': idSubcategorie=idTypePage;
break;
}
function getParameterByName(name)
{
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
CKEDITOR.plugins.add('collapse', {
lang: ['fr','en'],
init : function( editor ) {
var pluginName = 'Collapse';
function selectTabDefinition(langCode, lang) {
return {
id: 'SELECT',
label: lang.selectTab,
elements:[{
type: 'vbox',
children:[{
type: 'select',
id : 'segment',
label : lang.segment,
items : [[' --- '+ lang.segment +' --- ', '']],
style : 'width:300px',
validate : CKEDITOR.dialog.validate.notEmpty(lang.segmentError),
required :true,
onChange: function()
{
var secElement = this.getDialog().getContentElement('SELECT','section');
secElement.clear();
secElement.add(' --- '+ lang.category +' --- ', '', 1);
$.ajax ({url : '/administration/ajax/collapse/loadSections.php',
dataType:'json',
data:{segment:this.getValue(),lang:langCode}
}).done(function(data)
{
secElement.clear();
$.each(data, function(index, row)
{
secElement.add(row.secName, row.section, index+1);
});
if (idSection!=0)
secElement.setValue(idSection);
});
}
},{
type: 'select',
style : 'width:300px',
id : 'section',
label : lang.section,
items : [[' --- '+ lang.section +' --- ', '']],
className: 'catSelect',
required: false,
onChange: function()
{
var CatElement = this.getDialog().getContentElement('SELECT','categorie');
CatElement.clear();
CatElement.add(' --- '+ lang.question +' --- ', '', 1);
$.ajax ({url : '/administration/ajax/collapse/loadCategories.php',
dataType:'json',
data:{section:this.getValue(),
lang:langCode}
}).done(function(data)
{
CatElement.clear();
$.each(data, function(index, row)
{
CatElement.add(row.catName, row.categorie, index+1);
});
if (idCategorie!=0)
CatElement.setValue(idCategorie);
});
}
},{
type: 'select',
style : 'width:300px',
id : 'categorie',
label : lang.categorie,
items : [[' --- '+ lang.categorie +' --- ', '']],
className: 'catSelect',
required: false,
onChange: function()
{
var scatElement = this.getDialog().getContentElement('SELECT','subcategorie');
scatElement.clear();
scatElement.add(' --- '+ lang.question +' --- ', '', 1);
$.ajax ({url : '/administration/ajax/collapse/loadSubcategories.php',
dataType:'json',
data:{categorie:this.getValue(),lang:langCode}
}).done(function(data)
{
scatElement.clear();
$.each(data, function(index, row)
{
scatElement.add(row.scatName, row.subcategorie, index+1);
});
if (idSubcategorie!=0)
scatElement.setValue(idSubcategorie);
});
var questionElement = this.getDialog().getContentElement('SELECT','question');
questionElement.add(' --- '+ lang.question +' --- ', '', 1);
$.ajax ({url : '/administration/ajax/collapse/loadQuestions.php',
dataType:'json',
data:{categorie:this.getValue(),
lang:langCode}
}).done(function(data)
{
questionElement.clear();
questionElement.add(' --- '+ lang.question +' --- ', '', 1);
$.each(data, function(index, row)
{
questionElement.add(row.questionName, row.question, index+1);
});
});
}
},{
type: 'select',
style : 'width:300px',
id : 'subcategorie',
label : lang.subcategorie,
items : [[' --- '+ lang.subcategorie +' --- ', '']],
className: 'catSelect',
required: false,
onChange: function()
{
var questionElement = this.getDialog().getContentElement('SELECT','question');
questionElement.add(' --- '+ lang.question +' --- ', '', 1);
$.ajax ({url : '/administration/ajax/collapse/loadQuestions.php',
dataType:'json',
data:{subcategorie:this.getValue(),
lang:langCode}
}).done(function(data)
{
questionElement.clear();
questionElement.add(' --- '+ lang.question +' --- ', '', 1);
$.each(data, function(index, row)
{
questionElement.add(row.questionName, row.question, index+1);
});
});
}
},{
type: 'select',
style : 'width:300px',
id : 'question',
//validate : CKEDITOR.dialog.validate.notEmpty(lang.questionError),
label : lang.question,
items : [[' --- ' + lang.question + ' --- ', '']],
required :false,
onChange: function()
{
var dialog = this.getDialog();
$.ajax ({url : '/administration/ajax/collapse/loadQuestions.php',
dataType:'json',
data:{qid:this.getValue(),
lang: langCode}
}).done(function(data)
{
});
}
}]
}]
};
}
CKEDITOR.dialog.add('collapse', function(editor)
{
return {
title : editor.lang.collapse.title,
buttons: [CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton],
resizable: CKEDITOR.DIALOG_RESIZE_NONE,
minWidth: 300,
minHeight: 200,
contents: [selectTabDefinition(editor.langCode, editor.lang.collapse)], //editTabDefinition(editor.langCode, editor.lang.collapse)],
onOk: function(data)
{
var collapseTag='';
if (this.getContentElement('SELECT','segment').getValue()!="")
collapseTag='[collapse]seg=' + this.getContentElement('SELECT','segment').getValue() + '[/collapse]';
if (this.getContentElement('SELECT','section').getValue()!="")
collapseTag='[collapse]sec=' + this.getContentElement('SELECT','section').getValue() + '[/collapse]';
if (this.getContentElement('SELECT','categorie').getValue()!="")
collapseTag='[collapse]cat=' + this.getContentElement('SELECT','categorie').getValue() + '[/collapse]';
if (this.getContentElement('SELECT','subcategorie').getValue()!="")
collapseTag='[collapse]scat=' + this.getContentElement('SELECT','subcategorie').getValue() + '[/collapse]';
if (this.getContentElement('SELECT','question').getValue()!="")
collapseTag='[collapse]q=' + this.getContentElement('SELECT','question').getValue() + '[/collapse]';
this.getParentEditor().insertText(collapseTag); // BIIIIIEN.
} ,
onShow: function()
{
var segment = this.getContentElement('SELECT', 'segment');
$.ajax ({url : '/administration/ajax/collapse/load_segments.php',
dataType:'json',
data:{lang:editor.langCode}
}).done(function(data)
{
$.each(data, function(index, row)
{
segment.add(row.segName, row.segment, index + 1);
if (idSegment!=0)
{
segment.setValue(idSegment);
}
if(idSection!=0)
{
$.ajax ({url : '/administration/ajax/collapse/load_segments.php',
dataType:'json',
data:{idSection:idSection}
}).done(function(data)
{
$.each(data, function(index, row)
{
idSection = row.section;
idSegment = row.segment;
segment.setValue(idSegment);
section.setValue(idSection);
});
});
}
if(idCategorie!=0)
{
$.ajax ({url : '/administration/ajax/collapse/load_segments.php',
dataType:'json',
data:{idCategorie:idCategorie}
}).done(function(data)
{
$.each(data, function(index, row)
{
idCategorie = row.categorie;
idSection = row.section;
idSegment = row.segment;
segment.setValue(idSegment);
});
});
}
if(idSubcategorie!=0)
{
$.ajax ({url : '/administration/ajax/collapse/load_segments.php',
dataType:'json',
data:{idSubcategorie:idSubcategorie}
}).done(function(data)
{
$.each(data, function(index, row)
{
idSubcategorie = row.subcategorie;
idCategorie = row.categorie;
idSection = row.section;
idSegment = row.segment;
segment.setValue(idSegment);
});
});
}
});
});
}
};
});
editor.addCommand('collapse', new CKEDITOR.dialogCommand('collapse'));
editor.ui.addButton('Collapse', { label: 'Collapse',
command: 'collapse',
icon: this.path + 'images/collapse.png'});
}
});
|