Last active
January 5, 2017 13:34
-
-
Save leoherzog/3eebcd24257265d9aa61a549fa3f6b3d to your computer and use it in GitHub Desktop.
Turn Wunderground API or Dark Sky API Conditions into Unicode Symbols
This file contains hidden or 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
| // 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