$(function () {
if ($('.most-popular-episodes').length > 0) {
$.ajax({
url: DOMAIN_SECURE_URL + '/api2/public/mostPopularEpisodes',
type: 'GET',
data: {site: site},
dataType: 'json',
success: function (result) {
if (result.code === 200) {
$.each(result.data, function (id, res) {
$('.most-popular-episodes').append('
' + res.title + '');
});
}
},
});
}
loadEpisodeHits();
(function showTopToolBar () {
$('body').prepend('');
})();
});
function loadEpisodeHits() {
var query = [];
$('.post_toolbar_download .wait-load.hits').each(function () {
query.push({
file: $(this).attr('data-file'),
w: $(this).attr('data-w'),
});
});
if (query.length === 0 && $('#home_visitor_stat,.home_visitor_stat_span').length===0) {
return;
}
$.ajax({
url: DOMAIN_SECURE_URL + '/api2/public/filesPlays',
type: 'GET',
data: {site: site, query: query},
dataType: 'json',
success: function (result) {
if (result.code === 200) {
$.each(result.data, function (id, count) {
if (id === 'allFile') {
if ($('.show_block').length > 0) {
if (count > 100000) {
$('.show_block span.counts').css('font-size', '15px');
}
$('#home_visitor_stat,.home_visitor_stat_span').text(addCommas(count));
}
} else {
id = id.replace(/\./g, '_');
let div = $('.hits_' + id);
if (count > 0) {
div.text(count);
} else {
div.parent('.hits').prev('span').remove();
div.parent('.hits').remove();
}
}
});
}
},
});
}
function addCommas(nStr) {
nStr += '';
var x = nStr.split('.');
var x1 = x[0];
var x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
}
function findGetParameter(parameterName) {
var result = null,
tmp = [];
var items = location.search.substr(1).split('&');
for (var index = 0; index < items.length; index++) {
tmp = items[index].split('=');
if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
}
return result;
}
//