User:Blaster Niceshot/wikia.js

//Script to get table info //See http://community.wikia.com/wiki/Thread:1018387 for more details

var lookupResult = {};

//Add a click function for //each button here $('#unit-statistics-button1').click(function{   getPageData('Goblins'); }); $('#unit-statistics-button2').click(function{   getPageData('Goblins'); });

function getPageData(page) { var property = ''; //Add code here that will //execute while AJAX request is running $('.unit-statistics-button').addClass('button-grayed'); $.get('http://clashroyale.wikia.com/index.php?title=' + page) .done(function(statData){       $('#unit-statistics-table tbody tr:eq(0) th',statData).each(function(i){ lookupResult[page] = {}; property = $(this).clone.children.remove.end.text.trim; if (i > 0) { lookupResult[page][property] = [0]; $('#unit-statistics-table tbody tr',statData).each(function(a){                   if (a > 0) {                        lookupResult[page][property].push($('td:eq(' + i + ')',$(this)).text.trim);                        if (a === $('#unit-statistics-table tbody tr',statData).length - 1 && i === $('#unit-statistics-table tbody tr:eq(0) th',statData).length - 1) {                            //Add code here that will execute                            //after AJAX request has finished and                            //data has been added to lookupResult object                            $('.unit-statistics-button').removeClass('button-grayed');                        }                    }                }); }       });    }); }