Skip to content

Instantly share code, notes, and snippets.

@leoherzog
Last active January 5, 2017 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leoherzog/3eebcd24257265d9aa61a549fa3f6b3d to your computer and use it in GitHub Desktop.
Save leoherzog/3eebcd24257265d9aa61a549fa3f6b3d to your computer and use it in GitHub Desktop.
Turn Wunderground API or Dark Sky API Conditions into Unicode Symbols
// possible options: https://www.wunderground.com/weather/api/d/docs?d=resources/icon-sets (image file names)
function getWundergroundIcon(condition) {
var conditionEmoji = "";
if (condition.indexOf("sunny") > -1 || condition.indexOf("clear") > -1) {
conditionEmoji = "☀️ ";
} else if (condition.indexOf("partlysunny") > -1 || condition.indexOf("mostlysunny") > -1) {
conditionEmoji = "⛅ ";
} else if (condition.indexOf("partlycloudy") > -1 || condition.indexOf("mostlycloudy") > -1) {
conditionEmoji = "🌥 ";
} else if (condition.indexOf("cloudy") > -1 || condition.indexOf("fog") > -1 || condition.indexOf("hazy") > -1) {
conditionEmoji = "☁️ ";
} else if (condition.indexOf("rain") > -1 || condition.indexOf("sleet") > -1) {
conditionEmoji = "🌧 ";
} else if (condition.indexOf("tstorms") > -1) {
conditionEmoji = "🌩 ";
} else if (condition.indexOf("snow") > -1 || condition.indexOf("flurries") > -1) {
conditionEmoji = "🌨 ";
} else {
GmailApp.sendEmail('weather@hope.edu', 'Emoji Icon Not Recgonized - Weather Signage API', 'The forecast emoji "icon" value that was pulled down from wunderground is a new one... You should tweak the code. Unrecgonized icon name: ' + condition);
}
return conditionEmoji;
}
// possible options: https://www.wunderground.com/weather/api/d/docs?d=resources/icon-sets (image file names)
function getWundergroundNightIcon(condition) {
var conditionEmoji = "";
if (condition.indexOf("sunny") > -1 || condition.indexOf("clear") > -1) {
conditionEmoji = "🌙 ";
} else if (condition.indexOf("partlysunny") > -1 || condition.indexOf("mostlysunny") > -1) {
conditionEmoji = "⛅ ";
} else if (condition.indexOf("partlycloudy") > -1 || condition.indexOf("mostlycloudy") > -1) {
conditionEmoji = "🌥 ";
} else if (condition.indexOf("cloudy") > -1 || condition.indexOf("fog") > -1 || condition.indexOf("hazy") > -1) {
conditionEmoji = "☁️ ";
} else if (condition.indexOf("rain") > -1 || condition.indexOf("sleet") > -1) {
conditionEmoji = "🌧 ";
} else if (condition.indexOf("tstorms") > -1) {
conditionEmoji = "🌩 ";
} else if (condition.indexOf("snow") > -1 || condition.indexOf("flurries") > -1) {
conditionEmoji = "🌨 ";
} else {
GmailApp.sendEmail('weather@hope.edu', 'Emoji Icon Not Recgonized - Weather Bot Scripts', 'The forecast emoji "icon" value that was pulled down from wunderground is a new one... You should tweak the code. Unrecgonized icon name: ' + condition);
}
return conditionEmoji;
}
// possible options: https://darksky.net/dev/docs/response (under the "icon" section)
function getDarkSkyIcon(condition) {
var conditionEmoji = "";
if (condition.indexOf("clear") > -1) {
conditionEmoji = "☀️ ";
} else if (condition.indexOf("partly-cloudy") > -1) {
conditionEmoji = "⛅ ";
} else if (condition.indexOf("cloudy") > -1 || condition.indexOf("fog") > -1) {
conditionEmoji = "☁️ ";
} else if (condition.indexOf("rain") > -1 || condition.indexOf("sleet") > -1) {
conditionEmoji = "🌧 ";
} else if (condition.indexOf("tstorms") > -1) {
conditionEmoji = "🌩 ";
} else if (condition.indexOf("snow") > -1) {
conditionEmoji = "🌨 ";
} else if (condition.indexOf("wind") > -1) {
conditionEmoji = "🍃 ";
} else {
GmailApp.sendEmail('weather@hope.edu', 'Emoji Icon Not Recgonized - Weather Bot Scripts', 'The seekend summary emoji "icon" value that was pulled down from the Dark Sky API is a new one... You should tweak the code. Unrecgonized icon name: ' + condition);
}
return conditionEmoji;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment