Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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',s); } var re1 = RegExp( '[AaPp][Mm]' ); var re2 = RegExp( '[0-9][0-9]:[0-9][0-9]' ); if ( s===null ) { void(s); } else { if ( encodeURIComponent(s).match(re1) || encodeURIComponent(s).match(re2) ) { /*has time/* } else { s = s + ' pm'; /*if there isn't an AM or PM in the text, add the default "pm" time*/ } if (s) { /*open a new window with this information in the Google Calendar event creation page.*/ void(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') ); } }
Add Comment
Please, Sign In to add comment