Sha256: 33aff834d148339c7cf2bf796a5323c08c77eaba423b63d7d8d4503fe7316813

Contents?: true

Size: 555 Bytes

Versions: 1

Compression:

Stored size: 555 Bytes

Contents

var LivePageHandler = new Class({
	initialize: function() {
		var referrer_url = encodeURIComponent(document.location.href);
		var socket_url = JSONSocket.websocketUrlForPath('/sinatra/liveviews/ws');

		this.websocket = new JSONSocket({
			url: socket_url + '?url=' + referrer_url,
			on_exec: function(data) {
				$(data.selector)[data.method](data.content);
			},

			on_message: function(data) {
				console.log('live pages: ' + data.content);
			}

		});
	}
});

$(document).ready(function() {
	window._live_page_handler = new LivePageHandler();
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sinatra-liveviews-0.5.0 lib/sinatra/js/live-pages.js