function pad(num) {
- var s = num+"";
- while (s.length < 2) s = "0" + s;
- return s;
+ var s = num + "";
+ while (s.length < 2) s = "0" + s;
+ return s;
}
-$(window).ready(function() {
- var pageHeight = $(window).height();
- var navHeight = pageHeight - 125;
- $('#desk_center').css({"max-height": navHeight + 'px'});
+$(window).ready(function () {
+ var pageHeight = $(window).height();
+ var navHeight = pageHeight - 125;
+ $('#desk_center').css({ "max-height": navHeight + 'px' });
launchTimer();
});
-var launchTimer = function(){
+var launchTimer = function () {
// chronometer
- $('.autotimer').each(function(){
+ $('.autotimer').each(function () {
window.timer = new Timer();
$timerSpan = $(this);
var value = $timerSpan.text()
// convert text value of timer to seconds
var timeArray = value.split(':');
var seconds = parseInt(timeArray[0], 10) * 3600 + parseInt(timeArray[1], 10) * 60 + parseInt(timeArray[2], 10);
- window.timer.start({precision: 'seconds', startValues: {seconds: seconds}});
+ window.timer.start({ precision: 'seconds', startValues: { seconds: seconds } });
window.timer.addEventListener('secondsUpdated', function (e) {
- var timeValues = window.timer.getTimeValues();
- var hours = timeValues.days * 24 + timeValues.hours
- $timerSpan.html(pad(hours) + ':' + pad(timeValues.minutes) + ':' + pad(timeValues.seconds));
+ var timeValues = window.timer.getTimeValues();
+ var hours = timeValues.days * 24 + timeValues.hours
+ $timerSpan.html(pad(hours) + ':' + pad(timeValues.minutes) + ':' + pad(timeValues.seconds));
});
});
}
+function onLoadSeminar(seminarId, username) {
+ // send a request when user load a seminar
+ json([seminarId, username], 'teleforma.seminar_load', function () { return null; });
+}
+
+function onUnloadSeminar(seminarId, username) {
+ try {
+ var params = JSON.stringify({ "id": "jsonrpc", "params": [seminarId, username], "method": "teleforma.seminar_unload", "jsonrpc": "1.0" })
+ navigator.sendBeacon("json/", params);
+ }
+ catch {
+ // compatibility with old navigators
+ json_sync([seminarId, username], 'teleforma.seminar_unload', function () { return null; });
+ }
+}
var f = seminarUtils;
-$(document).ready(function( ){
- f.load('{{seminar.id}}','{{user.username}}');
- });
+var f = seminarUtils;
+$(document).ready(function(){
+ onLoadSeminar('{{seminar.id}}','{{user.username}}')
+});
$(window).ready(function( ){
{% if user.is_staff %}
}
});
{% endif %}
- $(window).bind('beforeunload', function(){
- f.unload('{{seminar.id}}','{{user.username}}');
- });
+ $(window).bind('beforeunload', function(){
+ onUnloadSeminar('{{seminar.id}}','{{user.username}}')
});
+});
</script>