Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#rvis_text Insanity Radio 103.2
= image_tag '/system/radiovis/branding-320x240.png', id: 'rvis_image_a'
= image_tag '/system/radiovis/branding-320x240.png', id: 'rvis_image_b', style: 'display:none;'
#no_websockets{style: 'display:none;'}
%strong Whoops, your browser doesn't support WebSockets!
This means your web browser will not be able to view real-time updates about what you're listening to.
For the best listening experience please upgrade to Firefox 11+, Chrome 17+, or Internet Explorer 11+. WebSockets are pretty newfangled things and older browsers don't support them.
$(function() {
var supported = ("WebSocket" in window);
if(!supported) {
} else {
// We've got websockets so do our setup for RadioVIS integration
var url = "ws://";
var text_client = Stomp.client(url);
var image_client = Stomp.client(url);
var target_image = 'b';
text_connect_callback = function() {
text_client.subscribe("/topic/fm/ce1/c08f/10320/text", function(message){$('#rvis_text').text(message.body.replace("TEXT ",""));});
image_connect_callback = function() {
image_client.subscribe("/topic/fm/ce1/c08f/10320/image", function(message) {
$('#rvis_image_'+target_image).attr('src',message.body.replace("SHOW ","")+"?cachebuster="+(new Date().getTime()));
$('#rvis_image_'+target_image).fadeIn(500, 'swing');
if (target_image == 'a') {
target_image = 'b';
} else {
target_image = 'a';
$('#rvis_image_'+target_image).fadeOut(500, 'swing');
image_client.connect("guest", "guest", image_connect_callback);
text_client.connect("guest", "guest", text_connect_callback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment