Created
September 14, 2008 04:47
-
-
Save fernandotakai/10701 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/ubiquity/chrome/content/builtincmds.js Sat Sep 13 23:44:07 2008 +0800 | |
+++ b/ubiquity/chrome/content/builtincmds.js Sun Sep 14 01:24:51 2008 -0300 | |
@@ -1299,13 +1299,15 @@ | |
req.open('POST', currentCalendar, false); | |
req.setRequestHeader('Authorization', 'GoogleLogin auth=' + authKey); | |
req.setRequestHeader('Content-type', 'application/atom+xml'); | |
- req.send(quickAddEntry); | |
+ req.send(quickAddEntry); | |
if (req.status == 401) { | |
displayMessage("Please make sure you are logged in to Google Calendar"); | |
return; | |
} else if (req.status != 201) { | |
displayMessage("Error creating the event. Error code: " + req.status + " " + req.statusText); | |
return; | |
+ } else { | |
+ displayMessage("Event " + eventString + " added!") | |
} | |
} | |
@@ -1316,13 +1318,15 @@ | |
CmdUtils.CreateCommand({ | |
name: "add-to-calendar", | |
takes: {"event": noun_arb_text}, // TODO: use DateNounType or EventNounType? | |
+ modifiers: {'on': noun_type_date, 'at': noun_type_time }, | |
icon : "chrome://ubiquity/skin/icons/calendar_add.png", | |
- preview: "Adds the event to Google Calendar.<br/> Enter the event naturally e.g., \"3pm Lunch with Myk and Thunder\", or \"Jono's Birthday on Friday\".", | |
+ preview: "Adds the event to Google Calendar.<br/> Enter the event with the format <event> on <date> at <time>", | |
description: "Adds an event to your calendar.", | |
help: "Currently, only works with <a href=\"http://calendar.google.com\">Google Calendar</a>, so you'll need a " + | |
- "Google account to use it. Try issuing "add lunch with dan tomorrow".", | |
- execute: function( eventString ) { | |
- addToGoogleCalendar( eventString.text ); | |
+ "Google account to use it. Try issuing "add lunch with dan on tomorrow at 14pm".", | |
+ execute: function( eventString, modifiers ) { | |
+ var calEvent = eventString.text + " " + modifiers.on.data.toString("dd/MM/yyyy") + " " + modifiers.at.text | |
+ addToGoogleCalendar( calEvent ); | |
} | |
}); | |
diff -r f073a8b1d0b3 -r e3d4caebc6ef ubiquity/chrome/content/nlparser/en/nountypes.js | |
--- a/ubiquity/chrome/content/nlparser/en/nountypes.js Sat Sep 13 23:44:07 2008 +0800 | |
+++ b/ubiquity/chrome/content/nlparser/en/nountypes.js Sun Sep 14 01:24:51 2008 -0300 | |
@@ -99,16 +99,48 @@ | |
} | |
}; | |
+var noun_type_time = { | |
+ _name: "time", | |
+ | |
+ default: function(){ | |
+ var time = Date.parse("now"); | |
+ var text = time.toString("hh:mm tt") | |
+ return CmdUtils.makeSugg(text, null, time) | |
+ }, | |
+ | |
+ suggest: function(text, html){ | |
+ if (typeof text != "string"){ | |
+ return []; | |
+ } | |
+ | |
+ var time = Date.parse( text ); | |
+ if(!time ){ | |
+ return [] | |
+ } | |
+ | |
+ text = time.toString("hh:mm tt"); | |
+ return [ CmdUtils.makeSugg(text, null, time) ] | |
+ } | |
+} | |
+ | |
var noun_type_date = { | |
_name: "date", | |
+ | |
+ default: function(){ | |
+ var date = Date.parse("today"); | |
+ var text = date.toString("dd MM, yyyy"); | |
+ return CmdUtils.makeSugg(text, null, date); | |
+ }, | |
+ | |
suggest: function( text, html ) { | |
if (typeof text != "string") { | |
return []; | |
} | |
- if (text == "") { | |
- // If input is blank, suggest today's date | |
- return this.suggest("today"); | |
- } | |
+ | |
+ // if (text == "") { | |
+ // // If input is blank, suggest today's date | |
+ // return this.suggest("today"); | |
+ // } | |
var date = Date.parse( text ); | |
if (!date) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment