TechTalks from Nitin

September 29, 2007

GMScript: Small bubbles of information triggered by double-clicking any word

Filed under: Greasemonkey Script — TheOne @ 6:14 pm

Friends,

While visiting various sites i usually come around this problem. When I don’t know meaning of any word i have to open dictionay.com and than search for it.

So, to get a solution of this is came with a GreaseMonkey Script, which opens information bubble on double-clicking on any word in the page.

Example is shown in screenshot below: The meaning of “Slumped” is shown in a small bubble.

Dictionary on double-click

How to install this ?? here is the step by step guide to do so :

NOTE: This script uses services from answers.com. So all the credits are to them.

September 8, 2007

Moo.fx: Guide to use it with prototype (part 2)

Filed under: Uncategorized — TheOne @ 4:17 pm

Continuing with me last blog about accordion, here is another code example to use moo.fx V2.0 for changing style.

So lets start……

Just see the following lines of code to change left style property of any DOM element.

var leftdec = new Fx.Style(“panel2″,”left”,{duration:1000});
var d = $(‘panel2′);
leftdec.custom(parseInt(d.style.left), (parseInt(d.style.left) – 105));

Here Fx.Style(“panel2″,”left”,{duration:1000}); is everything. “panel2″ is the id of the DOM element. “left” is the property, and last argument of the constructor is optional properties.

Now it is the last line to change the “left” property. All we have to do is:

leftdec.custom(parseInt(d.style.left), (parseInt(d.style.left) – 105));

Here leftdec is the object we created.

custom is the function which requires two arguments, first is the property “FROM” and second is property “TO”. In this particular example i wanted to change left property current-105 so what is did is (parseInt(d.style.left) – 105).

Isn’t it really easy.

Javascript Effects Library: moo.fx

Filed under: Accordion, Javascript, moo.fx — TheOne @ 4:16 pm

Recently i was very much attracted toward moo.fx library. For my website I was previously using scriptaculous, but because of the size problem i decided to move toward moo.fx. The size of moo.fx library is really pretty low(its just around 3kb).
As a matter of fact i would like to tell u that i just wanted to use moo.fx over prototype, i didn’t wanted to use mootools. Actually initially when the development of moo.fx started it was just built on top of prototype.js, but later on they moved to make mootools as underlying library in place of prototype.
During my study i couldn’t find any good article on web which can give me some example to use just moo.fx. The documentation available on http://docs.mootools.net is using mootools library. Other resources available on internet are using some older version of moo.fx. So i finally thought that it would be better it i write something which can be used directly to use moo.fx library.

I don’t believe in talking about code, its always better to understand code as it is.
The first example is to make an Accordion.

At first include the files in <head> section

<script type=”text/javascript” src=”js/prototype.js”></script>
<script type=”text/javascript” src=”js/moo.fx.js”></script>
<script type=”text/javascript” src=”js/accordion.js”></script>

Write following code in <body> section.

<div id=”accordion”>
<h3 class=”toggler”>
History
</h3>
<div class=”element”>
<p>
The first suggestion that all organisms may have had a common ancestor and diverged
Venus physique. </p>
</div>
<h3 class=”toggler”>
Evidence of universal common descent
</h3>
<div class=”element”>
<h4>
Common biochemistry and genetic code
</h4>
<p>
All known forms of life are based on the same fundamental biochemical organisation:
common descent. Analysis of the small differences in the genetic code has also
provided support for. </p>
<div style=”clear:both”></div>
</div>
<h3 class=”toggler”>
Examples of common descent
</h3>
<div class=”element”>
<h4>
Artificial selection
</h4>
<p>
Artificial selection offers remarkable examples of the amount of diversity that can
selection, like the ones below, occurred without the guidance of modern scientific
insight.
</p>
</div></div>
Now come the actual catch: Copy this code in last of body section.

<script type=”text/javascript”>
var h3s =document.getElementsByClassName(‘toggler’)
var divs = document.getElementsByClassName(‘element’)
var accordion = new Fx.Accordion(h3s, divs);
</script>

I think this would help you in creating accordion using moo.fx.

Wait for next blog, to use moo.fx in changing styles.

Blog at WordPress.com.