/    Sign up×
Community /Pin to ProfileBookmark

Need help with sleep

Hello, i got this javascript :

[code]$(document).keyup(function(e){
if(e.which==69){
for(var i in g.npc){
if ((Math.abs(hero.rx – g.npc[i].x) <= 1 && Math.abs(hero.ry – g.npc[i].y) <= 1) && (g.npc[i].type == 2 || g.npc[i].type == 3)){
message(‘id: “‘+g.npc[i].nick+'”‘);
_g(“reg&a=name&auto=1&id=-“+i);
break;
}
}
}
});[/code]

This javascript is used when key “E” pressed, i need add 5000 milisecound sleep to that function ( even if I press the E key a few times in a row, the function will be executed only once in 5000 milliseconds).

I tried do that with setTimeout, but can’t

Can someone help me?

Thanks

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@KorSep 20.2011 — Hello, i got this javascript :
[/QUOTE]

You got that... JQuery? Prototype? MooTools? Scriptaculous? Google API? yahoo API? Other JavaScript library? Which one?

Please, when you write a code which is a custom part of a JavaScript library, specify which library you have used.
Copy linkTweet thisAlerts:
@rnd_meSep 20.2011 — [CODE]function [COLOR="Red"]me[/COLOR](e){
if(e.which==69 [COLOR="Red"] && (!me.last || (+new Date - me.last) >5000)[/COLOR]){
[COLOR="Red"] me.last=+new Date[/COLOR]
...[/CODE]

changes in red
Copy linkTweet thisAlerts:
@marketingbossSep 20.2011 — yeah what is the library that was used?
Copy linkTweet thisAlerts:
@rnd_meSep 20.2011 — yeah what is the library that was used?[/QUOTE]

what do you mean?

isn't it obvious that it's jQuery?

jQuery is used on MOST big sites, learn it or perish.

and, just to be clear, the question had nothing to do with any library, it's a js question that had a js answer...
Copy linkTweet thisAlerts:
@KorSep 21.2011 — what do you mean?

isn't it obvious that it's jQuery?[/QUOTE]

No, it is not obvious. The presumption that all the coders in this world know perfectly the JQuery syntax (to be able to recognize it even within 3 lines of code) is wrong.

In fact, isn't obvious that, if you have a JQuery problem, you should start by telling everybody from the beginning: "Hey, I have [I][B]a JQuery[/B][/I] problem!"? That should filter better your needs, so that only those who know JQuery will open, read the thread and give a solution.

Now, only [I]this[/I] is really obvious!?
Copy linkTweet thisAlerts:
@rnd_meSep 21.2011 — 
In fact, isn't obvious that, if you have a JQuery problem, you should start by telling everybody from the beginning: "Hey, I have [I][B]a JQuery[/B][/I] problem!"? That should filter better your needs, so that only those who know JQuery will open, read the thread and give a solution.
[/QUOTE]


ok, but it wasn't a jQuery problem. i don't think that using the lib should prevent good coders like kor from helping. I've been anti-jQuery since the beginning but it behooves me to hold at least a basic familiarity with its most-used features.
×

Success!

Help @creif spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...