User:Glorat/BoglebotTableDev

Boglebot Table Widget Guide
This page is hosting bleeding edge under development code for BoglebotTable. Noone but Glorat should refer to this because things will surely break

Global Equity ETFs for non-US

function gen(data, elem) { var Html = mw.html; const {rows, fields, headers} = data; // Mandatory name field at the start const idx = fields.findIndex(x => x === 'name'); if (idx>0) { fields.splice(idx, 1); headers.splice(idx, 1); } headers.unshift('Name'); var ths = headers.map(function(h) {return Html.element('th', {class:'headerSort', tabIndex:'0', role: 'columnheader button', title: 'Sort ascending'}, h);}); var trs = rows.map(function(row) {   var cells = [];    cells.push(Html.element('a', {href:'https://www.boglebot.com/quotesdb/' + row.id, class: 'external text'}, row.name));    fields.forEach(function(path) { cells.push(row[path]) });

var tds = cells.map(function(col){return ' ' + col + ' '}); return ' ' + tds.join('') + ' ' }); // Relocate the original link to a nice place  trs.push(` Source: ${elem.outerHTML}  `);

var tbody = Html.element('tbody',{}, new Html.Raw(trs.join(''))); var thead = ' ' + ths.join('') + ' '; var table = Html.element('table', {class:'dyntable wikitable sortable jquery-tablesorter'}, new Html.Raw(thead + tbody));

return table; }

async function doIt { const functionUrl = 'https://asia-northeast1-gainstrack.cloudfunctions.net/fastQuoteSourceTableQuery'; $('a[href^="https://www.boglebot.com/assetdb?args="]').each(function(index, elem) {   const href = elem.href;    const link = href.replace('https://www.boglebot.com/assetdb', functionUrl);    $.getJSON(link, function(data) { const html = gen(data, elem); $(elem).replaceWith(html); $('table', elem).tablesorter; }) });

}

window.addEventListener('load', function { // mw.loader.using( ['jquery.tablesorter'] ).then( function  { setTimeout(function {     console.log('All assets are loaded');      doIt;    },100 ); })