Created
August 27, 2018 15:58
-
-
Save jerrickhakim/6405261e4b25cbce982eaea34deb9ea2 to your computer and use it in GitHub Desktop.
Change img src based on time example
This file contains 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
// JERRICK'S STATUS JS | |
jQuery(function(){ | |
// get current hour | |
var now = new Date(Date.now()); | |
var hour = now.getHours(); | |
var min = now.getMinutes() | |
var statustitle = jQuery('#jh_status').attr('title'); | |
if (hour >= 0 & hour <=7 ) { | |
jQuery('#jh_status').attr('src', 'https://d33t7gcdmhxpn0.cloudfront.net/getting-out-of-bed.png'); jQuery('#status-text h2').text("Sleeping Zzzz..."); | |
} else if (hour >= 8 & hour <= 9 ) { jQuery('#jh_status').attr('src', 'https://d33t7gcdmhxpn0.cloudfront.net/getting-out-of-bed.png'); jQuery('#status-text h2').text("Morning!!"); | |
} else if (hour == 10) { jQuery('#jh_status').attr('src', 'https://d33t7gcdmhxpn0.cloudfront.net/have-a-great-day.png'); jQuery('#status-text h2').text("Have a great day!"); | |
} else if (hour >= 12 & hour <= 15) { jQuery('#jh_status').attr('src', 'https://d33t7gcdmhxpn0.cloudfront.net/good-afternoon.png'); jQuery('#status-text h2').text("Good Afternoon!"); | |
} else if (hour == 16) { jQuery('#jh_status').attr('src', 'https://d33t7gcdmhxpn0.cloudfront.net/me-hungrey.png'); jQuery('#status-text h2').text("Me Hungrey!"); | |
} else if (hour >= 17 & hour <=18 ) { jQuery('#jh_status').attr('src', 'https://d33t7gcdmhxpn0.cloudfront.net/thinking.png'); jQuery ('#status-text h2').text("Thinking..."); | |
} else if (hour >= 19 && hour <=24 ) { jQuery('#jh_status').attr('src', 'https://d33t7gcdmhxpn0.cloudfront.net/good-evening.png');jQuery('#status-text h2').text("Good Evening!"); | |
} else if (hour == 11 ) { jQuery('#jh_status').attr('src', 'https://d33t7gcdmhxpn0.cloudfront.net/coffee.png'); jQuery('#status-text h2').text("Coffee?"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment