Jump to content

Topic on Talk:Structured Discussions/Flow

Here's how you would show the number of topics on the [Discussion] tab in your Special:MyPage/common.js or a Gadget:

  • make Flow's "table of contents" API request for 100 topics on Discussion page (sample)
  • in a successful API response, zero in on, in jq syntax, .flow["view-topiclist"].result.topiclist.revisions and gets its length (or maybe get the length of ...topiclist.roots, Flow API results are complicated).
  • change length to "99+" if it's 100
  • append this length to the "Discussion" tab with
    $( '#ca-talk a' ).append( ' <span style="color: orange"><small>' + length + '</small></span>');
    

If you're already viewing the Discussion page there might be a way to reuse the API requests the Flow board has already made or the HTML it has already produced.

"Those who can, do, those who can't, pseudocode" 😎

Be the first to comment! • 03:54, 5 November 2015 10 years ago