MediaWiki:Mobile app debug.js

From Terraria Wiki
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
function scrollAnchor(id) {
  var scrollTo = $('#' + id).offset().top - 15;
  window.scrollTo(0, scrollTo);
  console.log(scrollTo);
}

$(document).ready(function() {
  if ($('body').find('> .modal-table').length !== 1) {
    $('table').each(function() {
      if (!$(this).hasClass('msgbox') && !$(this).hasClass('modal-table') && $(this).outerWidth() > window.innerWidth - 32) {
        var descText = '';

        $(this).hide();
        $(this).parent().attr('style', '');

        if ($(this).data('description')) {
          descText = $(this).data('description');
        }

        $(this).before('<button type="button" class="modal-button"><strong>View Table' + ($(this).data('description') ? ": " : "") + descText + '</strong></button>');
      }
    });
  }

  $('button.modal-button').click(function() {
    var tableContainer = $('<div>');
    var table = this.nextSibling.cloneNode(true);

    $(table).appendTo(tableContainer);

    table.classList.add('modal-table');
    $(table).attr('style', '');
    console.log(tableContainer.html());
  });
});