MediaWiki:Gadget-LiveRC 1x.js/InserisciTemplate.js: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
-intoken deprecato
Semplificazioni varie
Riga 625:
// ####################################################################################################################
 
/**
// * Add options in the "Tag" form
 
*/
function lrcRunInsertTemplate( data ) {
var TagSelect = document.getElementById( 'LiveTagReason' );,
var TemplateList = Custom_lstMyTemplate;
 
var TemplateList = Custom_lstMyTemplate;
if ( !Object.keys( TemplateList ).length ) {
TemplateList = lstMyTemplate;
Riga 654:
LiveRC_AddHook( "AfterPreviewArticle", lrcRunInsertTemplate );
 
/**
// * Function launched when choosing one of this extension options
 
*/
getLiveTagFunctions.InserisciTemplateExtension = function( page, option ) {
lrcDisableLink( "LiveTagReason" );
Riga 665 ⟶ 666:
}
var message = TemplateList[ option.value ];
 
new mw.Api().get( {
format: 'json',
Riga 682:
function InserisciTemplate_PostTagPage( res, page, message ) {
var resPage = Object.values( res.query.pages )[0];
var Isprotected = false;
for ( var prEntry in resPage.protection ) {
if ( prEntry.type == "edit" && mw.config.get( 'wgUserGroups' ).indexOf( prEntry.level ) == -1 ) {
LiveRC_alert( "<b>" + lrcMakeText( "PROTECTEDPAGE" ).split( "$1" ).join( page ) + "</b>" );
Isprotected = true;
breakreturn;
}
}
var tpl = InserisciTemplate_showDialog( message, page );
 
if ( Isprotected ) {
LiveRC_alert( "<b>" + lrcMakeText( "PROTECTEDPAGE" ).split( "$1" ).join( page ) + "</b>" );
return;
}
 
var tpl = InserisciTemplate_showDialog( message, page );
}
 
/**
// * Show the dialog in order to ask for the template parameters.
 
*/
function InserisciTemplate_showDialog( data, page ) {
var $dialog, $fieldset;
Riga 705 ⟶ 699:
$dialog = $( '#gtb-dialog' ).html( lrcMakeText( "IT_InsertTemplate1" ) );
$( '<a>' )
.attr( 'href', mw.configutil.getgetUrl( 'wgArticlePathTemplate:' ).split( "$1" ).join( lrcGetNamespaceName( 10 ) ) + data.template ) )
.attr( 'target', '_blank' )
.attr( 'tabindex', '-1' )
Riga 777 ⟶ 771:
}
 
/**
// * Check the dialog box and create the wikitext from the template and its params
 
*/
function InserisciTemplate_dumpTemplate( template, params ) {
var templateParams = LiveRC_FormatTemplateParams( params || {} );
Riga 799 ⟶ 794:
}
 
/**
// * Save the edit
 
*/
function InserisciTemplate_postTemplate( data, text, page ) {
lrcDisableLink( "LiveTagReason" );
Riga 813 ⟶ 809:
};
 
var addText;
if ( data.where == 'bottom' ) {
addTextEditParam.appendtext = "\n" + text;
EditParam.appendtext = addText;
} else { // top or default = top
addTextEditParam.prependtext = text + "\n";
EditParam.prependtext = addText;
}
 
Riga 828 ⟶ 821:
new mw.Api().postWithEditToken( EditParam )
.done( function () {
LiveRC_alert( "<b>" + page + " : " + lrcMakeText( "TAG_DONE" ) + "</b> <small>(" + addTexttext + ")</small>" );
} );
}
Riga 835 ⟶ 828:
 
 
/**
// ===== * Create a fieldset in the configuration panel =====
 
*/
function InserisciTemplate_CreateConfigPanel() {
var InserisciTemplateUl = LiveRC_ManageParams_CreateNewListMenu( "InserisciTemplateLegend", LiveRC_ManageParams_CreateActionButtons() );
Riga 900 ⟶ 894:
return;
}
Div.parentNode.removeChild$( Div ).remove();
}
 
Riga 911 ⟶ 905:
Title.innerHTML = "{{" + Template.template + "}} ";
Title.target = "_blank";
Title.href = lrcGetPageURLmw.util.getUrl( lrcGetNamespaceName( 10 ) + "Template:" + Template.template );
Title.title = lrcGetNamespaceName( 10 ) + "Template:" + Template.template;
Title.onclick = function() {
liveArticle( lrcGetNamespaceName( 10 ) + "Template:" + Template.template );
return false;
};
Riga 1 109 ⟶ 1 103:
}
Select_type.onchange = function() {
InserisciTemplate_ChageValueTypeInserisciTemplate_ChangeValueType( this );
};
LI_Param.appendChild( Select_type );
Riga 1 162 ⟶ 1 156:
}
 
function InserisciTemplate_ChageValueTypeInserisciTemplate_ChangeValueType( Select ) {
var NewType = Select.value;
var Li = Select.parentNode;
Riga 1 286 ⟶ 1 280:
}
 
/**
// ===== * Check the fieldset and add a text to be saved in /LiveRCparam.js page =====
 
*/
function InserisciTemplate_CheckConfigPanel() {
var ITConfigPanel = document.getElementById( 'LiveRC_OptionsContent_InserisciTemplateLegend' );
Riga 1 422 ⟶ 1 417:
}
 
// =====*** Vars for configuration panel fieldset =====*/
 
// Texts
 
lrcTexts.IT_InsertTemplate1 = "Inserisce il template {{";
Riga 1 436 ⟶ 1 429:
lrcTexts.IT_AddOption = "Aggiungi una nuova opzione";
 
 
// Descriptions
lrcParamDesc.DescIT_InsertTemplate1 = "[InserisciTemplate] Inserisci la parte 1 della frase del template";
lrcParamDesc.DescIT_InsertTemplate2 = "[InserisciTemplate] Inserisci la parte 2 della frase del template";
Riga 1 453 ⟶ 1 444:
// Hide/Show tabs panel item
addParamMenuTab( "InserisciTemplateLegend", true );
 
/* ************************************************************************************************************************************************ */