User:Glorat

Introduction
I am the author of https://www.boglebot.com - a community approved tool for its international 2-fund portfolio helper.

In this home page, I will perform various wiki experiments

Experiments
Experimental wiki tricks here

Here is a search link to all Ireland domiciled ETFs that target global market indicies.

https://www.boglebot.com/assetdb?args=%7B%22query%22%3A%5B%7B%22where%22%3A%5B%22asset.type%22,%22%3D%3D%22,%22ETF%22%5D%7D,%7B%22where%22%3A%5B%22asset.domicile%22,%22%3D%3D%22,%22Ireland%22%5D%7D,%7B%22where%22%3A%5B%22asset.geography%22,%22%3D%3D%22,%22Global%22%5D%7D%5D%7D

Note that this dynamic feature does not work under IE11 (although it would be simple but ugly code to support IE11 if needed)

{ "query": [{"where":["asset.type","==","ETF"]}], "fields": ["asset.type", "ticker"], "headers": ["Type", "Ticker"] }

{ "query": [{"where":["asset.type","==","Fund"]}], "fields": ["asset.type", "asset.isin", "asset.incomeTreatment"], "headers": ["Type", "ISIN", "Acc/Dist"] }

Usage instructions (DRAFT PROPOSAL)
Dynamic boglebot tables can be injected the following sample content in your wiki page

&lt;div class="boglebottable"&gt; { "query": [{"where":["asset.type","==","ETF"]}], "fields": ["asset.type", "ticker"], "headers": ["Type", "Ticker"] } &lt;/div&gt;

This can then be customised by adjusting the three options
 * query: A JSON array of where clauses, listing field, operator and value
 * fields: The fields to extract from the underlying database
 * headers: The table headers to display the fields

A (TODO) will need to be included in the target wiki page so that the code knows to convert this wiki content into an actual wiki table

Installation dependencies
This script has no external dependencies (although the code would be much neater if we had access to Handlebars and lodash)

Widget Javascript
Hidden in this section (do view-source, or edit this section to see the source) is the source code for the widget. It should probably be centralised somewhere

function _index(obj,i) {return obj[i]} function lodashGet(obj, path) { return path.split('.').reduce(_index, obj) }

function gen2(rows, params) { var Html = mw.html; var fields = params.fields; var headers = params.headers; headers.unshift('Name'); // Mandatory 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 cols = [];    cols.push(Html.element('a', {href:'https://www.boglebot.com/quotesdb/' + row.id, class: 'external text'}, row.name));    fields.forEach(function(path) { cols.push(lodashGet(row, path)) });

var tds = cols.map(function(col){return ' ' + col + ' '}); // TODO return ' ' + tds.join('') + ' ' }); 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 url = 'https://asia-northeast1-gainstrack.cloudfunctions.net/fastQuoteSources';

$('.boglebottable').each(function(index, elem) {   const params = JSON.parse(elem.innerText); // TODO: error handle this    $.ajax({ type: "POST", url: url, // The key needs to match your method's input parameter (case-sensitive). data: JSON.stringify({query:params.query}), contentType: "application/json; charset=utf-8", dataType: "json", success: function(data){ const html = gen2(data.rows, params); $(elem).html(html); $('table', elem).tablesorter; },     error: function(errMsg) { console.error(errMsg); }   });

});

}

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

Pages in development
I'm currently working on the following pages, which are under my username. All wiki editors are welcome to contribute.