';
}
if (data.showbackground) {
$('#ondemand-hero').css('backgroundImage', 'url('+data.mezzanine+')');
}
showinfo += '
About this show '+replacecode(data.showdesc)+'';
const $funderMessage = $('#fundermessage');
const $funderWrapper = $('#fundermessagewrapper');
// Only proceed if #fundermessage exists
if ($funderMessage.length && ($funderMessage.html() || '').trim() === '') {
if (data.funder_message) {
const fundermessage = '
' + replacecode(data.funder_message) + '';
$funderMessage.html(fundermessage).show();
} else {
$funderWrapper.hide();
}
}
$('#showposter').html(showposter);
$('#showinfo').html(showinfo);
specials(data.showid);
collections(data.showid);
previews(data.showid);
getschedule(data.showid);
//TURNING THIS OFF FOR NOW
videoseriesstub($showid,data.showtitle);
});
} //end get show function
function checkBtnPosition(btn,i) {
var dropdownHeight = $('.add-to-calendar-dropdown').eq(i).height();
var dropdownWidth = $('.add-to-calendar-dropdown').eq(i).width();
if ( (btn.offset().top - $(window).scrollTop()) > ($(window).height() / 2) ) {
$('.add-to-calendar-dropdown').eq(i).css({'top': btn.offset().top - dropdownHeight, 'left': btn.offset().left });
} else {
$('.add-to-calendar-dropdown').eq(i).css({'top': btn.offset().top + btn.outerHeight(), 'left': btn.offset().left });
}
if ( btn.offset().left + dropdownWidth > $(window).width() ) {
$('.add-to-calendar-dropdown').eq(i).css({'left': btn.offset().left - dropdownWidth + btn.width() });
} else {
$('.add-to-calendar-dropdown').eq(i).css({'left': btn.offset().left });
}
}
/**
* JSON-LD metadata for series
*/
function buildSeriesJSON_LD(data) {
let seriesJSON = `{
"@context":"https://schema.org",
"@type":"TVSeries",
"name":"${data.showtitle}",
"description":"${data.showdesc}",
"image":"${data.showposter}",
"url":"${window.location.href}",
"potentialAction":{
"@type":"ViewAction",
"target":[
{
"@type":"EntryPoint",
"url":"${window.location.href}",
"actionPlatform":[
"http://schema.org/DesktopWebPlatform",
"http://schema.org/MobileWebPlatform",
"http://schema.org/IOSPlatform",
"http://schema.org/AndroidPlatform"
]
}
]
}
}`;
let jsonld = document.getElementById('json-ld');
jsonld.innerHTML = seriesJSON;
}
/**
* JSON-LD metadata for episodes
*/
function buildEpisodeJSON_LD(data) {
let episodeJSON = `{
"@context": "https://schema.org",
"@graph": [
{
"@type": "TVEpisode",
"@id": "${window.location.href}",
"name": "${data.thetitle}",
"url": "${window.location.href}",
"description": "${data.longdesc}",
"image": {
"@type": "ImageObject",
"url": "${data.mezzanine}"
},
"dateCreated": "${data.thedateiso}",
"duration": "${data.thelength}",
"episodeNumber": "${data.epnumber}",
"partOfSeries": {
"@type": "TVSeries",
"url": "https://pbswisconsin.org/watch/${data.showslug}/",
"datePublished": "${data.thedateiso}"
}
}
]
}`;
let jsonld = document.getElementById('json-ld');
jsonld.innerHTML = episodeJSON;
}
// show/hide embed code
$("#showcode").click(function(){
$("#theembedcode").slideToggle();
});
// Check Cove Video -- kiiling this
if(typeof window.addEventListener==='function'){
window.addEventListener("message",receiveCOVEVideoMessage,false);
}else{
window.attachEvent("onmessage",receiveCOVEVideoMessage);
}
var COVEVideoTitle;
var COVELastAction;
function receiveCOVEVideoMessage(evt){
if(typeof window["dataLayer"]==='undefined'){
dataLayer = [];
}
if ( evt.origin == 'http://player.pbs.org' || evt.origin == 'https://player.pbs.org' ) {
var thissourcewindow = evt.source;
var data=evt.data,
action=evt.data.split('::')[0],
value=evt.data.split('::')[1];
if (action==="video") {
if (value==="playing" && COVELastAction !=="seeking") {
//videoInfo = JSON.parse(value);
//send to ga
COVELastAction=value;
} else if (value==="seeking") {
COVELastAction=value;
} else if (value==="finished" && COVELastAction !=="finished") {
COVELastAction=value;
playnext(COVEVideoTitle);
}
} else if (action === "videoInfo") {
videoInfo = JSON.parse(value);
COVEVideoTitle = videoInfo.title;
COVESeries='';
if (typeof videoInfo.program.title !== 'undefined') {
COVEVideoTitle = COVEVideoTitle;
}
if (typeof videoInfo.program.slug !== 'undefined') {
COVESeries = videoInfo.program.slug;
}
finaltitle=COVESeries+':'+COVEVideoTitle;
finaltitle = finaltitle.replace(/'/g, '');
finaltitle = finaltitle.replace(/\s+/g, '-').toLowerCase();
}
}
}
// Custom Search Form
$('#clearsearch').click(function(e){
e.preventDefault();
$('#upkw').val('');
$('#topic').val('');
$('#lecture').val('');
$('#campus').val('');
$('#upresults').empty();
$('#uploading').addClass('d-none');
})
//prevent enter button
$('#upsearchform input').keydown(function (e) {
if (e.keyCode == 13) {
e.preventDefault();
return false;
}
});
$('#upsearchform').submit(function(e){
e.preventDefault();
loadseries();
});
//on change genre
$('#topic').change(function(event) {
$('#upkw').val('');
loadseries();
});
//on change genre
$('#lecture').change(function(event) {
$('#upkw').val('');
loadseries();
});
$('#campus').change(function(event) {
$('#upkw').val('');
loadseries();
});
function sanitize(string) {
const map = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": ''',
"/": '/',
};
const reg = /[&<>"'/]/ig;
return string.replace(reg, (match)=>(map[match]));
}
// on textsearch
var timerid;
$("#upkw").on("input",function(e){
var value = $(this).val();
if($(this).data("lastval")!= value){
$(this).data("lastval",value);
clearTimeout(timerid);
timerid = setTimeout(function() {
//if empty reset
if(value==''){
$('#magicon').css('color', 'grey');
$('#uplacesortlink').show();
uplace_reset();
}else{
//change action
$('#magicon').css('color', 'white');
$('#uplacesortlink').hide();
$('#uplacesorttitle').html('Episodes Containing “'+sanitize(value)+'”');
$('#topic').val('');
$('#lecture').val('');
$('#campus').val('');
loadseries();
} //end if
},700);
};
});
// new univeristy place click
$('.filterlink').click(function(event) {
//clear keyword
$("#upkw").val('');
//close the list of links
$('#uplace-dropdown').slideToggle();
//get values
$datatype=$(this).data('type');
$val=$(this).attr("ID");
$catext=$(this).text();
if($datatype=='topic'){
$('#topic').val($val);
$('#lecture').val('');
loadseries();
}
if($datatype=='lecture'){
$('#lecture').val($val);
$('#topic').val('');
loadseries();
}
if($datatype=='reset'){
uplace_reset();
}
//set sort by title
$('#uplacesorttitle').html($catext);
});
// new university place reset -- get most recent episodes
function uplace_reset(){
$('#upresults').empty();
$('#topic').val('');
$('#lecture').val('');
$('#upkw').val('');
$('#upresults').empty();
$('#uploading').addClass('d-none');
if('sewing-nancy'=='university-place'){
moreps('f4843c18-9fbb-44ea-a0ec-b06aef41369b',1);
}
}
// load of the series
function loadseries($page,$append) {
$page=$page || 1;
$append=$append || false;
var datastring = $('#upsearchform').serialize();
if ($append) {
// nothing
} else {
$('#upresults').empty();
}
// show loading
$('#uploading').removeClass('d-none');
$.ajax({
type: "GET",
url: "/wp-content/plugins/wpt-cove/css/json-up-tags.php?page="+$page,
data: datastring,
success: function(data) {
if($append){
$('#upresults').append(data);
}else{
$('#upresults').html(data);
}
$('#uploading').addClass('d-none');
// view more click button
$('.upsearchonly').click(function(){
$(this).hide();
var page=$(this).attr('id');
loadseries(page,true);
});
},
error: function() {
alert('error handing here');
}
}); // end ajax
} // end University Place search function
}); // end ready