Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
25389b5a
Commit
25389b5a
authored
Jan 16, 2012
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Close page event logging works in FF and Chrome
parent
c598b6de
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
9 deletions
+22
-9
js/video_player.js
+22
-9
No files found.
js/video_player.js
View file @
25389b5a
// Things to abstract out to another file
var
close_event_logged
=
false
;
// 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"
;
//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.
// 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
))
{
/*
while((close_event_logged != "done") && (d.getTime() < t+500)) {
console.log(close_event_logged);
}
}
*/
}
window
.
onbeforeunload
=
log_close
;
...
...
@@ -217,19 +221,28 @@ function videoDestroy() {
}
function
log_event
(
e
,
d
)
{
$
.
get
(
"/event"
,
{
data
=
{
"event_type"
:
e
,
"event"
:
JSON
.
stringify
(
d
),
"page"
:
document
.
URL
},
}
$
.
ajax
({
type
:
'GET'
,
url
:
'/event'
,
dataType
:
'json'
,
data
:
data
,
async
:
!
log_close_event
,
// HACK: See comment on log_close_event
success
:
function
(){},
headers
:
{
'X-CSRFToken'
:
getCookie
(
'csrftoken'
)}
});
/*, // Commenting out Chrome bug fix, since it breaks FF
function(data) {
console.log("closing");
if (close_event_logged == "waiting") {
close_event_logged = "done";
console.log("closed");
}
});
});
*/
}
function
seek_slide
(
type
,
oe
,
value
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment