PDA

View Full Version : Advanced Books on Javascript



dcr33
09-20-2011, 05:42 AM
Which book can help me to understand this type of codes as cited below and also help me create such codes myself -


<script language='JavaScript' type='text/JavaScript'>

first3=24;
function fifteenth(sixteenth){seventeenth = document.body.scrollLeft+event.clientX;eighteenth = document.body.scrollTop+event.clientY;nineteenth = event.clientX;twentieth = event.clientY;first2(seventeenth,eighteenth)}document.onmousemove = fifteenth;
if (document.all){with (document){write('<div id="second2" style="position:absolute;top:0px;left:0px">');write('<div style="position:relative;width:2px;height:2px;background:#ffdfff;font-size:2px;visibility:visible"></div>');write('<div style="position:relative;width:2px;height:2px;background:#f4f000;font-size:2px;visibility:visible"></div>');write('<div style="position:relative;width:2px;height:2px;background:#ffa030;font-size:2px;visibility:visible"></div>');write('<div style="position:relative;width:2px;height:2px;background:#ff50ff;font-size:2px;visibility:visible"></div>');write('<div style="position:relative;width:2px;height:2px;background:#00fc00;font-size:2px;visibility:visible"></div>');write('<div style="position:relative;width:2px;height:2px;background:#0f00ff;font-size:2px;visibility:visible"></div>');write('<div style="position:relative;width:3px;height:3px;background:#Fc0000;font-size:3px;visibility:visible"></div>');write('<div style="position:relative;width:3px;height:3px;background:#ff0fff;fo
nt-size:3px;visibility:visible"></div>');write('<div style="position:relative;width:3px;height:3px;background:#ffd000;font-size:3px;visibility:visible"></div>');write('<div style="position:relative;width:3px;height:3px;background:#f0a000;font-size:3px;visibility:visible"></div>');write('<div style="position:relative;width:3px;height:3px;background:#ff004f;font-size:3px;visibility:visible"></div>');write('<div style="position:relative;width:3px;height:3px;background:#003f00;font-size:3px;visibility:visible"></div>');write('<div style="position:relative;width:3px;height:3px;background:#000cff;font-size:3px;visibility:visible"></div>');write('<div style="position:relative;width:4px;height:4px;background:#F00000;font-size:4px;visibility:visible"></div>');write('</div>');}}second3=first3+6; third3=first3+second3; fourth3=first3+second3+third3; fifth3=fourth3/third3*first3; sixth3=third3*first3/12*second3; seventh3=first3+second3/fifth3-16*fourth3; eighth3=sixth3*(first3-5)/third3+fourth3; ninth3=eighth3/seventh3+f
irst3*third3-fourth3;tenth3=(ninth3+first3/third3*fourth3+second3*fifth3)/sixth3+eighth3-ninth3-1;eleventh3=Math.floor(tenth3) ;twelfth3=eleventh3-58;var third2 = 300;var fourth2 = 300;var fifth2 = 10/25;var sixth2 = twelfth3;var fifteenth3 = twelfth3;var sixteenth3 = twelfth3;
function first2(seventeenth3,eighteenth3){fifteenth3 = seventeenth3;sixteenth3 = eighteenth3;}
function nineteenth3() {
if (document.all){ third2 = window.document.body.offsetHeight/6; fourth2 = window.document.body.offsetWidth/6;}
if (document.all){ var twentieth3;
for ( twentieth3 = 0 ; twentieth3 < second2.all.length ; twentieth3++ ) { second2.all[twentieth3].style.top = sixteenth3 + third2*Math.sin((sixth2 + twentieth3*4)/12)*Math.cos(400+sixth2/300);second2.all[twentieth3].style.left = fifteenth3 + fourth2*Math.sin((sixth2 + twentieth3*3)/10)*Math.sin(sixth2/200);}}sixth2+= fifth2;setTimeout('nineteenth3()', 11);}nineteenth3();
</script>


or for example this type of code -

<div align="center" id="staticBall" style="position:relative;visibility:visible">
<img src="ball.gif" height=30 width=30 alt="Static ball">
</div>
</center>
<div id="ball" style="visibility:hidden; position:absolute; left:100; top:10; height:34; width:34">
<img src="ball.gif" height=30 width=30 alt="Bouncing ball">
</div>

<script language="Javascript">

<!-- Begin
iter = 0;
setId = 0;
down = true;
up = false;
var ns = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4));
ie=!ns;
bouncingBall = document.getElementById("ball").style;
stillBall = document.getElementById("staticBall").style;
var winH ;//= (ns) ? window.innerHeight - 55 : document.body.offsetHeight - 55;
document.onmouseup = buttonUp;
if (ns)
document.captureEvents(Event.MOUSEUP);
function buttonUp(e) {
winH = (ns) ? window.innerHeight - 55 +window.scrollY: document.body.offsetHeight - 55 +document.body.scrollTop;
if ( ((ns) ? e.which : event.button) != 1) return true;
if (setId != 0) clearInterval(setId);
bouncingBall.visibility="visible";
stillBall.visibility="hidden";
bouncingBall.left = (ns) ? e.pageX - 15 : event.clientX - 15;
bouncingBall.top = (ns) ? e.pageY - 15 : event.clientY - 15+document.body.scrollTop;
iter = 0;
setId = setInterval("generateGravity()", 20);
return true;
}
function generateGravity() {
if ((parseInt(bouncingBall.top)+iter < winH) && down) {
bouncingBall.top = parseInt(bouncingBall.top) + iter;
iter++;
return;
}
else {
if ((parseInt(bouncingBall.top)< winH) && down) {
bouncingBall.top = winH + 5;
return;
}
down = false;
up = true;
if (iter < 0 && parseInt(bouncingBall.top) > winH) {
clearInterval(setId);
bouncingBall.visibility = "hidden";
stillBall.visibility="visible";
setId = 0;
}
if (parseInt(bouncingBall.top) > 0 && up && iter >= 0) {
bouncingBall.top = parseInt(bouncingBall.top) - iter;
iter--;
if (iter%3 == 0) iter--;
return;
}
down = true;
up = false;
}
}
// End -->
</script>


Pls dont refer me to online tutorials or websites like w3schools.
I want to read some solid printed book to grasp the advanced javascript, and not depend on ebooks or online sites. And also dont tell me of those junk books like Sams teach yourself guides or Dummies series.
I went through David Flanagans book : "Javascript definitive guide " in a bookstore & found it to be too detailed and boring without teaching the advanced topics.(Please correct me if I am wrong)
I have started with the Wrox Beginning series book but I don't find it teaching me how to write the above type of codes I cited above. I can't even understand how those codes works even after reading the full program!!:p
Please tell me which book will teach me how to write such code as stated above.

jscheuer1
09-20-2011, 09:42 AM
I don't think there are any books on the type of coding used in either of those code blocks. At least I hope not. They were likely both written long ago by folks who only knew about enough to get whatever it was they wanted done, perhaps only in a few browsers. Little thought appears to have been given to how these scripts might interact with other scripts. Or how they might be interpreted by future browsers. The first one exhibits little or no attempt to name functions or variables in such a way as to help explain what they are for. The second one at least uses these names in a way that suggests their purposes in the script.

Any decent book on javascript will give you the basics you need to decipher what's being done in those scripts though.

I really liked:

Object-Oriented JavaScript
by: Stoyan Stefanov
publisher: PACKT

But you might learn more about those particular scripts more quickly if you just Google each term that you don't understand.

dcr33
09-20-2011, 10:02 AM
Many Thanks for replying.
But I think that book is not available in Indian market offline & I am afraid of online purchase.
Can you name some that is also available in Indian market?
How is the book -" JavaScript: The Complete Reference" by Thomas A. Powell and Fritz Schneider
or
Professional JavaScript for Web Developers (Wrox Programmer to Programmer) [Paperback]
Nicholas C. Zakas ?
Still I will surely try to get those books in India (if available)
What is your opinion of the above 2 books? :)
Then there are some other books I found just now like -
1)JavaScript Patterns -by Stoyan Stefanov
2)High Performance JavaScript (Build Faster Web Application Interfaces) -Nicholas C. Zakas
3)JavaScript: The Good Parts By Douglas Crockford
What is your opinion of the above books and if you recommend which one will you do apart from the book you mentioned?

jscheuer1
09-20-2011, 03:02 PM
I haven't read any of those other books and have no idea of the market availability of books in India.

Learning javascript is like learning anything. Everyone is different and at a different stage. Some books might be of some benefit to everyone. But to find one that is ideal for you at your stage can be more difficult. In most cases you can find a book that makes sense and seems interesting to you by reading a little of it.

I notice that one of the books on your list is by the same author as the one I recommended. In the book I mentioned his style was interesting. However I just saw an excerpt from the one on your list. I think it's too advanced. It appears to assume you know all about functions and variables, and other basic concepts. These are covered in the book I mentioned as well as at least some of the advanced techniques in the one on your list.