Jump to content
  • 0

Auto search after inactivity


Pumpedplop

Question

4 answers to this question

Recommended Posts

  • 1

Hi @Pumpedplop,

I guess what you are using right now is a report datapage. I can suggest you use auto-refresh instead for your workflow.

If you have your own webpage I can suggest using this JavaScript code to detect inactivity on your site:

<script>
     var time = new Date().getTime();
     $(document.body).bind("mousemove keypress", function(e) {
         time = new Date().getTime();
     });

     function refresh() {
         if(new Date().getTime() - time >= 60000) 
             window.location.reload(true);
         else 
             setTimeout(refresh, 10000);
     }
     setTimeout(refresh, 10000);
</script>

Source: https://stackoverflow.com/questions/4644027/how-to-automatically-reload-a-page-after-a-given-period-of-inactivity

 

But if you just have a datapage for now, you may use this how to article to refresh a page, though it may not detect inactivity.

https://howto.caspio.com/tech-tips-and-articles/how-to-auto-refresh-a-page/

 

I hope this helps! 

Link to comment
Share on other sites

  • 0
On 1/5/2023 at 5:35 PM, Kronos said:

<script>

var time = new Date().getTime(); $(document.body).bind("mousemove keypress", function(e) { time = new Date().getTime(); }); function refresh() { if(new Date().getTime() - time >= 60000) window.location.reload(true); else setTimeout(refresh, 10000); } setTimeout(refresh, 10000);

</script>

Source: https://stackoverflow.com/questions/4644027/how-to-automatically-reload-a-page-after-a-given-period-of-inactivity

If I would use this code on my caspio page, where would I need to place it?

Link to comment
Share on other sites

  • 0
1 hour ago, Pumpedplop said:

If I would use this code on my caspio page, where would I need to place it?

Since the script seems to run after the DataPage loads, I think it will be best to add it on the Footer block. Just add Header and Footer on your DataPage in the configure search fields section and go to source or disable HTML editor

Link to comment
Share on other sites

  • 0

The code works but looks clumsy refreshing the page, that's why I tried altering the code to click the actual search button with information gathered from (Auto search Caspio forums). This doesn't seem to work, can you see any reason why?

<script>
     var thisDP = document.querySelector(`[action*="[@cbAppKey]"]`);
     var time = new Date().getTime();
     $(document.body).bind("mousemove keypress", function(e) {
         time = new Date().getTime();
     });

     function refresh() {
         if(new Date().getTime() - time >= 60000) 
            console.log('Clicked');
          thisDP.querySelector('.cbSearchButton').click();
         else 
             setTimeout(refresh, 10000);
     }
     setTimeout(refresh, 10000);
</script>

 

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.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

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

Loading...
×
×
  • Create New...