Google Code Style ?

A

AzGhanv/.

Hi,
really intresting query ...

At page ....... http://www.google.com/reader/view/

i found this code ........ now on clicking the Feed Setting... it
shows another div which act as a submenu.Can any one tell me, how can
one attach a onClick handler without giving an ID to an span. <span
class="button-body unselectable">Feed settings...</span>

Any idea how'd google managed it.
It seems really advance thing, meaning full answers are appreciated.
Thanks.

Following is the full code ...

<table id="stream-prefs-menu" class="button-container unselectable
button-container-menu single-feed-menu">
<tbody>
<tr>
<td class="btl"/>
<td class="btr"/>
</tr>
<tr>
<td class="bbl"/>
<td class="bbr">
<div class="button-body-container">
<div class="button-menu-arrow"/>
<span class="button-body unselectable">Feed settings...</span>
</div>
</td>
</tr>
</tbody>
</table>
 
A

AzGhanv/.

Thanks for replying but,

I got this idea too but finally changed my mind as ...
the document.getElementsByTagName('span'); is the most exhaustive
search of DOM, and i'm sure one cant get the performance by doing
document.getElementsByTagName again and again.

What do you think?
 
A

AzGhanv/.

AzGhanv/. said the following on 4/21/2007 1:57 AM:

<top-posting corrected>

Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?






And thank you for not top-posting in the future.


Actually, getElementsByTagName('*') would be more exhaustive.


You don't do it "again and again", you only have to do it once when the
page loads. Assign the event handlers. Why do you think you have to do
it again and again?


After looking at the page and being required to sign in to see what you
are talking about, I decided it wasn't worth the effort required to see
how Google does it. I would be pretty confident in my conjecture about
how they do it though. It is the simplest way to do it short of
explicitly assigning it:

<span onclick="someFunction()">

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/

Any one else have any better idea ... about googles implementation.
Im not satisfied with above reply!

Thanks
 
R

RobG

AzGhanv/. said the following on 4/21/2007 1:57 AM:
AzGhanv/. said the following on 4/20/2007 4:17 PM:
Hi,
really intresting query ...
At page .......http://www.google.com/reader/view/
i found this code ........ now on clicking the Feed Setting... it
shows another div which act as a submenu.Can any one tell me, how can
one attach a onClick handler without giving an ID to an span. <span
class="button-body unselectable">Feed settings...</span>
Without even looking at the code, the answer is simple.
var allSpans = document.getElementsByTagName('span');
Then iterate the collection checking the className and when it matches,
you assign an event handler. [...]
I got this idea too but finally changed my mind as ...
the document.getElementsByTagName('span'); is the most exhaustive
search of DOM,
Actually, getElementsByTagName('*') would be more exhaustive.
You don't do it "again and again", you only have to do it once when the
page loads. Assign the event handlers. Why do you think you have to do
it again and again?
After looking at the page and being required to sign in to see what you
are talking about, I decided it wasn't worth the effort required to see
how Google does it. I would be pretty confident in my conjecture about
how they do it though. It is the simplest way to do it short of
explicitly assigning it:
<span onclick="someFunction()">

Any one else have any better idea ... about googles implementation.

I doubt it.

Im not satisfied with above reply!

Then look yourself at the their obfuscated, minified code - it's here:

<URL: http://www.google.com/reader/ui/1133234683-scroll.js >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top