NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name univision injector
// @namespace http://tv.univision.mn/24/watch
// @include http://tv.univision.mn/24/watch
// @include https://code.jquery.com/jquery-1.11.3.min.js
// @version 1.2
// @grant none
// ==/UserScript==
function getPrograms(id, cDate) {
$('ul.schedule-dialog').html(_template4);
$.post(
loadUrl,
{id: id, cDate: cDate },
function(data){
updateChannel(data);
updateProgramListEvent();
},
"json"
);
}
var programs = {
1: { code: 'mnb', name: 'МҮОНТ'}
,2: {code: 'mongolhd', name: 'Монгол ТВ' }
,3: {code: 'ubs', name: 'UBS'}
,4: {code: 'ntv', name: 'nTV'}
,5: {code: 'etv', name: 'ETV'}
//,8: {code: 'shuud', name: 'Shuud'}
,9: {code: 'ehoron', name: 'Эх Орон'}
,22: {code: 'mn25', name: '25'}
,23: {code: 'edu', name: 'Боловсрол'}
,24: {code: 'mnb_2', name: 'МҮОНТ 2'}
,25: {code: 'eagle', name: 'Eagle'}
,26: {code: 'tv5', name: 'tv5'}
,27: {code: 'sbn', name: 'SBN'}
,31: {code: 'tv9', name: 'TV9'}
//,32: {code: 'sportbox', name: 'SportBox'}
,38: {code: 'royal', name: 'Royal'}
,41: {code: 'bloomberg', name: 'Bloomberg'}
,42: {code: 'parliament', name: 'Parliament'}
};
$(document).ready(function(){
for (var i = 1; i < 99999; i++)
window.clearInterval(i);
jwplayer('mediaspace').onReady(function(){
window.filename = jwplayer('mediaspace').getPlaylistItem().sources[0].file;
window.token = filename.substring(filename.lastIndexOf('/'));
});
window.updateChannel = function(data) {
channelId = data.ID;
var header = _template2.replace("{_LOGO_}", data.Channel.LogoBig).replace("{_TITLE_}", data.Channel.Title);
$('.dialog-title').html(header);
var d = new Date(data.CurrentDate.cDate);
var weekday = new Array(7);
weekday[0]= "Ням";
weekday[1] = "Даваа";
weekday[2] = "Мягмар";
weekday[3] = "Лхагва";
weekday[4] = "Пүрэв";
weekday[5] = "Баасан";
weekday[6] = "Бямба";
$('.dialog-date').text(weekday[d.getDay()] + ' / ' + data.CurrentDate.cDate);
nDate = data.CurrentDate.nDate;
pDate = data.CurrentDate.pDate;
if (data.Programs.length > 0) {
var li = '';
$.each(data.Programs, function() {
var program = this;
var timeObj = new Date();
var startTime = timeObj.getFullYear()+"-"+("0"+(timeObj.getMonth()+1)).slice(-2)+"-"+("0"+timeObj.getDate()).slice(-2)+" "+("0"+timeObj.getHours()).slice(-2)+":"+("0"+timeObj.getMinutes()).slice(-2)+":"+("0"+timeObj.getSeconds()).slice(-2);
var endTime = startTime;
var now = startTime;
var archive_url = _archive_url.replace("ID", program.id).replace("TITLE", 'mnb-2').replace("CDATE", data.CurrentDate.cDate);
var live_url = _live_url.replace("_CHANNELID", 24);
if(now > program.end_time)
{
li += '<li class="past">';
li += '<span class="ch-time label label-default">' + program.viewTime1 + '</span>';
li += '<a id="' + program.id + '" name="' + program.id + '" href="' + archive_url + '">' + program.title + '</a>'
li += '</li>';
}
else
{
if(startTime >= program.start_time)
{
li += '<li class="active">';
li += '<span class="ch-time label label-default">' + program.viewTime1 + '</span>';
li += '<a id="live" href="' + live_url + '">' + program.title + '</a>';
li += '</li>';
}
else
{
li += '<li>';
li += '<span class="ch-time label label-default">' + program.viewTime1 + '</span>';
li += '<a href="javascript:;">' + program.title + '</a>';
li += '</li>';
}
}
});
$('ul.schedule-live').html(li);
}
else {
$('ul.schedule-live').html(_template3);
}
$('#program-list').scrollTo('#live',{duration:'slow', offsetTop : '50'});
};
var $boxcontent = $(".box-content");
var $swipercontainer = $boxcontent.find(".swiper-container");
var $slides = $swipercontainer.find(".swiper-slide");
var $tvhutulbur = $boxcontent.find(".tv-hutulbur");
var $programlist = $tvhutulbur.find("#program-list");
var $channellist = $programlist.find(".channel-list");
var $chprev = $tvhutulbur.find(".ch-prev");
var $chnext = $tvhutulbur.find(".ch-next");
$chprev.off();
$chprev.click(function(e){
e.preventDefault();
getPrograms(channelId, pDate);
});
$chnext.off();
$chnext.click(function(e){
e.preventDefault();
getPrograms(channelId, nDate);
});
$.each($slides, function(i, slide){
var $slide = $(slide);
var $a = $slide.find("a");
$a.click(function(e){
e.preventDefault();
$slide.addClass("active").siblings().removeClass("active");
var id = $a.data("id");
window.channelId = id;
jwplayer('mediaspace').setup({
file: "http://202.70.45.36/hls/_definst_/tv_mid/smil:" + programs[id].code + ".smil" + window.token,
image: 'http://tv.univision.mn/js/jwplayer/images/Anywhere.png',
logo: {
file: 'http://tv.univision.mn/js/jwplayer/images/logo.png',
link: 'http://www.univision.mn'
},
autostart: 'true',
width: '100%',
aspectratio: '16:9',
stretching: 'fill'
});
$.post(
loadUrl,
{id: id, cDate: cDate },
function(data){
updateChannel(data);
updateProgramListEvent();
},
"json"
);
});
});
updateProgramListEvent();
});
function updateProgramListEvent(){
$.each($("#program-list").find(".channel-list").children("li"),function(i, li){
var $li = $(li);
var $a = $li.find("a");
var hrefarr = $a.attr("href").split("/");
var date =hrefarr.pop();
var time = $li.find(".ch-time").text().replace(":","-")+"-00";
$a.off();
$a.click(function(e){
e.preventDefault();
console.log()
jwplayer('mediaspace').setup({
file: 'http://202.70.45.36/vod/_definst_/mp4:tv/medium/'+programs[parseInt(channelId)].code+'.stream-'+date+'-'+time+window.token,
image: 'http://tv.univision.mn/js/jwplayer/images/Anywhere.png',
logo: {
file: 'http://tv.univision.mn/js/jwplayer/images/logo.png',
link: 'http://www.univision.mn'
},
autostart: 'true',
width: '100%',
aspectratio: '16:9',
stretching: 'fill'
});
});
});
}