Fix bug.
This commit is contained in:
parent
59a8b96c89
commit
d1d3d6b89f
|
@ -102,6 +102,76 @@ if (typeof onYouTubeIframeAPIReady !== 'function'){
|
||||||
});
|
});
|
||||||
if(window.yt_players == undefined)
|
if(window.yt_players == undefined)
|
||||||
window.yt_players = {};
|
window.yt_players = {};
|
||||||
|
function find_out_yt_event_list_key(yt_player){
|
||||||
|
var defalt_key = 'o';
|
||||||
|
var all_keys = Object.keys(ytp).filter(function(s){return s.length == 1});
|
||||||
|
var prop_nums_thresh = 6;
|
||||||
|
if(all_keys.indexOf(defalt_key) != -1){
|
||||||
|
if((yt_player[defalt_key] instanceof Object) && Object.keys(yt_player[defalt_key]).length > prop_nums_thresh){
|
||||||
|
return defalt_key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var event_key;
|
||||||
|
all_keys.forEach(function(k){
|
||||||
|
if((yt_player[k] instanceof Object) && Object.keys(yt_player[k]).length > prop_nums_thresh){
|
||||||
|
event_key = k;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return event_key;
|
||||||
|
}
|
||||||
|
function find_out_yt_event_list_count_key(yt_player, event_list_key){
|
||||||
|
var defalt_key = 'v';
|
||||||
|
var all_keys = Object.keys(ytp).filter(function(s){return s.length == 1});
|
||||||
|
var equal_count = yt_player[event_list_key].length;
|
||||||
|
if(all_keys.indexOf(defalt_key) != -1){
|
||||||
|
if(yt_player[defalt_key] == equal_count){
|
||||||
|
return defalt_key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var count_key;
|
||||||
|
all_keys.forEach(function(k){
|
||||||
|
if(yt_player[k] == equal_count){
|
||||||
|
count_key = k;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return count_key;
|
||||||
|
}
|
||||||
|
function find_out_yt_event_list_array_key(event_dict){
|
||||||
|
var defalt_key = 'i';
|
||||||
|
var all_keys = Object.keys(event_dict);
|
||||||
|
if(all_keys.indexOf(defalt_key) != -1){
|
||||||
|
if(Array.isArray(event_dict[defalt_key]) && event_dict[defalt_key].indexOf('onStateChange') != -1){
|
||||||
|
return defalt_key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var array_key;
|
||||||
|
all_keys.forEach(function(k){
|
||||||
|
if(Array.isArray(event_dict[k]) && event_dict[k].indexOf('onStateChange') != -1){
|
||||||
|
array_key = k;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return array_key;
|
||||||
|
}
|
||||||
|
function find_out_yt_event_relation_key(event_dict){
|
||||||
|
var defalt_key = 'j';
|
||||||
|
var all_keys = Object.keys(event_dict);
|
||||||
|
if(all_keys.indexOf(defalt_key) != -1){
|
||||||
|
if((event_dict[defalt_key] instanceof Object) && event_dict[defalt_key]['onStateChange']){
|
||||||
|
return defalt_key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var relation_key;
|
||||||
|
all_keys.forEach(function(k){
|
||||||
|
if((event_dict[k] instanceof Object) && event_dict[k]['onStateChange']){
|
||||||
|
relation_key = k;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return relation_key;
|
||||||
|
}
|
||||||
function onYouTubeIframeAPIReady(){
|
function onYouTubeIframeAPIReady(){
|
||||||
$(".w-ba-banner").each(function(i,banner){
|
$(".w-ba-banner").each(function(i,banner){
|
||||||
var iframes = $(banner).find("iframe");
|
var iframes = $(banner).find("iframe");
|
||||||
|
@ -134,15 +204,24 @@ if (typeof onYouTubeIframeAPIReady !== 'function'){
|
||||||
try{
|
try{
|
||||||
delete (event.target.B || event.target.H || event.target.I).onStateChange;
|
delete (event.target.B || event.target.H || event.target.I).onStateChange;
|
||||||
}catch(e){console.log("{onReady: true, onStateChange: true} missing!")};
|
}catch(e){console.log("{onReady: true, onStateChange: true} missing!")};
|
||||||
var onStateChange_idx = event.target.l.i.onStateChange;
|
var event_list_key = find_out_yt_event_list_key(event.target);
|
||||||
|
if(event_list_key){
|
||||||
|
var event_dict = event.target[event_list_key];
|
||||||
|
var array_key = find_out_yt_event_list_array_key(event_dict);
|
||||||
|
var count_key = find_out_yt_event_list_count_key(event_dict, array_key);
|
||||||
|
var relation_key = find_out_yt_event_relation_key(event_dict);
|
||||||
|
var onStateChange_idx = event_dict[relation_key].onStateChange;
|
||||||
onStateChange_idx.reverse();
|
onStateChange_idx.reverse();
|
||||||
var event_size = 3;
|
var event_size = 3;
|
||||||
onStateChange_idx.forEach(function(start_idx){
|
onStateChange_idx.forEach(function(start_idx){
|
||||||
event.target.l.h.splice(start_idx,event_size);
|
event_dict[array_key].splice(start_idx,event_size);
|
||||||
});
|
});
|
||||||
event.target.l.i.onStateChange = [];
|
event_dict[relation_key].onStateChange = [];
|
||||||
event.target.l.s = event.target.l.h.length;
|
event_dict[count_key] = event_dict[array_key].length;
|
||||||
event.target.addEventListener('onStateChange',onPlayerStateChange);
|
event.target.addEventListener('onStateChange',onPlayerStateChange);
|
||||||
|
}else{
|
||||||
|
console.log("YT player changes its variables!")
|
||||||
|
}
|
||||||
{{extra_ready_script}}
|
{{extra_ready_script}}
|
||||||
},
|
},
|
||||||
'onStateChange': onPlayerStateChange
|
'onStateChange': onPlayerStateChange
|
||||||
|
|
Loading…
Reference in New Issue