Help Logs Database

Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Ircnet  |  Dalnet
Page: 1 2 3 4 5 6 7 8

<khaladan> function(o) { return function() { window[call_js_function](o.data); } } (this);
<Zyclops> every button ends up calling the same function... thats strang since we are returning a new scope for every function
<chino> is sleep a js function ?
<Zyclops> this is too painfull :)
<khaladan> hmmf
<Zyclops> thankyou for your help though khaladan, it's really appreciated
<khaladan> sure... wish i was more help. i thought that's how i did it before
<khaladan> im looking through my code now to see what i did...
<Zyclops> khaladan: would i be able to send you the js?
<khaladan> sure
<Zyclops> basically there are 4 user definied functions in the html file
<Zyclops> when you right click in the area of those red boxes, it should display the function called, and the data contained within the lang tag of the element which triggered the even
<Zyclops> t
<khaladan> okay
<khaladan> i see two red boxes
<Zyclops> yeap, right click in the top one
<Zyclops> or on the link
<Zyclops> or on any of the li's
<khaladan> ok
<chino> am i alloud to do while(1) { } ?
<khaladan> and what is desired?
<khaladan> i'm not getting the menu for the LIs in IE, but i am in FF, btw.
<chino> im using xmlhttprequest to update a certain part of a page so i wanted to do while(1){ sleep 5; //do xmlhttp } so that the part of the page updates every 5 seconds
<Zyclops> wehn you click on Mark Complete, it gets the contents of the lang tag and p***es it to a custom object defined in the array
<Zyclops> thats strange, its working in my ff
<Zyclops> and IE
<TheoCode> adios guy
<Zyclops> ahh actually
<Zyclops> nope not in IE
<Zyclops> minor issue :)
<Zyclops> notice how though if you click on delete, it returns mark_complete
<khaladan> yeah i see
<khaladan> heh oops
<khaladan> ok i see the problem
<khaladan> must be late :(
<Zyclops> ahh do tell :)
<khaladan> so we fixed the scope for the data but not for the function name
<khaladan> should be this:
<khaladan> new_menu_item.onclick = function(o, f) { return function() { window[f](o.event_element_data); } } (this, call_js_function);
<Zyclops> i think that qualifies for an omg
<khaladan> heh
<Zyclops> thankyou for that, that code really does show some amazing understading
<Zyclops> lol, there is no way i'd have ever worked that out
<chino> help
<khaladan> heh thanks, yea using closures can be tricky
<khaladan> chino there is no js sleep, see setTimeout instead
<Zyclops> i think thats the hardest problem/solution i've ever had
<Zyclops> i seriously thought this was only going to take 4 - 5 hours to finish :)
<khaladan> :) well, now you know how to capture data properly using anonymous functions!
<khaladan> by making a new lexical sope with another function that returns a function!
<chino> can i get away with that ?
<khaladan> no sir
<chino> has to have a value for the function ?
<khaladan> yes
<chino> ok
<khaladan> setTimeout runs a function after x milliseconds
<Zyclops> yeah so my understanding of that code is onclick, call a function with two arguments o, f so that o = this and f = call_js_function. we need to return a function to get a new lexacal scope, but every function gets a new reference to this and a different call_js_function
<khaladan> yeah
<khaladan> that's it
<khaladan> see, the way it was SEEMED like it might work because the variables where in a loop, but if it DID work that way, then say you had var x = 1; function foo() { alert(x); } x = 2; foo(); // what gets alerted?
<khaladan> the answer is 2 of course
<khaladan> but when you do stuff like that in a loop it's easy to think it might be different, when it's not
<chino> while(true){ self.setTimeout('runUpdates()',5000); }
<chino> how about that ?
<khaladan> mmm
<chino> i put the cmd's into updates
<khaladan> that'd be bad too
<chino> why ?
<chino> it calls a function..
<khaladan> you'd end up calling runUpdates constantly
<chino> yea!
<chino> lol
<chino> Updates!
<khaladan> no, i mean, not just every 5 seconds
<chino> :\ huh ?
<khaladan> *constantly*
<khaladan> do this
<chino> but the timeout makes it wait
<khaladan> no
<chino> :[
<khaladan> setTimeout runs immediately
<khaladan> it doesn't sleep
<chino> This method is used to call a function or evaluate an expression after a specified number of milliseconds.
<khaladan> function runUpdates() { /* do updates */; setTimeout('runUpdates()', 5000); }
<khaladan> right, it says nothing about sleeping
<khaladan> then just call runUpdates(); once somewhere
<chino> but it says after so many milliseconds
<khaladan> right
<khaladan> and it will
<chino> im lost
<chino> i know what your new function does its recursive
<khaladan> setTimeout('foo()', 10000); alert('hi');
<khaladan> when does hi get alerted?
<khaladan> immediately
<khaladan> then foo runs 10 seconds later
<khaladan> chino so what's wrong with my method?
<chino> after foo
<khaladan> no not after foo
<chino> nothing im just saying i dont undersatnd
<khaladan> hi gets alerted immediately
<khaladan> not after anything
<chino> oh i get it
<chino> it makes it wait while everything else goes on
<chino> thats what they ment
<khaladan> right
<chino> ah so that would litarlly loud infinite ammounts
<khaladan> right
<chino> bah
<chino> thanks
<khaladan> so, consider my method
<khaladan> it will do what you want, i think
<chino> so run updates then wait wil everything else goes on then run again
<chino> and so on
<khaladan> yes
<chino> cool funny how js has features i wanted in php lol
<khaladan> the languages have different uses :)
<chino> yea well php ****s ;p i'm having lots of fun with perl
<chino> can i just runUpdates(); right in my js file ?
<chino> yea of course right ?
<khaladan> yes
<khaladan> just call it once
<khaladan> and it'll go every 5 seconds after that
<chino> :[
<chino> how do i print again just so i can see if its working
<chino> cause im not getting any output
<khaladan> eh?
<chino> like print "inside loop"
<khaladan> alert("");
<chino> ah
<khaladan> that pops up a dialog box
<khaladan> with whatever text you want
<chino> no pop :\
<chino> http://forsaken-reborn.dyndns.org:81/~chino/chess/js/main.js thats my file if you got a moment
<khaladan> you have errors elsewhere
<chino> i do ?
<khaladan> yes
<khaladan> }else(method == 'chats'){
<chino> is there still more that i dont see ?
<chino> what am i doing
<chino> is thre an elseif ?
<khaladan> you want "else if"
<chino> sign up if you want
<chino> that part works
<chino> lol
<khaladan> :) that's all i can see
<chino> what do you mean
<khaladan> as far as errors
<chino> ah cause the rest of hte page comes form xmlhttprequest
<chino> oh


Return to javascript
or
Go to some related logs:

web
football
cataclyst linux

Copyright © 2005 www.irclogs.ws. All rights reserved. » disclaimer » contact