Permalink
Browse files

Tabs to spaces in all files

  • Loading branch information...
Ricket committed Sep 9, 2012
1 parent 439a9d5 commit 9ddd866ff4f3a0f63521ff244299a7a9fb9cc730
View
@@ -2,25 +2,25 @@
// This code is licensed under the MIT license; see LICENSE.txt for details.
global.nodebot_prefs = {
- realname: 'Nodebot v0.8',
- nickname: 'nodebot1337',
-
- /* NickServ details, case-insensitive.
- * Note: regex characters must be escaped, as these values are placed
- * into a regex (not the password).
- */
- nickserv_nickname: 'NickServ',
- nickserv_hostname: 'NickServ@services\\.',
- nickserv_password: 'password',
-
- command_prefix: '~', /* not yet implemented; ~ is the hardcoded prefix */
- server: 'irc.freenode.net',
- port: 6667,
- secret: 'secret', /* password to become admin */
-
- default_location: '90210',
-
- /* bitly.js */
- bitly_username: '',
- bitly_apikey: ''
-};
+ realname: 'Nodebot v0.8',
+ nickname: 'nodebot1337',
+
+ /* NickServ details, case-insensitive.
+ * Note: regex characters must be escaped, as these values are placed
+ * into a regex (not the password).
+ */
+ nickserv_nickname: 'NickServ',
+ nickserv_hostname: 'NickServ@services\\.',
+ nickserv_password: 'password',
+
+ command_prefix: '~', /* not yet implemented; ~ is the hardcoded prefix */
+ server: 'irc.freenode.net',
+ port: 6667,
+ secret: 'secret', /* password to become admin */
+
+ default_location: '90210',
+
+ /* bitly.js */
+ bitly_username: '',
+ bitly_apikey: ''
+};
View
@@ -31,90 +31,90 @@ var request = require('request');
var jsdom = require('jsdom');
Date.prototype.pad = function (n) {
- return (n < 10) ? '0' + n : n;
+ return (n < 10) ? '0' + n : n;
};
Date.prototype.toISODate = function () {
- return this.getFullYear() + '-'
- + this.pad(this.getMonth() + 1) + '-'
- + this.pad(this.getDate());
+ return this.getFullYear() + '-'
+ + this.pad(this.getMonth() + 1) + '-'
+ + this.pad(this.getDate());
};
var get = function (callback, location, forecastDate) {
- var currentConditions = {
- 'date' : null,
- 'condition' : null,
- 'temperature' : null,
- 'humidity' : null,
- 'wind' : {
- 'direction' : null,
- 'speed' : null
- }
- };
-
- var forecast = [];
-
- var uri = 'http://www.google.com/ig/api?weather='
- + escape(location);
-
- request({
- 'method' : 'GET',
- 'uri' : uri,
- 'headers' : {
- 'User-Agent' : 'Nintendo Gameboy/1.0'
- }
- }, function (error, response, body) {
- if (!error && response.statusCode == 200) {
- jsdom.env(body, [],
- function(errors, window) {
- try {
- var document = window.document;
- var info = document.getElementsByTagName('forecast_information')[0];
- var current = document.getElementsByTagName('current_conditions')[0];
- var forecasts = document.getElementsByTagName('forecast_conditions');
-
- var baseDateString = info.getElementsByTagName('forecast_date')[0].getAttribute('data');
- var baseDate = new Date(baseDateString);
-
- currentConditions.date = baseDateString;
- currentConditions.condition = current.getElementsByTagName('condition')[0].getAttribute('data');
- currentConditions.temperature = current.getElementsByTagName('temp_f')[0].getAttribute('data');
-
- var humidityString = current.getElementsByTagName('humidity')[0].getAttribute('data');
- currentConditions.humidity = /(\d+)%/.exec(humidityString)[1];
-
- var windString = current.getElementsByTagName('wind_condition')[0].getAttribute('data');
- var windMatches = /([NESW]+)\sat\s([0-9]+)\smph/.exec(windString);
- currentConditions.wind.direction = windMatches[1];
- currentConditions.wind.speed = windMatches[2];
-
- for (var i = 0; i < forecasts.length; i++) {
- var d = new Date(baseDate.getTime() + ( i * 24 * 3600 * 1000 ));
- var condition = forecasts[i].getElementsByTagName('condition')[0].getAttribute('data');
- var lowTemp = forecasts[i].getElementsByTagName('low')[0].getAttribute('data');
- var highTemp = forecasts[i].getElementsByTagName('high')[0].getAttribute('data');
-
- var forecastDay = {
- 'date' : d.toISODate(),
- 'condition' : condition,
- 'temperature' : {
- 'low' : lowTemp,
- 'high' : highTemp
- }
- };
-
- forecast[d.toISODate()] = forecastDay;
- }
-
- callback(currentConditions, forecast[forecastDate]);
- } catch(err) {
- callback(null, null);
- return;
- }
- }
- );
- }
- });
+ var currentConditions = {
+ 'date' : null,
+ 'condition' : null,
+ 'temperature' : null,
+ 'humidity' : null,
+ 'wind' : {
+ 'direction' : null,
+ 'speed' : null
+ }
+ };
+
+ var forecast = [];
+
+ var uri = 'http://www.google.com/ig/api?weather='
+ + escape(location);
+
+ request({
+ 'method' : 'GET',
+ 'uri' : uri,
+ 'headers' : {
+ 'User-Agent' : 'Nintendo Gameboy/1.0'
+ }
+ }, function (error, response, body) {
+ if (!error && response.statusCode == 200) {
+ jsdom.env(body, [],
+ function(errors, window) {
+ try {
+ var document = window.document;
+ var info = document.getElementsByTagName('forecast_information')[0];
+ var current = document.getElementsByTagName('current_conditions')[0];
+ var forecasts = document.getElementsByTagName('forecast_conditions');
+
+ var baseDateString = info.getElementsByTagName('forecast_date')[0].getAttribute('data');
+ var baseDate = new Date(baseDateString);
+
+ currentConditions.date = baseDateString;
+ currentConditions.condition = current.getElementsByTagName('condition')[0].getAttribute('data');
+ currentConditions.temperature = current.getElementsByTagName('temp_f')[0].getAttribute('data');
+
+ var humidityString = current.getElementsByTagName('humidity')[0].getAttribute('data');
+ currentConditions.humidity = /(\d+)%/.exec(humidityString)[1];
+
+ var windString = current.getElementsByTagName('wind_condition')[0].getAttribute('data');
+ var windMatches = /([NESW]+)\sat\s([0-9]+)\smph/.exec(windString);
+ currentConditions.wind.direction = windMatches[1];
+ currentConditions.wind.speed = windMatches[2];
+
+ for (var i = 0; i < forecasts.length; i++) {
+ var d = new Date(baseDate.getTime() + ( i * 24 * 3600 * 1000 ));
+ var condition = forecasts[i].getElementsByTagName('condition')[0].getAttribute('data');
+ var lowTemp = forecasts[i].getElementsByTagName('low')[0].getAttribute('data');
+ var highTemp = forecasts[i].getElementsByTagName('high')[0].getAttribute('data');
+
+ var forecastDay = {
+ 'date' : d.toISODate(),
+ 'condition' : condition,
+ 'temperature' : {
+ 'low' : lowTemp,
+ 'high' : highTemp
+ }
+ };
+
+ forecast[d.toISODate()] = forecastDay;
+ }
+
+ callback(currentConditions, forecast[forecastDate]);
+ } catch(err) {
+ callback(null, null);
+ return;
+ }
+ }
+ );
+ }
+ });
};
-exports.get = get;
+exports.get = get;
View
@@ -8,71 +8,71 @@
var fs = require('fs');
exports.getDB = function (dbName) {
- var fileName = 'data/'+dbName+'.txt';
- var values;
-
- try {
- values = fs.readFileSync(fileName, 'ascii');
- if(values && values.length > 0) {
- values = values.split('\n');
- } else {
- values = [];
- }
- } catch(err) {values = [];}
-
- function writeFile() {
- fs.writeFileSync(fileName, values.join('\n'), 'ascii');
- }
-
- return {
- getName: function () {
- return dbName;
- },
- getAll: function() {
- return values;
- },
- hasValue: function (value, ignoreCase) {
- ignoreCase = ignoreCase || false;
-
- var i;
- for(i=0; i<values.length; i++) {
- if(ignoreCase) {
- if(values[i].toUpperCase() == value.toUpperCase()) {
- return true;
- }
- } else {
- if(values[i] == value) {
- return true;
- }
- }
- }
-
- return false;
- },
- add: function (value) {
- values.push(value);
-
- writeFile();
- },
- remove: function (value, ignoreCase) {
- ignoreCase = ignoreCase || false;
-
- var i;
- for(i=0; i<values.length; i++) {
- if(ignoreCase) {
- if(values[i].toUpperCase() == value.toUpperCase()) {
- values.splice(i,1);
- i--;
- }
- } else {
- if(values[i] == value) {
- values.splice(i,1);
- i--;
- }
- }
- }
-
- writeFile();
- }
- }
+ var fileName = 'data/'+dbName+'.txt';
+ var values;
+
+ try {
+ values = fs.readFileSync(fileName, 'ascii');
+ if(values && values.length > 0) {
+ values = values.split('\n');
+ } else {
+ values = [];
+ }
+ } catch(err) {values = [];}
+
+ function writeFile() {
+ fs.writeFileSync(fileName, values.join('\n'), 'ascii');
+ }
+
+ return {
+ getName: function () {
+ return dbName;
+ },
+ getAll: function() {
+ return values;
+ },
+ hasValue: function (value, ignoreCase) {
+ ignoreCase = ignoreCase || false;
+
+ var i;
+ for(i=0; i<values.length; i++) {
+ if(ignoreCase) {
+ if(values[i].toUpperCase() == value.toUpperCase()) {
+ return true;
+ }
+ } else {
+ if(values[i] == value) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ },
+ add: function (value) {
+ values.push(value);
+
+ writeFile();
+ },
+ remove: function (value, ignoreCase) {
+ ignoreCase = ignoreCase || false;
+
+ var i;
+ for(i=0; i<values.length; i++) {
+ if(ignoreCase) {
+ if(values[i].toUpperCase() == value.toUpperCase()) {
+ values.splice(i,1);
+ i--;
+ }
+ } else {
+ if(values[i] == value) {
+ values.splice(i,1);
+ i--;
+ }
+ }
+ }
+
+ writeFile();
+ }
+ }
}
Oops, something went wrong.

0 comments on commit 9ddd866

Please sign in to comment.