Monday, 18 June 2012

gCalendar js

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'
)
);
view raw gistfile1.js hosted with ❤ by GitHub

No comments:

Post a Comment