MediaWiki:Jony.js

From The iPhone Wiki
Revision as of 22:23, 3 January 2014 by 5urd (talk | contribs) (Created page with "/** * The iPhone Wiki MediaWiki:ios7.js * - JavaScript to fix issues regarding the iOS 7 theme * Copyright (c) 2013 Cole Johnson <coleharrisjohnson@gmail.com> * Licensed...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Note: After saving, 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: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/**
 * The iPhone Wiki MediaWiki:ios7.js
 *   - JavaScript to fix issues regarding the iOS 7 theme
 * Copyright (c) 2013 Cole Johnson <coleharrisjohnson@gmail.com>
 * Licensed under CC BY-SA 3.0 <http://creativecommons.org/licenses/by-sa/3.0/>
 **/

// This function exists also at [[MediaWiki:ios6.js]], so if you change it here, change it there also (be sure to test on both skins seperatly first)
// Automatically adds the "nobborderplz" class to applicable table cells
function autoAddNoBBorderPlzClass() {
    var tables = $("table[class=wikitable]");
    
    // "table" appears to have another purpose (at least in Chrome's console)
    for (var tabel = 0; tabel < tables.length; tabel++) {
        var children = tables[tabel].children;
        if (children.length > 0 && children[0].localName == "tbody") {
            children = children[0].children; // skip the tbody tag
        }
        var height = children.length;
        for (var tr = 0; tr < height; tr++) {
            var row = children[tr].children;
            var width = row.length;
            // on a four row table, the second row, this equation will be "3 - 1" (0 based) or 2
            var dist = height - tr;
            for (var td = 0; td < width; td++) {
                var this_cell = row[td];
                if (this_cell.rowSpan != 1 && this_cell.rowSpan == dist) {
                    // this is the last cell in a column, and it has a rowspan
                    if (this_cell.className == undefined || this_cell.className == "") {
                        this_cell.className = "nobborderplz";
                    } else {
                        this_cell.className = this_cell.className + " nobborderplz";
                    }
                }
            }
        }
    }
}

autoAddNoBBorderPlzClass();