Commit a8e03a24 by Ernie Park

merge

parents c877e538 7600920f
// Things to abstract out to another file // Things to abstract out to another file
// We do sync AJAX for just the page close event.
// TODO: This should _really_ not be a global.
var log_close_event = false;
function log_close() {
var d=new Date();
var t=d.getTime();
//close_event_logged = "waiting";
log_close_event = true;
log_event('page_close', {});
log_close_event = false;
// Google Chrome will close without letting the event go through.
// This causes the page close to be delayed until we've hit the
// server. The code below fixes it, but breaks Firefox.
// TODO: Check what happens with no network.
/*while((close_event_logged != "done") && (d.getTime() < t+500)) {
console.log(close_event_logged);
}*/
}
window.onbeforeunload = log_close;
function getCookie(name) { function getCookie(name) {
var cookieValue = null; var cookieValue = null;
if (document.cookie && document.cookie != '') { if (document.cookie && document.cookie != '') {
...@@ -199,23 +221,28 @@ function videoDestroy() { ...@@ -199,23 +221,28 @@ function videoDestroy() {
} }
function log_event(e, d) { function log_event(e, d) {
//$("#eventlog").append("<br>"); data = {
//$("#eventlog").append(JSON.stringify(e)); "event_type" : e,
"event" : JSON.stringify(d),
// TODO: Decide if we want seperate tracking server. "page" : document.URL
// If so, we need to resolve: }
// * AJAX from different domain (XMLHttpRequest cannot load http://localhost:7000/userlog. Origin http://localhost:8000 is not allowed by Access-Control-Allow-Origin.) $.ajax({type:'GET',
// * Verifying sessions/authentication url: '/event',
dataType: 'json',
/*window['console'].log(JSON.stringify(e));*/ data: data,
$.get("/event", async: !log_close_event, // HACK: See comment on log_close_event
{ success: function(){},
"event_type" : e, headers : {'X-CSRFToken':getCookie('csrftoken')}
"event" : JSON.stringify(d), });
"page" : document.URL
}, /*, // Commenting out Chrome bug fix, since it breaks FF
function(data) { function(data) {
}); console.log("closing");
if (close_event_logged == "waiting") {
close_event_logged = "done";
console.log("closed");
}
});*/
} }
function seek_slide(type,oe,value) { function seek_slide(type,oe,value) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment