PDA

View Full Version : JavaScript Timer Bookmarklet


TheRafeSCV
01-15-2010, 03:05 AM
Hello everyone, I have some previous programming knowledge but need some help with this. I need to create a JavaScript bookmarklet like the one that Instapaper.com (http://www.instapaper.com) has.

I want for this bookmarklet to have the following functionality and look:


Popup on the corner of the page (which I could specify in the code)
Display a count-up timer from 0 to 60 seconds
Have a "timer"-like icon/graphic under the main count (see the instapaper.com script)


Those are all the basic requirements however, if someone could do the above and also help me with these that would be greatly appreciated:


From 45 seconds to 60 seconds, I would like the font color red and flashing
After 60 seconds, I would like it to display a messagebox with a message I could enter
If before 60 seconds, you click on it, it would close


... and those are all the more complex requirements. If there is a way to make an "option" button under the element where you could customize these fields, that would be great!

Any and all help pointing me in the right direction or providing me with some code would be awesome. Also, I'm not sure how much of this is do-able but if someone could just help me out with the first 3 bullet points above it would be much appreciated.

Thanks!

For reference the script in the Instapaper bookmarlet is as follows:

function iprl5(){
var d = document,
z = d.createElement('scr'+'ipt'),
b=d.body;
try {
if (!b) throw(0);
d.title='(Saving...) ' + d.title;
z.setAttribute('src',
'http://www.instapaper.com/j/299Brz2Hi560?u=' +
encodeURIComponent(d.location.href) + '&t=' +
(new Date().getTime())
);
b.appendChild(z);
} catch(e){ alert('Please wait until the page has loaded.');}
}
iprl5();
void(0)

and for the script at the page referenced please go here:

http://www.instapaper.com/j/299Brz2Hi560

If at all possible I want mine to be standalone without referencing an external page.

Let me know and thanks again!

I do have the following which works as a real simple timer:

javascript:(function(){setTimeout('alert(\'Service%20Hold%20Now\')',60000);})()

rodg
01-15-2010, 03:57 AM
CodingForums.com > :: Server side development > Java and JSP
check #176