From fcaa479640044cc7430702e5d9c79199d58481d7 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Sun, 16 Aug 2015 11:28:18 +0200 Subject: js: Clean up charops.js & tagops.js charops.js was already recently (re)written and followed much of the new conventions, so that was easy. tagops.js has been simplified somewhat, and does not rely on the position of the "tagspl#" class anymore. --- data/js/charops.js | 115 +++++++++++++++++++++++++++++---------------------- data/js/tagops.js | 119 ++++++++++++++++++++++++++--------------------------- 2 files changed, 123 insertions(+), 111 deletions(-) diff --git a/data/js/charops.js b/data/js/charops.js index afb762b7..7adb6ae2 100644 --- a/data/js/charops.js +++ b/data/js/charops.js @@ -1,66 +1,81 @@ -if(byId('charops')) { (function() { +var spoil, sexual, t; + + +// Fixes the commas between trait names and the hidden status of the entire row +function fixrow(c) { + var l = byName(byName(c, 'td')[1], 'span'); + var first = 1; + for(var i=0; i 1 : + hasClass(k[i], 'charspoil_1') ? spoil < 1 : spoil < 2); + for(var i=0; i<3; i++) + setClass(h[i], 'sel', spoil == i); + if(h[3]) + setClass(h[3], 'sel', sexual); + if(k.length) + restripe(); + return false; +} + + +function init() { var h = byName(byId('charops'), 'a'); - var t = byClass('table', 'stripe'); - var spoil; - var sexual; - // Fixes the commas between trait names and the hidden status of the entire row - var fixrow = function(c) { - var l = byName(byName(c, 'td')[1], 'span'); - var first = 1; - for(var i=0; i 1 : - hasClass(k[i], 'charspoil_1') ? spoil < 1 : spoil < 2); - for(var i=0; i<3; i++) - setClass(h[i], 'sel', spoil == i); - if(h[3]) - setClass(h[3], 'sel', sexual); - if(k.length) - restripe(); - return false; - }; + t = byClass('table', 'stripe'); + + // Spoiler level for(var i=0; i<3; i++) { h[i].num = i; h[i].onclick = function() { spoil = this.num; - return setall(); + return setall(h); }; if(hasClass(h[i], 'sel')) spoil = i; }; + + // Sexual toggle if(h[3]) { h[3].onclick = function() { sexual = !sexual; - return setall(); + return setall(h); }; sexual = hasClass(h[3], 'sel'); } - setall(); -})(); } + setall(h); +} + + +if(byId('charops')) + init(); diff --git a/data/js/tagops.js b/data/js/tagops.js index 26728dc4..3f789ee6 100644 --- a/data/js/tagops.js +++ b/data/js/tagops.js @@ -1,68 +1,65 @@ -function tvsInit() { - if(!byId('tagops')) - return; - var l = byName(byId('tagops'), 'a'); - for(var i=0;i