‘;
this.div = document.querySelectorAll(this.divSelector)[0];
this.div.appendChild(html);
if(this.div.getElementsByClassName(‘app-badge-google’).length > 0 && browser && browser.name && browser.name == ‘ios’) {
this.div.getElementsByClassName(‘app-badge-google’)[0].classList.add(‘hide’);
}
jQuery(‘.play-button’).first().clone().appendTo(‘.play-button-mobile’);
document.body.classList.add(‘has-livebar’);
document.body.classList.add(‘livebar-‘+this.station_type);
}
// set height
this.setHeight = function() { // TODO variable height
var innerDocContentHeight = 80;
this.div.style.height = innerDocContentHeight + “px”;
}
this.removeUrlProtocol = function(url) {
var newstr = url.replace(‘http://’, ‘//’);
return newstr;
};
// subscribe events
this.subscribeEvents = function() {
var _this = this;
for (var i in this.configChannels) {
var channelName = this.configChannels[i];
var channel = this.pusher.subscribe(channelName);
for (var j in this.events) {
var eventName = this.events[j];
channel.bind(eventName, function(data) {
_this.pusherEvent(channelName, eventName, data);
});
}
_this.channels.push(channel);
}
};
// process real time `cue` event from Pusher.com
this.pusherEvent = function(channelName, eventName, pusherData) {
this.processTrackOrEvent(pusherData);
};
this.latestEpisode = function() {
var episode = this.latest_episode;
var data = {
type: ‘podcast’,
artist: “http://www.1057thepoint.com/”, // episode.podcast_title,
trackName: this.truncate(episode.post_title, 71),
art: episode.post_thumbnail,
url: episode.url
}
this.processTrackOrEvent(data);
}
// grabs the latest track from the api
this.ajaxLatestTrack = function() {
var endpoint = this.endpoint + ‘/hll_widget_livebar_cues.php’;
var data = {
‘limit’: ‘1’
};
var _this = this;
var httpRequest = new XMLHttpRequest();
httpRequest.open(‘POST’, endpoint);
httpRequest.setRequestHeader(“Content-type”, “application/json”);
httpRequest.send(JSON.stringify(data));
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
var json = JSON.parse(httpRequest.responseText);
_this.processTrackOrEvent(json.data.response[0]);
}
}
};
// grabs the latest event from the api
this.ajaxLatestEvent = function() {
var endpoint = this.endpoint + ‘/hll_widget_livebar_events.php’;
var data = {
‘limit’: ‘3’
};
var _this = this;
var httpRequest = new XMLHttpRequest();
httpRequest.open(‘POST’, endpoint);
httpRequest.setRequestHeader(“Content-type”, “application/json”);
httpRequest.send(JSON.stringify(data));
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
var json = JSON.parse(httpRequest.responseText);
_this.processTrackOrEvent(json.data.response[0]);
}
}
};
// grabs the latest podcast episode from the wp-json api
this.ajaxLatestEpisode = function() {
var endpoint = ‘/wp-json/hbi/v1/liveplayer/latestepisode’;
var _this = this;
var httpRequest = new XMLHttpRequest();
httpRequest.open(‘GET’, endpoint);
httpRequest.setRequestHeader(“Content-type”, “application/json”);
httpRequest.send();
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
var episode = JSON.parse(httpRequest.responseText);
var data = {
type: ‘podcast’,
artist: “http://www.1057thepoint.com/”, // episode.podcast_title,
trackName: _this.truncate(episode.post_title, 71),
art: episode.post_thumbnail,
url: episode.url
}
_this.processTrackOrEvent(data);
}
}
};
// process the track or event data and update the HTML
this.processTrackOrEvent = function(d) {
// debug: print data to console
// window.console.log(‘processTrackOrEvent’,d);
// workaround: ignore spots for now
var type = d.type;
if (type !== ‘podcast’ && type !== ‘song’ && type !== ‘show’ && type !== ‘special-event’ && type !== ‘guest’ && type !== ‘other’) {
return;
}
if(type == ‘song’) {
var trackId = d.data.musicbrainz_recording;
var artist = d.data.artist “http://www.1057thepoint.com/” “http://www.1057thepoint.com/”;
var trackName = d.data.description “http://www.1057thepoint.com/” “http://www.1057thepoint.com/”;
var art = this.removeUrlProtocol(d.data.art_url “http://www.1057thepoint.com/” “https://www.1057thepoint.com/wp-content/plugins/hbi-player-widgets//assets/img/track.png”);
art = art + ‘?ver=3’;
}
else if(type == ‘podcast’) {
var artist = d.artist “http://www.1057thepoint.com/” “http://www.1057thepoint.com/”;
var trackName = d.trackName “http://www.1057thepoint.com/” “http://www.1057thepoint.com/”;
var art = this.removeUrlProtocol(d.art “http://www.1057thepoint.com/” “https://www.1057thepoint.com/wp-content/plugins/hbi-player-widgets//assets/img/track.png”);
this.setEpisodeTimer();
}
else {
var trackId = d.id;
var timeRange = function() {
let start_date = moment(d.start_date);
let end_date = moment(d.end_date);
let default_format = ‘h:mma’;
let start_day_format = (default_format);
let end_day_format = (default_format);
// If start and end dates both fall in AM or PM, make it brief
// Example: 10:00-11:00am vs 10:00am-11:00am
if(start_date.format(‘a’) === end_date.format(‘a’)) {
start_day_format = ‘h:mm’;
}
// Remove minutes if 00
if(start_date.minutes() == 0) {
start_day_format = ‘h’;
}
if(end_date.minutes() == 0) {
end_day_format = ‘ha’;
}
return start_date.format(start_day_format) + “-” + end_date.format(end_day_format);
};
var artist = timeRange();
var trackName = d.name “http://www.1057thepoint.com/” “http://www.1057thepoint.com/”;
var art = this.removeUrlProtocol(d.photo “http://www.1057thepoint.com/” “https://www.1057thepoint.com/wp-content/plugins/hbi-player-widgets//assets/img/event.png”);
// Start timer
this.setEventTimer();
}
// This block retrieves art work as a blob so we can render it in the DOM
// … and additionally process its color swatches in a canvas context via Vibrant.js
// … with only ONE network request.
// https://stackoverflow.com/questions/23013871/how-to-parse-into-base64-string-the-binary-image-from-response
// https://stackoverflow.com/questions/33902299/using-jquery-ajax-to-download-a-binary-file
fetchBlob(art, function(arrayBuffer) {
var blob = new Blob([arrayBuffer], {type: “image/jpeg”});
var url = URL.createObjectURL(blob);
// Set artwork in DOM
document.getElementsByClassName(‘album-art-img’)[0].src=url;
document.getElementsByClassName(‘album-art-img’)[0].classList.remove(‘d-none’);
document.getElementsByClassName(‘live-player-background’)[0].src=url;
// Use live player button color if set in Customizer
if(window.livePlayerButtonColor) {
// set color of large and compact play buttons with customizer color
Array.from(document.getElementsByClassName(‘play-circle-outline-path’)).forEach(function(element) {
element.style.fill = window.livePlayerButtonColor;
// display play button if hidden (avoids color flash on load)
document.getElementById(‘play-button-column’).classList.remove(‘invisible’);
});
return;
}
// If live player button color is not manually set, automatically get album art color from vibrant.js
var img = document.getElementsByClassName(‘album-art-img’)[0];
img.addEventListener(‘load’, function() {
var vibrant = new Vibrant(img);
var swatches = vibrant.swatches();
var swatch = swatches[‘LightVibrant’] “http://www.1057thepoint.com/” swatches[‘Vibrant’] “http://www.1057thepoint.com/” swatches[‘Muted’] “http://www.1057thepoint.com/” swatches[‘DarkMuted’];
// trap edge case where Vibrant.js doesn’t return a swatch
if(swatch !== undefined) {
// get hex from swatch library
var hex = swatch.getHex();
// set color of large and compact play buttons
Array.from(document.getElementsByClassName(‘play-circle-outline-path’)).forEach(function(element) {
element.style.fill = hex;
});
}
// display play button if hidden (avoids color flash on load)
document.getElementById(‘play-button-column’).classList.remove(‘invisible’);
});
});
this.div.getElementsByClassName(‘onair-artist’)[0].innerHTML = artist;
this.div.getElementsByClassName(‘onair-track’)[0].innerHTML = trackName;
// link to episode if live player is in podcast mode
if(type == ‘podcast’) {
jQuery(‘.play-button a, #circles, .album-art a, .track a’).attr(‘href’,d.url).removeAttr(‘target’);
jQuery(‘.onair-artist’).hide();
}
// Skip TextFit step for podcast episodes
if(this.station_type == ‘podcast’) {
return;
}
// Dynamically size long track titles – https://github.com/STRML/textFit
// var textFitOptions = {
// alignVert: false, // if true, textFit will align vertically using css tables
// alignHoriz: false, // if true, textFit will set text-align: center
// multiLine: false, // if true, textFit will not set white-space: no-wrap
// detectMultiLine: false, // disable to turn off automatic multi-line sensing
// minFontSize: 11, // in px
// maxFontSize: 40, // in px
// reProcess: true, // if true, textFit will re-process already-fit nodes. Set to ‘false’ for better performance
// widthOnly: false, // if true, textFit will fit text to element width, regardless of text height
// alignVertWithFlexbox: false, // if true, textFit will use flexbox for vertical alignment
// }
if (textFit !== “undefined”) {
textFit(this.div.getElementsByClassName(‘onair-track’)[0], {
alignVert: false, // if true, textFit will align vertically using css tables
alignHoriz: false, // if true, textFit will set text-align: center
multiLine: false, // if true, textFit will not set white-space: no-wrap
detectMultiLine: false, // disable to turn off automatic multi-line sensing
minFontSize: 13, // in px
maxFontSize: 31, // in px
reProcess: true, // if true, textFit will re-process already-fit nodes. Set to ‘false’ for better performance
widthOnly: false, // if true, textFit will fit text to element width, regardless of text height
alignVertWithFlexbox: true, // if true, textFit will use flexbox for vertical alignment
});
textFit(this.div.getElementsByClassName(‘onair-artist’)[0], {
alignVert: false, // if true, textFit will align vertically using css tables
alignHoriz: false, // if true, textFit will set text-align: center
multiLine: false, // if true, textFit will not set white-space: no-wrap
detectMultiLine: false, // disable to turn off automatic multi-line sensing
minFontSize: 11, // in px
maxFontSize: 30, // in px
reProcess: true, // if true, textFit will re-process already-fit nodes. Set to ‘false’ for better performance
widthOnly: false, // if true, textFit will fit text to element width, regardless of text height
alignVertWithFlexbox: true, // if true, textFit will use flexbox for vertical alignment
});
}
}
// Set timer for event refresh
this.setEventTimer = function() {
var _this = this;
setTimeout(function(){
_this.ajaxLatestEvent();
}, this.eventRefreshTime);
};
// Set timer for episode refresh
this.setEpisodeTimer = function() {
var _this = this;
setTimeout(function(){
_this.ajaxLatestEpisode();
}, this.eventRefreshTime);
};
// https://stackoverflow.com/questions/1199352/smart-way-to-truncate-long-strings
this.truncate = function(str, n){
return (str.length > n) ? str.substr(0, n-1) + ‘…’ : str;
};
// https://stackoverflow.com/questions/23013871/how-to-parse-into-base64-string-the-binary-image-from-response
function fetchBlob(uri, callback) {
var xhr = new XMLHttpRequest();
xhr.open(‘GET’, uri, true);
xhr.responseType = ‘arraybuffer’;
xhr.onload = function(e) {
if (this.status == 200) {
var blob = this.response;
if (callback) {
callback(blob);
}
}
};
xhr.send();
};
}
// Set and intialize
var hllLiveBarWidget = new hllLiveBarWidgetObject(‘player-widget-livebar’);
hllLiveBarWidget.init();
The Rizzuto Show
Crap On Extra: Kevin Bacon’s Favorite Halloween Movies, music and more!
We cover music, tv and movies. Including Kevin Bacon’s Favorite Halloween movies.
Follow us @RizzShow @MoonValjeanHere @KingScottRules @LernVsRadio @IamRafeWilliams > Check out King Scott’s band @FreeThe2SG and Check out Moon’s bands GREEK FIRE @GreekFire GOLDFINGER @GoldfingerMusic THE TEENAGE DIRTBAGS @TheTeenageDbags and Lern’s band @LaneNarrows http://www.1057thepoint.com/Rizz
Learn more about your ad choices. Visit podcastchoices.com/adchoices
‘;
this.div = document.querySelectorAll(this.divSelector)[0];
this.div.appendChild(html);
this.innerWrapper = this.div.querySelectorAll(this.innerWrapperSelector)[0];
};
this.removeUrlProtocol = function(url) {
var newstr = url.replace(‘http://’, ‘//’);
return newstr;
};
// grabs the latest rewards
this.ajaxLatestRewards = function() {
var endpoint = this.endpoint + ‘/hll_widget_rewards_rewards.php’;
var data = {};
var _this = this;
var httpRequest = new XMLHttpRequest();
httpRequest.open(‘POST’, endpoint);
httpRequest.setRequestHeader(“Content-type”, “application/json”);
httpRequest.send(JSON.stringify(data));
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
var json = JSON.parse(httpRequest.responseText);
_this.processRewards(json.data);
}
}
};
// process the event reward and update the HTML
this.processRewards = function(d) {
var _this = this;
_this.rewards = [];
_this.featuredRewards = [];
d.forEach(function(element, index) {
var obj = {};
obj.id = element.id;
obj.title = element.title;
obj.image = _this.removeUrlProtocol(element.photo);
obj.type = element.type;
obj.featured = element.featured;
obj.hours = Math.floor(element.hours / 3600);
obj.hoursLabel = obj.hours == 1 ? ‘hour’ : ‘hours’;
if(obj.type == ‘geolocation’) {
obj.type = ‘app’
}
if(obj.type === ‘smack-the-track’){
var displayName = element.smackTheTrackFields.display_name;
//Format the display name to add dashes to replace spaces and special chars with “-”
obj.type = displayName.replace(/(W+?)/g,’-‘);
}
// only add if should be in widget
if(element.in_widgets === true) {
_this.rewards.push(obj);
}
});
if(_this.rewards.length > 0) {
// Show wrapper
this.div.querySelectorAll(‘.rewards-wrapper’)[0].classList.remove(“hide”);
this.div.querySelectorAll(‘.read_more’)[0].classList.remove(“hide”);
// Start sliders
this.startRewardsSliders();
} else {
// Show no rewards message
this.div.querySelectorAll(‘.no-rewards-wrapper’)[0].classList.remove(“hide”);
}
};
// Set timer for rewards refresh
this.setRewardsTimer = function() {
var _this = this;
setInterval(function(){
_this.ajaxLatestRewards();
}, this.rewardsRefreshTime);
},
// Start rewards sliders
this.startRewardsSliders = function() {
var _this = this;
if(_this.eventRotateTimer) {
return;
}
// Intialize light sliders
var sliderOptions = {
item: 2,
pager: false,
loop: true,
controls: false,
enableDrag: false,
enableTouch: false
};
// Setup sliders
_this.eventRotateTimer = true;
_this.rewardsSlider = this.div.querySelectorAll(‘#lightSlider’)[0];
_this.setupSlides();
// Start sliders
_this.rewardsSliderInstance = jQuery(_this.rewardsSlider).lightSlider(sliderOptions);
_this.rotateSlides();
},
// Slide rewards
this.setupSlides = function() {
var _this = this;
// Check for rewards
if(this.rewards.length 0) {
rewardElement.getElementsByClassName(‘content’)[0].getElementsByClassName(‘info’)[0].getElementsByClassName(‘time’)[0].innerHTML = ‘Listen for ‘ + element.hours + “http://www.1057thepoint.com/” + element.hoursLabel;
} else {
rewardElement.getElementsByClassName(‘content’)[0].getElementsByClassName(‘info’)[0].getElementsByClassName(‘time’)[0].innerHTML = “http://www.1057thepoint.com/”;
}
var featuredAnchor = this.div.getElementsByClassName(‘reward-featured-url’)[0];
featuredAnchor.setAttribute(‘href’,”https://live.1057thepoint.com/listen/rewards/” + element.id + “/?utm_source=station-website&utm_medium=widget&utm_campaign=rewards”);
// reward type badge
var typeBadge = rewardElement.getElementsByClassName(‘content’)[0].getElementsByClassName(‘info’)[0].getElementsByClassName(‘type-badge’)[0];
var typeBadgeclassListAsArray = new Array(typeBadge.classList.length);
for (var j = 0, len = typeBadge.classList.length; j