Sunday, August 30, 2009

Google code

Yest i wanted to publish my work related to javascript here and blogger had irritated me to the extent possible. It doesnt allow me to put HTML content and if i put it in Edit HTML mode then it uses its itelligence to destory my code and indentations. Finally i used Text area tag of HTML to do it. Even in this the blogger inserted un-necessary irritating
codes. huh! how do i get over this?

Then thought if content delivery sites can help me and went to Ziddu.com; now this fellow doesnt allow me to  upload HTML content. oh god!

I remembered i read about cloud computing at one of the sun forums; and heard Google gives an app engine. I tried with google and uploadded an applicaiton on that app server to serve my file.

I dont know how long will he let the content exist there; i didnt make any effort to know it either.:(

Ok what ever, finally got my things working on Google App server serverd via google CDN; he was mentionling about some payment on his site (if i read it right then it comes in when hits > 5million peryear?)

finlly happy ending.

Accordian -starting

below is the code that creates multiple divs one below the other and when clicked flies them down. This is a very very naive form of accordian implementation, however a good start. Hope some body out there is searchig for a simple example of how this one works. View source for this iframe below to get the src code.

Saturday, August 29, 2009

funny ans


2 women in heaven

1st woman: Hi! My name is Sandra.
2nd woman: Hi! I'm Sylvia. How'd you die?

1st woman: I froze to death.
2nd woman: How horrible!

1st woman: It wasn't so bad. After I quit shaking from the cold, I began to get warm & sleepy, and finally died a peaceful death. What about you?

2nd woman: I died of a massive heart attack. I suspected that my husband was cheating, so I came home early to catch him in the act. But instead, I found him all by himself in the den watching TV.

1st woman: So, what happened?

2nd woman: I was so sure there was another woman there somewhere that I started running all over the house looking.
I ran up into the attic and searched,and down into the basement. Then I went through every closet and checked under all the beds.
I kept this up until I had looked everywhere, and finally I became so exhausted that I just keeled over with a heart attack and died.

1st woman: Too bad you didn't look in the freezer---we' d both still be alive.

PRICELESS!

Q


Wednesday, August 19, 2009

Q

Never interrupt your enemy when he is making a mistake.
-Napoleon Bonaparte (1769-1821)


Tuesday, August 18, 2009

Q

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.
Albert Einstein (1879-1955)


Sunday, August 16, 2009

Drag

I jus did some experiment to get the drag drop func of elements and finally below is the code i could get working; The element gets draged on mouse over.

there are a few issues.. say when u make a quick drag and the mouse goes out .. i.e.. the element is not attached to the mouse evet. Ok the blogger isnt allowing me to put the HTML code. I m putting the css + js. Just include the div with id called draggableId in ur html nd things should work.

var origX;
var origY;
var flag=false;
function drag(){
var evt=window.event;
var v1 =evt.clientX + document.body.scrollLeft - document.body.clientLeft;
var v2 =evt.clientY + document.body.scrollTop - document.body.clientTop;
if(!flag){
flag=true;
origX=v1;
origY=v2 - 10 ;
}
var deltaX=v1-origX;
var deltaY=v2-origY;
var divEle = document.getElementById('dragableId');
//alert('>>' + divEle.offsetLeft);
divEle.style.left = divEle.offsetLeft + deltaX;
divEle.style.top = divEle.offsetTop + deltaY;
origX=v1;
origY=v2;
}

div.dragable{
position:absolute;
background:yellow;
right:500px;
top:300px;
padding:20px;
}

[div id='dragableId' class='dragable' onmousedown='drag();' onmousemove='drag()' ]
This is dragable
[/div]

A more nices + complicated impl is at: http://www.brainjar.com/dhtml/drag/

Saturday, August 15, 2009

Ek chotisi love story

Once upon a time, a guy asked a girl 'Will you marry me?'
The girl said, 'NO!' And the guy lived happily ever after and rode motorcycles and went fishing and hunting and played golf a lot and drank beer and scotch and left the toilet seat up and farted whenever he wanted.

Tuesday, August 11, 2009

Writing content at the cursor location in text area

This was the problem and it ate all my day. Mozilla is a good boy and gives an attibute which can help, but IE.. aaah! what ever, the below is the code to do the same.

     var objTextArea = dc('contentId');
     objTextArea.focus();
       document.selection.createRange().text = link.innerHTML;
       objTextArea.caretPos = document.selection.createRange().duplicate();

actually i got this from this site: http://forums.aspfree.com/html-javascript-and-css-help-7/tip-adding-text-in-caret-position-of-textarea-39329.html; infact he gives a working html code also.

Monday, August 3, 2009