Skip to content

Instantly share code, notes, and snippets.

@michaelschofield
Last active August 29, 2015 14:24
Show Gist options
  • Save michaelschofield/ea482c0adab2b5f2a434 to your computer and use it in GitHub Desktop.
Save michaelschofield/ea482c0adab2b5f2a434 to your computer and use it in GitHub Desktop.
var libchat = $( '[id^=libchat]' );
if ( libchat ) {
$.when(
$.getScript( '//v2.libanswers.com/load_chat.php?hash=350f6f82c9ebecede6fa0c8773102b53')
).done(function() {
$( window ).load( function() {
// This is a little inelegant but
// I am just having some fun.
var libchat__button = $( 'button[class^=libchat]' ),
libchat__status = ( libchat__button.is( '[class$=online]' ) ? true : false );
if ( libchat__status ) {
// Chat is online! Do something
// Such as ...
libchat__button.html( 'Need help? <strong><u>Chat with an NSU Librarian</strong></u> right now!')
libchat.show();
} else {
// Chat is offline :(. Do something
libchat__button.html( 'We aren\'t on <strong>chat</strong> yet, but <u>submit your question</u> and we will respond as fast as we can.');
}
libchat__button
.attr( 'style', 'text-align: left; background-color: transparent; box-shadow: none; color: white !important; margin: 0 0 1em !important; padding: 0 !important; border: none; font-family: "Calibri","Myriad Pro",Myriad,Tahoma,"DroidSansRegular",Geneva,"Helvetica Neue",Helvetica,Arial,sans-serif;' );
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment