Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 42 additions & 27 deletions src/template/ACR_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -987,14 +987,26 @@
/**
Called when downloading of all videos took too long, show a message and block the hit.
**/
function show_message_too_long_loading(){
if(page_loading_timer){
clearTimeout(page_loading_timer);
page_loading_timer= null;
}
alert('It looks like that your Internet connection is too slow for this task. Please return this hit and try again later with a better network connection. Thanks');
disableTheHIT(Hide_HIT_REASON.AUTO_TEST_FAILED);
}
function show_message_too_long_loading(){
if(page_loading_timer){
clearTimeout(page_loading_timer);
page_loading_timer= null;
}
alert('It looks like that your Internet connection is too slow for this task. Please return this hit and try again later with a better network connection. Thanks');
disableTheHIT(Hide_HIT_REASON.AUTO_TEST_FAILED);
}

/**
Called when a video element cannot be loaded
**/
function show_message_video_load_error(url){
if(page_loading_timer){
clearTimeout(page_loading_timer);
page_loading_timer= null;
}
alert('Failed to load video: '+url+'. Please ensure the file is publicly accessible and that CORS is enabled.');
disableTheHIT(Hide_HIT_REASON.AUTO_TEST_FAILED);
}

/**
called when all videos are loaded
Expand Down Expand Up @@ -2341,25 +2353,28 @@
req.open('GET', src, true);
req.responseType = 'blob';

req.onload = function(){
if (this.status === 200) {
loading_duration = Date.now()- download_start.get(id);
download_duration.set(id, loading_duration);
console.log("Loading duration for "+id+":"+loading_duration);
let size = this.getResponseHeader('content-length');
let tmp = ((size /1024)/1024)
video_size_MB = video_size_MB + tmp;
var videoBlob = this.response;
var vurl = URL.createObjectURL(videoBlob);
document.getElementById(id).src = vurl;
}else{
console.log(this.status + ' ERROR: '+id+ ', src:'+tmp_src);
load_videos_to_storage(id);
}
};
req.onerror = function() {
console.log('Error on loading '+id);
}
req.onload = function(){
if (this.status === 200) {
loading_duration = Date.now()- download_start.get(id);
download_duration.set(id, loading_duration);
console.log("Loading duration for "+id+":"+loading_duration);
let size = this.getResponseHeader('content-length');
let tmp = ((size /1024)/1024)
video_size_MB = video_size_MB + tmp;
var videoBlob = this.response;
var vurl = URL.createObjectURL(videoBlob);
document.getElementById(id).src = vurl;
}else{
console.log(this.status + ' ERROR: '+id+ ', src:'+tmp_src);
recordError('VIDEO_LOAD_STATUS_'+this.status, tmp_src);
show_message_video_load_error(tmp_src);
}
};
req.onerror = function() {
console.log('Error on loading '+id);
recordError('VIDEO_LOAD_ERROR', tmp_src);
show_message_video_load_error(tmp_src);
}
download_start.set(id, Date.now());
if (start_page_load==null){
start_page_load = Date.now();
Expand Down
71 changes: 43 additions & 28 deletions src/template/DCR_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -1071,14 +1071,26 @@
/**
Called when downloading of all videos took too long, show a message and block the hit.
**/
function show_message_too_long_loading(){
if(page_loading_timer){
clearTimeout(page_loading_timer);
page_loading_timer= null;
}
alert('It looks like that your Internet connection is too slow for this task. Please return this hit and try it later with a better network connection. Thanks');
disableTheHIT(Hide_HIT_REASON.AUTO_TEST_FAILED);
}
function show_message_too_long_loading(){
if(page_loading_timer){
clearTimeout(page_loading_timer);
page_loading_timer= null;
}
alert('It looks like that your Internet connection is too slow for this task. Please return this hit and try it later with a better network connection. Thanks');
disableTheHIT(Hide_HIT_REASON.AUTO_TEST_FAILED);
}

/**
Called when a video element cannot be loaded
**/
function show_message_video_load_error(url){
if(page_loading_timer){
clearTimeout(page_loading_timer);
page_loading_timer= null;
}
alert('Failed to load video: '+url+'. Please ensure the file is publicly accessible and that CORS is enabled.');
disableTheHIT(Hide_HIT_REASON.AUTO_TEST_FAILED);
}

/**
Called when all videos are loaded
Expand Down Expand Up @@ -2582,26 +2594,29 @@
req.open('GET', src, true);
req.responseType = 'blob';

req.onload = function(){
if (this.status === 200) {
loading_duration = Date.now()- download_start.get(id);
download_duration.set(id, loading_duration);
console.log("Loading duration for "+id+":"+loading_duration);
let size = this.getResponseHeader('content-length');
let tmp = ((size /1024)/1024)
console.log(tmp_src+': '+tmp);
video_size_MB = video_size_MB + tmp;
var videoBlob = this.response;
var vurl = URL.createObjectURL(videoBlob);
document.getElementById(id).src = vurl;
}else{
console.log(this.status + ' ERROR: '+id+ ', src:'+tmp_src);
load_videos_to_storage(id);
}
};
req.onerror = function() {
console.log('Error on loading '+id);
}
req.onload = function(){
if (this.status === 200) {
loading_duration = Date.now()- download_start.get(id);
download_duration.set(id, loading_duration);
console.log("Loading duration for "+id+":"+loading_duration);
let size = this.getResponseHeader('content-length');
let tmp = ((size /1024)/1024)
console.log(tmp_src+': '+tmp);
video_size_MB = video_size_MB + tmp;
var videoBlob = this.response;
var vurl = URL.createObjectURL(videoBlob);
document.getElementById(id).src = vurl;
}else{
console.log(this.status + ' ERROR: '+id+ ', src:'+tmp_src);
recordError('VIDEO_LOAD_STATUS_'+this.status, tmp_src);
show_message_video_load_error(tmp_src);
}
};
req.onerror = function() {
console.log('Error on loading '+id);
recordError('VIDEO_LOAD_ERROR', tmp_src);
show_message_video_load_error(tmp_src);
}

download_start.set(id, Date.now());
if (start_page_load==null){
Expand Down
65 changes: 40 additions & 25 deletions src/template/avatar_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -1185,12 +1185,24 @@
Called when downloading of all videos took too long, show a message and block the hit.
**/
function show_message_too_long_loading(){
if(page_loading_timer){
clearTimeout(page_loading_timer);
page_loading_timer= null;
}
alert('It looks like that your Internet connection is too slow for this task. Please return this hit and try again later with a better network connection. Thanks');
disableTheHIT(Hide_HIT_REASON.AUTO_TEST_FAILED);
if(page_loading_timer){
clearTimeout(page_loading_timer);
page_loading_timer= null;
}
alert('It looks like that your Internet connection is too slow for this task. Please return this hit and try again later with a better network connection. Thanks');
disableTheHIT(Hide_HIT_REASON.AUTO_TEST_FAILED);
}

/**
Called when a video element cannot be loaded
**/
function show_message_video_load_error(url){
if(page_loading_timer){
clearTimeout(page_loading_timer);
page_loading_timer= null;
}
alert('Failed to load video: '+url+'. Please ensure the file is publicly accessible and that CORS is enabled.');
disableTheHIT(Hide_HIT_REASON.AUTO_TEST_FAILED);
}

/**
Expand Down Expand Up @@ -2901,25 +2913,28 @@
req.open('GET', src, true);
req.responseType = 'blob';

req.onload = function(){
if (this.status === 200) {
loading_duration = Date.now()- download_start.get(id);
download_duration.set(id, loading_duration);
console.log("Loading duration for "+id+":"+loading_duration);
let size = this.getResponseHeader('content-length');
let tmp = ((size /1024)/1024)
video_size_MB = video_size_MB + tmp;
var videoBlob = this.response;
var vurl = URL.createObjectURL(videoBlob);
document.getElementById(id).src = vurl;
}else{
console.log(this.status + ' ERROR: '+id+ ', src:'+tmp_src);
load_videos_to_storage(id);
}
};
req.onerror = function() {
console.log('Error on loading '+id);
}
req.onload = function(){
if (this.status === 200) {
loading_duration = Date.now()- download_start.get(id);
download_duration.set(id, loading_duration);
console.log("Loading duration for "+id+":"+loading_duration);
let size = this.getResponseHeader('content-length');
let tmp = ((size /1024)/1024)
video_size_MB = video_size_MB + tmp;
var videoBlob = this.response;
var vurl = URL.createObjectURL(videoBlob);
document.getElementById(id).src = vurl;
}else{
console.log(this.status + ' ERROR: '+id+ ', src:'+tmp_src);
recordError('VIDEO_LOAD_STATUS_'+this.status, tmp_src);
show_message_video_load_error(tmp_src);
}
};
req.onerror = function() {
console.log('Error on loading '+id);
recordError('VIDEO_LOAD_ERROR', tmp_src);
show_message_video_load_error(tmp_src);
}
download_start.set(id, Date.now());
if (start_page_load==null){
start_page_load = Date.now();
Expand Down