-
Notifications
You must be signed in to change notification settings - Fork 0
/
video_embed_aol.js
42 lines (38 loc) · 1.2 KB
/
video_embed_aol.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* @file
* This file contains an AJAX loader for AOL ON video player.
*/
(function($) {
Drupal.behaviors.video_embed_aol = {
attach: function (context, settings) {
/*
* Load the information about the video and insert video script on it's place.
*/
if (typeof settings.video_embed_aol !== 'undefined') {
var get_videos = function (selector, val) {
$('#' + selector, context).once (selector, function() {
$.ajax({
url: val.api_endpoint_url,
crossDomain: true,
dataType: 'json',
error: function() {
$('#' + selector).text(Drupal.t('Error'));
},
success: function(data) {
if (typeof data.items !== 'undefined') {
if (0 in data.items) {
var player = data.items[0].player.source;
var src = $(player).attr('src');
$.getScript(src);
$('#' + selector)[0].innerHTML = player;
}
}
}
});
});
};
$.each(settings.video_embed_aol, get_videos);
}
}
};
})(jQuery);