Jump to content

Appearing by time


gbligh

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

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