Jump to content

Random Tip using a Noticeboard widget

Graham Quince

Recommended Posts

This bit of code took a lot more faffing than I was expecting, but I think it might be useful.  Imagine you want to display a random tip from a bank of tips each time someone logs in:

  • Add a noticeboard
  • Hide the Refresh options
  • Get the noticeboard's UUID and add the following code:
  • <div class="styling"></div>
    var noticeboardUUID = '5594BCA620028E9D37048F60FB777D056CBF7E6CC2DFC92B';
    function shuffle(array) {
      let currentIndex = array.length,  randomIndex;
      while (currentIndex != 0) {
        // Pick a remaining element...
        randomIndex = Math.floor(Math.random() * currentIndex);
          // And swap it with the current element.
        [array[currentIndex], array[randomIndex]] = [
          array[randomIndex], array[currentIndex]];
      return array;
            'div[data-content-uuid="' + noticeboardUUID + '"] .notice-table {'+
                'display: none;'+
        tips = $('div[data-content-uuid="' + noticeboardUUID + '"]').find('.notice-table');
        var tipsArray = [];
        $.each(tips.find('.topic-row'), function (key, tip) {
            tipsArray.push( $(this).attr('class') );
        var classToShow = tipsArray[0].split(' ');
    }, 3000);



Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...