-1

I have a code that shows a notifications box when there has occurred a new earthquake in the world. I want reduce at an icon if the user, for 20 seconds since the box appears, does not do anything

So if not resize,scroll,click and press button on keyboard.

Is there a fast way to do this? How can combine all these events?

I hope can you suggest me something :)

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Borja
  • 3,359
  • 7
  • 33
  • 66
  • Do you have some code yet? Tried anything? As suggestion: set a timer on appearance. If something happens in this time, reset or quit the timer... – GreyRoofPigeon Mar 02 '18 at 12:43
  • @LinkinTED not yet... but do you think that i write all events ? – Borja Mar 02 '18 at 12:45
  • I don't know if you do, I know I do... But please consider that this is a helping community, not a scripting from scratch community. So if you are looking for someone to make you the script, I don't think you'll find it here :) – GreyRoofPigeon Mar 02 '18 at 12:47
  • i write "suggest me something" not "write code"... – Borja Mar 02 '18 at 12:48
  • I suggested you a timer :) – GreyRoofPigeon Mar 02 '18 at 12:50
  • This question is a possible duplicate of: https://stackoverflow.com/questions/667555/detecting-idle-time-in-javascript-elegantly – Joost Meijer Mar 02 '18 at 12:54
  • Possible duplicate of [Detecting idle time in JavaScript elegantly](https://stackoverflow.com/questions/667555/detecting-idle-time-in-javascript-elegantly) –  Mar 02 '18 at 12:58

2 Answers2

1

I have not enough reputation to answer in the commentary, so i am writing here. An example - you can write onclick, onkeydown and other events, then add "!" to before the statement with setTimeout.

  • Don't post commentary as answer. Having not enough rep doesn't mean you can just ignore the rules. –  Mar 02 '18 at 12:59
0

i solved in this way:

        var notifiche_active= true;
        $(document).on('keypress click mousemove resize scroll',function(){
            notifiche_active = false;
        });

        setTimeout(function(){
            if(notifiche_active == true){
                $('#notifiche_terremoti').hide();
                alert('nascondi');
            }
            notifiche_active= true;
        },20000);

I hope that here i write all EVENTS..

thanks all for suggestions

Borja
  • 3,359
  • 7
  • 33
  • 66