MediaWiki:Test.js: различия между версиями

Страница интерфейса MediaWiki
Нет описания правки
Нет описания правки
Строка 1: Строка 1:
$(function () {
$(function () {
   $('.chem-recipe').each(function () {
   $('.chem-recipe').each(function () {
     var $box = $(this);
     var recipeBox = $(this);
    var name = $box.data('name');
    var recipe = $box.find('.recipe').html();
    var effects = $box.find('.effects').html();
    var description = $box.find('.description').html();


     var $formatted = $('<div class="chem-box" style="border:1px solid #aaa; border-radius:8px; padding:10px; margin:10px 0; background:#f9f9f9;"></div>');
     var name = recipeBox.find('.chem-name').text();
    var recipe = recipeBox.find('.chem-recipe-body').html();
    var effects = recipeBox.find('.chem-effects').html();
    var description = recipeBox.find('.chem-description').html();


     if (name) {
     var html = '<div style="border:1px solid #aaa; border-radius:8px; padding:10px; margin:10px 0; background:#f9f9f9;">';
      $('<h3 style="margin-top:0;">').text(name).appendTo($formatted);
 
    }
    html += '<div style="font-weight:bold; font-size:1.2em; margin-bottom:6px;">' + name + '</div>';


     if (recipe) {
     if (recipe) {
       $('<div style="margin-bottom:5px;"><strong>Рецепт:</strong><br>' + recipe + '</div>').appendTo($formatted);
       html += '<div style="margin-bottom:5px;"><b>Рецепт:</b><br>' + recipe + '</div>';
     }
     }


     if (effects) {
     if (effects) {
       $('<div style="margin-bottom:5px;"><strong>Эффекты:</strong><br>' + effects + '</div>').appendTo($formatted);
       html += '<div style="margin-bottom:5px;"><b>Эффекты:</b><br>' + effects + '</div>';
     }
     }


     if (description) {
     if (description) {
       $('<div style="color:#555;"><em>' + description + '</em></div>').appendTo($formatted);
       html += '<div style="color:#555;"><em>' + description + '</em></div>';
     }
     }


     $box.replaceWith($formatted);
     html += '</div>';
 
    recipeBox.replaceWith(html);
   });
   });
});
});

Версия от 13:55, 19 апреля 2025

$(function () {
  $('.chem-recipe').each(function () {
    var recipeBox = $(this);

    var name = recipeBox.find('.chem-name').text();
    var recipe = recipeBox.find('.chem-recipe-body').html();
    var effects = recipeBox.find('.chem-effects').html();
    var description = recipeBox.find('.chem-description').html();

    var html = '<div style="border:1px solid #aaa; border-radius:8px; padding:10px; margin:10px 0; background:#f9f9f9;">';

    html += '<div style="font-weight:bold; font-size:1.2em; margin-bottom:6px;">' + name + '</div>';

    if (recipe) {
      html += '<div style="margin-bottom:5px;"><b>Рецепт:</b><br>' + recipe + '</div>';
    }

    if (effects) {
      html += '<div style="margin-bottom:5px;"><b>Эффекты:</b><br>' + effects + '</div>';
    }

    if (description) {
      html += '<div style="color:#555;"><em>' + description + '</em></div>';
    }

    html += '</div>';

    recipeBox.replaceWith(html);
  });
});