Skip to content

Instantly share code, notes, and snippets.

@adispen
Created July 2, 2016 00:14
Show Gist options
  • Save adispen/32116c5e2346b187d754349302aae465 to your computer and use it in GitHub Desktop.
Save adispen/32116c5e2346b187d754349302aae465 to your computer and use it in GitHub Desktop.
var debug = require('../helpers/debug');
function checkBind() {
console.log('checking');
console.log($('.live-count').length);
if ($('.live-count').length) {
console.log('exists');
$.each($('.live-count').data('events'), function(i) {
if (i === 'DOMSubtreeModified') {
console.log('its bound bitch');
return true;
}
});
return false;
}
}
module.exports = function() {
if (bttv.settings.get('showViewersInPlayer') === true) {
if (checkBind() === true) {
console.log('unbind');
$('.live-count').unbind('DOMSubtreeModified');
}
var x = 1;
console.log(x + 1);
debug.log('Replacing "LIVE" with viewer count');
$('span.js-live-label').text(function() {
return $('.live-count').text() + 'Viewers';
});
$('.live-count').bind('DOMSubtreeModified', function() {
$('span.js-live-label').text(function() {
return $('.live-count').text() + 'Viewers';
});
});
}
if (bttv.settings.get('showViewersInPlayer') === false) {
debug.log('Restoring "LIVE" in the player');
if (checkBind() === true) {
console.log('unbind');
$('.live-count').unbind('DOMSubtreeModified');
}
$('span.js-live-label').text(function() {
return 'Live';
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment