well not unless i want to extend the extention im using i guess is it normal for javascript to force you to nest
no, something could generate a fake load event; but that's unlikely
ok thank you very much
("it isn't" === "it's not")
does eval() return a string also?
or would I have to do String(eval())
is there a way to create multi-line strings without escaping tons of stuff and wrapping each line in a var += ""; junk?
i'm geting an object required error from "var totalCost = document.getElementById("cost").value;"
I create an iframe, set its onload property to output a message and its innerHTML, then set its src property. I run it once and only the message shows, on the second time the HTML shows and for all times after that unless I refresh the page.
so why isn't the contentDocument.body.innerHTML showing on the first execution?
If I just run it once and the HTML doesn't show, then if I run just the command to output the HTML it works. so that means the onload is firing when the html hosting has not loaded fully?
roeic which way do you call innerHTML?
iframe.innerHTML?
iframe.onload?
iframe.contentDocument.body.innerHTML
iframe.onload = on_load();
which spits out the innerHTML to the console
do i have to poll the readystate or some other workaround?
iframe.onload = on_load;
on_load would be an immediate function call.
*on_load()
You should probably try to attach the event listener to the window object, which isn't necessarily the iframe itself.
iframe.contentWindow.onload for IE, for instance.
i'm in firefox
You've heard there are other browsers out there, right?
Or are you doing a private thing?
no! i'll google event listeners and see what turns up
it is a development script for now so i just need it to work in my test enviornment
Hmm well if that satisfies you…
well the first step is for it to work?
yeah sure
i'm trying to have the iframe load synchronously and JS seems to make that difficult
Synchonously as in you want it to be loaded before the stuff following it in the document?
meaning i want my javascript code to wait until the iframe has loaded before continuing to execute
ah ok
iframe.addEventListener("load", function() { console.log( 'onload ' + iframe.contentDocument.body.innerHTML ) } )
why isn't that valid?
Not valid as in?
Error message, or is it just not doing anything?
Third argument is missing, by the way.
it just doesn't do anything
addEventListener(eventName, function, capture)
http://wiki.greasespot.net/HTML_injection_tips — that is the site i found
ah i was missing the 3rd argument.
Yeah, and they pass the third argument.
I found the docs for addEventListener, that's what i needed.
but now how to solve the sync problem? i want control flow to halt
You cannot halt anything in Javascript.
It's a single thread, you cannot pause it.
You can create another thread, and make it resume your currrent operations in n milliseconds.
setTimeout(function() { tryAgain(); }, 1000);
yes so it's setTimeout polling, i've done that before
You can of course use the onload event of the iframe to continue whatever you're waiting for.
i'm trying to avoid encapsulating the rest of my program in either a setTimeout or an onload event listener function
is there no way around doing so?
nope
sockets
sockets? how…
….
i don't think they apply !
TheCaster have you ever seen a function like waitUntilLoaded( function() { ..code..} ) to solve the problem before?
That piece of code doesn't make sense to me.
can something like that be done in native javascript without XPCOM?
You don't have to wait for functions to load in JS.
whenLoaded( function(){ /* code to run */ } );
The first thing the JSEngine does is examine functions.
i understand, that's using a function of an extention to firefox
so there is no way to have similar functionality in native javascript?
I still don't quite get what you're driving at.
waitUntilLoaded(function() { … }() );
?
yes that works but can that be done in native javascript without XPCOM?
that waits until the page has loaded
and then resumes execution
I don't know XPCOM, but the code up there doesn't make sense either.
so the only two solutions I have are setTimeout and putting code in the onload listeners function?
waitUntilLoaded(iframe.onload)
Is that it?
well that would be nice
how they made the function is that waitUntilLoaded fires when the document is loaded
so you would do something like load(iframe.onload) whenLoaded(…)
but that's exactly what i want, what you typed there.
i just cant seem to avoid encapsulating my entire program each time i want to wait for an event which seems crazy.
You don't have a choice at that point.
well not unless i want to extend the extention i'm using i guess. is it normal for javascript to force you to nest setTimeouts for each thing you are waiting to load when the order matters?
You have to break your code at that point and make iframe.onload call some function continueing it.
yeah
so if i'm waiting for 5 iframes then i need 5 nested setTimeouts…
isn't this a very common problem to solve with javascript?
i don't want to force users to have to download an extention.
No, you require one timeout periodically checking each of the five iframes.
so every 5 seconds or so check to see if the onload event has fired for each iframe?
Or you just make each of the iframes call a function iframeReady(id) onload and let that function decide when to continue with the remaining code.
hi.. i m using tinymce using aculo drag/drop it creates textarea dynamically, but its not showing textarea as editor..
how would having the iframes call a function(id) work? i had thought about having them set a value in an array that is iterated through each time setTimeout is run
function(id) would have to set some sort of global var, right?
yeah
A single values does the job, though.
*value
func(1) func(2) func(4) func(8) func(16)
how? the solution i thought about was having a global array the size of the number of iframes to be kept track of.
so the number determins which codeblock to run within func?
function func(value) { myVar &= value; if (value == 31) {/*ready*/} }
eh pardon me
myVar |= value;
|?
binary bitwise operator
i don't understand what that does
myVar |= value; gains you what ?
I can use a single variable, and I don't only know when all of the five iframes are ready, but also which of the iframes have been loaded already.
Initially myVar is 0.
That is binary 00…0000000
|= 1 would result in 00….0000001
00….0000010
this is pissing me off
http://pastebin.ca/673216
| is binary or ?
The paste 673216 has been copied to http://erxz.com/pb/4203
how could I do that?
google won't let me search for |=
Yeah, binary or.
what is myVar going to be used for now that it has this binary value from 'myVar | value' ?
if func is determing what blocks of code to run depending on the value returned from onload, isn't the value var enough?
That is each time you sort of "add" a value (1,2,4,…), you get the current value and a '1' at position 1 (2^0), 2 (2^1), 4 (2^2) … (speaking of the binary representation
I thought you wanted to wait for all of the frames.
i do
so it is a counter?
jep
is there a link for using binary or as a counter in javascript so i can read more about it?
i have not seen this before
dunno
You could read up about binary operations in general.
i know some that are useful but for a counter i would just use myvar+=1
Or for a start you could just add up all the incoming values using the common + operator.
Sure, but how would you check whether iframe 2 was loaded?
myvar is global correct?
You cannot do that in a single operation.
Yeah, global.
so the binary trick enables us to determin which specific ones have loaded and not loaded yet?
without using an array
exactly
that is very handy
you are brilliant!
not quite
if (myVar & 2)
That would give 0 if second frame wasn't loaded, 1 otherwise.
gikid what is it you're trying there?
well
ugh
let me look at it again
i forgot
0
these binary tricks must have been discovered a long time ago and work in all the languages. is there a book or website about them that you know of for learning?
roeic no, sorry
how did you learn?
ok, theres a button, you press it and it adds a first user price, from there you can keep clicking it and it will add an additional user price
They're the basis of anything in your computer, so…
its adding this price to a text box
Those operators are even hardwired in your machine.
gikid no it's not.
i dont even know what im doing anymore
bleh.value is a string, not a reference to your text field.
i know that! i want to use them in the context of programming though to do neat things.
maybe I should go to bed
i though I read somwhere that the text firld could be modified throught bleh.value
Sure it can, but bleh.value *is* the value, not a reference to the text fields value.
So doing 'var myvar = bleh.value; myvar = 5;' doesn't change the textfield's value, but the value of myvar.
It's a simple string.
var myvar = totalcost; if (…) { myvar += addcost; } else { …. }; bleh.value = myvar;
i should have known that
ok
thanks
ah wait
is it possible to grab all the inputs which names are selected[] and see if they are greater then 0. kind of like if ( sizeof( selected[] ) ) alert();
var myvar = +bleh.value;
That way.
THANK YOU
it works perfectly now
i owe you something…
crap now look what I did….
I made my self owe someone something because of my early morning stupidity
schnoowork there is no predefined function for that.
Yeah, you should probably go to bed.
var count = 0; function add(id) {count |= id;};add(3);if (count&2) {output( 'count & 2' )}
shouldn't that not output count & 2 because 2 didn't go off yet? only 3 did
TheCastor, is it possible or easy to do ?
roeic it's not that easy.
3 is binary 0…0011
2 is binary 0…0010
They match to some extent, right?
no?
they are unique binary numbers
so they are different by one bit
Yeah.
But that's not the bit you're checking with 'value & 2'.
but you said ' That would give 0 if second frame wasn't loaded, 1 otherwise.'
did i not understand correctly?
what is the proper way to check then?
But I didn't use 3.
I used 1,2,4,8,… for a reason.
but there are 5 iframes
!!!!!
it only works in base two
jep
It's not a solution for everything, as an integer gives you only 32bits.
so i should just Math.pow(id,2) and then it will be fixed ?
schnoowork if a loop matches what you'd call easy, then yes.
They're not created dynamically, so you could just fix it manually, no need to call Math.pow for that.
i'm after a dynamic solution though, both the checking and the ids have to be in sequential powers of two
document.getElementById('firstSubmenu').class='open' set class="open" of the element who has that id ?
15 does what you did via Math.pow.
No, it'll create a new property called "class" and assign "open" to it.
a left bit shift?
mixandgo class is a reserved keyword.
You probably want className.
className is what you're looking for.
That doesn't mean you can't use it as a property.
var foo; foo.class = "a"; foo['class']
Aankhen“: Error: Error: missing name after . operator at line 0: var foo; foo.class = "a"; foo['class']
Aankhen“ it pretty much does.
var foo = { }; foo.class = "a"; foo['class']
Aankhen“: Error: Error: missing name after . operator at line 0: var foo = { }; foo.class = "a"; foo['class']
thank you
Whoa.
var foo = { }; foo['class'] = "a"; foo['class']
Aankhen“: a
Ah, there we go.
You can use it as a property name, just not using the dot form.
1 5 works but it starts at 32 … ?
Aankhen“ yeah right, *you* can use it.
how can I make sure a number is always carried out to 2 decimal places?
Not talking about the browser making anything out of it.
roeic 2^5 is 32…
I pointed that out to mixandgo quite a while ago.
Er, TheCastor.
Aankhen“: i'm not sure if I was here?
Sorry, that sentence was misaimed.
ah
can I change the id of an element ? with document.getElementById('firstMenu').id='something'
Sure.
thanks
NP.
1# changing # changes the exponent resulting in powers of two ?
GOOGLE IS GOD
num.toFixed(2)
is what i wanted
heh, this script is getting sexy
Pervert.
lol
roeic yeah
this might seem like a dumb question but what is the correct spelling for Javascript? is it javascript host or Javascript?
JavaScript.
really, it is in camelCase?
Look at it again and you should be able to answer that for yourself.
yes, you'e absolutely right
that was a dumb question
this is camelCase. This Is StudlyCaps.
Or so I've been tol.
Told, even.
HotJava + LiveScript = JavaScript ! right ?
heh, got it
I don't quite remember the history of JS, but I don't believe that's correct.
I belive it is
I don't see any mention of HotJava at http://www.oreillynet.com/pub/a/javascript/2001/04/06/js_history.html.
Nor at http://javascript.about.com/od/reference/a/history.htm.
Nor at http://www.howtocreate.co.uk/jshistory.html.
The only relation JavaScript has to Java is the name.
Douglas Crockford tells a bit about the history of JS
http://developer.yahoo.com/yui/theater/
Livescript was not developed by Sun, and Sun was only involved in terms of the name, not the implementation itself.
Douglas Crockford "The JavaScript Programming Language"
hello
I have an select list on my site
now I want to find out with javascript which option is selected
create an option object from that line
and then edit that option line
and put it back in the select on exactly the same place
any tips on how to do that?
I know I can use document.getElementById('ID_of_select').selectedIndex to find out which option is selected, but how to create an option object from it?
hmm
idea
document.getelementById('ID_of_select').options[document.getElementById('ID_of_select').selectedIndex].text
hello
tag ?
bonjour
replace(/nbsp/g,"") should stript all nbsp strings rite ?
yes it does
w00t
my idea seams to work
`js domref
w3.org/DOM/ , http://developer.mozilla.org/en/docs/DOM , www.mozilla.org/docs/dom/domref/ , www.zvon.org/xxl/DOM2reference/Output/index.html , www.krook.org/jsdom/ , http://phrogz.net/objJob/languages.asp
anything blatantly wrong with this? http://pastebin.ca/673293 keypress works fine but calling keydown followed by keyup does not
The paste 673293 has been copied to http://erxz.com/pb/4208
Douglas Crockford is a pretty sharp guy
i like him
he made jslint, right?
yes
useful
he also made this really handy object function
i learned a lot about OOP from him
and has some interesting things to say about inheritance
yeah
and he made me really appreciate javascript
yeah, it's beautiful
i want to have sex with it
I want to implement javascript on mobile devices, like in palm os, or on gba
it's already kinda on nintendoDS in opera
that's pretty cool
I'm dreamin. Compilers are damned hard
yeah i stick to regular browsers
i like the feel of it
But I'm hopeful, cos if you look on crockford's site, he has an article detailing how to write a javascript compiler
in javascript
haha nice
it compiles to what?
other javascript?
well he doesn't go all the way
so it's just the parsing phase
hmm
it outputs a parse tree
XML
nah
json
of course
ahh
that's how he implemented jslint
it's a javascript compiler
sounds pretty sweet, but beyond me
written in javascript
anything wrong with this statement ? document.getElementById('subSubMenu1').display='block';
document.getElementById('subSubMenu1').style.display='block'
i think that would be better maybe
tobins2, thank you
you're welcome
good catch
i'm experimenting with crazy stuff now
in java servlet hosting mostly
rhino involved?
no
just regular web stuff
JSTL and custom tags
oh, and socket servers
now i'm playing with applets
i hate them, but it needs to be done
I'm submitting a form. But I do some validation with JS. when that validation failes I don't want to submit the form. But how can I stop that submit? I thought it was by putting return false in the onSubmit attribute, but it still submits
is return false in the method you wrote or directly in the onSubmit="" ?
both . It is in the method AND in the onsubmit valkue
ahh, cause i've found it needs to be directly in there sometimes
hi room
how can I check that mouse over some div?
Who is that room? Heard of him several times, never met him though.
yeah, I had it first only in my method. Then I copied it to the form tag
but it still submits
he is always here, but keeps silence… very imperturbable admin…
Cybertinus normally it's onsubmit="return myfunc()", function myfunc() { ….; return false|true; }
ok TheCastor
gonna try it that way
anyone can answer me??
Gorb well that's a tricky thing.
onmouseover and onmouseout
yeah thats my trouble ))
However, you have to check if, onmouseout, you're really leaving the element or just entering one of its childnodes.
….and there is no way to check it?
I have like you said, but it still submits
err, I think I know why
myfunc() has a few errors
I want to find out what they are
so I want to stop the submit
but it doesn't call return false, because myfunc() is chrashed before it
Remove the onsubmit handler and use onclick instead.
temporaly switch my submitbutton for an normal button
indeed, and then move the onsubmid handler to the onclick of that button
Gorb there's onmousemove, but that's very expensive talking about resources.
ok I'm understanding
thank you a lot
argh
problem found
2nd time the Mozilla DOM reference isn't correct :/
Cybertinus huh?
http://developer.mozilla.org/en/docs/HTML:Element:select I see an method setSelectedIndex() method there. When I use that function in Mozilla Firefox 2.0.0.6 I get an error that that method just doesn't exists :/
this happened to me yesterday also, but then with the method getSelectedIndex()
Cybertinus that's an object reference.
The backend.
selectedIndex
ok, my fault then
where can I find then all the things I can do with an object?
Hmm devguru, for instance.
devguru.com
indeed
thnx TheCastor
that was where I was searching for
anyone up for a challenge?
Choose your weapons.
http://erxz.com/pb/4209
i need to figure out how to make that rotate in the center of the canvas
http://erxz.com/pb/4210
full html there
first one is the js
its rotating around the 0,0 axis
http://developer.apple.com/documentation/AppleApplications/Reference/SafariJSRef/Classes/Canvas.html#//apple_ref/javascript/Canvas.restore
thats the canvas class reference
and i'm thoroughly confusticated.
re
i think i have to change the coordinates dynamically, according to the rotation
And the translation to -300 is correct?
nope
thats kinda just mid-stream-of-conciousness hacked up code
i took an example from some site and im in the process of figuring out how it works
I wasn't referring to the value itself, but to the sign.
Have you tried a positive value?
yup
ctx.translate(-300, -300)
that gets it to rotate around the 0,0 point, almost
ctx.translate(-250, -250) gets it to rotate around 0,0 perfectly, since its 500×500 image
Draw the image to 0,0
translate before rotate
Error in translation: Language "Before" is not available
That does the job.
Well, draw the publish your images online to -imageWidth/2, -imageHeight/2
buubot translate I don't like being interrupted.
Stored translate I don't like
Error in translation: Language "I" is not available
and this is why bot command always should begin with an wierd character (something like ^ or ` or something)
lol
perfect, man
its beautiful.
im gonna work on a mootools abstraction, if I can, now
hahaha, first, the rotation, tomorrow, the world
or at least a mountain dew bottling plant.
ya, I'd like that,
buubot javascript string
translate javascript string
Error in translation: Language "Javascript" is not available
translate german car
Error in translation: Cannot translate from "German" to "Car"
translate englisch javascript string
Error in translation: Language "Englisch" is not available
translate english javascript string
Error in translation: Cannot translate from "English" to "Javascript"
translate english german car
Auto
oha
translate english dutch javascript
Error in translation: Cannot translate from "English" to "Dutch"
stupid thing :p
why can't it do that?
deutsch auto?
or something like that
?
Dutch is the language that is spoken in The Nederlands
it isn't a typo or something
*nether
We all know.
Now, what's it with deutsch auto?
indeed, I didn't understand that either
deutsch is german in german, isnt it?
i dunno
I thought it was correcting my "typo" Dutch
been 10 years since high school german
was an abortive attempt at being clever
var xOff = img.height/2;
var yOff = img.width/2;
using that for the translate variables makes it easy
img.height1
hmpf strange client
whats wrong wiht this statement ? ul id="subSubMenu1" style="display: none;" onmouseout="style='display: none;'"
this.style.display='none'
style="display:none" for starters
granted, if you *want* it to be invisible, then its fine
but if you wanted to see it, then display:none is teh bad.
hi everyone!
works for an invisible element :/
Is there someone who's familiar with rhino?
I want it to be invisible by default and hide when mouse moves out
yeah
large, grey skin, big horns
I need to use rhino in several places of my program, different threads and stuff.
dont piss 'em off, they're kinda mean
oh
nm
mixandgo you want it to be…eh…invisible and then hide?
What should I store, Context, Scriptable or both?
block
(Or maybe I better ask on ##java)
setting a property that has only a getter
Ah ok, then the above solution should work.
you mean the "this.style" thingy ?
it doesn't work
hi there. Is there any way I can write something, so on blur,it changes a date format(could be 01-01-2007, or something else) to a correct format: dd-mm-yy ?
AdvoWork yeah, your very own way.
Anyone know whats wrong with "var content = document.getElementById("contentSub").innerHTML;"?
TheFearow and contentSub is what exactly?
A div with the id of contentSub
Nevermind, I was executing in head before the body was loaded
And your problem is?
I wish JLearn was here
Yeah, don't we all love him?
heh
It refused to work, but I found the problem
Yeah I got that, my typing was a little slow.
thanks TheCastor, i really appreciate that
that was my goal tonight, i wanted to make an image spin around
bthat was my goal tonight, i wanted to make an image spin around/b
good night, all
setting a property that has only a getter
read only
Which property is iti?
ul id="subSubMenu1" style="display: none;" onmouseout="this.style='display: none;'"
onmouseout
you probably want .style.display = 'none';
is reddit.com down?
GarethAdams, yes, thank you
mixandgo cannot you even copy text?
8 PM| TheCastor
TheCastor, I did'n notice the difference
style is not a plain string but an object, thus you cannot assign it a string.
something is not working right, the onmouseout event is applied to the entire ul, but it's catched when I mouseout a li
am I missing something ?
var ifr = document.createElement('iframe');ifr.addEventListener("load", function(){alert( ' onload ');}, false )ifr.src = 'http://google.com';
Hmm, it should fire the moment you *enter* a list item, not leave one.
why doesn't the even listener ever fire?
event*
Because ifr is only an element, not a window reference.
Or not necessarily a window reference.
er i didn't add it to the page x_x
TheCastor, so when I enter a li element, I leave the ul ?
mixandgo yeah
is there a way to pass a global var to a function by reference or do I have to use window.globalvar ?
You have to check whether the entered element is a descendant of the ul.
hmm… I thought thats default
roeic depends on the type. Number and string are passed by value.
do this on ul and nothing on descendants
for that I need to add some onmouseover event to each li ?
or is there a smart way to do it
There is.
onmouseout gives you an event object.
Containing a reference of the element you moved the cursor to.
Do you know how to deal with events?
not really, for now, but I am willing to learn
hmm
I setup a function to create iframes but it used the local var instead of the global var which i set the created iframe to
How would I source file in javascript?
I.e. read it and evaluate its contents?
ilyak you want to access a local file?
"cas" at 71.6.194.243 pasted "ul onmouseout="myfunc(event)"" (33 lines) at http://erxz.com/pb/4211
Yeah. And I'm using server-side js.
mixandgo look at that code sample
So security isn't a question.
ah
Should I just read it down and eval()?
Or maybe there's something like special for that case?
Or maybe I should call back to interpreter asking it to eval files for me?
true
TheCastor, thank you, I will try to understand how that works
Oh, I see there's load() in rhino.
Perhaps I should use that.
can anyone verify if reddit.com is down?
Yeah, it doesn't respond.
yes it is
very good question. One I would like to know the answer to as well
I get tru when comparing a subclass instance against either the subclass or baseclass… I don't think this should happen and I may be wrong in my implementation and so thought I ask
I get tru when comparing a subclass instance against either the subclass or baseclass… I don't think this should happen and I may be wrong in my implementation and so thought I ask