Permalink
Browse files

tidy

  • Loading branch information...
1 parent b698575 commit 6e65a0c34d3f34467625d9075687c1674981dfe8 @obra committed Aug 9, 2012
Showing with 31 additions and 31 deletions.
  1. +31 −31 app/scripts/plugins/weather.js
@@ -4,10 +4,10 @@ define(['plugins/weather'], function() {
name: 'weather',
reply: function(args) {
if (!this.shouldAnswer(args)) {
- return { confidence: 0, message: "No weather word"}
+ return { confidence: 0, message: 'No weather word'};
}
- var place = 'San Francisco, CA';
- var url = 'http://www.google.com/ig/api?weather='+place;
+ var place = 'San Francisco, CA';
+ var url = 'http://www.google.com/ig/api?weather=' + place;
args.jQuery.ajax({
url: url,
@@ -16,17 +16,17 @@ define(['plugins/weather'], function() {
async: false,
success: function(data) {
console.log(data);
- output = "Right now, Google says it's "+
- data.getElementsByTagName("temp_f")[0].getAttribute("data") +
- " and " +
- data.getElementsByTagName("condition")[0].getAttribute("data")
- + " in "+place +".\n";
+ output = "Right now, Google says it's " +
+ data.getElementsByTagName('temp_f')[0].getAttribute('data') +
+ ' and ' +
+ data.getElementsByTagName('condition')[0].getAttribute('data')
+ + ' in '+ place + '.\n';
- output = output + "Tomorrow, it should be " +
- data.getElementsByTagName("condition")[1].getAttribute("data") +
- " with a low of " + data.getElementsByTagName("low")[1].getAttribute("data") +
- " and a high of " + data.getElementsByTagName("high")[1].getAttribute("data") + ".";
+ output = output + 'Tomorrow, it should be ' +
+ data.getElementsByTagName('condition')[1].getAttribute('data') +
+ ' with a low of ' + data.getElementsByTagName('low')[1].getAttribute('data') +
+ ' and a high of ' + data.getElementsByTagName('high')[1].getAttribute('data') + '.';
@@ -36,17 +36,17 @@ define(['plugins/weather'], function() {
},
shouldAnswer: function(args) {
var statements = this.myStatements();
- console.log("in shouldanswer");
+ console.log('in shouldanswer');
console.log(this.myStatements());
- for (var statement in statements){
+ for (var statement in statements) {
// If the query contains
// hot, warm, cold, chilly, freezing, wet, rain, snow, icy,
// forecast, weather, sun, raincoat, umbrella, sunscreen
var result;
if (result = XRegExp.exec(args.rawInput, XRegExp(statements[statement]))) {
- console.log("Input matches "+statements[statement]);
+ console.log('Input matches '+ statements[statement]);
console.log(result.condition);
- return true;
+ return true;
}
}
@@ -65,30 +65,30 @@ define(['plugins/weather'], function() {
},
myStatements: function() {
return [
- 'weather',
+ 'weather',
'is it (?<condition>.*?) out',
'(?:what\'s|what is) it like outside',
'weather forecast',
'what\'s the forecast',
'will it be (?<condition>\\w+)\\s+(?<time>.*)?',
- '(?:do|will) i need a (?:raincoat|macintosh|umbrella|slicker)',
+ '(?:do|will) i need a (?:raincoat|macintosh|umbrella|slicker)'
];
},
timeSense: function(statement) {
var countTimeUnits = '(?<count>.*?)\\s+(?<units>second|minute|hour|day|week|fortnight|month|quarter|year|decade|aeon)';
- return [
- "right now",
- "now",
- "in "+countTimeUnits,
- countTimeUnits + " ago",
- "yesterday",
- "today",
- "tonight",
- "tomorrow (?<timeofday>morning|afternoon|evening|night)",
-
- ]
+ return [
+ 'right now',
+ 'now',
+ 'in '+ countTimeUnits,
+ countTimeUnits + ' ago',
+ 'yesterday',
+ 'today',
+ 'tonight',
+ 'tomorrow (?<timeofday>morning|afternoon|evening|night)'
- },
- }
+ ];
+
+ }
+ };
});

0 comments on commit 6e65a0c

Please sign in to comment.