User:Quarenon/questchecklist.js

/* */ /** * questchecklist.js * * Adds a checklist on quest pages for required/recommended items. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */

$(document).ready(function {	if (wgAction == 'view' && wgNamespaceNumber === 0) {		var cookie = getCookie('qcl_' + wgPageName);

var $cells = $('.toccolours:first tr'); if ($cells.eq(0).text.indexOf('Official quest description:') != -1) { var $ul = $cells.eq(7).find('ul'); $ul.css('listStyle', 'none outside none'); var $li = $ul.find('li'); var i = 0; $li.each(function {				var $cb = $(' ').attr({type: 'checkbox'}).addClass('questItemCb').change(function { var val = ''; $('.questItemCb').each(function {						val += $(this).attr('checked') ? 'T' : 'F';					}); setCookie('qcl_' + wgPageName, val, 60 * 60 * 24 * 7); // 1 week });

$(this).prepend($cb); $cb.attr('checked', (cookie.charAt(i) == 'T') ? 'checked' : '');

i++; });			var $reset = $(' ').attr({type: 'button'}).val('Reset').click(function { $('.questItemCb').attr('checked', false); setCookie('qcl_' + wgPageName, '', -1); });			var $td = $(' ').append($reset);			var $tr = $(' ').append($td);			$cells.eq(7).after($tr);		}	} }); /* */