Wikibooks:Popup di navigazione: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Emc2 (discussione | contributi)
Riga 143:
Potrebbero essere aggiunte altre opzioni, e le richieste di una maggiore flessibilità di configurazione sono più che benvenute.
 
=== AdvancedPersonalizzazione customizationavanzata ===
YouÈ canpossibile definedefinire customfiltri filterspersonalizzati forper articles.gli Thesearticoli, arefunzioni javascript functionsche whichvengono areeseguite rundopo afterche thele pagestatistiche statisticsdella arepagina generatedsono state generate, ande il theirloro output isviene appendedinserito (ascome HTML) toin thatquella partparte of thedel popup. (NoteNota thatbene ifche se simplePopups isè true oro popupSummaryDatapopupSummaryDaya isè false, then nothingnon willverrà bemostrato displayednulla).
 
ThePer waymettere tosu setuna thiscosa updel isgenere, toè writenevessario ascrivere filteruna functionfunzione whichfiltro acceptsche aaccetti stringuna stringa (theil wikitextwikitesto of the articledell'articolo) ascome input, ande returnsritorni aun fragmentframmento ofdi HTML. RepeatRipeti forquante asvolte many filters as you wantvuoi, andpoi thencrea create anun array <tt>extraPopupFilters</tt> whichche containscontenga alltutte ofle the functionsfunzioni, in the ordernell'ordine in which you wantcui themvuoi toche bevengano runeseguite.
 
Per esempio, mettiamo che vuoi che ti venga detto ogniqualvolta il wikitesto di un articolo contiene una tabella scritta utilizzando tag HTML piuttosto che il linguaggio wiki. Un modo per realizzarlo è aggiungere le seguenti linee al tuo file javascript:
For example, let's say you want to be told whenever the wikitext of an article contains a table written using HTML tags rather than wiki markup. One way to do this is to add the following to your user javascript file:
 
<pre>
// initialize theinizializza l'array - onlyfallo dosoltanto thisuna oncevolta
extraPopupFilters=[];
 
// definisce la funzione
// define the function
function popupFilterHtmlTable (wikiText) {
if (/<table/i.test(wikiText)) return '&amp;lt;tabletabella&amp;gt;';
else return '';
};
 
// addaggiunge thela function to thefunzione all'array (youpuoi canripeterlo repeatper thistutte forle lotsfunzioni ofche functionsvuoi)
extraPopupFilters.push(popupFilterHtmlTable);
</pre>
 
ThenDopodiché, whenquando aun popup isviene generatedgenerato forper auna pagepagina containingcontenente anuna tabella HTML table, youdovresti should seevedere &lt;tabletabella&gt; in thenel popup. (ItPotrebbe mayapparire alsoanche appearper foraltre other pagespagine, such as thiscome pagequesta. CorrectingLa thiscorrezione defectdi istale leftdifetto asè anlasciata exerciseal forlettore thecome readeresercizio).
 
== Crediti ==