Skip to content

Instantly share code, notes, and snippets.

@walterdavis
Last active August 29, 2015 14:01
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 walterdavis/39c88d9d21415a0968d9 to your computer and use it in GitHub Desktop.
Save walterdavis/39c88d9d21415a0968d9 to your computer and use it in GitHub Desktop.
var h = new Date().getHours();
var slots = $H({
morning: $R(4,11).toArray(),
afternoon: $R(12,16).toArray(),
evening: $R(17,23).toArray().concat($R(0,3).toArray())
});
slots.each(function(time){
if(time.value.include(h)){
if(!!$('video').readAttribute('poster')){
$('video').writeAttribute('poster',
$('video').readAttribute('poster').
replace(/morning/, time.key));
}
if(!!$('video').readAttribute('src')){
$('video').writeAttribute('src',
$('video').readAttribute('src').
replace(/morning/, time.key));
}
$('video').select('source').each(function(elm){
elm.src = elm.src.replace(/morning/, time.key);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment