gbligh Posted January 9, 2022 Posted January 9, 2022 Hi all Just wondered if there was a bit of code that I could use to make things appear at a certain time of the day? Maybe by widget UUID? Thanks
gbligh Posted January 9, 2022 Author Posted January 9, 2022 4 hours ago, gbligh said: Hi all Just wondered if there was a bit of code that I could use to make things appear at a certain time of the day? Maybe by widget UUID? Thanks Forgot to copy in the usual contributors! @ADT @pconkie @Graham Quince
ADT Posted January 10, 2022 Posted January 10, 2022 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> 2 1
Graham Quince Posted February 16, 2022 Posted February 16, 2022 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.
Graham Quince Posted February 25, 2022 Posted February 25, 2022 Had a chance to try this out, but I think it needs some real world testing before I publish it. A15F90222001B969D7685FA701B9700AED669B0C1E28AC30.tgz
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now