Mercurial > hip
comparison verbs.js @ 13:8dcc88f93829
Broke up hip.js into some smaller js files
author | jonathandicarlo@localhost |
---|---|
date | Wed, 02 Jul 2008 12:04:46 -0700 |
parents | |
children | 5fce4c8f3ebd |
comparison
equal
deleted
inserted
replaced
12:aa56c4aa5b11 | 13:8dcc88f93829 |
---|---|
1 var fly = new Verb( "fly", null, null, { "from": city, "to": city } ); | |
2 fly.getDescription = function( directObject, mods ) { | |
3 var fromCity = mods[ "from" ]; | |
4 var toCity = mods["to"]; | |
5 if ( !fromCity ) { | |
6 fromCity = "from somewhere"; | |
7 } | |
8 if ( !toCity ) { | |
9 toCity = "to somewhere else"; | |
10 } | |
11 return "Buy airplane tickets from " + fromCity + " to " + toCity; | |
12 }; | |
13 var define = new Verb( "define", "word", anyWord, {} ); | |
14 define.getDescription = function( directObject, mods ) { | |
15 if (directObject ) { | |
16 return "Search for definition of the word "" + directObject + """; | |
17 } else { | |
18 return "Search for the definition of a word."; | |
19 } | |
20 }; | |
21 var google = new Verb( "google", "word", anyWord, {} ); | |
22 google.getDescription = function( directObject, mods ) { | |
23 if (directObject ) { | |
24 return "Search Google for "" + directObject + """; | |
25 } else { | |
26 return "Search Google for a word or phrase."; | |
27 } | |
28 }; | |
29 var go = new Verb( "go", "tab", tab, {} ); | |
30 go.getDescription = function( directObject, mods ) { | |
31 if (directObject ) { | |
32 return "Switch to the Firefox tab "" + directObject + """; | |
33 } else { | |
34 return "Search to a given Firefox tab."; | |
35 } | |
36 }; | |
37 var close = new Verb( "close", null, null, {} ); | |
38 close.getDescription = function( directObject, mods ) { | |
39 return "Close the front window or tab."; | |
40 }; | |
41 var translate = new Verb( "translate", "text", anyWord, { "from": language, "to": language } ); | |
42 translate.getDescription = function( directObject, mods ) { | |
43 if (directObject ) { | |
44 var DO = "the phrase "" + directObject + """; | |
45 } else { | |
46 var DO = "a given phrase"; | |
47 } | |
48 var fromLang = mods["from"]; | |
49 if (!fromLang) { | |
50 fromLang = "a given language"; | |
51 } | |
52 var toLang = mods["to"]; | |
53 if (!fromLang) { | |
54 toLang = "another language."; | |
55 } | |
56 return "Translate " + DO + " from " + fromLang + " to " + toLang; | |
57 }; | |
58 var nuke = new Verb( "nuke", "city", city, {} ); | |
59 nuke.getDescription = function( directObject, mods ) { | |
60 if (!directObject) { | |
61 directObject = "a given city"; | |
62 } | |
63 return "Launch a nuclear missile at " + directObject; | |
64 }; | |
65 var open = new Verb( "open", "url", anyWord, { "with": application } ); | |
66 open.getDescription = function( directObject, mods ) { | |
67 if (directObject ) { | |
68 var desc = "Open the URL "" + directObject + """; | |
69 } else { | |
70 var desc = "Open a given URL"; | |
71 } | |
72 if ( mods["with"] ) { | |
73 desc += " using the application "" + mods["with"] + """; | |
74 } | |
75 return desc; | |
76 }; | |
77 var email = new Verb( "email", "text", anyWord, { "to": person, "subject": anyWord } ); | |
78 email.getDescription = function( directObject, mods ) { | |
79 if (directObject ) { | |
80 var DO = "the message "" + directObject + "" as an email"; | |
81 } else { | |
82 var DO = "an email"; | |
83 } | |
84 var target = mods["to"]; | |
85 if ( !target ) { | |
86 target = "someone from your address book"; | |
87 } | |
88 if ( mods["subject"] ) { | |
89 var subject = ", with the subject " + mods["subject"] + ", "; | |
90 } else { | |
91 var subject = " "; | |
92 } | |
93 return "Send " + DO + subject + "to " + target; | |
94 }; | |
95 | |
96 var encrypt = new Verb( "encrypt", "text", anyWord, { "for": person } ); | |
97 encrypt.getDescription = function( directObject, mods ) { | |
98 if (directObject ) { | |
99 var DO = "the message "" + directObject + """; | |
100 } else { | |
101 var DO = "a secret message"; | |
102 } | |
103 var target = mods["for"]; | |
104 if ( !target ) { | |
105 target = "one particular person"; | |
106 } | |
107 return "Encrypt " + DO + " so it can only be read by " + target; | |
108 }; | |
109 | |
110 var wiki = new Verb( "wikipedia", "word", anyWord, { "language": language } ); | |
111 wiki.getDescription = function( directObject, mods ) { | |
112 var desc = "Search "; | |
113 if ( mods["language"] ) { | |
114 desc = desc + "the " + mods["language"] + " language version of "; | |
115 } | |
116 desc = desc + "Wikipedia for "" + directObject + """; | |
117 return desc; | |
118 }; |