Jump to content

Appearing by time


gbligh
 Share

Recommended Posts

13 hours ago, gbligh said:

Forgot to copy in the usual contributors! :) 

@ADT @pconkie @Graham Quince

I had a play with this years ago....  well with the help of @Graham Quince if i remember!

 

<script>
///////////////////////////////////////////////////////////////
/// you will need the data-content-uuid of the widget you want to show/hide
// get this from the inspector (right click - - inspect)
//////////////////////////////////////////////////////////////
var widget_to_hide = "42140000200287F6954DBF1CEB29FA0C24F4607C6376CF04";

    // attach click functions to buttons
    $( ".showme" ).click(function() {
        $("div[data-content-uuid='"+widget_to_hide+"']").show();
    });
     $( ".hideme" ).click(function() {
        $("div[data-content-uuid='"+widget_to_hide+"']").hide();
    });
    
    // automatically by time of day?
    var format = 'hh:mm:ss';
    // var time = moment() gives you current time. no format required.
    var time = moment();
    var beforeTime = moment('10:30:00', format);
    var afterTime = moment('15:30:00', format);

    if (time.isBetween(beforeTime, afterTime)) {
        console.log('is between');
        //show?
        $("div[data-content-uuid='"+widget_to_hide+"']").show();
    } else {
        console.log('is not between');
        //hide?
        $("div[data-content-uuid='"+widget_to_hide+"']").hide();
    } 
</script>

<button class="showme" type="button">Show</button>
<button class="hideme" type="button">Hide</button>

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

  • 1 month later...

Just had a thought about this:  

If someone were to take the Set Keyword and Email widget's code as a roadmap, and use the bit that adds a key word, instead of having it be a button push, the function which adds the keyword and refreshes the site could occur when the time matches the settings.  Any widgets on the site with a Keyword Rule would then respond accordingly.

Not sure what would happen to a dashboard of course.  That might not work in the same way.

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

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

Guest
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.

 Share

×
×
  • Create New...