|
|
Línea 12: |
Línea 12: |
| ); | | ); |
| } | | } |
| });
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| $(document).ready(function() {
| |
| // Procesar todos los infobox dinámicos en la página
| |
| $('.infobox').each(function() {
| |
| var $infobox = $(this);
| |
| var params = mw.config.get('wgTemplateParams');
| |
|
| |
| // Procesar imágenes dinámicas
| |
| var imageIndex = 1;
| |
| while(params['image' + imageIndex]) {
| |
| var imgHtml = '<div class="infobox-image">' +
| |
| '[[File:' + params['image' + imageIndex] + '|' + (params['image_size'] || '250px') + ']]';
| |
|
| |
| if(params['caption' + imageIndex]) {
| |
| imgHtml += '<div class="infobox-caption">' + params['caption' + imageIndex] + '</div>';
| |
| }
| |
|
| |
| imgHtml += '</div>';
| |
| $infobox.find('.infobox-images-container').append(imgHtml);
| |
| imageIndex++;
| |
| }
| |
|
| |
| // Procesar secciones dinámicas
| |
| var sectionIndex = 1;
| |
| while(params['header' + sectionIndex]) {
| |
| var $section = $('<tr><th colspan="2">' + params['header' + sectionIndex] + '</th></tr>');
| |
| $infobox.find('table.infobox-data').append($section);
| |
|
| |
| // Procesar items de sección
| |
| var itemIndex = 1;
| |
| while(params['label' + sectionIndex + '_' + itemIndex]) {
| |
| var $row = $('<tr><th>' + params['label' + sectionIndex + '_' + itemIndex] + '</th>' +
| |
| '<td>' + (params['value' + sectionIndex + '_' + itemIndex] || '') + '</td></tr>');
| |
| $section.after($row);
| |
| itemIndex++;
| |
| }
| |
|
| |
| sectionIndex++;
| |
| }
| |
|
| |
| // Procesar campos fijos (opcional)
| |
| if(params['status']) {
| |
| $infobox.find('table.infobox-data').append(
| |
| '<tr><th colspan="2">Estado</th></tr>' +
| |
| '<tr><th>Estado</th><td>' + params['status'] + '</td></tr>'
| |
| );
| |
| }
| |
| });
| |
|
| |
| // Botón para agregar campos en modo edición
| |
| if(mw.config.get('wgAction') === 'edit') {
| |
| $('.editOptions').prepend(
| |
| '<button class="infobox-add-field" type="button">+ Agregar campo</button>'
| |
| );
| |
|
| |
| $('.infobox-add-field').click(function() {
| |
| // Lógica para agregar nuevos campos al formulario de edición
| |
| // Esto requeriría más código específico para tu wiki
| |
| });
| |
| }
| |
| }); | | }); |
/* Cualquier código JavaScript escrito aquí se cargará para todos los usuarios en cada carga de página */
// Mostrar avatar junto al nombre de usuario
$( function() {
if ( mw.config.exists( 'wgUserAvatar' ) ) {
var avatarUrl = mw.util.getUrl( 'File:' + mw.config.get( 'wgUserAvatar' ), {
width: 24
});
$('#pt-userpage, .mw-userlink').prepend(
$('<img>').addClass('user-avatar').attr( 'src', avatarUrl )
);
}
});