MediaWiki:DPLforumBoardImages.js

/** * @module             DPLforum board images * @description        Add images to DPLforum boards * @author             Forge the Hybrid * @version            1.0.0 * @license            ISC */ (function { var dplforumIndexLocation = window.dplforumIndexLocation || {    'en': 'Forum:Index',    'es': 'Foro:Índice'  };  var dplforumBoards = window.dplforumBoards || [{ boardName: 'help-desk' }, { boardName: 'watercooler' }];  // Only run on Forum:Index  if (mw.config.get('wgPageName') === (dplforumIndexLocation[mw.config.get('wgContentLanguage')] || dplforumIndexLocation.en)) {    // Get all the boards    var boards = document.querySelectorAll('td.forum_title');    // Get the number of `.forum_new` instances there are.    var forumNewNum = document.getElementsByClassName('forum_new');    /**     * For each td with class `forum_title` add classes `js-dplforum-board` and     * `js-dplforum-board__${boardName}`.     */    dplforumBoards.forEach(function(item, i) { boards[i].className += (' js-dplforum-board js-dplforum-board__' + item.boardName); });   /**     * Add class `js-forum-new--unset` to tags with the class `forum_new` so we     * can reset any styles that don't work with the board images.     */    for (let i=0; i < forumNewNum.length; i++) {      // Reset padding and remove bg image      forumNewNum[i].classList.add('js-forum-new--unset');    }  } });