Google Calendar Bookmarklet
A bookmarklet is a piece of JavaScript which you bookmark in order to add a little piece of additional functionality to your browser and make it easily accessible. Bookmarklets can be used to do things like change the font size or style on a website, or they can help make a task simpler.
Just the other day, I found that RememberTheMilk (I blogged about the greatness of RTM back in August) has a task creation bookmarklet (they call it a “QuickAdd“). Using that the past couple days, I realized how handy bookmarklets could be!
When I wanted to add the Penguins remaining schedule to my Google Calendar, I figured a bookmarklet could make the task easier. After some Googling, however, I couldn’t find exactly what I wanted. This article’s #4 was close, so I took it and modified it with some additional JavaScripting.
Without further ado, here is my first ever bookmarklet!
<edit>All right — WordPress won’t let me play nicely sharing a bookmarklet IN a link. So go here:
http://www.personal.psu.edu/dri106/_GCalIt.html
and do that.
Whenever you want to add something to your Google Calendar, click that bookmark and you’ll be at the New Event page. If you have text selected before clicking that link, the selected text will get put in as the “What”, otherwise, a prompt comes up in which you can type a “Quick Add” such as “Dinner with Mike at 7pm tomorrow”.
Code (modified from #4 at http://googlesystem.blogspot.com/2007/07/useful-google-bookmarklets.html):
javascript: var s;
//Figure out the selected text
if ( window.getSelection ) {
s = window.getSelection();
} else if ( document.getSelection ) {
s = document.getSelection();
} else {
s = document.selection.createRange().text;
}
//If there isn't any text selected, get user input
if ( s == '' ) {
s = prompt('QuickAdd');
}
var re = RegExp( '[AaPp][Mm]' );
if ( encodeURIComponent(s).match(re) ) {
} else {
s = s + ' 1pm'; //if there isn't an AM or PM in the text, add the default 1pm time
}
void(
//open a new window with this information in the Google Calendar event creation page.
window.open(
encodeURI('http://www.google.com/calendar/event?ctext='+s+'&action=TEMPLATE&pprop=HowCreated:QUICKADD'),
'addwindow',
'status=no,toolbar=no,width=520,height=470,resizable=yes'
)
);
1 Comment »
Leave a comment
-
Recent
-
Links
-
Archives
- April 2009 (1)
- March 2009 (7)
- December 2008 (1)
- September 2008 (6)
- August 2008 (16)
- July 2008 (17)
- June 2008 (11)
- May 2008 (10)
- April 2008 (1)
- January 2008 (7)
- December 2007 (2)
- November 2007 (2)
-
Categories
-
RSS
Entries RSS
Comments RSS
I’m sorry about the ugliness of this post…
The bookmarklet is pretty sweet though…
Comment by dannyiachini | March 11, 2009