# Place all the behaviors and hooks related to the matching controller here. # All this logic will automatically be available in application.js. # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ $(document).ready -> host = location.host.split(':')[0] localurl = 'ws://' + host + ':9876' zoomurl = 'ws://zoom.gina.alaska.edu:9876' initWebsockets('Local', 'local', localurl, true) initWebsockets('Zoom', 'zoom', zoomurl, false) $(document).on('click', '#feeds ul.nav-tabs a', (e) -> e.preventDefault(); $(this).tab('show'); $(this).data('unread', 0) updateUnreadBadge($(this).attr('href').replace('#', '')) ) updateUnreadBadge = (target, unread = null) -> badge = $("#feeds ul.nav-tabs a[href=\"##{target}\"] .badge") if unread == null unread = getTab(target).data('unread') if badge.length == 0 getTab(target).append(" #{unread}") else badge.text(unread) createTab = (name, target, url, active = false) -> $('#feeds ul.nav-tabs').append("
"+evt.data+"") ws.onclose = -> $("##{target}").prepend("
Socket Closed") ws.onopen = -> $("##{target}").prepend("
Socked Opened")