Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongmin committed Oct 24, 2017
1 parent da6d58c commit 9bd80a0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions static/js/hlsreader.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ $(document).ready(function() {
if ($(this).children().attr('class').match('badge-secondary')) {
m3u8Url = $(this).siblings('span').attr('data-item').trim();
targetId = $(this).siblings('span').attr('data-target-id').trim();
appendMediaPlaylist(targetId, m3u8Url, $(this).attr('href').slice(1), $(this).parent());
$(this).children().removeClass('badge-secondary').addClass('badge-info').text("Media Playlist");
appendMediaPlaylist(targetId, m3u8Url, $(this).attr('href').slice(1), $(this).parent(), $(this).children(), "Media Playlist");
}
});

$('#master-playlist').on('click', '.alternative-url', function() {
if ($(this).children().attr('class').match('badge-secondary')) {
m3u8Url = $(this).siblings('span').attr('data-item').trim();
targetId = $(this).siblings('span').attr('data-target-id').trim();
appendMediaPlaylist(targetId, m3u8Url, $(this).attr('href').slice(1), $(this).parent());
$(this).children().removeClass('badge-secondary').addClass('badge-info').text("Alternative Media Playlist");
appendMediaPlaylist(targetId, m3u8Url, $(this).attr('href').slice(1), $(this).parent(), $(this).children(), "Alternative Media Playlist");
}
});

Expand Down Expand Up @@ -56,20 +54,24 @@ function readM3u8(m3u8Url, selector) {
});
}

function appendMediaPlaylist(variantInfo, m3u8Url, elementId, element) {
function appendMediaPlaylist(variantInfo, m3u8Url, elementId, element, badge, badgeText) {
originalBadgeText = badge.text();
badge.text("loading...");
$.ajax({
url: 'http://220.230.118.50:8080',
type: 'POST',
data: {
m3u8Url: m3u8Url,
variantInfo: variantInfo
variantInfo: variantInfo
},
dataType: 'text',
success: function (result) {
element.append('<ul class="collapse" id=\"' + elementId + '\">' + result + '</ul>');
element.append('<ul class="collapse" id=\"' + elementId + '\">' + result + '</ul>');
badge.removeClass('badge-secondary').addClass('badge-info').text(badgeText);
},
error: function (xhr, status, errorThrown) {
alert('failed');
badge.text(originalBadgeText);
alert(errorThrown);
}
});
}

0 comments on commit 9bd80a0

Please sign in to comment.