MediaWiki:Gadget-LiveRC 1x.js/InserisciTemplate.js: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
Nessun oggetto della modifica |
Fixed by Dr Brains |
||
Riga 1:
/*
--------------------------------------------------------------------------------------
Riga 31 ⟶ 30:
{{Catégorisation JS|LiveRC}}
*/
//<source lang=javascript>
if (typeof(lrcHooks)!="undefined") { // DÉBUT IF
/////////////////////////////// CSS ///////////////////////////////////////////////////////
importStylesheetURI('//it.wikipedia.org/w/index.php?title=MediaWiki:Gadget-LiveRC 1x.js/InserisciTemplate.css&action=raw&ctype=text/css');
///////////////////////// VARIABLES ////////////////////////////////////////////////////////
Riga 157 ⟶ 159:
*/
Custom_lstMyTemplate = {};
lstMyTemplate = {
'A': { template:'A',
Riga 166 ⟶ 169:
motivo: {name: 'Motivo', type: 'string'},
argomento: {name: 'Argomento', type: 'select', value: templateArguments_A},
argomento2: {name: 'Argomento2', type: 'select', value: templateArguments_A},
mese: {name: 'Mese', type: 'string' , value: '{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}'}
}
},
Riga 180:
parameters: {
motivo: {name: 'Motivo', type: 'string'},
argomento: {name: 'Argomento', type: 'select', value: templateArguments_C},
mese: {name: 'Mese', type: 'string', value: '{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}'}
}
},
Riga 195 ⟶ 192:
motivo: {name: 'Motivo', type: 'string'},
argomento: {name: 'Argomento', type: 'select', value: templateArguments_E},
argomento2: {name: 'Argomento2', type: 'select', value: templateArguments_E},
mese: {name: 'Mese', type: 'string' , value: '{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}'}
}
},
Riga 209 ⟶ 203:
parameters: {
commento: {name: 'Commento', type: 'string'},
argomento: {name: 'Argomento', type: 'select', value: templateArguments_F},
mese: {name: 'Mese', type: 'string', value: '{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}'}
}
},
Riga 223 ⟶ 214:
parameters: {
argomento: {name: 'Argomento', type: 'select', value: templateArguments_O},
argomento2: {name: 'Argomento2', type: 'select', value: templateArguments_O},
mese: {name: 'Mese', type: 'string', value: '{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}'}
}
},
Riga 238 ⟶ 226:
motivo: {name: 'Motivo', type: 'string'},
argomento: {name: 'Argomento', type: 'select', value: templateArguments_P},
argomento2: {name: 'Argomento2', type: 'select', value: templateArguments_P},
mese: {name: 'Mese', type: 'string', value: '{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}'}
}
},
Riga 253 ⟶ 238:
argomento: {name: 'Argomento', type: 'select', value: templateArguments_S},
argomento2: {name: 'Argomento2', type: 'select', value: templateArguments_S}
}
},
Riga 265 ⟶ 247:
parameters: {
lingua: {name: 'Lingua', type: 'string'},
argomento: {name: 'Argomento', type: 'select', value: templateArguments_T},
mese: {name: 'Mese', type: 'string', value: '{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}'}
}
},
Riga 284 ⟶ 263:
argomento2: {name: 'Argomento2', type: 'select', value: templateArguments_U},
sezione: {name: 'Sezione', type: 'string'},
commento: {name: 'Commento', type: 'string'},
data: {name: 'Data', type: 'string' , value: '{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}'}
}
},
Riga 300 ⟶ 275:
argomento: {name: 'Argomento', type: 'select', value: templateArguments_Categorizzare},
commento: {name: 'Commento', type: 'string'}
}
},
Riga 313 ⟶ 285:
voce: {name: 'Nome voce', type: 'string'},
motivo: {name: 'Motivo', type: 'string'}
}
},
Riga 326 ⟶ 295:
argomento: {name: 'Argomento', type: 'select', value: templateArguments_Correggere},
argomento2: {name: 'Argomento2', type: 'select', value: templateArguments_Correggere},
commento: {name: 'Commento', type: 'string'},
mese: {name: 'Mese', type: 'string' , value: '{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}'}
}
},
Riga 339 ⟶ 305:
subst: false,
parameters: {
}
},
Riga 353 ⟶ 316:
argomento: {name: 'Argomento', type: 'select', value: templateArguments_DaAggiornare},
argomento2: {name: 'Argomento2', type: 'select', value: templateArguments_DaAggiornare},
commento: {name: 'Commento', type: 'string'},
mese: {name: 'Mese', type: 'string' , value: '{{subst:CURRENTMONTHNAME}}'},
anno: {name: 'Anno', type: 'string' , value: '{{subst:CURRENTYEAR}}'}
}
},
Riga 367 ⟶ 328:
parameters: {
fonte: {name: 'Fonte', type: 'string'}
}
},
Riga 379 ⟶ 337:
parameters: {
argomento: {name: 'argomento', type: 'select', value: templateArguments_Controlcopy},
motivo: {name: 'motivo', type: 'string'},
data: {name: 'Data', type: 'string' , value: '{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}'}
}
},
Riga 393 ⟶ 348:
parameters: {
url: {name: 'url', type: 'string'}
}
},
Riga 406 ⟶ 358:
arg: {name: 'arg', type: 'select', value: templateArguments_Cancellazione},
arg2: {name: 'arg2', type: 'select', value: templateArguments_Cancellazione}
}
},
Riga 419 ⟶ 368:
motivo: {name: 'motivo', type: 'select', value: templateArguments_CancellaSubito},
altroMotivo: {name: 'Altro motivo', type: 'string'}
}
},
Riga 436 ⟶ 382:
subst: false,
parameters: {
}
},
Riga 451 ⟶ 394:
titolo: {name: 'titolo', type: 'string' },
redirect: {name: 'redirect', type: 'string' }
}
}
};
function LiveRC_FormatTemplateParams(params) {
var text = new Array();
for(var arg in params){
if(params.hasOwnProperty(arg)) text.push(arg+"="+params[arg]);
}
return text.join("|");
}
// ####################################################################################################################
// ####################################################################################################################
function lrcRunInsertTemplate(data){
Riga 512 ⟶ 463:
return;
}
var Page = ObjetXML.getElementsByTagName("page")[0];
edittoken = Page.getAttribute("edittoken");
// show dialog
var tpl = InserisciTemplate_showDialog(message, page);
}
Riga 533 ⟶ 484:
// create the dialog html
$dialog = $('#gtb-dialog').html(
$('<a>')
.attr('href',
.attr('target', '_blank')
.attr('tabindex', '-1')
Riga 541 ⟶ 492:
.text(data.template)
.appendTo($dialog);
$dialog.append(
$fieldset = $('<fieldset>').css('border-color', 'gray').appendTo($dialog);
$('<legend>').text('Parametri').appendTo($fieldset);
Riga 584 ⟶ 535:
function InserisciTemplate_dumpTemplate(template, params) {
var text, templateParams = "";
templateParams = LiveRC_FormatTemplateParams(params || {});
text = (template.noinclude ? '<noinclude>' : '') +
'{{' + (template.subst ? 'subst:' : '') +
template.template +
(templateParams) +
'}}' +
(template.noinclude ? '</noinclude>' : '') + '\n';
Riga 640 ⟶ 590:
.attr('id', id)
.attr('type', 'text')
.attr('size', 50)
.attr('value', (data.value || ''));
} else if (data.type == 'checkbox') {
label = data.name;
Riga 662 ⟶ 613:
}
/* ########################################## CONFIGURATION PANEL ################################## */
// ===== Create a fieldset in the configuration panel =====
function InserisciTemplate_CreateConfigPanel(){
var InserisciTemplateUl = LiveRC_ManageParams_CreateNewListMenu("InserisciTemplateLegend", LiveRC_ManageParams_CreateActionButtons());
var Target = InserisciTemplateUl.parentNode;
var Templates = Custom_lstMyTemplate;
if(!Templates || lrcGetObjectLength(Templates)==0) Templates = lstMyTemplate;
for(var temp in Templates){
if(!Templates.hasOwnProperty(temp)) continue;
var Template = Templates[temp];
var TemplateForm = InserisciTemplate_CreateTemplateConfigPanel(Template);
Target.appendChild(TemplateForm);
}
var NewTemplate = document.createElement('p');
NewTemplate.id = "InserisciTemplate_AddNeTemplateP";
var NewTemplateLink = document.createElement('a');
NewTemplateLink.innerHTML = "(+)";
NewTemplateLink.title = lrcMakeText("IT_AddTemplate");
NewTemplateLink.href = "javascript:;";
NewTemplateLink.onclick = function(){ InserisciTemplate_AddNewTemplate(); };
NewTemplate.appendChild(NewTemplateLink);
Target.appendChild(NewTemplate);
InserisciTemplateUl.parentNode.removeChild(InserisciTemplateUl);
var ThisFieldset = document.getElementById("LiveRC_OptionsContent_InserisciTemplateLegend");
var TargetFieldset = document.getElementById("LiveRC_OptionsContent_lstParamMenuTabs");
if(ThisFieldset && TargetFieldset) TargetFieldset.parentNode.insertBefore(ThisFieldset, TargetFieldset);
}
LiveRC_AddHook("AfterCreateParamPanel", InserisciTemplate_CreateConfigPanel);
function InserisciTemplate_AddNewTemplate(){
var P = document.getElementById("InserisciTemplate_AddNeTemplateP");
if(!P) return;
var BlankTemplate = { template:'',
string:'',
where:'top',
noinclude: false,
subst: false,
parameters: {}
};
var NewDiv = InserisciTemplate_CreateTemplateConfigPanel(BlankTemplate);
P.parentNode.insertBefore(NewDiv, P);
}
function InserisciTemplate_DeleteTemplate(DeleteLink){
var Div = DeleteLink;
while(Div){
if(hasClass(Div, "InserisciTemplate_TemplateDiv")) break;
Div = Div.parentNode;
}
if(!Div) return;
Div.parentNode.removeChild(Div);
}
function InserisciTemplate_CreateTemplateConfigPanel(Template){
var TemplateDiv = document.createElement('div');
TemplateDiv.className = "InserisciTemplate_TemplateDiv ParamMenuLi";
var Legend = document.createElement('p');
var Title = document.createElement('a')
Title.className = "InserisciTemplate_template";
Title.innerHTML = "{{"+Template.template+"}} ";
Title.target = "_blank";
Title.href = lrcGetPageURL(lrcGetNamespaceName(10)+":"+Template.template);
Title.title = lrcGetNamespaceName(10)+":"+Template.template;
Title.onclick = function(){ liveArticle(lrcGetNamespaceName(10)+":"+Template.template); return false; };
Legend.appendChild(Title);
var DeleteTemplateLink = document.createElement('a');
DeleteTemplateLink.innerHTML = "(-)";
DeleteTemplateLink.title = lrcMakeText("IT_DeleteTemplate");
DeleteTemplateLink.href = "javascript:;";
DeleteTemplateLink.onclick = function(){ InserisciTemplate_DeleteTemplate(this); };
Legend.appendChild(DeleteTemplateLink);
TemplateDiv.appendChild(Legend);
var TemplateForm = document.createElement('form');
TemplateForm.className = "InserisciTemplate_TemplateForm";
TemplateDiv.appendChild(TemplateForm);
var UL = document.createElement('ul');
TemplateForm.appendChild(UL);
var LI_Template = document.createElement('li');
UL.appendChild(LI_Template);
// 'template': name of the template to be inserted
var Label_template = document.createElement('label');
Label_template.setAttribute('for', 'template');
Label_template.innerHTML = "template : ";
LI_Template.appendChild(Label_template);
var Input_template = document.createElement('input');
Input_template.id = 'template';
Input_template.type = "text";
Input_template.value = (Template.template || "");
LI_Template.appendChild(Input_template);
LI_Template.appendChild(document.createTextNode(" - "));
// 'string': option label in the template combo box
var Label_string = document.createElement('label');
Label_string.setAttribute('for', 'string');
Label_string.innerHTML = "string : ";
LI_Template.appendChild(Label_string);
var Input_string = document.createElement('input');
Input_string.id = 'string';
Input_string.type = "text";
Input_string.value = (Template.string || "");
LI_Template.appendChild(Input_string);
LI_Template.appendChild(document.createTextNode(" - "));
// 'where': where to insert the template in the page (top or bottom)
var Label_where = document.createElement('label');
Label_where.setAttribute('for', 'where');
Label_where.innerHTML = "where : ";
LI_Template.appendChild(Label_where);
var Select_where = document.createElement('select');
Select_where.id = 'where';
var Opts = ["top", "bottom"];
for(var a=0,l=Opts.length;a<l;a++){
var OptValue = Opts[a];
var Opt = document.createElement('option');
Opt.innerHTML = OptValue;
Opt.value = OptValue;
if(OptValue == Template.where) Opt.selected = "selected";
Select_where.appendChild(Opt);
}
LI_Template.appendChild(Select_where);
LI_Template.appendChild(document.createTextNode(" - "));
// 'noinclude': whether the template shall be tagged with "noinclude"
var Label_noinclude = document.createElement('label');
Label_noinclude.setAttribute('for', 'noinclude');
Label_noinclude.innerHTML = "noinclude : ";
LI_Template.appendChild(Label_noinclude);
var Input_noinclude = document.createElement('input');
Input_noinclude.id = 'noinclude';
Input_noinclude.type = "checkbox";
if(Template.noinclude) Input_noinclude.checked = "checked";
LI_Template.appendChild(Input_noinclude);
LI_Template.appendChild(document.createTextNode(" - "));
// 'subst': whether the template shall be "substed"
var Label_subst = document.createElement('label');
Label_subst.setAttribute('for', 'subst');
Label_subst.innerHTML = "subst : ";
LI_Template.appendChild(Label_subst);
var Input_subst = document.createElement('input');
Input_subst.id = 'subst';
Input_subst.type = "checkbox";
if(Template.subst) Input_subst.checked = "checked";
LI_Template.appendChild(Input_subst);
// 'parameters'
var LI_parameters = document.createElement('li');
UL.appendChild(LI_parameters);
var Label_parameters = document.createElement('label');
Label_parameters.setAttribute('for', 'parameters');
Label_parameters.innerHTML = "parameters : ";
LI_parameters.appendChild(Label_parameters);
var ParamsUL = document.createElement('ul');
ParamsUL.id = 'parameters';
LI_parameters.appendChild(ParamsUL);
for(var param in Template.parameters){
if(!Template.parameters.hasOwnProperty(param)) continue;
var LI_Param = InserisciTemplate_CreateNewParam(param, Template.parameters[param]);
ParamsUL.appendChild(LI_Param);
}
var Li_NewParam = document.createElement('li');
var Link_NewParam = document.createElement('a');
Link_NewParam.innerHTML = "(+)";
Link_NewParam.title = lrcMakeText("IT_AddParam");
Link_NewParam.href = "javascript:;";
Link_NewParam.onclick = function(){ InserisciTemplate_AddParamToTemplate(this); };
Li_NewParam.appendChild(Link_NewParam);
ParamsUL.appendChild(Li_NewParam);
return TemplateDiv;
}
function InserisciTemplate_AddParamToTemplate(AddParamLink){
var Li = AddParamLink.parentNode;
var NewParams = {name: '', type: 'string', value: ''};
var NewParamLi = InserisciTemplate_CreateNewParam("", NewParams);
Li.parentNode.insertBefore(NewParamLi, Li);
}
function InserisciTemplate_CreateNewParam(param, Params){
var ParamName = Params.name;
var ParamType = Params.type;
var ParamValue = Params.value;
var LI_Param = document.createElement('li');
LI_Param.className = "LI_parameters_li";
var DeleteParamLink = document.createElement('a');
DeleteParamLink.innerHTML = "(-)";
DeleteParamLink.title = lrcMakeText("IT_DeleteParam");
DeleteParamLink.href = "javascript:;";
DeleteParamLink.onclick = function(){ InserisciTemplate_DeleteParamFromTemplate(this); };
LI_Param.appendChild(DeleteParamLink);
LI_Param.appendChild(document.createTextNode(" - "));
//// parameters id
var Label_id = document.createElement('label');
Label_id.setAttribute('for', 'Param_id');
Label_id.innerHTML = "id : ";
LI_Param.appendChild(Label_id);
var Input_id = document.createElement('input');
Input_id.id = 'Param_id';
Input_id.type = "text";
Input_id.value = (param || "");
LI_Param.appendChild(Input_id);
LI_Param.appendChild(document.createTextNode(" - "));
//// parameters.name
var Label_name = document.createElement('label');
Label_name.setAttribute('for', 'Param_name');
Label_name.innerHTML = "name : ";
LI_Param.appendChild(Label_name);
var Input_name = document.createElement('input');
Input_name.id = 'Param_name';
Input_name.type = "text";
Input_name.value = (ParamName || "");
LI_Param.appendChild(Input_name);
LI_Param.appendChild(document.createTextNode(" - "));
//// parameters.type
var Label_type = document.createElement('label');
Label_type.setAttribute('for', 'Param_type');
Label_type.innerHTML = "type : ";
LI_Param.appendChild(Label_type);
var Select_type = document.createElement('select');
Select_type.id = 'Param_type';
var Opts = ["string", "select"];
for(var a=0,l=Opts.length;a<l;a++){
var OptValue = Opts[a];
var Opt = document.createElement('option');
Opt.innerHTML = OptValue;
Opt.value = OptValue;
if(OptValue == ParamType) Opt.selected = "selected";
Select_type.appendChild(Opt);
}
Select_type.onchange = function(){ InserisciTemplate_ChageValueType(this); }
LI_Param.appendChild(Select_type);
LI_Param.appendChild(document.createTextNode(" - "));
//// parameters.value
var Label_value = document.createElement('label');
Label_value.setAttribute('for', 'Param_value');
Label_value.innerHTML = "value : ";
LI_Param.appendChild(Label_value);
if(ParamType == "string"){
var Input_value = document.createElement('input');
Input_value.id = 'Param_value';
Input_value.type = "text";
Input_value.size = "30";
Input_value.value = (ParamValue || "");
LI_Param.appendChild(Input_value);
}else if(ParamType == "select"){
var Select_value = document.createElement('select');
Select_value.id = 'Param_value';
Select_value.style.width = '206px';
var Opts = ParamValue;
for(var a=0,l=Opts.length;a<l;a++){
var OptValue = Opts[a];
var Opt = document.createElement('option');
Opt.innerHTML = OptValue;
Opt.value = OptValue;
Select_value.appendChild(Opt);
}
LI_Param.appendChild(Select_value);
LI_Param.appendChild(document.createTextNode(" "));
var DeleteOptionLink = document.createElement('a');
DeleteOptionLink.innerHTML = "(-)";
DeleteOptionLink.title = lrcMakeText("IT_DeleteOption");
DeleteOptionLink.href = "javascript:;";
DeleteOptionLink.onclick = function(){ InserisciTemplate_DeleteOptionFromSelect(this); };
LI_Param.appendChild(DeleteOptionLink);
LI_Param.appendChild(document.createTextNode(" "));
var AddOptionLink = document.createElement('a');
AddOptionLink.innerHTML = "(+)";
AddOptionLink.title = lrcMakeText("IT_AddOption");
AddOptionLink.href = "javascript:;";
AddOptionLink.onclick = function(){ InserisciTemplate_AddOptionToSelect(this); };
LI_Param.appendChild(AddOptionLink);
}
return LI_Param;
}
function InserisciTemplate_ChageValueType(Select){
var NewType = Select.value;
var Li = Select.parentNode;
var Labels = Li.getElementsByTagName('label');
var LastLabel = Labels[(Labels.length-1)];
while(LastLabel.nextSibling){ LastLabel.nextSibling.parentNode.removeChild(LastLabel.nextSibling); }
if(NewType == "string"){
var Input_value = document.createElement('input');
Input_value.id = 'Param_value';
Input_value.type = "text";
Input_value.size = "30";
Input_value.value = "";
LastLabel.parentNode.appendChild(Input_value);
}else{
var Select_value = document.createElement('select');
Select_value.id = 'Param_value';
Select_value.style.width = '206px';
var Opt = document.createElement('option');
Opt.innerHTML = "";
Opt.value = "";
Select_value.appendChild(Opt);
LastLabel.parentNode.appendChild(Select_value);
LastLabel.parentNode.appendChild(document.createTextNode(" "));
var DeleteOptionLink = document.createElement('a');
DeleteOptionLink.innerHTML = "(-)";
DeleteOptionLink.title = lrcMakeText("IT_DeleteOption");
DeleteOptionLink.href = "javascript:;";
DeleteOptionLink.onclick = function(){ InserisciTemplate_DeleteOptionFromSelect(this); };
LastLabel.parentNode.appendChild(DeleteOptionLink);
LastLabel.parentNode.appendChild(document.createTextNode(" "));
var AddOptionLink = document.createElement('a');
AddOptionLink.innerHTML = "(+)";
AddOptionLink.title = lrcMakeText("IT_AddOption");
AddOptionLink.href = "javascript:;";
AddOptionLink.onclick = function(){ InserisciTemplate_AddOptionToSelect(this); };
LastLabel.parentNode.appendChild(AddOptionLink);
}
}
function InserisciTemplate_DeleteOptionFromSelect(DeleteOptionLink){
var Li = DeleteOptionLink.parentNode;
var Selects = Li.getElementsByTagName('select');
for(var a=0,l=Selects.length;a<l;a++){
var Select = Selects[a];
if(!Select.id || Select.id != 'Param_value') continue;
var SelectedOpt = Select.value;
var Options = Select.getElementsByTagName('option');
for(var b=0,m=Options.length;b<m;b++){
var thisOpt = Options[b];
if(thisOpt.value != SelectedOpt) continue;
thisOpt.parentNode.removeChild(thisOpt);
}
}
}
function InserisciTemplate_AddOptionToSelect(AddOptionLink){
var AddOptionForm = document.createElement('span');
var AddOptionInput = document.createElement('input');
AddOptionInput.type = 'text';
AddOptionForm.appendChild(AddOptionInput);
var AddOptionInputOK = document.createElement('input');
AddOptionInputOK.type = 'button';
AddOptionInputOK.value = lrcMakeText("OK");
AddOptionInputOK.onclick = function(){ InserisciTemplate_AddOptionToSelect_OK(this); };
AddOptionInputOK.onselect = function(){ InserisciTemplate_AddOptionToSelect_OK(this); };
AddOptionForm.appendChild(AddOptionInputOK);
var AddOptionInputCancel = document.createElement('input');
AddOptionInputCancel.type = 'button';
AddOptionInputCancel.value = lrcMakeText("Cancel");
AddOptionInputCancel.onclick = function(){ InserisciTemplate_AddOptionToSelect_Cancel(this); };
AddOptionInputCancel.onselect = function(){ InserisciTemplate_AddOptionToSelect_Cancel(this); };
AddOptionForm.appendChild(AddOptionInputCancel);
AddOptionLink.parentNode.insertBefore(AddOptionForm, AddOptionLink);
AddOptionLink.style.display = "none";
}
function InserisciTemplate_AddOptionToSelect_Cancel(AddOptionInputCancel){
var Span = AddOptionInputCancel.parentNode;
var Link = Span.nextSibling;
Span.parentNode.removeChild(Span);
Link.style.display = "";
}
function InserisciTemplate_AddOptionToSelect_OK(AddOptionInputOK){
var Input = AddOptionInputOK.previousSibling;
var NewOption = Input.value;
var Li = AddOptionInputOK.parentNode.parentNode;
var Selects = Li.getElementsByTagName('select');
for(var a=0,l=Selects.length;a<l;a++){
var Select = Selects[a];
if(!Select.id || Select.id != 'Param_value') continue;
var Option = document.createElement('option');
Option.innerHTML = NewOption;
Option.value = NewOption;
Select.appendChild(Option);
}
InserisciTemplate_AddOptionToSelect_Cancel(AddOptionInputOK)
}
function InserisciTemplate_DeleteParamFromTemplate(DeleteParamLink){
var Li = DeleteParamLink.parentNode;
Li.parentNode.removeChild(Li);
}
// ===== Check the fieldset and add a text to be saved in /LiveRCparam.js page =====
function InserisciTemplate_CheckConfigPanel(){
var ITConfigPanel = document.getElementById('LiveRC_OptionsContent_InserisciTemplateLegend');
if(!ITConfigPanel) return;
var ElementForms = getElementsByClass("InserisciTemplate_TemplateForm", ITConfigPanel, "form");
var Items = new Object();
for(var a=0,l=ElementForms.length;a<l;a++){
var ThisForm = ElementForms[a];
var NewItem = new Object();
NewItem.template = getElementWithId('template', 'input', ThisForm).value;
NewItem.string = getElementWithId('string', 'input', ThisForm).value;
NewItem.where = getElementWithId('where', 'select', ThisForm).value;
NewItem.noinclude = (getElementWithId('noinclude', 'input', ThisForm).checked ? true : false );
NewItem.subst = (getElementWithId('subst', 'input', ThisForm).checked ? true : false );
NewItem.parameters = new Object();
var ParamLIs = getElementsByClass("LI_parameters_li", ThisForm, "li");
for(var b=0,m=ParamLIs.length;b<m;b++){
var ParamLi = ParamLIs[b];
var NewParam = new Object();
var NewParamId = getElementWithId('Param_id', 'input', ParamLi).value;
NewParam.name = getElementWithId('Param_name', 'input', ParamLi).value;
NewParam.type = getElementWithId('Param_type', 'select', ParamLi).value;
if(NewParam.type == "string"){
NewParam.value = getElementWithId('Param_value', 'input', ParamLi).value;
}else{
NewParam.value = new Array();
var ParamValueSelect = getElementWithId('Param_value', 'select', ParamLi);
var Opt = ParamValueSelect.getElementsByTagName('option');
for(var c=0,k=Opt.length;c<k;c++){
NewParam.value.push(Opt[c].value);
}
}
NewItem.parameters[NewParamId] = NewParam;
}
Items[NewItem.template] = NewItem;
}
var SavedText = "\nCustom_lstMyTemplate = {\n";
var SavedItems = new Array();
for(var item in Items){
var SavedItem = " '"+item+"':{\n";
var ThisTemplate = Items[item];
for(var tempParam in ThisTemplate){
SavedItem += " "+tempParam+" : ";
var tempParamValue = ThisTemplate[tempParam];
if(tempParam!="parameters"){
SavedItem += ( typeof(tempParamValue)=="string" ? lrcEscapeStr(tempParamValue) : tempParamValue ) + ",\n";
}else{
SavedItem += "{\n";
var tempParameters = new Array();
for(var parameter in tempParamValue){
var thisparam = tempParamValue[parameter];
var ParamItems = new Array();
for(var paramItem in thisparam){
var thisparamItemValue = thisparam[paramItem];
if(paramItem!="value" || typeof(thisparamItemValue)=="string"){
ParamItems.push( paramItem + ":" + lrcEscapeStr(thisparamItemValue) );
}else{
var ThisParamValue = new Array();
for(var a=0,l=thisparamItemValue.length;a<l;a++){
ThisParamValue.push(lrcEscapeStr(thisparamItemValue[a]));
}
ParamItems.push( paramItem +": [" + ThisParamValue.join(",") + "]" );
}
}
tempParameters.push(" " + lrcEscapeStr(parameter) + " : {" + ParamItems.join(",") + "}");
}
SavedItem += tempParameters.join(",\n");
SavedItem += "\n }";
}
}
SavedItem += "\n }";
SavedItems.push(SavedItem);
}
SavedText += SavedItems.join(",\n");
SavedText += "};\n\n";
LiveRC_Config["BeforeParamPanelSavedHookResult"] += SavedText;
}
LiveRC_AddHook("BeforeParamPanelSaved", InserisciTemplate_CheckConfigPanel);
// ===== Vars for configuration panel fieldset =====
// Texts
try{
lrcTexts["IT_InsertTemplate1"] = "Inserisce il template {{";
lrcTexts["IT_InsertTemplate2"] = "}} nella pagina.";
lrcTexts["IT_AddTemplate"] = "Aggiungi un nuovo template";
lrcTexts["IT_DeleteTemplate"] = "Cancella questo template";
lrcTexts["IT_AddParam"] = "Aggiungi un nuovo parametro";
lrcTexts["IT_DeleteParam"] = "Cancella questo parametro";
lrcTexts["IT_DeleteOption"] = "Cancella l'opzione selezionata";
lrcTexts["IT_AddOption"] = "Aggiungi una nuova opzione";
}catch(e){ }
// Descriptions
try{
lrcParamDesc["DescIT_InsertTemplate1"] = "[InserisciTemplate] Inserisci la parte 1 della frase del template";
lrcParamDesc["DescIT_InsertTemplate2"] = "[InserisciTemplate] Inserisci la parte e della frase del template";
lrcParamDesc["DescIT_AddTemplate"] = "[InserisciTemplate] Frase Aggiungi un nuovo template";
lrcParamDesc["DescIT_DeleteTemplate"] = "[InserisciTemplate] Frase Cancella questo template";
lrcParamDesc["DescIT_AddParam"] = "[InserisciTemplate] Frase Aggiungi un nuovo parametro";
lrcParamDesc["DescIT_DeleteParam"] = "[InserisciTemplate] Frase Cancella questo parametro";
lrcParamDesc["DescIT_DeleteOption"] = "[InserisciTemplate] Frase Cancella l'opzione selezionata";
lrcParamDesc["DescIT_AddOption"] = "[InserisciTemplate] Frase Aggiungi una nuova opzione";
lrcParamDesc["DescInserisciTemplateLegend"] = "Parametri per l'estensione InserisciTemplate";
lrcParamDesc["DescInserisciTemplateLegend_short"] = "InserisciTemplate";
}catch(e){ }
// Hide/Show tabs panel item
addParamMenuTab("InserisciTemplateLegend", true);
/* ************************************************************************************************************************************************ */
|