MediaWiki:DPLforumBoardCustomization.js

/** * @module             DPLforumBoardCustomization * @description        Support for customizing the DPLforum board index * @author             Fijalmire * @version            1.1.0 */

(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}`. * If `boardDescription` is defined for a boards, append it to the board * inside a ` ` tag with class `js-dplforum-board__description`. */   dplforumBoards.forEach(function(item, i) {      boards[i].className += (' js-dplforum-board js-dplforum-board__' + item.boardName);

if (item.boardDescription !== undefined) { boards[i].innerHTML += '' + item.boardDescription + ' '; }   });

/**    * 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'); } } });