Jump to content
Graham Quince

Random Tip using a Noticeboard widget

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...