2012-04-25 22:48:27 +02:00
|
|
|
|
/**
|
|
|
|
|
* OpenSlides projector functions
|
|
|
|
|
*
|
2013-08-04 12:59:11 +02:00
|
|
|
|
* :copyright: 2011–2013 by OpenSlides team, see AUTHORS.
|
2012-04-25 22:48:27 +02:00
|
|
|
|
* :license: GNU GPL, see LICENSE for more details.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-08-04 12:59:11 +02:00
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
if ($('#content.reload').length > 0) {
|
|
|
|
|
updater.start();
|
|
|
|
|
}
|
|
|
|
|
});
|
2012-07-04 15:00:08 +02:00
|
|
|
|
|
2013-08-04 12:59:11 +02:00
|
|
|
|
var projector = {
|
|
|
|
|
_loaded_files: {},
|
|
|
|
|
|
|
|
|
|
load_file: function(src) {
|
|
|
|
|
if (projector._loaded_files[src] === undefined) {
|
|
|
|
|
projector._loaded_files[src] = document.createElement('script');
|
|
|
|
|
projector._loaded_files[src].setAttribute("type","text/javascript");
|
|
|
|
|
projector._loaded_files[src].setAttribute("src", src);
|
|
|
|
|
$('head').append(projector._loaded_files[src]);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2013-10-17 15:32:54 +02:00
|
|
|
|
scroll: function(value) {
|
2013-10-23 17:08:08 +02:00
|
|
|
|
$('#content').css('margin-top', -10 * value + 'em');
|
2013-10-17 15:32:54 +02:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
scale: function(value) {
|
2013-10-23 17:08:08 +02:00
|
|
|
|
$('#content').css('font-size', 100 + 20 * value + '%');
|
2013-10-17 15:32:54 +02:00
|
|
|
|
},
|
|
|
|
|
|
2013-10-26 12:59:39 +02:00
|
|
|
|
get_server_time: function () {
|
|
|
|
|
var date = new Date();
|
2013-11-09 21:28:45 +01:00
|
|
|
|
date.setTime(date.getTime() - projector.server_time_offset);
|
2013-10-26 12:59:39 +02:00
|
|
|
|
return date;
|
|
|
|
|
},
|
|
|
|
|
|
2013-11-06 14:42:14 +01:00
|
|
|
|
set_server_time: function(value) {
|
|
|
|
|
var local_time = Date.parse(new Date().toUTCString());
|
|
|
|
|
projector.server_time_offset = local_time - value * 1000;
|
|
|
|
|
},
|
|
|
|
|
|
2013-08-04 12:59:11 +02:00
|
|
|
|
update_data: function(data) {
|
2013-10-17 15:32:54 +02:00
|
|
|
|
$.each(data, function (key, value) {
|
2013-08-04 12:59:11 +02:00
|
|
|
|
if (key === 'load_file')
|
|
|
|
|
projector.load_file(value);
|
2013-11-06 14:42:14 +01:00
|
|
|
|
else if (key === 'call') {
|
|
|
|
|
try {
|
|
|
|
|
eval(value);
|
|
|
|
|
} catch (e) {}
|
2013-10-26 12:59:39 +02:00
|
|
|
|
} else
|
2013-08-04 12:59:11 +02:00
|
|
|
|
projector[key] = value;
|
2011-07-31 10:46:29 +02:00
|
|
|
|
});
|
|
|
|
|
}
|
2013-08-04 12:59:11 +02:00
|
|
|
|
};
|
2011-07-31 10:46:29 +02:00
|
|
|
|
|
2013-08-04 12:59:11 +02:00
|
|
|
|
var updater = {
|
|
|
|
|
socket: null,
|
2011-07-31 10:46:29 +02:00
|
|
|
|
|
2013-08-04 12:59:11 +02:00
|
|
|
|
start: function() {
|
2013-10-26 10:42:48 +02:00
|
|
|
|
var url = "http://" + location.host + "/projector/socket";
|
|
|
|
|
updater.socket = new SockJS(url);
|
2013-08-04 12:59:11 +02:00
|
|
|
|
updater.socket.onmessage = function(event) {
|
2013-10-26 10:42:48 +02:00
|
|
|
|
updater.updateProjector(event.data);
|
2013-08-04 12:59:11 +02:00
|
|
|
|
}
|
|
|
|
|
updater.socket.onclose = function() {
|
|
|
|
|
setTimeout('updater.start()', 5000);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
updateProjector: function(data) {
|
2013-10-17 15:32:54 +02:00
|
|
|
|
if (data.content) {
|
2013-10-04 11:38:39 +02:00
|
|
|
|
$('#content').removeClass('fullscreen');
|
|
|
|
|
$('#footer').removeClass('black');
|
|
|
|
|
$('body').removeClass('black');
|
2013-10-17 15:32:54 +02:00
|
|
|
|
$('#content').html(data.content);
|
|
|
|
|
}
|
|
|
|
|
if (data.overlays) {
|
|
|
|
|
$.each(data.overlays, function (key, value) {
|
|
|
|
|
var overlay = $('#overlays #overlay_' + key)
|
|
|
|
|
if (!value)
|
|
|
|
|
overlay.remove();
|
|
|
|
|
else {
|
|
|
|
|
if (overlay.length) {
|
|
|
|
|
overlay.html(value.html)
|
|
|
|
|
} else {
|
|
|
|
|
$('#overlays').append(value.html);
|
|
|
|
|
}
|
|
|
|
|
projector.update_data(value.javascript);
|
2013-08-04 12:59:11 +02:00
|
|
|
|
}
|
2013-10-17 15:32:54 +02:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (data.calls) {
|
|
|
|
|
$.each(data.calls, function (call, argument) {
|
|
|
|
|
projector[call](argument);
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-08-04 12:59:11 +02:00
|
|
|
|
}
|
|
|
|
|
};
|