//animaiton
var isAnimating = false,
newLocation = '';
firstLoad = false;
var album;
var userProfile;
var selectedMainCategories = "";
var selectedSubCategory = "";
var mainCategoriesAdded = {};
var mediaElement = false;
var currentVideo = "";
var currentArtist = "";
var currentAlbum = "";
var currentPlaylist = "";
var contentToAdd;
var openAddToPlaylist = false;
var playlist;
var contentToStream;
var isContinueLis = false;
var isRqtSent = 0;
var isLoading = false;
var serverError = 0;
var limit = 10;
var pageName = "";
var mainBanners;
var smallBanners;
var playAll = false;
var selectedPackage = "";
var selectedPayment;
var selectedOperator = 0;
var selectedPackageForTelco;
var otherPayment = false;
var isJazzUser;
var isUfoneUser;
var isTelenorUser;
var isZongUser;
var windowWidth = 1500;
var widthLimit = 1919;
var loginSelOperator = 2;
var favArtistIds = [];
try {
windowWidth = $(window).width();
} catch (er) {
windowWidth = 1500;
}
isDoubleConfirmation = false;
function changeTheme() {
// event.preventDefault();
if ($('body').hasClass("white-theme")) {
$('body').removeClass("white-theme");
$('body').addClass("black-theme");
$(".main-logo").attr("src", "/theme/images/logo.png");
$(".img-googleplay").attr("src", "/theme/images/googleplay-black.png");
$(".img-appstore").attr("src", "/theme/images/appstore-black.png");
localStorage.setItem("theme", "black");
// $(".btnChangeTheme").html("Light Mode");
$("#subcribemodal2").addClass("modal-subcblack-charge");
$("#subcribemodal2 .subccharge-padd img").attr("src", "/theme/images/bajaoprowhite-logo.png");
} else {
$("#subcribemodal2").removeClass("modal-subcblack-charge");
$('body').addClass("white-theme");
$('body').removeClass("black-theme");
$(".main-logo").attr("src", "/theme/images/white-theme/logo.png");
$(".img-googleplay").attr("src", "/theme/images/googleplay.png");
$(".img-appstore").attr("src", "/theme/images/appstore.png");
localStorage.setItem("theme", "white");
// $(".btnChangeTheme").html("Dark Mode");
$("#subcribemodal2").removeClass("modal-subcblack-charge");
$("#subcribemodal2 .subccharge-padd img").attr("src", "/theme/images/bajaopro-logo.png");
}
// $("#switchTheme").trigger("click");
var url = window.location.pathname;
if (url != "/" && url.indexOf("/home") > -1 && url.indexOf("/index") > -1) {
if ($('body').hasClass("white-theme")) {
$('#header-wrap').addClass("white-header").removeClass("black-header");
} else {
$('#header-wrap').addClass("black-header").removeClass("white-header");
}
}
}
function loadPageContent(bodyName, bool) {
if (bodyName) {
pageName = bodyName;
try {
if (mediaStream && mediaStream.renderer && mediaStream.renderer.destroy) {
mediaStream.renderer.destroy();
} else if (mediaStream && mediaStream.renderer) {
mediaStream.renderer.destroy();
mediaStream = null;
}
} catch (err) {
// console.log("");
}
// sessionStorage.setItem("prevpage", window.location.pathname);
replacePageUrlByName("/" + bodyName);
// ga('send', 'pageview', {
// 'page': '/' + bodyName,
// 'title': '' + capitalize(bodyName.substring(0, bodyName.indexOf("?")))
// });
// $('#indexBody').children().remove();
$('.more-listshow').removeClass('active');
var pathArray = window.location.pathname.split('/');
if (pathArray.length > 3 && pathArray[1]) {
$('#indexBody').load(pathArray[1]);
} else {
$('#indexBody').load(bodyName);
}
}
}
$(document).on("click", "#closeModal", function (e) {
e.preventDefault();
e.stopPropagation();
const urlParams = new URLSearchParams(window.location.search);
const m = urlParams.get('m');
if (m == 1) {
window.location.replace("https://bajaoapp.page.link/cuHZ");
} else {
/*$('#subcribemodal2').modal('toggle');*/
window.location.href = "/home";
}
});
function switchContent(bodyName) {
// window.event.preventDefault();
// if (bodyName == "radios") {
/**
* Trigger Radio clevertap event
*/
// try {
//
// clevertap.event.push("Radio", {
// "Radio opened": 1,
// "Platform": "WEB"
// });
// } catch (er) {
// console.log("Error logging clevertap events" + er);
// }
/**
* end trigger
*/
// }
if (!isAnimating)
changePage("/" + bodyName, true);
firstLoad = true;
}
function reloadJs() {
try {
$.xhrPool.abortAll();
} catch (er) {
}
loadRegionals();
getUserProfile();
$("#sidebar-tab li,#main-nav-top li").removeClass("active");
album = "";
selectedMainCategories = "";
selectedSubCategory = "";
mainCategoriesAdded = {};
mediaElement = false;
currentVideo = "";
currentArtist = "";
currentAlbum = "";
// currentPlaylist = "";
contentToAdd = "";
openAddToPlaylist = false;
playlist = "";
// contentToStream = "";
isContinueLis = false;
isRqtSent = 0;
isLoading = false;
serverError = 0;
limit = 15;
playCurrentSong = false;
setTimeout(function () {
//call first load owl-nav image height
getHeight_owl();
// get .custome-carousel3 image height end
getHeight_customecarousel3();
//get item-box image height
getHeight_itembox();
// Full height .main-wrap
fix_height();
// checkbox-genre
$(".content").mCustomScrollbar({mouseWheelPixels: 300});
$(".checkbox-genre input[type='checkbox']").change(function () {
if ($(this).is(":checked")) {
$(this).closest('.list-genre-select').addClass("active");
} else {
$(this).closest('.list-genre-select').removeClass("active");
}
});
$("#homeslider .owl-prev").show();
}, 4000);
var url = window.location.pathname;
if (url != "/" && url.indexOf("/home") > -1 && url.indexOf("/index") > -1) {
if ($('body').hasClass("white-theme")) {
$('#header-wrap').addClass("white-header").removeClass("black-header");
} else {
$('#header-wrap').addClass("black-header").removeClass("white-header");
}
try {
$("#sideMoreContentLoader").removeClass("hidden").addClass("visible-lg");
$("footer").addClass("col-sm-12 col-md-12 col-lg-9");
} catch (er) {
}
} else {
try {
$("#sideMoreContentLoader").addClass("hidden").removeClass("visible-lg");
$("footer").removeClass("col-sm-12 col-md-12 col-lg-9");
} catch (er) {
}
}
if ($('body').hasClass("white-theme")) {
$(".main-logo").attr("src", "/theme/images/white-theme/logo.png");
// $(".btnChangeTheme").html("Dark Mode");
$("#subcribemodal2").removeClass("modal-subcblack-charge");
} else {
$(".main-logo").attr("src", "/theme/images/logo.png");
// $(".btnChangeTheme").html("Light Mode");
$("#subcribemodal2").addClass("modal-subcblack-charge");
$("#subcribemodal2 .subccharge-padd img").attr("src", "/theme/images/bajaoprowhite-logo.png");
}
$("html, body").animate({scrollTop: 0}, "slow");
if ($(".footer-player").length > 1) {
window.location.reload();
}
}
//////////common js/////////////////
var isMobile = false; //initiate as false
var isIphone = false;
// device detection
if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)
|| /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0, 4))
|| navigator.platform.toUpperCase().indexOf('MAC') >= 0
) {
isMobile = true;
if (navigator.userAgent.includes("iPhone")) {
isIphone = true;
}
if (screen.width > 1024) {
isMobile = false;
}
} else {
isMobile = false;
}
var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
////////////////////loading banners//////////////////////////////
//$(".mbanner-img").one("load", function () {
// try {
// console.log("here");
// $("#homesliderLoader").parent().hide("300");
//// $("#homesliderLoader").parent().remove();
// } catch (er) {
// }
//});
// function loadMainBanners(catId) {
// //// $(".loader-generic").show();
// if (mainBanners) {
// var data = mainBanners;
// $.each(data, function (i, item) {
// var backThumb = "background" + data[i].id;
// if (data[i].albumId !== 6181) {
// $(mainBannerTemplate({
// // thumb: data[i].bannerContent.thumbnailList.horizontal,
// thumb: data[i].imageName,
// thumbWebp: data[i].imageName.replace(".jpg", ".webp"),
// backThumb: backThumb
// })).data("content", data[i]).appendTo("#banner-app");
// }
// });
// $(".loader-generic").hide();
// // $("#homeslider").owlCarousel({
// // loop: true,
// // items: 1,
// // margin: 0,
// // autoplayTimeout: 5000,
// // autoplay: true,
// // dots: false,
// // nav: true,
// // navText: [" ", " "],
// // pagination: false,
// // responsive: {
// // 0: {items: 1, },
// // 480: {items: 1, },
// // 768: {items: 1, }
// // }
// // });
// $("#homeslider").owlCarousel({
// loop: false,
// margin: 40,
// dots: true,
// nav: false,
// navText: [""],
// pagination: false,
// responsive: {
// 0: {
// items: 1,
// stagePadding: 0,
// margin: 0,
// },
// 480: {
// items: 1,
// stagePadding: 0,
// margin: 0,
// },
// 600: {
// items: 1,
// stagePadding: 0,
// margin: 0,
// },
// 700: {
// items: 1,
// stagePadding: 0,
// margin: 0,
// },
// 768: {
// items: 2,
// margin: 40,
// stagePadding: 50,
// },
// 1000: {
// items: 2,
// margin: 40,
// stagePadding: 50,
// },
// 1024: {
// items: 2,
// margin: 40,
// stagePadding: 50,
// },
//
// 1200: {
// items: 2,
// margin: 40,
// stagePadding: 100,
//
// },
// 1366: {
// items: 2,
// margin: 40,
// stagePadding: 150,
//
// },
// 1600: {
// items: 2,
// margin: 40,
// stagePadding: 200,
// },
// 1920: {
// items: 2,
// margin: 40,
// stagePadding: 220,
// }
// }
// });
// $("#homeslider .owl-prev").hide();
// try {
// $("#homesliderLoader").parent().hide();
// $(".allproduct-sh-main-loader").remove();
// } catch (er) {
// }
// } else {
// var params = "catId=" + catId;
// $.ajax({
// type: 'POST',
// url: '/api/home/banners?siteid=' + getParameterByName("siteid"),
// data: params,
// dataType: "JSON"
// }).done(function (res) {
// if (res.respCode === "00" && res.respData !== null) {
// var data = res.respData;
// if (data.length > 0) {
// mainBanners = data;
// }
// $.each(data, function (i, item) {
// if (data[i].albumId !== 6181) {
// var backThumb = "background" + data[i].id;
// $(mainBannerTemplate({
// thumb: data[i].imageName,
// thumbWebp: data[i].imageName.replace(".jpg", ".webp"),
// backThumb: backThumb
// })).data("content", data[i]).appendTo("#banner-app");
// }
// });
// $(".loader-generic").hide();
// $("#homeslider").owlCarousel({
// loop: false,
// margin: 40,
// dots: true,
// nav: false,
// navText: [""],
// pagination: false,
// responsive: {
// 0: {
// items: 1,
// stagePadding: 0,
// margin: 0,
// },
// 480: {
// items: 1,
// stagePadding: 0,
// margin: 0,
// },
// 600: {
// items: 1,
// stagePadding: 0,
// margin: 0,
// },
// 700: {
// items: 1,
// stagePadding: 0,
// margin: 0,
// },
// 768: {
// items: 2,
// margin: 40,
// stagePadding: 50,
// },
// 1000: {
// items: 2,
// margin: 40,
// stagePadding: 50,
// },
// 1024: {
// items: 2,
// margin: 40,
// stagePadding: 50,
// },
//
// 1200: {
// items: 2,
// margin: 40,
// stagePadding: 100,
//
// },
// 1366: {
// items: 2,
// margin: 40,
// stagePadding: 150,
//
// },
// 1600: {
// items: 2,
// margin: 40,
// stagePadding: 200,
// },
// 1920: {
// items: 2,
// margin: 40,
// stagePadding: 220,
// }
// }
// });
// $("#homeslider .owl-prev").hide();
// try {
// // $("#homesliderLoader").parent().hide();
// $(".allproduct-sh-main-loader").remove();
// } catch (er) {
// }
// } else {
// $("#pl-main-div").hide();
// }
// }).fail(function (response) {
// }).always(function () {
// $(".loader-generic").hide();
// });
// }
// }
//==================== Bajao Campaign Banners ======================//
function loadMainBanners(catId) {
//// $(".loader-generic").show();
if (mainBanners) {
var data = mainBanners;
$.each(data, function (i, item) {
var backThumb = "background" + data[i].id;
if (data[i].albumId !== 6181) {
$(mainBannerTemplate({
// thumb: data[i].bannerContent.thumbnailList.horizontal,
thumb: data[i].imageName,
thumbWebp: data[i].imageName.replace(".jpg", ".webp"),
backThumb: backThumb
})).data("content", data[i]).appendTo("#banner-app");
}
});
$(".loader-generic").hide();
$("#homeslider").owlCarousel({
loop: false, margin: 40, dots: true, nav: false, navText: [""], pagination: false, responsive: {
0: {
items: 1, stagePadding: 0, margin: 0,
}, 480: {
items: 1, stagePadding: 0, margin: 0,
}, 600: {
items: 1, stagePadding: 0, margin: 0,
}, 700: {
items: 1, stagePadding: 0, margin: 0,
}, 768: {
items: 2, margin: 40, stagePadding: 50,
}, 1000: {
items: 2, margin: 40, stagePadding: 50,
}, 1024: {
items: 2, margin: 40, stagePadding: 50,
},
1200: {
items: 2, margin: 40, stagePadding: 100,
}, 1366: {
items: 2, margin: 40, stagePadding: 150,
}, 1600: {
items: 2, margin: 40, stagePadding: 200,
}, 1920: {
items: 2, margin: 40, stagePadding: 220,
}
}
});
$("#homeslider .owl-prev").hide();
try {
$("#homesliderLoader").parent().hide();
$(".allproduct-sh-main-loader").remove();
} catch (er) {
}
} else {
var params = "catId=" + catId;
$.ajax({
type: 'POST',
url: '/api/home/banners?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res.respCode === "00" && res.respData !== null) {
var data = res.respData;
if (data.length > 0) {
mainBanners = data;
}
$.each(data, function (i, item) {
if (item.albumId !== 6181) {
var backThumb = "background" + item.id;
var imageSrc = item.imageName;
var imageWebpSrc = item.imageName.replace(".jpg", ".webp");
// Use mainBannerTemplate to create the HTML
var bannerItem = $(mainBannerTemplate({
thumb: imageSrc,
thumbWebp: imageWebpSrc,
backThumb: backThumb
})).data("content", item);
// Append the banner item to the homeslider
$("#homeslider").append(bannerItem);
// Add click event to trigger bannerClick
bannerItem.on('click', function() {
bannerClick($(this).data('content'));
});
}
});
$(".loader-generic").hide();
$("#homeslider").owlCarousel({
loop: false, margin: 40, dots: false, nav: true,
autoplay: true,
autoplayTimeout: 3000,
navText: [""], pagination: false, responsive: {
0: {
items: 1, stagePadding: 0, margin: 0,
}, 480: {
items: 1, stagePadding: 0, margin: 0,
}, 600: {
items: 1, stagePadding: 0, margin: 0,
}, 700: {
items: 1, stagePadding: 0, margin: 0,
}, 768: {
items: 2, margin: 40, stagePadding: 50,
}, 1000: {
items: 2, margin: 40, stagePadding: 50,
}, 1024: {
items: 2, margin: 40, stagePadding: 50,
}, 1200: {
items: 2, margin: 40, stagePadding: 100,
}, 1366: {
items: 2, margin: 40, stagePadding: 50,
}, 1600: {
items: 2, margin: 40, stagePadding: 50,
}, 1920: {
items: 2, margin: 40, stagePadding: 50,
}
}
});
$("#homeslider .owl-prev").hide();
try {
// $("#homesliderLoader").parent().hide();
$(".allproduct-sh-main-loader").remove();
} catch (er) {
}
} else {
$("#pl-main-div").hide();
}
}).fail(function (response) {
}).always(function () {
$(".loader-generic").hide();
});
}
}
/////////////////////////loading sections content on home//////////////////////
//var sections;
function loadAllSectionWithContent(URL, page, start, end) {
var params = "page=" + page + "&sIndex=" + start + "&fIndex=" + end;
// console.log('loading all sections');
$.ajax({
type: 'POST',
url: URL + '?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null && res !== -1) {
var sections = res.respData;
$.each(sections, function (i, item) {
if (sections[i]) {
var hiddenShowAll = "hidden";
var secClass = "homesection sec_" + sections[i].id;
var carousalClass = "full-width-float custome-carousel custome-carousel-big";
if (sections[i].id == 53) {
hiddenShowAll = "";
carousalClass = "full-width-float custome-carousel-row";
} else if (sections[i].type == "PLAYLIST" || sections[i].id == 52) {
// } else if (sections[i].type == "ALBUM" || sections[i].type == "PLAYLIST" || sections[i].id == 52) {
carousalClass = "full-width-float custome-carousel";
} else if (sections[i].type == "ARTIST") {
hiddenShowAll = "";
secClass = "homesection artist-trending sec_" + sections[i].id;
}
$(mainSectionsV1Template({
secTitle: sections[i].title,
secClass: secClass,
id: sections[i].id,
hidden: hiddenShowAll,
divId: "section_" + sections[i].id + "_" + i,
type: sections[i].type,
carousalClass: carousalClass
})).appendTo("#allSectionsDiv");
var playlists = sections[i].playLists;
$.each(playlists, function (j, jItem) {
if (playlists.length > 1) {
if (sections[i].id != 2 || sections[i].id == 3) {
if (playlists[j]) {
var thumb = playlists[j].thumbnailList;
if (windowWidth > widthLimit || isIphone || isSafari) {
thumb = thumb && thumb.horizontal ? thumb.horizontal : defaultThumb();
thumb = thumb.replace(".webp", ".jpg");
} else {
thumb = thumb && thumb.mobileHorizontal ? thumb.mobileHorizontal : defaultThumb();
thumb.replace(".webp", ".jpg");
}
$(albumCarouselTemplateLazyLoad({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: playlists[j].title,
count: playlists[j].totalContent + (playlists[j].totalContent === 1 ? " track" : " tracks"),
sectionId: sections[i].id
})).data("content", playlists[j]).appendTo("#section_" + sections[i].id + "_" + i);
$("#section_" + sections[i].id + "_" + i).find(".albumToPlay").addClass("playlistToPlay").removeClass("albumToPlay");
}
$("#section_" + sections[i].id + "_" + i).closest("section").removeClass("hidden");
$("#section_" + sections[i].id + "_" + i).parent().find(".loader-background").hide();
}
} else {
var content = playlists[j].dataList;
if (sections[i].type == "AUDIO" || sections[i].type == "VIDEO" || sections[i].type == "NONE") {
if (sections[i].id == 53) {
var dynamicId = 0;
$.each(content, function (k, kItem) {
if (k % 2 == 0) {
dynamicId++;
$("#section_" + sections[i].id + "_" + i).append("
");
}
if (content[k].data) {
// var count = secondsTimeSpanToHMS(content[k].data.duration);
var count = content[k].data.artistTitle;
var progressWidth = "";
// if (res.data[0] && res.data[0].playlistId === 44) {
// progressWidth = (data[i].data.durationListened * 100) / data[i].data.duration;
// }
var thumb = content[k].data.thumbnailList;
if (windowWidth > widthLimit || isIphone || isSafari) {
thumb = thumb && thumb.square ? thumb.square : defaultThumbSquare();
thumb = thumb.replace(".webp", ".jpg");
} else {
thumb = thumb && thumb.mobileSquare ? thumb.mobileSquare : defaultThumbSquare();
thumb.replace(".webp", ".jpg");
}
var disabled = "";
if (content[k].data.contentId == 0) {
disabled = "disabled-div";
}
var proIcon = "hidden";
if (content[k].data.isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
$(contentCarouselTemplateLazyLoad({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: content[k].data.contentTitle,
category: count,
proIcon: proIcon,
contentId: content[k].data.contentId,
contentTitle: content[k].data.contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
sectionId: sections[i].id,
progressWidth: progressWidth + "%"
})).data("content", content[k].data).addClass(disabled).appendTo("#double_" + sections[i].id + "_" + dynamicId);
}
});
} else if (sections[i].id == 10) {
$.each(content, function (k, kItem) {
if (content[k].data) {
var thumb = content[k].data.thumbnailList;
if (windowWidth > widthLimit || isIphone || isSafari) {
thumb = thumb && thumb.square ? thumb.square : defaultThumbSquare();
thumb = thumb.replace(".webp", ".jpg");
} else {
thumb = thumb && thumb.mobileSquare ? thumb.mobileSquare : defaultThumbSquare();
thumb.replace(".webp", ".jpg");
}
var progressWidth = "";
if (content[k].data.durationListened) {
progressWidth = (content[k].data.durationListened * 100) / content[k].data.duration;
}
var disabled = "";
if (content[k].data.contentId == 0) {
disabled = "disabled-div";
}
var proIcon = "hidden";
if (content[k].data.isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
$(contentCarouselKeepListenTemplateLazyLoad({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: content[k].data.contentTitle,
contentId: content[k].data.contentId,
contentTitle: content[k].data.contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
category: content[k].data.artistTitle,
sectionId: sections[i].id,
proIcon: proIcon,
progressWidth: progressWidth
})).data("content", content[k].data).addClass(disabled).appendTo("#section_" + sections[i].id + "_" + i);
}
});
} else {
$.each(content, function (k, kItem) {
if (content[k].data) {
var thumb = content[k].data.thumbnailList;
if (windowWidth > widthLimit || isIphone || isSafari) {
thumb = thumb && thumb.square ? thumb.square : defaultThumbSquare();
thumb = thumb.replace(".webp", ".jpg");
} else {
thumb = thumb && thumb.mobileSquare ? thumb.mobileSquare : defaultThumbSquare();
thumb.replace(".webp", ".jpg");
}
var disabled = "";
if (content[k].data.contentId == 0) {
disabled = "disabled-div";
}
var proIcon = "hidden";
if (content[k].data.isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
$(contentCarouselTemplateLazyLoad({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: content[k].data.contentTitle,
contentId: content[k].data.contentId,
contentTitle: content[k].data.contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
category: content[k].data.artistTitle,
sectionId: sections[i].id,
proIcon: proIcon
})).data("content", content[k].data).addClass(disabled).appendTo("#section_" + sections[i].id + "_" + i);
}
});
}
} else if (sections[i].type == "ARTIST") {
$.each(content, function (k, kItem) {
if (content[k].data) {
var thumb = content[k].data.thumbnailList;
if (windowWidth > widthLimit || isIphone || isSafari) {
thumb = thumb && thumb.square ? thumb.square : defaultThumbSquare();
thumb = thumb.replace(".webp", ".jpg");
} else {
thumb = thumb && thumb.mobileSquare ? thumb.mobileSquare : defaultThumbSquare();
thumb.replace(".webp", ".jpg");
}
if (content[k].data) {
$(artistCarouselTemplateLazyLoad({
title: content[k].data.title,
link: "/artist/" + content[k].data.id + "/" + content[k].data.title.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
sectionId: sections[i].id
})).data("content", content[k].data).appendTo("#section_" + sections[i].id + "_" + i);
}
}
});
} else if (sections[i].type == "ALBUM") {
$.each(content, function (k, kItem) {
if (content[k].data) {
var thumb = content[k].data.thumbnailList;
if (windowWidth > widthLimit || isIphone || isSafari) {
thumb = thumb && thumb.horizontal ? thumb.square : defaultThumb();
thumb = thumb.replace(".webp", ".jpg");
} else {
thumb = thumb && thumb.mobileHorizontal ? thumb.square : defaultThumb();
thumb.replace(".webp", ".jpg");
}
$(albumSquareCarouselTemplateLazyLoad({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: content[k].data.title,
contentId: content[k].data.id,
contentTitle: content[k].data.title.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
category: content[k].data.totalContent + (content[k].data.totalContent === 1 ? " track" : " tracks"),
sectionId: sections[i].id
})).data("content", content[k].data).appendTo("#section_" + sections[i].id + "_" + i);
// $(albumCarouselTemplate({
// thumb: thumb,
// thumbWebp: thumb.replace(".jpg", ".webp"),
// title: content[k].data.title,
// count: content[k].data.totalContent + content[k].data.totalContent === 1 ? " track": " tracks"),
// sectionId: sections[i].id
// })).data("content", content[k].data).appendTo("#section_" + sections[i].id + "_" + i);
}
});
} else {
$.each(content, function (k, kItem) {
if (content[k].data) {
var thumb = content[k].data.thumbnailList;
if (windowWidth > widthLimit || isIphone || isSafari) {
thumb = thumb && thumb.horizontal ? thumb.horizontal : defaultThumb();
thumb = thumb.replace(".webp", ".jpg");
} else {
thumb = thumb && thumb.mobileHorizontal ? thumb.mobileHorizontal : defaultThumb();
thumb.replace(".webp", ".jpg");
}
$(albumCarouselTemplateLazyLoad({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: content[k].data.title,
count: content[k].data.totalContent + (content[k].data.totalContent === 1 ? " track" : " tracks"),
sectionId: sections[i].id
})).data("content", content[k].data).appendTo("#section_" + sections[i].id + "_" + i);
}
});
}
if (content.length > 0) {
$("#section_" + sections[i].id + "_" + i).closest("section").removeClass("hidden");
$("#section_" + sections[i].id + "_" + i).parent().find(".loader-background").hide();
}
}
});
// $(albumCarouselTemplate({
// thumb: data[i].data.thumbnailList ? data[i].data.thumbnailList.square : "",
// thumbWebp: data[i].data.thumbnailList ? data[i].data.thumbnailList.square.replace(".jpg", ".webp") : "",
// title: data[i].data.title,
// count: data[i].data.totalContent + (playlists[j].totalContent === 1 ? " track": " tracks"),
// sectionId: id
// })).data("content", data[i].data).appendTo("#section_" + id);
}
var owl = $("#section_" + sections[i].id + "_" + i);
if (sections[i].type == "ARTIST") {
owl.owlCarousel({
loop: false,
margin: 10,
dots: true,
lazyLoad: true,
nav: true,
navText: [" ", " "],
pagination: false,
responsive: {
0: {
items: 3,
margin: 0,
stagePadding: 25,
},
480: {
items: 3,
stagePadding: 25,
},
600: {
items: 4,
stagePadding: 30,
},
700: {
items: 4,
stagePadding: 30,
},
768: {
items: 4,
stagePadding: 30,
},
1000: {
items: 5,
stagePadding: 30,
},
1024: {
items: 5,
stagePadding: 30,
},
1200: {
items: 6,
stagePadding: 50,
},
1600: {
items: 6,
stagePadding: 50,
},
1920: {
items: 7,
stagePadding: 50,
}
}
});
} else if (sections[i].id == 52) {
owl.owlCarousel({
loop: false,
margin: 10,
dots: true,
lazyLoad: true,
nav: true,
navText: [" ", " "],
pagination: false,
responsive: {
0: {
items: 2,
margin: 5,
stagePadding: 20,
},
480: {
items: 3,
stagePadding: 20,
},
600: {
items: 3,
stagePadding: 70,
},
700: {
items: 3,
stagePadding: 70,
},
768: {
items: 4,
stagePadding: 70,
},
1000: {
items: 5,
stagePadding: 70,
},
1024: {
items: 5,
stagePadding: 70,
},
1200: {
items: 5,
stagePadding: 70,
},
1600: {
items: 5,
stagePadding: 70,
},
1920: {
items: 7,
stagePadding: 70,
}
}
});
} else if ((sections[i].type == "AUDIO" || sections[i].type == "VIDEO" || sections[i].type == "NONE" || sections[i].type == "ALBUM" || sections[i].id == 3) && sections[i].id !== 52) {
if (sections[i].id == 53) {
owl.owlCarousel({
loop: false,
margin: 10,
lazyLoad: true,
dots: true,
nav: true,
navText: [" ", " "],
pagination: false,
responsive: {
0: {
items: 3,
stagePadding: 25,
},
480: {
items: 4,
stagePadding: 20,
},
600: {
items: 4,
stagePadding: 70,
},
700: {
items: 4,
stagePadding: 70,
},
768: {
items: 4,
stagePadding: 70,
},
1000: {
items: 5,
stagePadding: 70,
},
1024: {
items: 5,
stagePadding: 70,
},
1200: {
items: 6,
stagePadding: 70,
},
1600: {
items: 7,
stagePadding: 70,
},
1920: {
items: 8,
stagePadding: 70,
}
}
});
} else {
owl.owlCarousel({
loop: false,
margin: 10,
lazyLoad: true,
dots: true,
nav: true,
navText: [" ", " "],
pagination: false,
onInitialize: function (element) {
},
responsive: {
0: {
items: 3,
margin: 5,
stagePadding: 20,
},
480: {
items: 3,
stagePadding: 20,
},
600: {
items: 4,
stagePadding: 70,
},
700: {
items: 4,
stagePadding: 70,
},
768: {
items: 4,
stagePadding: 70,
},
1000: {
items: 5,
stagePadding: 70,
},
1024: {
items: 5,
stagePadding: 70,
},
1200: {
items: 6,
stagePadding: 70,
},
1600: {
items: 7,
stagePadding: 70,
},
1920: {
items: 7,
stagePadding: 70,
}
}
});
}
} else
// if (sections[i].type == "RECOMMENDATION") {
// } else
{
owl.owlCarousel({
loop: false,
margin: 10,
lazyLoad: true,
dots: true,
nav: true,
navText: [" ", " "],
pagination: false,
onInitialize: function (element) {
// if (sections[i].id == 0) {
// owl.children().sort(function () {
// return Math.round(Math.random()) - 0.5;
// }).each(function () {
// $(this).appendTo(owl);
// });
// }
},
responsive: {
0: {
items: 2,
margin: 5,
stagePadding: 20,
},
480: {
items: 2,
stagePadding: 25,
},
600: {
items: 4,
stagePadding: 25,
},
700: {
items: 4,
stagePadding: 70,
},
768: {
items: 3,
stagePadding: 40,
},
1000: {
items: 4,
stagePadding: 70,
},
1024: {
items: 4,
stagePadding: 70,
},
1200: {
items: 4,
stagePadding: 70,
},
1600: {
items: 5,
stagePadding: 70,
},
1920: {
items: 5,
stagePadding: 70,
}
}
});
}
// if (sections[i].type !== "ARTIST" && sections[i].id !== 53) {
// owl.children().find(".owl-stage").css("padding-left", (Math.floor(Math.random() * 100) + 1) + "px !important");
// }
});
getheight_home();
}
}).fail().always(function () {
isLoading = false;
});
}
//var sections;
function loadAllSectionV2WithContent(URL, page, start, end) {
if ($("#allSectionsDiv" + page).html() == "") {
var params = "page=" + page + "&sIndex=" + start + "&fIndex=" + end;
$.ajax({
type: 'POST',
url: URL + '?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null && res !== -1) {
var sections = res.respData;
$.each(sections, function (i, item) {
if (sections[i]) {
var hiddenShowAll = "hidden";
var secClass = "homesection sec_" + sections[i].id;
var carousalClass = "full-width-float custome-carousel custome-carousel-big";
// if (sections[i].id == 53) {
// hiddenShowAll = "";
// carousalClass = "full-width-float custome-carousel-row";
// } else if (sections[i].type == "PLAYLIST" || sections[i].id == 52) {
//// } else if (sections[i].type == "ALBUM" || sections[i].type == "PLAYLIST" || sections[i].id == 52) {
// carousalClass = "full-width-float custome-carousel";
// } else
if (sections[i].type == "ARTIST") {
//hiddenShowAll = "";
secClass = "homesection artist-trending sec_" + sections[i].id;
}
$(mainSectionsV1Template({
secTitle: sections[i].title,
secClass: secClass,
id: sections[i].id,
hidden: hiddenShowAll,
divId: "section_" + sections[i].id + "_" + i,
type: sections[i].type,
carousalClass: carousalClass
})).appendTo("#allSectionsDiv" + page);
var playlists = sections[i].playLists;
$.each(playlists, function (j, jItem) {
// if (playlists.length > 1) {
var content = playlists[j].dataList;
if (page == "RADIO") {
$.each(content, function (k, kItem) {
if (content[k].data) {
var thumb = content[k].data.thumbnailList;
if (windowWidth > widthLimit || isIphone || isSafari) {
thumb = thumb && thumb.square ? thumb.square : defaultThumbSquare();
thumb = thumb.replace(".webp", ".jpg");
} else {
thumb = thumb && thumb.mobileSquare ? thumb.mobileSquare : defaultThumbSquare();
thumb.replace(".webp", ".jpg");
}
var disabled = "";
if (content[k].data.contentId == 0) {
disabled = "disabled-div";
}
var proIcon = "hidden";
if (content[k].data.isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
$(radioCarouselTemplateLazyLoad({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: content[k].data.stationName,
contentId: content[k].data.id,
contentTitle: content[k].data.stationName.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
category: content[k].data.contentType,
sectionId: sections[i].id,
proIcon: proIcon
})).data("content", content[k].data).addClass(disabled).appendTo("#section_" + sections[i].id + "_" + i);
}
});
} else if (page == "VIDEO") {
$.each(content, function (k, kItem) {
if (content[k].data) {
var thumb = content[k].data.thumbnailList;
if (windowWidth > widthLimit || isIphone || isSafari) {
thumb = thumb && thumb.square ? thumb.square : defaultThumbSquare();
thumb = thumb.replace(".webp", ".jpg");
} else {
thumb = thumb && thumb.mobileSquare ? thumb.mobileSquare : defaultThumbSquare();
thumb.replace(".webp", ".jpg");
}
var disabled = "";
if (content[k].data.contentId == 0) {
disabled = "disabled-div";
}
var proIcon = "hidden";
if (content[k].data.isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
$(videoCarouselTemplateLazyLoad({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: content[k].data.contentTitle,
contentId: content[k].data.contentId,
contentTitle: content[k].data.contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
category: content[k].data.artistTitle,
sectionId: sections[i].id,
proIcon: proIcon
})).data("content", content[k].data).addClass(disabled).appendTo("#section_" + sections[i].id + "_" + i);
}
});
} else {
if (sections[i].type == "AUDIO" || sections[i].type == "VIDEO" || sections[i].type == "NONE") {
if (sections[i].id == 2 || sections[i].id == 210 || sections[i].id == 265 || sections[i].id == 10 || sections[i].id == 269 || sections[i].id == 282) {
$.each(content, function (k, kItem) {
if (content[k].data) {
var thumb = content[k].data.thumbnailList;
if (windowWidth > widthLimit || isIphone || isSafari) {
thumb = thumb && thumb.square ? thumb.square : defaultThumbSquare();
thumb = thumb.replace(".webp", ".jpg");
} else {
thumb = thumb && thumb.mobileSquare ? thumb.mobileSquare : defaultThumbSquare();
thumb.replace(".webp", ".jpg");
}
var progressWidth = "";
if (content[k].data.durationListened) {
progressWidth = (content[k].data.durationListened * 100) / content[k].data.duration;
}
var disabled = "";
if (content[k].data.contentId == 0) {
disabled = "disabled-div";
}
var proIcon = "hidden";
if (content[k].data.isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
$(contentCarouselKeepListenTemplateLazyLoad({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: content[k].data.contentTitle,
contentId: content[k].data.contentId,
contentTitle: content[k].data.contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
category: content[k].data.artistTitle,
sectionId: sections[i].id,
proIcon: proIcon,
progressWidth: progressWidth
})).data("content", content[k].data).addClass(disabled).appendTo("#section_" + sections[i].id + "_" + i);
}
});
} else {
$.each(content, function (k, kItem) {
if (content[k].data) {
var thumb = content[k].data.thumbnailList;
if (windowWidth > widthLimit || isIphone || isSafari) {
thumb = thumb && thumb.square ? thumb.square : defaultThumbSquare();
thumb = thumb.replace(".webp", ".jpg");
} else {
thumb = thumb && thumb.mobileSquare ? thumb.mobileSquare : defaultThumbSquare();
thumb.replace(".webp", ".jpg");
}
var disabled = "";
if (content[k].data.contentId == 0) {
disabled = "disabled-div";
}
var proIcon = "hidden";
if (content[k].data.isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
$(contentCarouselTemplateLazyLoad({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: content[k].data.contentTitle,
contentId: content[k].data.contentId,
contentTitle: content[k].data.contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
category: content[k].data.artistTitle,
sectionId: sections[i].id,
playlistId: sections[i].playLists[0].id,
playlistName: sections[i].playLists[0].title,
proIcon: proIcon
})).data("content", content[k].data).addClass(disabled).appendTo("#section_" + sections[i].id + "_" + i);
}
});
}
} else if (sections[i].type == "PLAYLIST") {
if (playlists[j]) {
var thumb = playlists[j].thumbnailList;
if (windowWidth > widthLimit || isIphone || isSafari) {
thumb = thumb && thumb.square ? thumb.square : defaultThumbSquare();
thumb = thumb.replace(".webp", ".jpg");
} else {
thumb = thumb && thumb.square ? thumb.square : defaultThumbSquare();
thumb.replace(".webp", ".jpg");
}
$(homeSquareCarouselTemplateLazyLoad({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: playlists[j].title,
count: playlists[j].totalContent + (playlists[j].totalContent === 1 ? " track" : " tracks"),
sectionId: sections[i].id,
contentId: playlists[j].id,
playlistId: playlists[j].id,
playlistTitle: playlists[j].title.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
contentTitle: playlists[j].title.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
category: playlists[j].totalContent + (playlists[j].totalContent === 1 ? " track" : " tracks"),
})).data("content", playlists[j]).appendTo("#section_" + sections[i].id + "_" + i);
$("#section_" + sections[i].id + "_" + i).find(".albumToPlay").addClass("secPlaylistToPlay").removeClass("albumToPlay");
}
} else if (sections[i].type == "ARTIST") {
$.each(content, function (k, kItem) {
if (content[k].data) {
var thumb = content[k].data.thumbnailList;
if (windowWidth > widthLimit || isIphone || isSafari) {
thumb = thumb && thumb.square ? thumb.square : defaultThumbSquare();
thumb = thumb.replace(".webp", ".jpg");
} else {
thumb = thumb && thumb.mobileSquare ? thumb.mobileSquare : defaultThumbSquare();
thumb.replace(".webp", ".jpg");
}
if (content[k].data) {
$(artistCarouselTemplateLazyLoad({
title: content[k].data.title,
link: "/artist/" + (content[k].data.singerId === 0 ? content[k].data.starId : content[k].data.singerId) + "/" + content[k].data.title.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
sectionId: sections[i].id
})).data("content", content[k].data).appendTo("#section_" + sections[i].id + "_" + i);
}
}
});
} else if (sections[i].type == "ALBUM") {
$.each(content, function (k, kItem) {
if (content[k].data) {
var thumb = content[k].data.thumbnailList;
if (windowWidth > widthLimit || isIphone || isSafari) {
thumb = thumb && thumb.horizontal ? thumb.square : defaultThumb();
thumb = thumb.replace(".webp", ".jpg");
} else {
thumb = thumb && thumb.mobileHorizontal ? thumb.square : defaultThumb();
thumb.replace(".webp", ".jpg");
}
$(homeSquareCarouselTemplateLazyLoad({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: content[k].data.title,
contentId: content[k].data.id,
contentTitle: content[k].data.title.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
category: content[k].data.totalContent + (content[k].data.totalContent === 1 ? " track" : " tracks"),
playlistId: playlists[j].id,
playlistTitle: playlists[j].title.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
sectionId: sections[i].id
})).data("content", content[k].data).appendTo("#section_" + sections[i].id + "_" + i);
}
});
}
}
if (playlists[j]) {
$("#section_" + sections[i].id + "_" + i).closest("section").removeClass("hidden");
$("#section_" + sections[i].id + "_" + i).parent().find(".loader-background").hide();
}
});
}
var owl = $("#section_" + sections[i].id + "_" + i);
owl.owlCarousel({
loop: false,
margin: 10,
lazyLoad: true,
dots: true,
nav: true,
navText: [" ", " "],
pagination: false,
onInitialize: function (element) {
},
responsive: {
0: {
items: 2,
stagePadding: 30,
},
480: {
items: 3,
stagePadding: 30,
},
600: {
items: 3,
stagePadding: 70,
},
700: {
items: 3,
stagePadding: 70,
},
768: {
items: 4,
stagePadding: 70,
},
1000: {
items: 5,
stagePadding: 70,
},
1024: {
items: 5,
stagePadding: 70,
},
1200: {
items: 5,
stagePadding: 70,
},
1600: {
items: 5,
stagePadding: 70,
},
1920: {
items: 7,
stagePadding: 70,
}
}
});
});
getheight_home();
}
}).fail().always(function () {
isLoading = false;
});
}
}
function loadFooterSectionContent(page, start, end) {
var params = "page=" + page + "&sIndex=" + start + "&fIndex=" + end;
$.ajax({
type: 'POST',
url: '/api/home/footer?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null && res !== -1) {
var sections = res.respData;
$.each(sections, function (i, item) {
if (sections[i]) {
var playlists = sections[i].playLists;
$.each(playlists, function (j, jItem) {
if (playlists.length > 1) {
if (sections[i].id != 2) {
$(albumCarouselTemplate({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: playlists[j].title,
count: playlists[j].totalContent + (playlists[j].totalContent === 1 ? " track" : " tracks"),
sectionId: sections[i].id
})).data("content", playlists[j]).appendTo("#section_" + sections[i].id + "_" + i);
}
} else {
var content = playlists[j].dataList;
if (sections[i].type == "AUDIO" || sections[i].type == "VIDEO") {
{
$.each(content, function (k, kItem) {
if (content[k].data) {
var proIcon = "hidden";
if (content[k].data.isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
$(contentCarouselTemplate({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: content[k].data.contentTitle,
contentId: content[k].data.contentId,
contentTitle: content[k].data.contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
category: content[k].data.artistTitle,
sectionId: sections[i].id,
proIcon: proIcon
})).data("content", content[k].data).addClass(disabled).appendTo("#section_" + sections[i].id + "_" + i);
}
});
}
} else if (sections[i].type == "ARTIST") {
$.each(content, function (k, kItem) {
if (content[k].data) {
if (content[k].data) {
$(artistCarouselTemplate({
title: content[k].data.title,
link: "/artist/" + content[k].data.id + "/" + content[k].data.title.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
sectionId: sections[i].id
})).data("content", content[k].data).appendTo("#section_" + sections[i].id + "_" + i);
}
}
});
} else if (sections[i].type == "ALBUM") {
$.each(content, function (k, kItem) {
if (content[k].data) {
$(albumSquareCarouselTemplate({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: content[k].data.title,
contentId: content[k].data.id,
contentTitle: content[k].data.title.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
category: content[k].data.totalContent + (content[k].data.totalContent === 1 ? " track" : " tracks"),
sectionId: sections[i].id
})).data("content", content[k].data).appendTo("#section_" + sections[i].id + "_" + i);
}
});
} else {
$.each(content, function (k, kItem) {
if (content[k].data) {
$(albumCarouselTemplate({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: content[k].data.title,
count: content[k].data.totalContent + (content[k].data.totalContent === 1 ? " track" : " tracks"),
sectionId: sections[i].id
})).data("content", content[k].data).appendTo("#section_" + sections[i].id + "_" + i);
}
});
}
if (content.length > 0) {
$("#section_" + sections[i].id + "_" + i).closest("section").removeClass("hidden");
$("#section_" + sections[i].id + "_" + i).parent().find(".loader-background").hide();
}
}
});
}
});
getheight_home();
}
}).fail().always(function () {
isLoading = false;
});
}
function loadSectionContent(id, type, page, url) {
if (id == 2 && smallBanners) {
var data = smallBanners;
$.each(data, function (i, item) {
if (data[i]) {
var thumb = data[i].playlistThumbnailList;
if (windowWidth > widthLimit) {
thumb = thumb && thumb.horizontal ? thumb.horizontal : data[i].playlistImage;
} else {
thumb = thumb && thumb.mobileHorizontal ? thumb.mobileHorizontal : data[i].playlistImage;
}
$(smallBannersTemplate({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
})).data("content", data[i]).appendTo("#allproduct-sh-main");
}
});
$("#allproduct-sh-main").owlCarousel({
loop: true,
margin: 10,
// autoplayTimeout: 3000,
autoplay: false,
dots: false,
stagePadding: 90,
nav: false,
navText: [" ", " "],
pagination: false,
onInitialize: function (element) {
$("#allproduct-sh-main").children().sort(function () {
return Math.round(Math.random()) - 0.5;
}).each(function () {
$(this).appendTo($("#allproduct-sh-main"));
});
},
responsive: {
0: {
items: 2,
stagePadding: 25,
margin: 2,
},
480: {
items: 2,
stagePadding: 25,
margin: 2,
},
600: {
items: 2,
stagePadding: 80,
},
700: {
items: 2,
stagePadding: 80,
},
768: {
items: 2,
stagePadding: 50,
},
1000: {
items: 3,
stagePadding: 50,
},
1024: {
items: 3,
stagePadding: 30,
},
1200: {
items: 3,
stagePadding: 70,
},
1600: {
items: 3,
stagePadding: 150,
},
1920: {
items: 3,
stagePadding: 150,
},
}
});
try {
$(".allproduct-sh-main-loader").remove();
} catch (er) {
}
} else {
var params = "id=" + id + "&contentType=" + type + "&secType=" + page + "&url=";
$.ajax({
type: 'POST',
url: '/api/home/contentBySections?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null && res !== -1) {
$("#section_" + id).parent().find(".loader-background").hide();
if (page === "RADIO") {
var data = res.respData;
// if (data[0] && data[0].playlistName && data[0].playlistName.indexOf('Artists') > 0) {
// $.each(data, function (i, item) {
// var thumb = data[i].respData.thumbnailList;
// if (data[i].respData) {
// $(artistCarouselTemplate({
// title: data[i].respData.title,
// thumb: thumb && thumb.square ? thumb.square : "",
// thumbWebp: thumb && thumb.square ? thumb.square.replace(".jpg", ".webp") : "",
// sectionId: id
// })).data("content", data[i]).appendTo("#section_" + id);
// }
// });
// } else {
$.each(data, function (i, item) {
if (data[i]) {
$(albumCarouselTemplate({
thumb: data[i].thumbnailList.square.replace(".webp", ".jpg"),
thumbWebp: data[i].thumbnailList.square.replace(".jpg", ".webp"),
title: data[i].title,
count: data[i].totalContent + (data[i].totalContent === 1 ? " track" : " tracks"),
sectionId: id
})).data("content", data[i]).appendTo("#section_" + id);
$("#section_" + id).find(".albumToPlay").addClass("playlistToPlay").removeClass("albumToPlay");
}
});
// }
} else {
if (type === 'ALBUM') {
var data = res.respData[0].dataList;
if (data && data.length) {
$.each(data, function (i, item) {
if (data[i].data) {
$(albumCarouselTemplate({
thumb: data[i].data.thumbnailList ? data[i].data.thumbnailList.square.replace(".webp", ".jpg") : "",
thumbWebp: data[i].data.thumbnailList ? data[i].data.thumbnailList.square.replace(".jpg", ".webp") : "",
title: data[i].data.title,
count: data[i].data.totalContent + (data[i].data.totalContent === 1 ? " track" : " tracks"),
sectionId: id
})).data("content", data[i].data).appendTo("#section_" + id);
}
});
} else {
$("#section_" + id).closest("section").hide();
}
} else if (type === 'ARTIST') {
var data = res.respData[0].dataList;
if (data && data.length) {
$.each(data, function (i, item) {
var thumb = data[i].data.thumbnailList;
if (data[i].data) {
$(artistCarouselTemplate({
title: data[i].data.title,
link: "/artist/" + data[i].data.id + "/" + data[i].data.title.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
thumb: thumb && thumb.square ? thumb.square.replace(".webp", ".jpg") : "",
thumbWebp: thumb && thumb.square ? thumb.square.replace(".jpg", ".webp") : "",
sectionId: id
})).data("content", data[i].data).appendTo("#section_" + id);
}
});
} else {
$("#section_" + id).closest("section").hide();
}
} else if (type == 'PLAYLIST') {
var data = res.respData;
if (data && data.length) {
if (id == 2) {
if (data.length > 0) {
smallBanners = data;
}
$.each(data, function (i, item) {
if (data) {
var thumb = data[i].thumbnailList;
if (windowWidth > widthLimit) {
thumb = thumb && thumb.horizontal ? thumb.horizontal : data[i].playlistImage;
} else {
thumb = thumb && thumb.mobileHorizontal ? thumb.mobileHorizontal : data[i].playlistImage;
}
$(smallBannersTemplate({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp")
})).data("content", data[i]).appendTo("#allproduct-sh-main");
}
});
} else {
$.each(data, function (i, item) {
var count = data[i].totalContent + (data[i].totalContent === 1 ? " track" : " tracks");
var thumb = data[i].thumbnailList;
if (windowWidth > widthLimit) {
thumb = thumb && thumb.horizontal ? thumb.horizontal : data[i].playlistImage;
} else {
thumb = thumb && thumb.mobileHorizontal ? thumb.mobileHorizontal : data[i].playlistImage;
}
$(albumCarouselTemplate({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: data[i].title,
count: count,
sectionId: id,
progressWidth: ""
})).data("content", data[i]).appendTo("#section_" + id);
$("#section_" + id).find(".albumToPlay").addClass("playlistToPlay").removeClass("albumToPlay");
});
}
} else {
$("#section_" + id).closest("section").hide();
}
} else {
var data = res.respData[0].dataList;
if (data && data.length) {
if (id == 53) {
var dynamicId = 0;
$.each(data, function (i, item) {
if (i % 2 == 0) {
dynamicId++;
$("#section_" + id).append("
");
}
if (data[i].data) {
var count = data[i].data.albumTitle;
var progressWidth = "";
// if (res.data[0] && res.data[0].playlistId === 44) {
// progressWidth = (data[i].data.durationListened * 100) / data[i].data.duration;
// }
var thumb = data[i].data.thumbnailList;
if (windowWidth > widthLimit) {
thumb = thumb && thumb.horizontal ? thumb.horizontal : defaultThumb();
} else {
thumb = thumb && thumb.mobileHorizontal ? thumb.mobileHorizontal : defaultThumb();
}
var disabled = "";
if (data[i].data.contentId == 0) {
disabled = "disabled-div";
}
var proIcon = "hidden";
if (data[i].data.isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
$(contentCarouselTemplate({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: data[i].data.contentTitle,
category: count,
contentId: data[i].data.contentId,
contentTitle: data[i].data.contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
sectionId: id,
proIcon: proIcon,
progressWidth: progressWidth + "%"
})).data("content", data[i].data).addClass(disabled).appendTo("#double_" + id + "_" + dynamicId);
}
});
} else {
$.each(data, function (i, item) {
if (data[i].data) {
var count = data[i].data.albumTitle;
var progressWidth = "";
// if (res.data[0] && res.data[0].playlistId === 44) {
// progressWidth = (data[i].data.durationListened * 100) / data[i].data.duration;
// }
var thumb = data[i].data.thumbnailList;
if (windowWidth > widthLimit) {
thumb = thumb && thumb.horizontal ? thumb.horizontal : defaultThumb();
} else {
thumb = thumb && thumb.mobileHorizontal ? thumb.mobileHorizontal : defaultThumb();
}
var disabled = "";
if (data[i].data.contentId == 0) {
disabled = "disabled-div";
}
var proIcon = "hidden";
if (data[i].data.isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
$(contentCarouselTemplate({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: data[i].data.contentTitle,
contentId: data[i].data.contentId,
contentTitle: data[i].data.contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
category: count,
sectionId: id,
proIcon: proIcon,
progressWidth: progressWidth + "%"
})).data("content", data[i].data).addClass(disabled).appendTo("#section_" + id);
}
});
}
} else {
$("#section_" + id).closest("section").hide();
}
// if (res.data[0] && res.data[0].playlistId === 44) {
// $("#section_" + id + " .comple-profile-progress").removeClass("hidden");
// }
}
}
// preloadImages(imgArray);
if (type == 'ARTIST') {
$(".sec_" + id).removeClass("hidden");
$("#section_" + id).owlCarousel({
loop: false,
margin: 10,
dots: true,
nav: true,
navText: [" ", " "],
pagination: false,
responsive: {
0: {
items: 3,
stagePadding: 25,
},
480: {
items: 3,
stagePadding: 25,
},
600: {
items: 4,
stagePadding: 30,
},
700: {
items: 4,
stagePadding: 30,
},
768: {
items: 4,
stagePadding: 30,
},
1000: {
items: 5,
stagePadding: 30,
},
1024: {
items: 5,
stagePadding: 30,
},
1200: {
items: 6,
stagePadding: 50,
},
1600: {
items: 6,
stagePadding: 50,
},
1920: {
items: 7,
stagePadding: 50,
}
}
});
} else if (type == 'ALBUM' || page == "RADIO") {
$(".sec_" + id).removeClass("hidden");
$("#section_" + id).owlCarousel({
loop: false,
margin: 10,
dots: true,
nav: true,
navText: [" ", " "],
pagination: false,
responsive: {
0: {
items: 2,
stagePadding: 70,
},
480: {
items: 3,
stagePadding: 20,
},
600: {
items: 4,
stagePadding: 70,
},
700: {
items: 4,
stagePadding: 70,
},
768: {
items: 4,
stagePadding: 70,
},
1000: {
items: 5,
stagePadding: 70,
},
1024: {
items: 5,
stagePadding: 70,
},
1200: {
items: 6,
stagePadding: 70,
},
1600: {
items: 7,
stagePadding: 70,
},
1920: {
items: 7,
stagePadding: 70,
}
}
});
} else if (id == 2) {
$("#allproduct-sh-main").owlCarousel({
loop: true,
margin: 10,
// autoplayTimeout: 3000,
autoplay: false,
dots: false,
stagePadding: 90,
nav: false,
navText: [" ", " "],
pagination: false,
onInitialize: function (element) {
$("#allproduct-sh-main").children().sort(function () {
return Math.round(Math.random()) - 0.5;
}).each(function () {
$(this).appendTo($("#allproduct-sh-main"));
});
},
responsive: {
0: {
items: 2,
stagePadding: 25,
margin: 2,
},
480: {
items: 2,
stagePadding: 25,
margin: 2,
},
600: {
items: 2,
stagePadding: 80,
},
700: {
items: 2,
stagePadding: 80,
},
768: {
items: 2,
stagePadding: 50,
},
1000: {
items: 3,
stagePadding: 50,
},
1024: {
items: 3,
stagePadding: 30,
},
1200: {
items: 3,
stagePadding: 70,
},
1600: {
items: 3,
stagePadding: 150,
},
1920: {
items: 3,
stagePadding: 150,
},
}
});
try {
$(".allproduct-sh-main-loader").remove();
} catch (er) {
}
} else if (id == 53) {
$(".sec_" + id).removeClass("hidden");
$("#section_" + id).owlCarousel({
loop: false,
margin: 5,
dots: true,
nav: true,
navText: [" ", " "],
pagination: false,
responsive: {
0: {
items: 2,
stagePadding: 50,
},
480: {
items: 2,
stagePadding: 25,
},
600: {
items: 4,
stagePadding: 25,
},
700: {
items: 3,
stagePadding: 70,
},
768: {
items: 4,
stagePadding: 40,
},
1000: {
items: 4,
stagePadding: 70,
},
1024: {
items: 4,
stagePadding: 70,
},
1280: {
items: 4,
stagePadding: 70,
},
1600: {
items: 5,
stagePadding: 70,
},
1920: {
items: 6,
stagePadding: 70,
}
}
});
} else {
$(".sec_" + id).removeClass("hidden");
$("#section_" + id).owlCarousel({
loop: false,
margin: 10,
dots: true,
nav: true,
navText: [" ", " "],
pagination: false,
responsive: {
0: {
items: 2,
stagePadding: 30,
},
480: {
items: 2,
stagePadding: 25,
},
600: {
items: 4,
stagePadding: 25,
},
700: {
items: 4,
stagePadding: 70,
},
768: {
items: 3,
stagePadding: 40,
},
1000: {
items: 4,
stagePadding: 70,
},
1024: {
items: 4,
stagePadding: 70,
},
1200: {
items: 4,
stagePadding: 70,
},
1600: {
items: 5,
stagePadding: 70,
},
1920: {
items: 5,
stagePadding: 70,
}
}
});
}
} else {
$("#section_" + id).closest("section").hide();
}
}).fail(function (response) {
$("#section_" + id).closest("section").hide();
Noty.closeAll();
});
}
}
window.fbAsyncInit = function () {
//rocktest88@gmail.com
FB.init({
appId: '542598529405995',
status: true,
xfbml: true,
cookie: true
// version: 'v2.10'
});
// FB.AppEvents.logPageView();
};
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {
return;
}
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function categorySelected(categoryId, genreId, that) {
if ($(that)) {
$(that).parent().toggleClass("active");
}
if (categoryId in mainCategoriesAdded) {
var genresInMainCategories = mainCategoriesAdded[categoryId];
if (genresInMainCategories.indexOf(genreId) > -1) {
genresInMainCategories = genresInMainCategories.replace(genreId + ",", "");
} else {
genresInMainCategories = genresInMainCategories + genreId + ",";
}
mainCategoriesAdded[categoryId] = genresInMainCategories;
} else {
mainCategoriesAdded[categoryId] = categoryId + "=" + genreId + ",";
}
}
function getJazzSuccessNoty() {
$.ajax({
type: 'POST',
url: '/api/getJazzSuccessNoty',
dataType: "JSON"
}).done(function (res) {
if (res.respCode === "00") {
const myArray = res.msg.split("=");
if (myArray[0] === '00') {
displaySuccessNoty('' + myArray[1], false, 1500);
const urlParams = new URLSearchParams(window.location.search);
const cmpjc = urlParams.get('cmpjc');
if (cmpjc !== '' && cmpjc === '1') {
const sId = urlParams.get('siteId');
const msisdn = urlParams.get('x-jc-msisdn');
try {
firebaseObj.analytics()
.logEvent("Jazzcash_Paid_Now", {
siteId: sId,
msisdn: msisdn,
status: "success",
description: myArray[1]
});
} catch (er) {
}
try {
ttq.track('JazzCash_Monthly_subscription', {// string. Non-hashed public IP address of the browser.
"value": "1", // number. Value of the order or items sold. Example: 100.
"currency": "PKR", // string. The 4217 currency code. Example: "USD".
"contents": [
{
"site_id": sId, // string. ID of the product. Example: "1077218".
"msisdn": msisdn, // string. Either product or product_group.
"status": "success",
"description": myArray[1] // string. The name of the page or product. Example: "shirt".
}
]
})
} catch (er) {
}
}
} else {
displayErrorNoty('' + myArray[1], false, 1500);
const urlParams = new URLSearchParams(window.location.search);
const cmpjc = urlParams.get('cmpjc');
if (cmpjc !== '' && cmpjc === '1') {
const sId = urlParams.get('siteId');
const msisdn = urlParams.get('x-jc-msisdn');
try {
firebaseObj.analytics()
.logEvent("Pay_Now", {
siteId: sId,
msisdn: msisdn,
status: "failed",
description: myArray[1]
});
} catch (er) {
// console.log(er);
}
try {
ttq.track('JazzCash_Monthly_subscription_failed', {// string. Non-hashed public IP address of the browser.
"value": "1", // number. Value of the order or items sold. Example: 100.
"currency": "PKR", // string. The 4217 currency code. Example: "USD".
"contents": [
{
"site_id": sId, // string. ID of the product. Example: "1077218".
"msisdn": msisdn, // string. Either product or product_group.
"status": "failed",
"description": myArray[1] // string. The name of the page or product. Example: "shirt".
}
]
})
} catch (er) {
}
}
}
}
}).fail().always(function () {
// console.log("error")
});
}
function loadSimilarAudioContent(id, type) {
if (!userProfile) {
getUserProfile();
}
//// $(".loader-generic").show();
var params = "cId=" + id + "&cType=" + type + "&sIndex=0" + "&fIndex=7";
$.ajax({
type: 'POST',
url: '/api/content/similar?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res.respCode === "00" && res.respData !== null) {
$(".footer-player #similar-album h5").html("Similar Songs");
var data = res.respData;
if ((data && data.length < 7)) {
$("#moretd").parent().hide();
}
$("#content-table-sim").html("");
$.each(data, function (i, item) {
if (data[i]) {
var videoIcon;
if (data[i].videoId == 0) {
videoIcon = "hidden";
} else {
videoIcon = "videoToPlay";
}
var likedContent = userProfile.likedContentIdsMap;
var isIdPresent = likedContent ? likedContent[data[i].contentId] : false;
var thumb = data[i].thumbnailList.square ? data[i].thumbnailList.square : data[i].thumbnailList.square;
if (data.length == 1) {
$("#contentTale").addClass("show_overflow");
}
var proIcon = "hidden";
if (data[i].isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
if (isIdPresent) {
isContentLiked = true;
$(contentTableTemplateLiked({
artsitTitle: data[i].artistTitle,
contentThumb: thumb,
id: data[i].contentId,
proIcon: proIcon,
thumbWebp: thumb.replace(".jpg", ".webp"),
contentFile: "",
videoIcon: videoIcon,
albumTitle: data[i].albumTitle,
released: getReleasedYear(data[i].releasedDate),
isPlaying: "",
duration: secondsTimeSpanToHMS(data[i].duration),
contentTitle: data[i].contentTitle,
link: "/song/" + data[i].contentId + "/" + data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
contextMenuUp: (data.length === (i + 1)) ? "contentMenuUp" : ""
})).data("content", data[i]).appendTo("#content-table-sim");
$(".player_" + data[i].contentId).addClass("active").addClass("liked");
} else {
isContentLiked = false;
$(contentTableTemplate({
artsitTitle: data[i].artistTitle,
contentThumb: thumb,
proIcon: proIcon,
id: data[i].contentId,
thumbWebp: thumb.replace(".jpg", ".webp"),
contentFile: "",
videoIcon: videoIcon,
albumTitle: data[i].albumTitle,
released: getReleasedYear(data[i].releasedDate),
isPlaying: "",
duration: secondsTimeSpanToHMS(data[i].duration),
contentTitle: data[i].contentTitle,
link: "/song/" + data[i].contentId + "/" + data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
contextMenuUp: (data.length === (i + 1)) ? "contentMenuUp" : ""
})).data("content", data[i]).appendTo("#content-table-sim");
}
}
});
$("#content-table-sim").append(" ");
$(".loader-generic").hide();
} else {
loadTrendingSimilarEmpty(id, type);
$("#content-table-sim").html("No similar content.
");
$(".loader-generic").hide();
}
}).fail(function (response) {
loadTrendingSimilarEmpty(id, type);
$("#similar-album").hide();
$(".loader-generic").hide();
Noty.closeAll();
// displayErrorNoty("Internal server error.", false, 1500);
});
// }
}
function loadTopPlaylists() {
$.ajax({
type: 'POST',
url: '/api/section/userSections?siteid=' + getParameterByName("siteid"),
dataType: "JSON"
}).done(function (res) {
if (res.respCode === "00" && res.respData.playLists !== null) {
var data = res.respData.playLists;
$.each(data, function (i, item) {
if (data[i]) {
var thumb = data[i].thumbnailList.square ? data[i].thumbnailList.square : data[i].thumbnailList.square;
$(topPlaylistsTemplate({
title: data[i].title,
thumb: thumb,
sectionId: res.respData.id
})).data("content", data[i]).appendTo("#top-playlists");
}
});
$("#top-playlists").owlCarousel({
loop: false,
margin: 23,
dots: false,
nav: false,
pagination: false,
responsive: {
0: {
items: 2,
margin: 18,
},
480: {
items: 2,
margin: 18,
},
600: {
items: 2,
margin: 18,
},
700: {
items: 2,
margin: 18,
},
768: {
items: 3,
stagePadding: 50,
},
1000: {
items: 5,
stagePadding: 50,
},
1024: {
items: 4,
stagePadding: 50,
},
1200: {
items: 5,
stagePadding: 50,
},
1600: {
items: 6,
stagePadding: 50,
},
1920: {
items: 7,
stagePadding: 50,
}
}
});
}
}).fail(function (response) {
});
// }
}
function loadTrendingSimilarEmpty(id, type) {
if (!userProfile) {
getUserProfile();
}
//// $(".loader-generic").show();
var params = "cId=" + id + "&cType=" + type + "&sIndex=0" + "&fIndex=7";
$.ajax({
type: 'POST',
url: '/api/content/trending?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res.respCode === "00" && res.respData !== null) {
$(".footer-player #similar-album h5").html("Trending Songs");
var data = res.respData;
if ((data && data.length < 7)) {
$("#moretd").parent().hide();
}
$("#content-table-sim").html("");
$.each(data, function (i, item) {
if (data[i]) {
var videoIcon;
if (data[i].videoId == 0) {
videoIcon = "hidden";
} else {
videoIcon = "videoToPlay";
}
var likedContent = userProfile.likedContentIdsMap;
var isIdPresent = likedContent ? likedContent[data[i].contentId] : false;
var thumb = data[i].thumbnailList.square ? data[i].thumbnailList.square : data[i].thumbnailList.square;
if (data.length == 1) {
$("#contentTale").addClass("show_overflow");
}
var proIcon = "hidden";
if (data[i].isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
if (isIdPresent) {
isContentLiked = true;
$(contentTableTemplateLiked({
artsitTitle: data[i].artistTitle,
contentThumb: thumb,
id: data[i].contentId,
thumbWebp: thumb.replace(".jpg", ".webp"),
contentFile: "",
proIcon: proIcon,
videoIcon: videoIcon,
albumTitle: data[i].albumTitle,
released: getReleasedYear(data[i].releasedDate),
isPlaying: "",
duration: secondsTimeSpanToHMS(data[i].duration),
contentTitle: data[i].contentTitle,
link: "/song/" + data[i].contentId + "/" + data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
contextMenuUp: (data.length === (i + 1)) ? "contentMenuUp" : ""
})).data("content", data[i]).appendTo("#content-table-sim");
$(".player_" + data[i].contentId).addClass("active").addClass("liked");
} else {
isContentLiked = false;
$(contentTableTemplate({
artsitTitle: data[i].artistTitle,
contentThumb: thumb,
id: data[i].contentId,
proIcon: proIcon,
thumbWebp: thumb.replace(".jpg", ".webp"),
contentFile: "",
videoIcon: videoIcon,
albumTitle: data[i].albumTitle,
released: getReleasedYear(data[i].releasedDate),
isPlaying: "",
duration: secondsTimeSpanToHMS(data[i].duration),
contentTitle: data[i].contentTitle,
link: "/song/" + data[i].contentId + "/" + data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
contextMenuUp: (data.length === (i + 1)) ? "contentMenuUp" : ""
})).data("content", data[i]).appendTo("#content-table-sim");
}
}
});
$("#content-table-sim").append(" ");
$(".loader-generic").hide();
} else {
$("#content-table-sim").html("No similar content.
");
$(".loader-generic").hide();
}
}).fail(function (response) {
$("#similar-album").hide();
$(".loader-generic").hide();
Noty.closeAll();
// displayErrorNoty("Internal server error.", false, 1500);
});
// }
}
function loadPlayedContent() {
if (!isMobile && $("#sideRecentContent") && $("#sideRecentContent").html().trim() == "") {
$("#sideMoreContentLoader").removeClass("hidden").addClass("visible-lg");
//// $(".loader-generic").show();
var params = "secType=RECENTLYPLAYED";
$.ajax({
type: 'POST',
url: '/api/user/recentPlayed?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
var data = res.respData.dataList;
$.each(data, function (i, item) {
if (data[i]) {
var count = data[i].data.totalContent + (data[i].data.totalContent === 1 ? " track" : " tracks");
if (data[i].data.contentType === "FULLTRACK") {
var proIcon = "hidden";
if (data[i].data.isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
$(sideRecomContentTemplate({
sideId: "cnt-" + data[i].data.contentId,
contentThumb: data[i].data.thumbnailList.square,
thumbWebp: data[i].data.thumbnailList.square.replace(".jpg", ".webp"),
contentTitle: data[i].data.contentTitle,
link: "/song/" + data[i].data.contentId + "/" + data[i].data.contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
streamCount: data[i].data.streamCount + " plays",
proIcon: proIcon
// streamCount: data[i].data.artistTitle.replace("_", " ")
})).data("content", data[i].data).appendTo("#sideRecentContent");
}
}
});
$(".footer-player").addClass("player-width");
setTimeout(function () {
$(".sideRecentContent").mCustomScrollbar();
}, 200);
$(".loader-generic").hide();
$("#sideMoreContent").removeClass("hidden").addClass("visible-lg");
$("#sideMoreContentLoader").remove();
$("footer").addClass("col-sm-12 col-md-12 col-lg-9");
} else {
// $(".sideRecentContent").hide();
loadFreeContent(9);
$(".loader-generic").hide();
}
}).fail(function (response) {
// $(".sideRecentContent").hide();
loadFreeContent(9);
$(".loader-generic").hide();
});
} else {
////allways refresh recently played
if (!isMobile) {
var params = "secType=RECENTLYPLAYED";
$.ajax({
type: 'POST',
url: '/api/user/recentPlayed?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
var data = res.respData.dataList;
$("#sideRecentContent .mCSB_container li").remove();
$.each(data, function (i, item) {
if (data[i]) {
var count = data[i].data.totalContent + (data[i].data.totalContent === 1 ? " track" : " tracks");
if (data[i].data.contentType === "FULLTRACK") {
var proIcon = "hidden";
if (data[i].data.isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
$(sideRecomContentTemplate({
sideId: "cnt-" + data[i].data.contentId,
contentThumb: data[i].data.thumbnailList.square,
thumbWebp: data[i].data.thumbnailList.square.replace(".jpg", ".webp"),
contentTitle: data[i].data.contentTitle,
link: "/song/" + data[i].data.contentId + "/" + data[i].data.contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
streamCount: data[i].data.streamCount + " plays",
proIcon: proIcon
// streamCount: data[i].data.artistTitle.replace("_", " ")
})).data("content", data[i].data).appendTo("#sideRecentContent .mCSB_container");
}
}
});
$(".loader-generic").hide();
$("#sideMoreContent").removeClass("hidden").addClass("visible-lg");
$("#sideMoreContentLoader").remove();
$("footer").addClass("col-sm-12 col-md-12 col-lg-9");
}
}).fail(function (response) {
});
}
}
}
function loadSectionAllContent(id, start, end) {
// $(".loader-generic").show();
isLoading = true;
var params = "id=" + id + "&contentType=AUDIO&secType=home&url=&sIndex=" + start + "&fIndex=" + end;
$.ajax({
type: 'POST',
url: '/api/home/contentBySections?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
isLoading = false;
if (res && res.respData !== null) {
$("#m-title").html(res.respData[0].title);
var data = res.respData[0].dataList;
$.each(data, function (i, item) {
if (data[i]) {
var thumb = data[i].data.thumbnailList ? data[i].data.thumbnailList.square : data[i].data.thumbnailList.square;
var disabled = "";
if (data[i].data.contentId == 0) {
disabled = "disabled-div";
}
var proIcon = "hidden";
if (data[i].data.isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
$(simContentCarouselTemplate({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb ? thumb.replace(".jpg", ".webp") : "",
title: data[i].data.contentTitle,
released: getReleasedYear(data[i].data.releasedDate),
sectionId: "",
contentId: data[i].data.contentId,
contentTitle: data[i].data.contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
likeId: "like" + data[i].data.contentId,
album: data[i].data.albumTitle,
artist: data[i].data.artistTitle,
proIcon: proIcon
})).data("content", data[i].data).addClass(disabled).appendTo("#simVideos");
}
});
$(".playSimContent").addClass("contentToPlay").removeClass("playSimContent");
$(".loader-generic").hide();
} else {
serverError++;
$(".loader-generic").hide();
}
}).fail(function (response) {
isLoading = false;
$(".loader-generic").hide();
// displayErrorNoty("Internal server error.", false, 1500);
});
}
function loadRegionalAllContent(id, start, end) {
// $(".loader-generic").show();
isLoading = true;
var params = "subCat=" + id + "&sIndex=" + start + "&fIndex=" + end;
$.ajax({
type: 'POST',
url: '/api/regional/content?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
isLoading = false;
if (res && res.respData !== null) {
$("#m-title").html(getPathVariableByIndex(3));
var data = res.respData;
$.each(data, function (i, item) {
if (data[i]) {
var thumb = data[i].thumbnailList ? data[i].thumbnailList.square : data[i].thumbnailList.square;
var disabled = "";
if (data[i].contentId == 0) {
disabled = "disabled-div";
}
var proIcon = "hidden";
if (data[i].isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
$(simContentCarouselTemplate({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb ? thumb.replace(".jpg", ".webp") : "",
title: data[i].contentTitle,
released: getReleasedYear(data[i].releasedDate),
sectionId: "",
contentId: data[i].contentId,
contentTitle: data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
likeId: "like" + data[i].contentId,
album: data[i].albumTitle,
artist: data[i].artistTitle,
proIcon: proIcon
})).data("content", data[i]).addClass(disabled).appendTo("#simVideos");
}
});
$(".playSimContent").addClass("contentToPlay").removeClass("playSimContent");
$(".loader-generic").hide();
} else {
serverError++;
$(".loader-generic").hide();
}
}).fail(function (response) {
isLoading = false;
$(".loader-generic").hide();
// displayErrorNoty("Internal server error.", false, 1500);
});
}
function loadRegionalAllSubCategoryContent(id, start, end) {
// $(".loader-generic").show();
isLoading = true;
var params = "subCat=" + id + "&sIndex=" + start + "&fIndex=" + end;
$.ajax({
type: 'POST',
url: '/api/regional/subCatContent?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
isLoading = false;
if (res && res.respData !== null) {
$("#m-title").html(getPathVariableByIndex(3));
var data = res.respData;
$.each(data, function (i, item) {
if (data[i]) {
var thumb = data[i].thumbnailList ? data[i].thumbnailList.square : data[i].thumbnailList.square;
var disabled = "";
if (data[i].contentId == 0) {
disabled = "disabled-div";
}
var proIcon = "hidden";
if (data[i].isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
$(simContentCarouselTemplate({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb ? thumb.replace(".jpg", ".webp") : "",
title: data[i].contentTitle,
released: getReleasedYear(data[i].releasedDate),
sectionId: "",
contentId: data[i].contentId,
contentTitle: data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
likeId: "like" + data[i].contentId,
album: data[i].albumTitle,
artist: data[i].artistTitle,
proIcon: proIcon
})).data("content", data[i]).addClass(disabled).appendTo("#simVideos");
}
});
$(".playSimContent").addClass("contentToPlay").removeClass("playSimContent");
$(".loader-generic").hide();
} else {
serverError++;
$(".loader-generic").hide();
}
}).fail(function (response) {
isLoading = false;
$(".loader-generic").hide();
// displayErrorNoty("Internal server error.", false, 1500);
});
}
function loadAllArtists(start, end) {
// $(".loader-generic").show();
isLoading = true;
var params = "sIndex=" + start + "&fIndex=" + end;
$.ajax({
type: 'POST',
url: '/api/artist/all?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
isLoading = false;
if (res && res.respData !== null) {
$("#m-title").html("Artists");
var data = res.respData;
$.each(data, function (i, item) {
if (data[i]) {
var thumb = data[i].thumbnailList ? data[i].thumbnailList.square : defaultThumbSquare();
var disabled = "";
if (data[i].id == 0) {
disabled = "disabled-div";
}
$(allArtistContentCarouselTemplate({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: data[i].title,
released: "",
type: "artist",
sectionId: "",
contentId: data[i].id,
contentTitle: data[i].title.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
album: data[i].artistType,
artist: data[i].totalContent + (data[i].totalContent === 1 ? " track" : " tracks")
})).data("content", data[i]).addClass(disabled).appendTo("#simVideos");
}
});
$(".playSimContent").addClass("artistToPlay").removeClass("playSimContent");
$(".loader-generic").hide();
} else {
serverError++;
$(".loader-generic").hide();
}
}).fail(function (response) {
isLoading = false;
$(".loader-generic").hide();
// displayErrorNoty("Internal server error.", false, 1500);
});
}
function loadFreeContent(id) {
if (!isMobile && $("#sideRecentContent") && $("#sideRecentContent").html().trim() == "") {
//// $(".loader-generic").show();
var params = "id=" + id + "&contentType=AUDIO&secType=home&url=";
$.ajax({
type: 'POST',
url: '/api/home/contentBySections?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
$("#sideRecentHeading").html("Free Streaming");
var data = res.respData[0].dataList;
$.each(data, function (i, item) {
if (data[i]) {
var count = data[i].data.totalContent + (data[i].data.totalContent === 1 ? " track" : " tracks");
if (data[i].data.contentType === "FULLTRACK") {
var proIcon = "hidden";
if (data[i].data.isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
$(sideRecomContentTemplate({
sideId: "cnt-" + data[i].data.contentId,
contentThumb: data[i].data.thumbnailList.square,
thumbWebp: data[i].data.thumbnailList.square.replace(".jpg", ".webp"),
contentTitle: data[i].data.contentTitle,
link: "/song/" + data[i].data.contentId + "/" + data[i].data.contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
streamCount: data[i].data.streamCount + " plays",
proIcon: proIcon
// streamCount: data[i].data.artistTitle.replace("_", " ")
})).data("content", data[i].data).appendTo("#sideRecentContent");
}
}
});
$(".footer-player").addClass("player-width");
setTimeout(function () {
$(".sideRecentContent").mCustomScrollbar();
}, 200);
$(".loader-generic").hide();
$("#sideMoreContent").removeClass("hidden").addClass("visible-lg");
$("#sideMoreContentLoader").remove();
$("footer").addClass("col-sm-12 col-md-12 col-lg-9");
} else {
$(".sideRecentContent").hide();
$(".loader-generic").hide();
}
}).fail(function (response) {
$(".sideRecentContent").hide();
$(".loader-generic").hide();
});
} else {
$("#sideMoreContent").removeClass("hidden").addClass("visible-lg");
$("#sideMoreContentLoader").remove();
$("footer").addClass("col-sm-12 col-md-12 col-lg-9");
}
}
function loadUserPlayList() {
// $(".loader-generic").show();
$.ajax({
type: 'POST',
url: '/api/user/playlist?siteid=' + getParameterByName("siteid"),
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
var data = res.respData;
$(".userplaylists").html("");
if ($(".userplaylists").html().trim() === "") {
$.each(data, function (i, item) {
if (data[i]) {
var thumb = data[i].thumbnail ? data[i].thumbnail : defaultThumbSquare();
$(userPlaylistTemplate({
name: data[i].name,
thumb: thumb.replace(".webp", ".jpg"),
count: data[i].contentCount,
plId: data[i].id
})).data("content", data[i]).appendTo(".userplaylists");
}
});
}
$(".loader-generic").hide();
} else {
$(".loader-generic").hide();
if ($(".title-user") && $(".title-user").html().trim() === "LOGIN") {
showLoginMenu();
// window.location = window.location.pathname.substring(0, window.location.pathname.indexOf("/", 2)) + "/login";
}
}
}).fail(function (response) {
$(".loader-generic").hide();
});
}
function createUserPlayList(title) {
// $(".loader-generic").show();
var params = "title=" + title;
$.ajax({
type: 'POST',
data: params,
url: '/api/createPlaylist?siteid=' + getParameterByName("siteid"),
dataType: "JSON"
}).done(function (res) {
if (res && res.isSuccess) {
displaySuccessNoty('' + res.msg.replace(/\./g, ' '), false, 1500);
$("#createmylist").modal("hide");
/**
* Trigger Create Playlist clevertap event
*/
// try {
//
// clevertap.event.push("Create Playlist", {
// "Playlist Name": title,
// "Platform": "WEB"
// });
// } catch (er) {
// console.log("Error logging clevertap events" + er);
// }
/**
* end trigger
*/
if (openAddToPlaylist) {
loadUserPlayList();
$("#alreadyaddlist").modal("show");
openAddToPlaylist = false;
} else {
loadPlayListSection();
}
} else if (res && !res.isSuccess) {
$("#createmylist").modal("hide");
displayErrorNoty('' + res.msg.replace(/\./g, ' '), false, 1500);
} else {
// displayErrorNoty("Internal server error.", false, 1500);
}
$(".loader-generic").hide();
}).fail(function (response) {
$(".loader-generic").hide();
});
}
function updateUserPlayList(id, title) {
// $(".loader-generic").show();
var params = "title=" + title + "&id=" + id;
$.ajax({
type: 'POST',
data: params,
url: '/api/updatePlaylist?siteid=' + getParameterByName("siteid"),
dataType: "JSON"
}).done(function (res) {
if (res && res.isSuccess) {
displaySuccessNoty('' + res.msg.replace(/\./g, ' '), false, 1500);
$('#pl_' + id).html(title);
// loadPlayListSection();
} else {
displayErrorNoty('' + res.msg.replace(/\./g, ' '), false, 1500);
}
$(".loader-generic").hide();
}).fail(function (response) {
displayErrorNoty('Please check your internet connection.', false, 1500);
$(".loader-generic").hide();
});
}
function removeUserPlayListContent(id, contentId, that) {
// $(".loader-generic").show();
var params = "id=" + id + "&contentId=" + contentId;
$.ajax({
type: 'POST',
data: params,
url: '/api/removePlaylistContent?siteid=' + getParameterByName("siteid"),
dataType: "JSON"
}).done(function (res) {
if (res) {
displaySuccessNoty('' + res.msg.replace(/\./g, ' '), false, 1500);
$(that).closest("tr").hide("2000");
$(that).closest("tr").remove();
if ($(".contentDataDiv").length < 3) {
$("#contentTale").addClass("show_overflow");
}
} else {
// displayErrorNoty('Internal server error.', false, 1500);
}
$(".loader-generic").hide();
}).fail(function (response) {
$(".loader-generic").hide();
});
}
function addUserPlayListContent(pl, contentId, that) {
// $(".loader-generic").show();
var params = "id=" + pl.id + "&contentId=" + contentId;
$.ajax({
type: 'POST',
data: params,
url: '/api/addPlaylistContent?siteid=' + getParameterByName("siteid"),
dataType: "JSON"
}).done(function (res) {
if (res) {
displaySuccessNoty('' + res.msg.replace(/\./g, ' '), false, 1500);
if (res.respCode === "00") {
/**
* Trigger Add To playlist clevertap event
*/
try {
if (userProfile && userProfile != "") {
var likedPlaylists = userProfile.likedPlaylistIdsMap;
var isIdPresent = likedPlaylists ? likedPlaylists[pl.id] : false;
}
var isLiked = "0";
if (isIdPresent) {
isLiked = "1";
}
// clevertap.event.push("Added to Playlist", {
// "Playlist Name": pl.name,
// "Number of Songs": pl.contentCount,
// "Content Id": contentId,
// "Liked": isLiked,
// "Platform": "WEB"
//
// });
} catch (er) {
// console.log("Error logging clevertap events" + er);
}
loadUserPlayList();
// $(that).parent().parent().find(".playlistContentCount").html((pl.contentCount + 1) + "Songs");
}
} else {
// displayErrorNoty('Internal server error.', false, 1500);
}
$(".loader-generic").hide();
}).fail(function (response) {
$(".loader-generic").hide();
});
}
function loadRecommendedContentSide(start, end) {
if (!isMobile && $("#sideRecomContent") && $("#sideRecomContent").html().trim() == "") {
$("#sideMoreContentLoader").removeClass("hidden").addClass("visible-lg");
//// $(".loader-generic").show();
var params = "sIndex=" + start + "&fIndex=" + end;
$.ajax({
type: 'POST',
url: '/api/content/trending?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
var data = res.respData;
if (!isMobile && $("#sideRecomContent") && $("#sideRecomContent").html().trim() == "") {
$.each(data, function (i, item) {
if (data[i]) {
var proIcon = "hidden";
if (data[i].isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
// var count = data[i].totalContent + (playlists[j].totalContent === 1 ? " track": " tracks");
$(sideRecomContentTemplate({
sideId: "cnt-" + data[i].contentId,
contentThumb: data[i].thumbnailList.square,
thumbWebp: data[i].thumbnailList.square.replace(".jpg", ".webp"),
contentTitle: data[i].contentTitle,
link: "/song/" + data[i].contentId + "/" + data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
streamCount: data[i].streamCount + " plays",
proIcon: proIcon
})).data("content", data[i]).appendTo("#sideRecomContent");
}
});
}
$("#sideRecomContent").shuffleChildren();
setTimeout(function () {
$(".sideRecomContent").mCustomScrollbar();
}, 200);
$(".loader-generic").hide();
$("#sideMoreContent").removeClass("hidden").addClass("visible-lg");
$("#sideMoreContentLoader").remove();
$("footer").addClass("col-sm-12 col-md-12 col-lg-9");
} else {
$(".sideRecomContent").hide();
$(".loader-generic").hide();
}
}).fail(function (response) {
$(".sideRecomContent, .loader-generic").hide();
});
} else {
$("#sideMoreContent").removeClass("hidden").addClass("visible-lg");
$("#sideMoreContentLoader").remove();
$("footer").addClass("col-sm-12 col-md-12 col-lg-9");
}
}
function removeUserPlaylist(id, that) {
var params = "id=" + id;
Noty.closeAll();
$.noty.closeAll();
var n = noty({
text: "Confirm karne k lye click karein",
type: 'alert',
dismissQueue: true,
timeout: 1000,
layout: 'center',
theme: 'defaultTheme',
buttons: [
{
addClass: 'btn btn-vdo-positive btn-primary',
text: 'Yes',
onClick: function ($noty) {
$.noty.closeAll();
Noty.closeAll();
$.ajax({
type: "POST",
data: params,
url: "/api/removePlaylist?siteid=" + getParameterByName("siteid"),
dataType: 'json'
}).done(function (response) {
if (response.isSuccess) {
displaySuccessNoty(response.msg, false, 1500);
$(that).hide("2000");
$(that).parent().remove();
setTimeout(function () {
// window.location = window.location.pathname.substring(0, window.location.pathname.indexOf("/", 2)) + "/home";
}, 2000);
} else {
displayErrorNoty(response.msg, false, 1500);
setTimeout(function () {
// window.location = window.location.pathname.substring(0, window.location.pathname.indexOf("/", 2)) + "/home";
}, 2000);
}
loadPlayListSection();
}).fail(function () {
// console.log("Oops! Something went wrong.");
});
}
},
{
addClass: 'btn btn-vdo-negative fb_btn',
text: 'No',
onClick: function ($noty) {
$.noty.closeAll();
Noty.closeAll();
}
}
]
});
}
function showLoginMenu() {
// getNumber();
// getLastLoggedNumber();
// $(".pincode").val("");
// var theme = localStorage.getItem("theme");
// if (theme) {
// $(".logo-horiz img").attr("src", "/theme/images/logo-horiz.png");
// } else {
// $(".logo-horiz img").attr("src", "/theme/images/logo-horizblack.png");
// }
// $("#loginModal").modal("show");
// logEvent("show_login_dialog", "");
window.location.href = "/login";
}
var simSimCustomerId;
var simSimCustomerName;
var simSimCustomerEmail;
var simSimToken;
var simSimTxnId;
function changeSelPackage(pkg) {
selectedPackageForTelco = pkg;
}
/*function subscribeUser() {
const urlParams = new URLSearchParams(window.location.search);
var m = urlParams.get('m');
var msisdn = $('#msisdn').val();
var email = $('#email').val();
var cnic = $('#cnic').val();
var packageId;
var paymentId;
var isWalletPayment = false;
if (otherPayment === false) {
packageId = selectedPackage === "" || typeof selectedPackage === "undefined" ? $("#id").text() : selectedPackage;
paymentId = selectedPayment === "" || typeof selectedPayment === "undefined" ? $("#payment").text() : selectedPayment;
isWalletPayment = false;
} else if (otherPayment === true) {
paymentId = paymentMethodId;
packageId = selectedPackageForTelco;
if (packageId && packageId !== "") {
// if ($("#wallets").hasClass("active")) {
isWalletPayment = true;
// } else if ($("#allTelcos").hasClass("active")) {
// operatorId = $('input[name=telcoPaymentMethods]:checked').val();
// }
if (paymentMethodId == 64) {
selectedOperator = "2";
} else if (paymentMethodId == 78) {
selectedOperator = "3";
} else if (paymentMethodId == 79) {
selectedOperator = "5";
} else {
packageId = selectedPackageForTelco;
}
var transactionType = $("#type option:selected").val();
//JAZZCASH paymentmethodid =1 and EasyPay paymentmethodid=3
if ((paymentMethodId == 74 || paymentMethodId == 73) && isWalletPayment) {
displaySuccessNoty("Please allow payment from your phone", false, 1500);
}
if ((paymentMethodId == 74 || paymentMethodId == 73) && transactionType === "") {
displayWarningNoty("Please select type");
} else {
if (!userProfile) {
getUserProfile();
}
var loggedInUser;
if (userProfile && userProfile.msisdn && userProfile.msisdn != null) {
loggedInUser = userProfile.msisdn;
} else {
loggedInUser = userProfile.email;
}
var pin = $('#verification_code').val();
var app = "WEB";
// if (getParameterByName("src") == "MTA" || sessionStorage.getItem("referrer") == "MTA") {
// app = "MTA";
// }
}
}
}
var params = "mobileNo=" + msisdn + "&email=" + email + "&pkgId="
+ packageId + "&pmtId=" + paymentId + "&cnic=" + cnic +
"&opId=" + selectedOperator;
// var params = "pkgId=" + selectedPackage + "&pmtId=" + selectedPayment + "&opId=" + selectedOperator;
// $(".loader-generic").show();
$(".subscribeSubmit").attr("disabled", "disabled");
$(".subscribeSubmit").html(" Processing..");
$.ajax({
type: "POST",
url: "/api/user/subscribe?siteid=" + getParameterByName("siteid"),
data: params,
dataType: 'json'
}).done(function (response) {
$(".loader-generic").hide();
var loginFlowCheck = 0;
if (response.isSuccess) {
loginFlowCheck = 1;
try {
firebaseObj.analytics().logEvent("subscribe", {
package: selectedPackageForTelco,
operator: selectedOperator,
description: "success"
});
} catch (er) {
}
logDBEvent("subscribe", "event", selectedPackageForTelco + "_success");
// logSubscriptionEvent("success");
/!**
* Tracking FB pixel
*!/
var price;
var packageName = "";
if (packageId == '1') {
price = '7.17';
packageName = "Daily";
}
if (packageId == '2') {
price = '47.8';
packageName = "Weekly";
}
if (packageId == '3') {
price = '119.5';
packageName = "Monthly";
}
if (packageId == '10') {
packageName = "eWallets Premium";
price = '114.8';
}
try {
fbq('track', 'Subscribe', {value: price, currency: 'PKR', predicted_ltv: '0.00'});
} catch (er) {
console.log("Error fb track subscribe" + er);
}
//fbq('track', 'Subscribe', {value: price, currency: 'PKR', predicted_ltv: '0.00'});
//end tracking
/!**
* Trigger Charged clevertap event
*!/
try {
clevertap.event.push("Charged", {
"Package Name": packageName,
"Msisdn": response.respData.msisdn,
"Operator": response.respData.operator,
"Platform": "WEB"
});
} catch (er) {
console.log("Error logging clevertap events" + er);
}
/!**
* end trigger
*!/
//SIM SIM PAYMENT
if (paymentMethodId == 75) {
if (response.isSuccess && response.respData) {
$("#otp_div").removeClass("hidden");
$("#msisdn").prop('disabled', true);
$("#continuePayment").addClass("hidden");
// $("#continueSimSimPayment").removeClass("hidden");
$(".btnConfirmSubscription").removeClass("submitbutton").addClass("confirmSimSimPayment");
displaySuccessNoty(response.msg);
simSimCustomerId = response.respData.model.data.customerId;
simSimCustomerName = response.respData.model.data.customerName;
simSimCustomerEmail = response.respData.model.data.email;
simSimToken = response.respData.model.data.token;
simSimTxnId = response.respData.model.txnID;
try {
firebaseObj.analytics().logEvent("simsim_subscribe_event", {description: response.respData.model.data.customerName});
logDBEvent("simsim_subscribe", "event", response.respData.model.data.customerName);
} catch (er) {
}
} else {
displayWarningNoty(response.msg);
}
} else {
$("#subcribemodal2").modal("hide");
displaySuccessNoty("Subscription " + response.msg, true, 3500);
if (sessionStorage.getItem("gpsub") && sessionStorage.getItem("gpsub") == "true") {
sessionStorage.setItem("gpsub", "");
gtag_report_conversion("");
}
// try {
// firebaseObj.analytics().logEvent("subscribe_user_event", {description: response.msg});
// } catch (er) {
// }
if (m === null || m === "") {
setTimeout(function () {
// window.location = "/home";
var path = window.location.pathname;
if (path == "/welcome" || path == "/payments" || path == "/verification") {
window.location.href = "/home";
} else {
window.location.href = path;
}
}, 3000);
}
}
} else {
loginFlowCheck = 0;
// logSubscriptionEvent("failed - " + response.msg);
try {
logEvent("subscription_failed", "subscription failed - " + response.msg);
} catch (er){
}
logDBEvent("subscribe", "event", "failed");
$(".subcribemodal2").modal("hide");
displaySuccessNoty("Subscription " + response.msg, true, 2500);
}
$(".subscribeSubmit").removeAttr("disabled");
$(".subscribeSubmit").html("go bajao pro");
if (m == 1) {
if (loginFlowCheck === 0) {
window.location.replace("https://bajaoapp.page.link/cuHZ");
} else {
window.location.replace("https://bajaoapp.page.link/cuHZ");
}
}
}).fail(function (error) {
logEvent("subscription_failed", "subscription failed due to network error.");
logDBEvent("subscribe", "event", "failed, subscription failed due to network error.");
$(".loader-generic").hide();
displayErrorNoty("Something went wrong", false, 1500);
$(".subscribeSubmit").removeAttr("disabled");
$(".subscribeSubmit").html("go bajao pro");
if (m == 1) {
window.location.replace("https://bajaoapp.page.link/cuHZ");
}
}).always(function () {
$(".loader-generic").hide();
});
}*/
function subscribeUser() {
const urlParams = new URLSearchParams(window.location.search);
var m = urlParams.get('m');
var msisdn = $('#msisdn').val();
var email = $('#email').val();
var cnic = $('#cnic').val();
var packageId;
var paymentId;
var isWalletPayment = false;
if (otherPayment === false) {
packageId = selectedPackage === "" || typeof selectedPackage === "undefined" ? $("#id").text() : selectedPackage;
paymentId = selectedPayment;
paymentId = selectedPayment === "" || typeof selectedPayment === "undefined" ? $("#payment").text() : selectedPayment;
isWalletPayment = false;
} else if (otherPayment === true) {
paymentId = paymentMethodId;
packageId = selectedPackageForTelco;
if (packageId && packageId !== "") {
// if ($("#wallets").hasClass("active")) {
isWalletPayment = true;
// } else if ($("#allTelcos").hasClass("active")) {
// operatorId = $('input[name=telcoPaymentMethods]:checked').val();
// }
if (paymentMethodId == 64) {
selectedOperator = "2";
} else if (paymentMethodId == 78) {
selectedOperator = "3";
} else if (paymentMethodId == 79) {
selectedOperator = "5";
} else if (paymentMethodId == 86) {
selectedOperator = "4";
} else {
packageId = selectedPackageForTelco;
}
var transactionType = $("#type option:selected").val();
//JAZZCASH paymentmethodid =1 and EasyPay paymentmethodid=3
if (paymentMethodId == 74 && isWalletPayment) {
localStorage.setItem("jazzcashPackageId", selectedPackageForTelco);
if (msisdn.startsWith("92") && msisdn.length === 12) {
msisdn = "0" + msisdn.substring(2);
} else if (msisdn.startsWith("+92") && msisdn.length === 13) {
msisdn = "0" + msisdn.substring(3);
} else if (msisdn.startsWith("0092") && msisdn.length === 14) {
msisdn = "0" + msisdn.substring(4);
} else if (msisdn.startsWith("3") && msisdn.length === 10) {
msisdn = "0" + msisdn;
} else if (msisdn.startsWith("03") && msisdn.length === 11) {
msisdn = msisdn;
} else {
displayErrorNoty("Baraiy meharbani durust number enter karein.", !1, 1500);
return;
}
// if (msisdn.startsWith("92")) {
// msisdn = "0" + msisdn.substring(2);
// } else if (msisdn.startsWith("+92")) {
// msisdn = "0" + msisdn.substring(3);
// }
localStorage.setItem("jNumber", msisdn);
const urlParams = new URLSearchParams(window.location.search);
const app = urlParams.get('app');
if (app !== '' && app !== null) {
window.location.href = "/jazzCashRedirect/request?app=" + app;
} else {
window.location.href = "/jazzCashRedirect/request";
}
}
if (paymentMethodId == 73 && isWalletPayment) {
localStorage.setItem("easypaisaNumber", msisdn);
localStorage.setItem("easypaisaEmail", email);
doubleConfirmationForEasypaisa();
var id = $(".packages-subc").find("li.active").attr('data-id');
window.location.href = "/verification?id=" + packageId;
return;
}
if ((paymentMethodId == 74 || paymentMethodId == 73) && transactionType === "") {
displayWarningNoty("Please select type");
} else {
if (!userProfile) {
getUserProfile();
}
var loggedInUser;
if (userProfile && userProfile.msisdn && userProfile.msisdn != null) {
loggedInUser = userProfile.msisdn;
} else {
loggedInUser = userProfile.email;
}
var pin = $('#verification_code').val();
var app = "WEB";
// if (getParameterByName("src") == "MTA" || sessionStorage.getItem("referrer") == "MTA") {
// app = "MTA";
// }
}
}
}
processSubscription(msisdn, email, packageId, paymentId, cnic, null, m);
}
function processSubscription(msisdn, email, packageId, paymentId, cnic, pincode, m) {
var params = "mobileNo=" + msisdn + "&email=" + email + "&pkgId="
+ packageId + "&pmtId=" + paymentId + "&cnic=" + cnic + "&pincode=" + pincode +
"&opId=" + selectedOperator;
// var params = "pkgId=" + selectedPackage + "&pmtId=" + selectedPayment + "&opId=" + selectedOperator;
// $(".loader-generic").show();
$(".subscribeSubmit").attr("disabled", "disabled");
$(".subscribeSubmit").html(" Processing..");
$(".submitbutton").attr("disabled", "disabled");
$(".submitbutton").html(" Processing..");
$.ajax({
type: "POST",
url: "/api/user/subscribe?siteid=" + getParameterByName("siteid"),
data: params,
dataType: 'json'
}).done(function (response) {
$(".loader-generic").hide();
var loginFlowCheck = 0;
if (response.isSuccess) {
if (response.respCode == 777) {
window.location.href = response.respData.url;
}
loginFlowCheck = 1;
try {
firebaseObj.analytics().logEvent("subscribe", {
package: selectedPackageForTelco,
operator: selectedOperator,
description: "success"
});
} catch (er) {
}
logDBEvent("subscribe", "event", selectedPackageForTelco + "_success");
// logSubscriptionEvent("success");
/*
Tracking FB pixel
*/
var price;
var packageName = "";
if (packageId == '1') {
price = '10';
packageName = "Daily";
}
if (packageId == '2') {
price = '47.8';
packageName = "Weekly";
}
if (packageId == '3') {
price = '119.5';
packageName = "Monthly";
}
if (packageId == '10') {
packageName = "eWallets Premium";
price = '114.8';
}
try {
fbq('track', 'Subscribe', {value: price, currency: 'PKR', predicted_ltv: '0.00'});
} catch (er) {
// console.log("Error fb track subscribe" + er);
}
//fbq('track', 'Subscribe', {value: price, currency: 'PKR', predicted_ltv: '0.00'});
//end tracking
/*
Trigger Charged clevertap event
*/
// try {
//
// clevertap.event.push("Charged", {
// "Package Name": packageName,
// "Msisdn": response.respData.msisdn,
// "Operator": response.respData.operator,
// "Platform": "WEB"
//
// });
// } catch (er) {
// console.log("Error logging clevertap events" + er);
// }
/*
end trigger
*/
//SIM SIM PAYMENT
if (paymentMethodId == 75) {
if (response.isSuccess && response.respData) {
$("#otp_div").removeClass("hidden");
$("#msisdn").prop('disabled', true);
$("#continuePayment").addClass("hidden");
// $("#continueSimSimPayment").removeClass("hidden");
$(".btnConfirmSubscription").removeClass("submitbutton").addClass("confirmSimSimPayment");
displaySuccessNoty(response.msg);
simSimCustomerId = response.respData.model.data.customerId;
simSimCustomerName = response.respData.model.data.customerName;
simSimCustomerEmail = response.respData.model.data.email;
simSimToken = response.respData.model.data.token;
simSimTxnId = response.respData.model.txnID;
try {
firebaseObj.analytics().logEvent("simsim_subscribe_event", {description: response.respData.model.data.customerName});
logDBEvent("simsim_subscribe", "event", response.respData.model.data.customerName);
} catch (er) {
}
} else {
displayWarningNoty(response.msg);
}
} else {
$("#subcribemodal2").modal("hide");
displaySuccessNoty("Subscription " + response.msg, true, 3500);
if (sessionStorage.getItem("gpsub") && sessionStorage.getItem("gpsub") == "true") {
sessionStorage.setItem("gpsub", "");
gtag_report_conversion("");
}
// try {
// firebaseObj.analytics().logEvent("subscribe_user_event", {description: response.msg});
// } catch (er) {
// }
if (m === null || m === "") {
setTimeout(function () {
// window.location = "/home";
var path = window.location.pathname;
if (path == "/welcome" || path == "/payments" || path == "/verification") {
window.location.href = "/home";
} else {
window.location.href = path;
}
}, 3000);
}
}
} else {
loginFlowCheck = 0;
// logSubscriptionEvent("failed - " + response.msg);
try {
logEvent("subscription_failed", "subscription failed - " + response.msg);
} catch (er) {
}
logDBEvent("subscribe", "event", "failed");
$(".subcribemodal2").modal("hide");
displaySuccessNoty("Subscription " + response.msg, true, 2500);
}
$(".subscribeSubmit").removeAttr("disabled");
$(".subscribeSubmit").html("go bajao pro");
$(".submitbutton").removeAttr("disabled");
$(".submitbutton").html("go bajao pro");
$("#submit_pin").attr("disabled", false);
$("#submit_pin").html("submit");
if (m == 1) {
if (loginFlowCheck === 0) {
window.location.replace("https://bajaoapp.page.link/cuHZ");
} else {
window.location.replace("https://bajaoapp.page.link/cuHZ");
}
}
}).fail(function (error) {
logEvent("subscription_failed", "subscription failed due to network error.");
logDBEvent("subscribe", "event", "failed, subscription failed due to network error.");
$(".loader-generic").hide();
displayErrorNoty("Something went wrong", false, 1500);
$(".subscribeSubmit").removeAttr("disabled");
$(".subscribeSubmit").html("go bajao pro");
$(".submitbutton").removeAttr("disabled");
$(".submitbutton").html("go bajao pro");
$("#submit_pin").attr("disabled", false);
$("#submit_pin").html("submit");
if (m == 1) {
window.location.replace("https://bajaoapp.page.link/cuHZ");
}
}).always(function () {
$(".loader-generic").hide();
});
}
function loadPackage() {
var msisdn = $('#msisdnVal').val();
var params = "uuid=" + msisdn;
const urlParams = new URLSearchParams(window.location.search);
const id = urlParams.get('id');
$.ajax({
type: "POST",
url: "/api/user/payments?siteid=" + getParameterByName("siteid"),
dataType: 'json',
data: params
}).done(function (response) {
if (response && response.respData) {
for (let type in response.respData) {
console.log(type); // Print the type (walletBilling or mobileBilling)
response.respData[type].forEach(item => {
console.log("Item:");
item.paymentPackagesMappingCollection.forEach(package => {
if (package.packages.id.toString() === id) {
if (type === 'Mobile_Billing') {
$("#opName").text("Mobile Billing - " + item.description);
} else {
$("#opName").text("Wallet - " + item.description);
}
$("#payment").text(item.id);
$("#id").text(package.packages.id.toString());
$("#pkgName").text(package.packages.name);
$("#pkgFree").text(package.packages.dateFreeTime + " Hour Data FREE Usage");
$("#pkgDesc").text(package.packages.description);
}
});
});
}
// var data;
// data = response.respData["Mobile_Billing"][0].paymentPackagesMappingCollection;
// $("#opName").text("Mobile Billing - " + response.respData["Mobile_Billing"][0].description);
// $("#payment").text(response.respData["Mobile_Billing"][0].id);
// $.each(data, function (i, item) {
// if (data[i].packages.id.toString() === id) {
// $("#id").text(data[i].packages.id.toString());
// $("#pkgName").text(data[i].packages.name);
// $("#pkgFree").text(data[i].packages.dateFreeTime + " Hour Data FREE Usage");
// $("#pkgDesc").text(data[i].packages.description);
// }
// });
}
}).fail(function (error) {
displayErrorNoty("Internal server error.", false, 1500);
});
}
var otpClientTitle = "";
function loadPackages() {
if ($("#packgText").html().trim() == "") {
var msisdn = $('#msisdn_entered').val();
// if (msisdn == "") {
// msisdn = userProfile.msisdn;
// }
var params = "uuid=" + msisdn;
$.ajax({
type: "POST",
url: "/api/user/payments?siteid=" + getParameterByName("siteid"),
dataType: 'json',
data: params
}).done(function (response) {
if (response && response.respData) {
var data;
if (response.respData["Mobile_Billing"]) {
if (response.respData["Mobile_Billing"][0].id == 64) {
if (isJazzUser == null) {
$("#subcribemodal2").modal("show");
}
isJazzUser = true;
} else if (response.respData["Mobile_Billing"][0].id == 78) {
if (isTelenorUser == null) {
$("#subcribemodal2").modal("show");
}
isTelenorUser = true;
} else if (response.respData["Mobile_Billing"][0].id == 86) {
if (isZongUser == null) {
$("#subcribemodal2").modal("show");
}
isZongUser = true;
} else if (response.respData["Mobile_Billing"][0].id == 79) {
if (isUfoneUser == null) {
$("#subcribemodal2").modal("show");
}
isUfoneUser = true;
} else {
if (isJazzUser == null) {
$("#verifyModal").modal("show");
}
isJazzUser = false;
// window.location.href = "/account?otherPayment=true";
return;
}
data = response.respData["Mobile_Billing"][0].paymentPackagesMappingCollection;
}
if (response.respData["WALLET"]) {
// $(".subscribeSubmit").html("Goto Payment Options");
if (isJazzUser == null && isTelenorUser == null && isUfoneUser == null && isZongUser == null) {
getUserProfile();
if (userProfile == "") {
$("#verifyModal").modal("show");
} else {
var ot_pay = getParameterByName("otherPayment");
if (ot_pay != null && ot_pay == "true") {
$(".main-tab li").removeClass("active");
$("#my-tabs1").removeClass("active").removeClass("in");
$("#OT_PAYMENT").show();
$("#OT_PAYMENT").addClass("active");
$("#my-tabs10").addClass("active").addClass("in");
} else {
/*window.location.href = "/account?otherPayment=true";*/
}
}
}
// isJazzUser = false;
// window.location.href = "/account?otherPayment=true";
// return;
// data = response.respData["WALLET"][0].paymentPackagesMappingCollection;
}
// var data = response.respData[0].paymentPackagesMappingCollection;
var activeClass = "";
var isChecked = "";
if (data === undefined) {
$("#noPayment").removeClass("hidden");
$("#infoText").addClass("hidden");
$("#bajaoprobutton").addClass("hidden");
$("#noPayment").text("Use mobile wallets to pay for Bajao pro, as payment thru mobile billing not available for you mobile operator");
} else {
$("#noPayment").addClass("hidden");
$("#infoText").removeClass("hidden");
$("#bajaoprobutton").removeClass("hidden");
}
if ($("#packgText").html().trim() == "") {
$.each(data, function (i, item) {
// $("#packgText").append("" + data[1].packages.name + "
" + data[i].packages.description);
// $("#packgText").append();
if (i == 0) {
activeClass = "active";
isChecked = "checked='checked'";
selectedPackage = data[0].packages.id;
otpClientTitle = data[0].packages.otpClientTitle;
selectedPayment = response.respData["Mobile_Billing"][0].id;
} else {
activeClass = "";
isChecked = "";
}
var packagename = '';
if (data[i].packages.intervalDays == 1) {
packagename = 'Basic';
} else if (data[i].packages.intervalDays == 7) {
packagename = 'Standard';
} else if (data[i].packages.intervalDays == 30) {
packagename = 'Premium';
}
var freeText = "";
if (data[i].packages.dateFreeTime > 0) {
freeText = data[i].packages.dateFreeTime + " Hour Data FREE Usage";
} else if (data[i].packages.message) {
freeText = data[i].packages.message;
}
// console.log(data[i].packages.dateFreeTime + freeText);
$(subPackagesTemplateNew({
activeClass: activeClass,
otpClientTitle: data[i].packages.otpClientTitle,
isChecked: isChecked,
freeUsage: freeText,
name: data[i].packages.name,
desc: data[i].packages.description,
days: packagename,
pmtId: response.respData["Mobile_Billing"][0].id,
id: data[i].packages.id
})).data(data[i].packages).appendTo("#packgText");
});
}
if (true) {
$(".subc-tax").hide();
}
}
}).fail(function (error) {
// displayErrorNoty("Internal server error.", false, 1500);
});
}
}
function loginWithFacebook() {
// console.log('facebook');
FB.getLoginStatus(function (response) {
// console.log('loginWithFacebook');
});
// FB.login(function (response) {
// // Handle the response object, like in statusChangeCallback() in our demo
// // code.
// console.log('FB LOGIN');
// });
FB.login(function (loginResponse) {
if (loginResponse.authResponse) {
var userId = loginResponse.authResponse.userID;
} else {
//'User cancelled login or did not fully authorize.
}
}, {scope: 'email,user_birthday,user_location'});
}
$.fn.filterByData = function (prop, val) {
return this.filter(function () {
return $(this).data(prop) === val;
});
};
function likeContent(id) {
if ($(".title-user") && $(".title-user").html().trim() === "LOGIN") {
showLoginMenu();
} else {
var element = "";
if (id == "") {
id = getPathVariableByIndex(2);
element = ".likeCurrentVdo";
} else {
element = ".it_" + id;
}
var action = "";
var params = "aId=&pId=&cId=" + id + "&artId=&action=" + action;
// $(".loader-generic").show();
$.ajax({
type: 'POST',
url: '/api/content/like?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
logEvent("song_liked_unliked", id);
logDBEvent("song_liked_unliked", "event", id);
if (res) {
userProfile = res;
var likedContent = userProfile.likedContentIdsMap;
var isIdPresent = likedContent[id];
if (isIdPresent) {
$(".player_" + id).addClass("active").addClass("liked");
$(element).html(' ');
if (id == currentVideo.contentId) {
var currentCount = $("#fanHits").text();
$("#fanHits").html(parseInt(currentCount) + 1);
}
$("#like" + id).html("Unlike");
/**
* Trigger Like Content clevertap event
*/
// try {
//
// clevertap.event.push("Like Content", {
// "Content Id": id,
// "Msisdn": userProfile.msisdn,
// "Platform": "WEB"
//
// });
// } catch (er) {
// console.log("Error logging clevertap events" + er);
// }
/**
* end trigger
*/
// displaySuccessNoty("Song Liked", false, 1500);
} else {
$(".player_" + id).removeClass("active").removeClass("liked");
$(element).html(' ');
if (id == currentVideo.contentId) {
var currentCount = $("#fanHits").text();
$("#fanHits").html(parseInt(currentCount) - 1);
}
$("#like" + id).html("Like");
// displaySuccessNoty("Song UnLiked", false, 1500);
/**
* Trigger Unlike Content clevertap event
*/
// try {
//
// clevertap.event.push("Unlike Content", {
// "Content Id": id,
// "Msisdn": userProfile.msisdn,
// "Platform": "WEB"
//
// });
// } catch (er) {
// console.log("Error logging clevertap events" + er);
// }
/**
* end trigger
*/
}
} else {
}
$(".loader-generic").hide();
}).fail(function (response) {
$(".loader-generic").hide();
displayErrorNoty('Kuch dair bad dobara koshish karein. Shukriya.', false, 1500);
});
}
}
function getUserProfile() {
if (!userProfile) {
$.ajax({
type: 'GET',
url: '/api/user/profile?siteid=' + getParameterByName("siteid"),
async: false
}).done(function (res) {
if (res) {
userProfile = JSON.parse(res);
} else {
userProfile = "";
}
}).fail(function (response) {
// console.log('failed');
userProfile = "";
}).always(function () {
});
}
}
function loadAllOperators() {
$.ajax({
type: 'POST',
url: '/api/user/allOperators?siteid=' + getParameterByName("siteid"),
async: false
}).done(function (res) {
if (res.respCode == "00") {
var data = res.respData;
$.each(data, function (i, item) {
var activeClass = "";
if (i == 0) {
activeClass = "active";
}
$(loginOperatorTemplate({
thumb: data[i].image,
id: data[i].id,
active: activeClass
})).appendTo(".allLoginOperators");
});
}
}).fail(function (response) {
// console.log('failed');
}).always(function () {
});
}
function loadBrowseAllSection() {
$.ajax({
type: 'POST',
url: '/api/v2/browseAll?siteid=' + getParameterByName("siteid"),
async: false
}).done(function (res) {
if (res.respCode == "00") {
var data = res.respData;
$.each(data, function (i, item) {
// if (item.playlistImageSquare != null) {
if (item.playlistImage != null && item.playlistImage != '' && item.playlistImageSquare != null) {
$(browseListTemplate({
thumb: data[i].playlistImage
})).appendTo("#browseAllDiv").data("content", data[i]);
}
});
$("#browseAllDiv").owlCarousel({
loop: false,
touchDrag: false,
mouseDrag: false,
margin: 27,
dots: false,
nav: false,
pagination: false,
responsive: {
0: {
items: 2,
margin: 12,
},
480: {
items: 2,
margin: 12,
},
600: {
items: 3,
margin: 12,
},
700: {
items: 3,
margin: 12,
},
768: {
items: 4,
},
1000: {
items: 4,
},
1024: {
items: 4,
},
1200: {
items: 4,
},
1600: {
items: 5,
},
1920: {
items: 5,
}
}
});
}
}).fail(function (response) {
// console.log('failed');
}).always(function () {
});
}
function updateFavArtist(ids, page) {
if (ids.includes(0)) {
ids.splice(0, 1);
}
$.ajax({
type: 'POST',
url: '/api/user/favArtist/update?siteid=' + getParameterByName("siteid"),
async: false,
data: {ids: ids},
traditional: true
}).done(function (res) {
if (res.respCode == "00") {
getFavArtist("modal");
displaySuccessNoty("Artists have been updated successfully.", false, 1500);
if (page == "page") {
setTimeout(function () {
window.location.href = "/";
}, 500);
}
$("#closeArtistModal").trigger("click");
}
}).fail(function (response) {
// console.log('failed');
}).always(function () {
});
}
var liveEvent;
function getLiveActiveStreams() {
// if (!userProfile) {
var clickcode = getParameterByName("clickcode") ? getParameterByName("clickcode") : "";
$.ajax({
type: 'POST',
url: '/api/activestreams?siteid=' + getParameterByName("siteid"),
async: false
}).done(function (res) {
// respo = res;
// console.log("response:" + res);
if (res.respCode == "00") {
var data = res.respData[0];
liveEvent = data;
$("#liveEventThumb").attr("src", data.artistImage);
$("#liveEventTitle").html(data.description);
$("#liveEventTitle").attr("eventId", data.id);
// if (data.isWebPaid) {
setTimeout(function () {
$("#livestream").modal("show");
}, 3500);
// }
}
}).fail(function (response) {
// console.log('failed');
}).always(function () {
});
// }
}
function insertEventHistoryStreams(eventId) {
// if (!userProfile) {
var clickcode = getParameterByName("clickcode") ? getParameterByName("clickcode") : "";
$.ajax({
type: 'POST',
url: '/api/insertlivehistory?siteid=' + getParameterByName("siteid"),
data: {eventId: eventId},
async: false
}).done(function (res) {
// respo = res;
// console.log("response:" + res);
// window.location.href = "/live";
}).fail(function (response) {
// console.log('failed');
}).always(function () {
});
// }
}
function getLiveStreamStatus() {
setTimeout(function () {
if (liveEvent) {
getLikesViewsStreams(liveEvent.id, "false");
getLiveStreamStatus();
}
}, 15000);
}
function getLikesViewsStreams(eventId, updatelike) {
// if (!userProfile) {
var clickcode = getParameterByName("clickcode") ? getParameterByName("clickcode") : "";
$.ajax({
type: 'POST',
url: '/api/getlikeviews?siteid=' + getParameterByName("siteid"),
data: {eventId: eventId, updateLike: updatelike},
async: false
}).done(function (res) {
// console.log("response:" + res);
if (res.respCode == "00") {
var data = res.respData;
$("#totalLiveViews").html(" " + data.views);
$("#totalLiveLikes").html(" " + data.likes);
if (updatelike == "true") {
sessionStorage.setItem("eventId", data.id);
$("#likeLiveEvent").parent().addClass("active");
$("#totalLiveLikes").html(" " + data.likes + 1);
$(".liked-anim").toggleClass("press", 1000);
setTimeout(function () {
$(".liked-anim").toggleClass("hide-anim", 500);
}, 100);
}
if (data.incomingStreamStarted == false) {
$("#liveEnded").removeClass("hidden");
try {
var player = document.getElementById('vdoPlayer');
// player.setSrc("");
player.pause();
} catch (er) {
}
} else {
$("#liveEnded").addClass("hidden");
}
}
}).fail(function (response) {
// console.log('failed');
}).always(function () {
});
// }
}
function getContentByGenre(mCats) {
var params = "mainCats=" + mCats;
$.ajax({
type: "GET",
data: params,
url: "cgenres?siteid=" + getParameterByName("siteid")
// dataType: 'json'
}).done(function (response) {
// console.log('response');
// window.location = window.location.pathname.substring(0, window.location.pathname.indexOf("/", 2)) + "/home";
});
}
function setCategories(mCats, sCats) {
if (mCats !== "") {
var params = "mainCats=" + mCats + "&subCats=" + sCats;
$.ajax({
type: "POST",
data: params,
url: "/api/categories/setCategories?siteid=" + getParameterByName("siteid")
// dataType: 'json'
}).done(function (response) {
window.location = window.location.pathname.substring(0, window.location.pathname.indexOf("/", 2)) + "/home";
});
} else {
displayWarningNoty("Category ka intekhab karein.", false, 1500);
}
}
function removeCategories() {
var params = "";
$.ajax({
type: "POST",
data: params,
url: "/api/categories/removeCategories?siteid=" + getParameterByName("siteid")
// dataType: 'json'
}).done(function (response) {
loadSelectedCategories();
// $(".main-cats").removeClass("mainCat-selected");
// $(".subcats").removeClass("subCat-selected");
// window.location = window.location.pathname.substring(0, window.location.pathname.indexOf("/", 2)) + "/category";
});
}
function removeGenres() {
var params = "";
$.ajax({
type: "POST",
data: params,
url: "/api/categories/removeGenres?siteid=" + getParameterByName("siteid")
// dataType: 'json'
}).done(function (response) {
loadAllSelectedGenres();
});
}
function unsubscribe() {
var flag = 0;
Noty.closeAll();
$.noty.closeAll();
var n = noty({
text: "Are you sure you want to unsubscribe from BajaoMusic?",
type: 'alert',
dismissQueue: true,
timeout: 1000,
layout: 'center',
theme: 'defaultTheme',
buttons: [
{
addClass: 'btn btn-vdo-positive bt-primary',
text: 'Yes',
onClick: function ($noty) {
$.noty.closeAll();
Noty.closeAll();
// $(".loader-generic").show();
$.ajax({
type: "POST",
url: "/api/user/unsubscribe?siteid=" + getParameterByName("siteid"),
dataType: 'json'
}).done(function (response) {
if (response) {
logEvent("unsubscribe", "success");
logDBEvent("unsubscribe", "event", "success");
fbq('trackCustom', 'Unsubscribe');
displaySuccessNoty("UnSubscription " + response.msg, true, 2000);
// ga('send', {
// hitType: 'event',
// eventCategory: 'Un-Subscription',
// eventAction: 'successed',
// eventLabel: ''
// });
setTimeout(function () {
window.location = "/home";
}, 2000);
} else {
logEvent("exception", "unsubscription failed - " + response.msg);
logDBEvent("unsubscribe", "event", "failed" + response.msg);
// ga('send', {
// hitType: 'event',
// eventCategory: 'Un-Subscription',
// eventAction: 'failed',
// eventLabel: ''
// });
displayWarningNoty("UnSubscription " + response.msg, true, 2000);
// setTimeout(function () {
// window.location = "/home";
// }, 2000);
}
$(".loader-generic").hide();
}).fail(function () {
logEvent("exception", "unsubscription failed due to network error.");
logDBEvent("unsubscribe", "event", "failed due to network error.");
$(".loader-generic").hide();
// console.log("Oops! Something went wrong retrieving instant stream.");
});
}
},
{
addClass: 'btn btn-vdo-negative fb_btn',
text: 'No',
onClick: function ($noty) {
$.noty.closeAll();
Noty.closeAll();
}
}
]
});
}
function subscribeConfirmation() {
$("#subcribemodal2").modal("hide");
var flag = 0;
Noty.closeAll();
$.noty.closeAll();
var n = noty({
text: "Are you sure you want to proceed?",
type: 'alert',
dismissQueue: true,
timeout: 1000,
layout: 'center',
theme: 'defaultTheme',
buttons: [
{
addClass: 'btn btn-vdo-positive bt-primary',
text: 'Yes',
onClick: function ($noty) {
$.noty.closeAll();
Noty.closeAll();
otherPayment = false;
if (isJazzUser == true || isTelenorUser == true || isZongUser == true) {
if ($(".title-user") && $(".title-user").html().trim() === "LOGIN" && isToShowVerify) {
// window.location = window.location.pathname.substring(0, window.location.pathname.indexOf("/", 2)) + "/login";
// showLoginMenu();
$("#verifyModal").modal("show");
$("#subcribemodal2").modal("hide");
} else {
subscribeUser();
}
} else {
window.location.href = "/account?otherPayment=true";
}
}
},
{
addClass: 'btn btn-vdo-negative fb_btn',
text: 'No',
onClick: function ($noty) {
$.noty.closeAll();
Noty.closeAll();
}
}
]
});
}
var isToShowVerify = true;
var isUserDoubleVerified = false;
function generatePin() {
var msisdn = $('#msisdn_entered').val();
if (!msisdn || msisdn.trim() == "") {
if (userProfile != "") {
msisdn = userProfile.msisdn;
}
}
var paymentId = selectedPayment === "" || typeof selectedPayment === "undefined" ? $("#payment").text() : selectedPayment;
if (paymentId === '73') {
doubleConfirmationForEasypaisa();
return;
}
var params = "uuid=" + msisdn;
if (!$("#gen_pin").hasClass("hidden") && msisdn.length > 9) {
$("#gen_pin").attr("disabled", true);
//// $(".loader-generic").show();
$.ajax({
type: 'POST',
url: '/api/v2/login/generatePin?siteid=' + getParameterByName("siteid") + "&selOperator=" + loginSelOperator,
data: params,
dataType: "JSON"
}).done(function (response) {
// console.log('GeneratePin');
if (response.isSuccess) {
try {
firebaseObj.analytics()
.logEvent("pin_generation", {msisdn: msisdn, status: "success", description: response.msg});
} catch (er) {
}
logDBEvent("pin_generation", "event", "success");
if (response.respData) {
var rData = response.respData;
if (rData.exist == false) {
/**
* Trigger Sign Up clevertap event
*/
// try {
//
// clevertap.event.push("Sign Up", {
// "Msisdn": msisdn,
// "Platform": "WEB"
//
// });
// } catch (er) {
// console.log("Error logging clevertap events" + er);
// }
/**
* end trigger
*/
}
}
$('.pincode').eq(0).focus();
$("#msisdnPinSent").text(msisdnFormat($('#msisdn_entered').val()));
if (!isResend) {
if (response.respCode == "00") {
displaySuccessNoty(response.msg, false, 1500);
$(".loginTab").hide();
$(".verifyTab").show();
} else if (response.respCode == "05") {
// $("#loginModal").modal("hide");
// $(".loginTab").hide();
$(".subscribeSubmit").html("Continue");
// if (response.respData != null && response.respData == 0) {
// isJazzUser = false;
// } else {
// isJazzUser = true;
// }
if ($("#packgText").html().trim() == "") {
loadPackages();
}
$(".verifyTab").show();
if (isJazzUser != null) {
if (isJazzUser == true) {
// $("#subcribemodal2").modal("show");
} else {
// $("#verifyModal").modal("show");
}
}
// $(".btnSubscribe").trigger("click");
// displaySuccessNoty(response.msg, false, 1500);
// displayErrorNoty(response.msg, false, 1500);
} else if (response.respCode == "06") {
isToShowVerify = false;
// $("#loginModal").modal("hide");
$(".loginTab").hide();
$(".subscribeSubmit").html("Continue");
$(".btnSubscribe").trigger("click");
// displaySuccessNoty(response.msg, false, 1500);
// displayErrorNoty(response.msg, false, 1500);
} else {
displaySuccessNoty(response.msg, false, 1500);
$("#loginModal").modal("hide");
$("#verifyModal").modal("show");
}
} else {
displaySuccessNoty(response.msg, false, 1500);
// displaySuccessNoty("Pin Sent Successfully", false, 1500);
}
} else {
displayErrorNoty(response.msg, true, 2000);
try {
var number = msisdn;
if (!number) {
number = "undefined";
}
firebaseObj.analytics()
.logEvent("pin_generation", {msisdn: number, status: "failed", description: response.msg});
} catch (er) {
}
logDBEvent("pin_generation", "event", "failed");
}
$(".loader-generic").hide();
}).fail(function (response) {
logEvent("exception", "pin generation failed due to network error");
$(".loader-generic").hide();
displayErrorNoty('Something went wrong', false, 1500);
}).always(function () {
$(".loader-generic").hide();
$("#gen_pin").attr("disabled", false);
});
} else {
displayErrorNoty("Baraiy meharbani darust number enter karein.", false, 1500);
}
}
$(document).on("click", "#resendPin", function (e) {
e.preventDefault();
isResend = true;
generatePin();
$(this).removeClass("btn-link");
$(this).attr("id", "pinSent");
$(this).html("Pin Sent");
setTimeout(function () {
$("#pinSent").addClass("btn-link");
$("#pinSent").html("Resend PIN");
$("#pinSent").attr("id", "resendPin");
}, 15000);
});
var isResend = false;
$(document).on("click", "#gen_pin", function (e) {
e.preventDefault();
// e.stoppropagation();
isResend = false;
generatePin();
});
$("#loginMsisdnForm").submit(function (e) {
// e.preventDefault();
// e.stoppropagation();
isResend = false;
generatePin();
return false;
});
$("#loginPinForm").submit(function (e) {
// e.preventDefault();
// e.stoppropagation();
$("#submit_pin").trigger("click");
return false;
});
$(document).on("click", "#submit_pin", function (e) {
e.preventDefault();
var msisdn = $('#msisdn_entered').val();
if (msisdn === "" || typeof msisdn === "undefined") {
msisdn = userProfile.msisdn;
}
if (msisdn === "" || typeof msisdn === "undefined") {
msisdn = $('#msisdn').val();
msisdn = standardizeMsisdn(msisdn);
}
var pin = $(".pincode").val();
if (pin == "" || pin.length < 3) {
var pinCode = $(".pincodebox");
var pin = "";
for (var i = 0; i < pinCode.length; i++) {
pin = pin + $(pinCode[i]).val();
}
}
if (pin.length > 3) {
// $(".loader-generic").show();
var params = "uuid=" + msisdn + "&pin=" + pin + "&pkg=" + selectedPackage + "&otpClientTitle=" + otpClientTitle;
$("#submit_pin").attr("disabled", true);
$("#submit_pin").html(" Processing..");
var packageId = selectedPackage === "" || typeof selectedPackage === "undefined" ? $("#id").text() : selectedPackage;
var paymentId = selectedPayment === "" || typeof selectedPayment === "undefined" ? $("#payment").text() : selectedPayment;
if (paymentId === '73' || getParameterByName("x-bj-mid") === '73') {
var easypaisaNumber = localStorage.getItem("easypaisaNumber");
var easypaisaEmail = localStorage.getItem("easypaisaEmail");
if ((getParameterByName("ep") == "1") || (getParameterByName("x-bj-pid") == "34")) {
processSubscriptionEPCMP(easypaisaNumber, easypaisaEmail, getParameterByName("x-bj-pid"), getParameterByName("x-bj-mid"), "", pin, null);
} else {
processSubscription(easypaisaNumber, easypaisaEmail, packageId, paymentId, "", pin, null);
}
} else {
$.ajax({
type: 'POST',
url: '/api/login/verifyPin?siteid=' + getParameterByName("siteid") + "&selOperator=" + loginSelOperator,
data: params,
dataType: "JSON"
}).done(function (response) {
if (response.isSuccess) {
var path = window.location.pathname;
if ((isDoubleConfirmation || path == "/verification") && (getParameterByName("ep") == "1")) {
subscribeUserEPCMP();
} else if (isDoubleConfirmation || path == "/verification") {
subscribeUser();
} else {
try {
firebaseObj.analytics()
.logEvent("login", {msisdn: msisdn, status: "success", description: response.msg});
} catch (er) {
}
logDBEvent("login", "event", "success");
$("#verifyModal").modal("hide");
$("#thankyouModal").modal("show");
// setTimeout(function () {
// window.location = "/home";
if (response.respCode == "01") {
// var path = window.location.pathname;
// if (path == "/welcome") {
window.location.href = "/fav-artist";
} else {
window.location.href = "/home";
}
}
// }, 2000);
} else {
try {
firebaseObj.analytics()
.logEvent("login", {msisdn: msisdn, status: "failed", description: response.msg});
} catch (er) {
}
logDBEvent("login", "event", "failed");
displayErrorNoty("Verification " + response.msg, false, 1500);
$("#submit_pin").attr("disabled", false);
$("#submit_pin").html("submit");
}
}).fail(function () {
logEvent("exception", "pin verification failed due to network error.");
// displayErrorNoty("Network Error", true, 2000);
}).always(function () {
$(".loader-generic").hide();
});
}
} else {
displayErrorNoty("Baraiy meharbani darust PIN code enter karein.", false, 1500);
}
});
$(document).on("click", ".payEasypaisaBtn", function (e) {
e.preventDefault();
e.stopPropagation();
otherPayment = true;
var msisdn = $('#msisdn').val();
var email = $('#email').val();
var packageId = selectedPackageForTelco = 34;
var methodId = paymentMethodId = 73;
var checkbox2 = document.getElementById("checkbox2");
var errorspan2 = $("#errorspan2");
var errorspan3 = $("#errorspan3");
var validRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
$("#errorspancheckbox2").hide();
errorspan2.hide();
errorspan3.hide();
// Check if the checkbox is checked
if (!checkbox2.checked) {
$("#errorspancheckbox2").show();
$("#errorspancheckbox2").text("Please agree to proceed");
return;
}
msisdn = standardizeMsisdn(msisdn);
if (methodId !== 64 && (msisdn === undefined || msisdn === "")) {
errorspan2.text("Please enter valid mobile number.");
errorspan2.show();
} else if ((methodId !== 64 && methodId !== 74 && (email === undefined || email === "") && methodId !== 75) || !validRegex.test(email)) {
errorspan3.text("Please enter email address.");
errorspan3.show();
} else if (packageId === undefined || packageId === "") {
errorspan3.text("Please select package.");
errorspan3.show();
} else {
subscribeUserEPCMP();
}
});
function subscribeUserEPCMP() {
const urlParams = new URLSearchParams(window.location.search);
var m = urlParams.get('m');
var msisdn = $('#msisdn').val();
var email = $('#email').val();
var cnic = $('#cnic').val();
var packageId;
var paymentId;
var isWalletPayment = false;
if (otherPayment === false) {
packageId = selectedPackage === "" || typeof selectedPackage === "undefined" ? $("#id").text() : selectedPackage;
paymentId = selectedPayment;
paymentId = selectedPayment === "" || typeof selectedPayment === "undefined" ? $("#payment").text() : selectedPayment;
isWalletPayment = false;
} else if (otherPayment === true) {
paymentId = paymentMethodId;
packageId = selectedPackageForTelco;
if (packageId && packageId !== "") {
// if ($("#wallets").hasClass("active")) {
isWalletPayment = true;
// } else if ($("#allTelcos").hasClass("active")) {
// operatorId = $('input[name=telcoPaymentMethods]:checked').val();
// }
if (paymentMethodId == 64) {
selectedOperator = "2";
} else if (paymentMethodId == 78) {
selectedOperator = "3";
} else if (paymentMethodId == 79) {
selectedOperator = "5";
} else if (paymentMethodId == 86) {
selectedOperator = "4";
} else {
packageId = selectedPackageForTelco;
}
var transactionType = $("#type option:selected").val();
//JAZZCASH paymentmethodid =1 and EasyPay paymentmethodid=3
if (paymentMethodId == 74 && isWalletPayment) {
localStorage.setItem("jazzcashPackageId", selectedPackageForTelco);
if (msisdn.startsWith("92") && msisdn.length === 12) {
msisdn = "0" + msisdn.substring(2);
} else if (msisdn.startsWith("+92") && msisdn.length === 13) {
msisdn = "0" + msisdn.substring(3);
} else if (msisdn.startsWith("0092") && msisdn.length === 14) {
msisdn = "0" + msisdn.substring(4);
} else if (msisdn.startsWith("3") && msisdn.length === 10) {
msisdn = "0" + msisdn;
} else if (msisdn.startsWith("03") && msisdn.length === 11) {
msisdn = msisdn;
} else {
displayErrorNoty("Baraiy meharbani durust number enter karein.", !1, 1500);
return;
}
// if (msisdn.startsWith("92")) {
// msisdn = "0" + msisdn.substring(2);
// } else if (msisdn.startsWith("+92")) {
// msisdn = "0" + msisdn.substring(3);
// }
localStorage.setItem("jNumber", msisdn);
const urlParams = new URLSearchParams(window.location.search);
const app = urlParams.get('app');
if (app !== '' && app !== null) {
window.location.href = "/jazzCashRedirect/request?app=" + app;
} else {
window.location.href = "/jazzCashRedirect/request";
}
}
if (paymentMethodId == 73 && isWalletPayment) {
localStorage.setItem("easypaisaNumber", msisdn);
localStorage.setItem("easypaisaEmail", email);
doubleConfirmationForEasypaisa();
var id = $(".packages-subc").find("li.active").attr('data-id');
// window.location.href = "/verification?id=" + packageId + "&ep=1";
return;
}
if ((paymentMethodId == 74 || paymentMethodId == 73) && transactionType === "") {
displayWarningNoty("Please select type");
} else {
if (!userProfile) {
getUserProfile();
}
var loggedInUser;
if (userProfile && userProfile.msisdn && userProfile.msisdn != null) {
loggedInUser = userProfile.msisdn;
} else {
loggedInUser = userProfile.email;
}
var pin = $('#verification_code').val();
var app = "WEB";
// if (getParameterByName("src") == "MTA" || sessionStorage.getItem("referrer") == "MTA") {
// app = "MTA";
// }
}
}
}
processSubscriptionEPCMP(msisdn, email, packageId, paymentId, cnic, null, m);
}
function processSubscriptionEPCMP(msisdn, email, packageId, paymentId, cnic, pincode, m) {
var params = "mobileNo=" + msisdn + "&email=" + email + "&pkgId="
+ packageId + "&pmtId=" + paymentId + "&cnic=" + cnic + "&pincode=" + pincode +
"&opId=" + selectedOperator;
// var params = "pkgId=" + selectedPackage + "&pmtId=" + selectedPayment + "&opId=" + selectedOperator;
// $(".loader-generic").show();
$(".subscribeSubmit").attr("disabled", "disabled");
$(".subscribeSubmit").html(" Processing..");
$(".submitbutton").attr("disabled", "disabled");
$(".submitbutton").html(" Processing..");
$.ajax({
type: "POST",
url: "/api/user/subscribeEPCMP?siteid=",
data: params,
dataType: 'json'
}).done(function (response) {
$(".loader-generic").hide();
var loginFlowCheck = 0;
if (response.isSuccess) {
if (response.respCode == 777) {
window.location.href = response.respData.url;
}
loginFlowCheck = 1;
try {
firebaseObj.analytics().logEvent("subscribe", {
package: selectedPackageForTelco,
operator: selectedOperator,
description: "success"
});
} catch (er) {
}
logDBEvent("subscribe", "event", selectedPackageForTelco + "_success");
// logSubscriptionEvent("success");
/*
Tracking FB pixel
*/
var price;
var packageName = "";
if (packageId == '1') {
price = '10';
packageName = "Daily";
}
if (packageId == '2') {
price = '47.8';
packageName = "Weekly";
}
if (packageId == '3') {
price = '119.5';
packageName = "Monthly";
}
if (packageId == '10') {
packageName = "eWallets Premium";
price = '114.8';
}
try {
fbq('track', 'Subscribe', {value: price, currency: 'PKR', predicted_ltv: '0.00'});
} catch (er) {
// console.log("Error fb track subscribe" + er);
}
//fbq('track', 'Subscribe', {value: price, currency: 'PKR', predicted_ltv: '0.00'});
//end tracking
/*
Trigger Charged clevertap event
*/
// try {
//
// clevertap.event.push("Charged", {
// "Package Name": packageName,
// "Msisdn": response.respData.msisdn,
// "Operator": response.respData.operator,
// "Platform": "WEB"
//
// });
// } catch (er) {
// console.log("Error logging clevertap events" + er);
// }
/*
end trigger
*/
//SIM SIM PAYMENT
if (paymentMethodId == 75) {
if (response.isSuccess && response.respData) {
$("#otp_div").removeClass("hidden");
$("#msisdn").prop('disabled', true);
$("#continuePayment").addClass("hidden");
// $("#continueSimSimPayment").removeClass("hidden");
$(".btnConfirmSubscription").removeClass("submitbutton").addClass("confirmSimSimPayment");
displaySuccessNoty(response.msg);
simSimCustomerId = response.respData.model.data.customerId;
simSimCustomerName = response.respData.model.data.customerName;
simSimCustomerEmail = response.respData.model.data.email;
simSimToken = response.respData.model.data.token;
simSimTxnId = response.respData.model.txnID;
try {
firebaseObj.analytics().logEvent("simsim_subscribe_event", {description: response.respData.model.data.customerName});
logDBEvent("simsim_subscribe", "event", response.respData.model.data.customerName);
} catch (er) {
}
} else {
displayWarningNoty(response.msg);
}
} else {
$("#subcribemodal2").modal("hide");
displaySuccessNoty("Subscription " + response.msg, true, 3500);
if (sessionStorage.getItem("gpsub") && sessionStorage.getItem("gpsub") == "true") {
sessionStorage.setItem("gpsub", "");
gtag_report_conversion("");
}
// try {
// firebaseObj.analytics().logEvent("subscribe_user_event", {description: response.msg});
// } catch (er) {
// }
if (m === null || m === "") {
setTimeout(function () {
// window.location = "/home";
var path = window.location.pathname;
if (path == "/welcome" || path == "/payments" || path == "/verification") {
window.location.href = "/home";
} else {
window.location.href = path;
}
}, 3000);
}
}
} else {
loginFlowCheck = 0;
// logSubscriptionEvent("failed - " + response.msg);
try {
logEvent("subscription_failed", "subscription failed - " + response.msg);
} catch (er) {
}
logDBEvent("subscribe", "event", "failed");
$(".subcribemodal2").modal("hide");
displaySuccessNoty("Subscription " + response.msg, true, 2500);
}
$(".subscribeSubmit").removeAttr("disabled");
$(".subscribeSubmit").html("go bajao pro");
$(".submitbutton").removeAttr("disabled");
$(".submitbutton").html("go bajao pro");
$("#submit_pin").attr("disabled", false);
$("#submit_pin").html("submit");
if (m == 1) {
if (loginFlowCheck === 0) {
window.location.replace("https://bajaoapp.page.link/cuHZ");
} else {
window.location.replace("https://bajaoapp.page.link/cuHZ");
}
}
}).fail(function (error) {
logEvent("subscription_failed", "subscription failed due to network error.");
logDBEvent("subscribe", "event", "failed, subscription failed due to network error.");
$(".loader-generic").hide();
displayErrorNoty("Something went wrong", false, 1500);
$(".subscribeSubmit").removeAttr("disabled");
$(".subscribeSubmit").html("go bajao pro");
$(".submitbutton").removeAttr("disabled");
$(".submitbutton").html("go bajao pro");
$("#submit_pin").attr("disabled", false);
$("#submit_pin").html("submit");
if (m == 1) {
window.location.replace("https://bajaoapp.page.link/cuHZ");
}
}).always(function () {
$(".loader-generic").hide();
});
}
$(document).on("click", "#link_msisdn", function (e) {
e.preventDefault();
var msisdn = $('#msisdn_entered').val();
if (msisdn === "") {
msisdn = userProfile.msisdn;
}
var pin = $(".pincode").val();
if (pin == "" || pin.length < 3) {
var pinCode = $(".pincodebox");
var pin = "";
for (var i = 0; i < pinCode.length; i++) {
pin = pin + $(pinCode[i]).val();
}
}
if (pin.length > 3) {
// $(".loader-generic").show();
var params = "uuid=" + msisdn + "&pin=" + pin + "&pkg=" + selectedPackage + "&otpClientTitle=" + otpClientTitle;
$("#submit_pin").attr("disabled", true);
$("#submit_pin").html(" Processing..");
$.ajax({
type: 'POST',
url: '/api/linkMsisdnWithSocial?siteid=' + getParameterByName("siteid") + "&selOperator=" + loginSelOperator,
data: params,
dataType: "JSON"
}).done(function (response) {
if (response.isSuccess) {
try {
firebaseObj.analytics()
.logEvent("login", {msisdn: msisdn, status: "success", description: response.msg});
} catch (er) {
}
logDBEvent("login", "event", "success");
$("#verifyModal").modal("hide");
$("#thankyouModal").modal("show");
window.location.href = "/home";
} else {
try {
firebaseObj.analytics()
.logEvent("login", {msisdn: msisdn, status: "failed", description: response.msg});
} catch (er) {
}
logDBEvent("login", "event", "failed");
displayErrorNoty("Verification " + response.msg, false, 1500);
}
}).fail(function () {
logEvent("exception", "pin verification failed due to network error.");
}).always(function () {
$(".loader-generic").hide();
$("#submit_pin").attr("disabled", false);
$("#submit_pin").html("Continue");
});
} else {
displayErrorNoty("Baraiy meharbani darust PIN code enter karein.", false, 1500);
}
});
$(document).on("click", "#close-confirmation", function (e) {
document.getElementsByClassName('sub-confirmation-overlay')[0].style.display = 'none';
});
$(document).on("click", "#submit_pin_sub_sclick", function (e) {
e.preventDefault();
var msisdn = $('#msisdn_entered').val();
var pinCode = $(".pincodebox");
var pin = "";
for (var i = 0; i < pinCode.length; i++) {
pin = pin + $(pinCode[i]).val();
}
if (pin.length > 3) {
$("#finalPin").val(pin);
selectedPackage = $("#txtPkgPlan").val();
// $(".loader-generic").show();
// var params = "uuid=" + msisdn + "&pin=" + pin + "&pkg=" + selectedPackage + "&otpClientTitle=" + otpClientTitle;
var formParams = $("#pinSubForm");
$("#submit_pin_sub").attr("disabled", true);
$("#submit_pin_sub").html(" Processing..");
$.ajax({
type: 'POST',
url: '/user/confirmSubOtp?siteid=' + getParameterByName("siteid") + "&selOperator=" + loginSelOperator,
data: formParams.serialize(),
dataType: "JSON"
}).done(function (response) {
if (response.isSuccess) {
// if (isDoubleConfirmation) {
// subscribeUser();
// } else {
if (response.respCode == "01") {
// var path = window.location.pathname;
// if (path == "/welcome") {
logDBEvent("subscribed_via_campaign", "event", "success");
$("#thankyouModal").modal("show");
try {
firebaseObj.analytics()
.logEvent("subscribed_via_campaign", {
msisdn: msisdn,
status: "success",
description: response.msg
});
} catch (er) {
}
window.location.href = "/fav-artist";
} else if (response.respCode == "00" || response.respCode == "18") {
logDBEvent("subscribed_via_campaign", "event", "success");
$("#successMsg").html(response.msg);
$("#thankyouModal").modal("show");
try {
firebaseObj.analytics()
.logEvent("subscribed_via_campaign", {
msisdn: msisdn,
status: "success",
description: response.msg
});
} catch (er) {
}
/*setTimeout(function () {
window.location.href = "/home";
}, 1500);*/
} else {
displayErrorNoty("Verification " + response.msg, false, 1500);
}
// }
// }, 2000);
} else {
try {
firebaseObj.analytics()
.logEvent("subscribed_via_campaign", {
msisdn: msisdn,
status: "failed",
description: response.msg
});
} catch (er) {
}
logDBEvent("subscribed_via_campaign", "event", "failed");
displayErrorNoty("Verification " + response.msg, false, 1500);
}
}).fail(function () {
logEvent("exception", "pin verification failed due to network error.");
// displayErrorNoty("Network Error", true, 2000);
}).always(function () {
$(".loader-generic").hide();
$("#submit_pin_sub").attr("disabled", false);
$("#submit_pin_sub").html("SUBSCRIBE");
});
} else {
displayErrorNoty("Baraiy meharbani darust PIN code enter karein.", false, 1500);
}
});
$(document).on("click", "#submit_pin_sub", function (e) {
e.preventDefault();
var msisdn = $('#msisdn_entered').val();
var pinCode = $(".pincodebox");
var pin = "";
for (var i = 0; i < pinCode.length; i++) {
pin = pin + $(pinCode[i]).val();
}
if (pin.length > 3) {
$("#finalPin").val(pin);
selectedPackage = $("#txtPkgPlan").val();
// $(".loader-generic").show();
// var params = "uuid=" + msisdn + "&pin=" + pin + "&pkg=" + selectedPackage + "&otpClientTitle=" + otpClientTitle;
var formParams = $("#pinSubForm");
$("#submit_pin_sub").attr("disabled", true);
$("#submit_pin_sub").html(" Processing..");
$.ajax({
type: 'POST',
url: '/user/confirmSubOtp?siteid=' + getParameterByName("siteid") + "&selOperator=" + loginSelOperator,
data: formParams.serialize(),
dataType: "JSON"
}).done(function (response) {
if (response.isSuccess) {
// if (isDoubleConfirmation) {
// subscribeUser();
// } else {
if (response.respCode == "01") {
// var path = window.location.pathname;
// if (path == "/welcome") {
logDBEvent("subscribed_via_campaign", "event", "success");
$("#thankyouModal").modal("show");
try {
firebaseObj.analytics()
.logEvent("subscribed_via_campaign", {
msisdn: msisdn,
status: "success",
description: response.msg
});
} catch (er) {
}
window.location.href = "/fav-artist";
} else if (response.respCode == "00" || response.respCode == "18") {
logDBEvent("subscribed_via_campaign", "event", "success");
$("#successMsg").html(response.msg);
$("#thankyouModal").modal("show");
try {
firebaseObj.analytics()
.logEvent("subscribed_via_campaign", {
msisdn: msisdn,
status: "success",
description: response.msg
});
} catch (er) {
}
setTimeout(function () {
window.location.href = "/home";
}, 1500);
} else {
displayErrorNoty("Verification " + response.msg, false, 1500);
}
// }
// }, 2000);
} else {
try {
firebaseObj.analytics()
.logEvent("subscribed_via_campaign", {
msisdn: msisdn,
status: "failed",
description: response.msg
});
} catch (er) {
}
logDBEvent("subscribed_via_campaign", "event", "failed");
displayErrorNoty("Verification " + response.msg, false, 1500);
}
}).fail(function () {
logEvent("exception", "pin verification failed due to network error.");
// displayErrorNoty("Network Error", true, 2000);
}).always(function () {
$(".loader-generic").hide();
$("#submit_pin_sub").attr("disabled", false);
$("#submit_pin_sub").html("SUBSCRIBE");
});
} else {
displayErrorNoty("Baraiy meharbani darust PIN code enter karein.", false, 1500);
}
});
function loadArtistById(id, start, end) {
//// $(".loader-generic").show();
var params = "aId=" + id + "&sIndex=" + start + "&fIndex=" + end;
$.ajax({
type: 'POST',
url: '/api/artist/details?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
currentArtist = res.respData;
if ($("#pl-title").html().trim() === "") {
var thumbH = res.respData.thumbnailList ? res.respData.thumbnailList.horizontal : defaultThumb();
var thumbS = res.respData.thumbnailList ? res.respData.thumbnailList.square : defaultThumbSquare();
// $("#pl-main-div").css("background-image", "url('" + thumbH + "')");
$("#pl-title").html(res.respData.title);
$("#pl-title").removeClass("animated-background");
$("#pl-followers").html(res.respData.totalFollowers + " followers");
$("#pl-songs").html(res.respData.totalContent + (res.respData.totalContent === 1 ? " track" : " tracks"));
$(".pl-thumb").attr("src", thumbS);
}
} else {
// $("#pl-main-div").hide();
}
$(".loader-generic").hide();
}).fail(function (response) {
$(".loader-generic").hide();
// displayErrorNoty('Internal server error.', false, 1500);
}).always(function () {
// loadSimilarAlbums(id, type);
});
}
function loadContentByArtistId(id, start, end) {
//// $(".loader-generic").show();
isLoading = true;
var params = "aId=" + id + "&sIndex=" + start + "&fIndex=" + end;
$.ajax({
type: 'POST',
url: '/api/artist/content?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
if ($("#pl-title").html().trim() === "") {
// var thumbH = res.respData.thumbnailList ? res.respData.thumbnailList.horizontal : defaultThumb();
// var thumbS = res.respData.thumbnailList ? res.respData.thumbnailList.square : "/theme/images/default-square.jpg";
// $("#pl-main-div").css("background-image", "url('" + thumbH + "')");
// $("#pl-title").html(res.respData.title);
// $("#pl-followers").html(res.respData.followers + " followers");
// $("#pl-songs").html(res.respData.totalSongs + (playlists[j].totalContent === 1 ? " track": " tracks"));
// $(".pl-thumb").attr("src", thumbS);
}
var data = res.respData;
if ((data && data.length < 20) || res.respData.totalSongs <= 20) {
$("#moreArtistTd").parent().hide();
}
$.each(data, function (i, item) {
if (data[i]) {
var index = $.inArray(data[i].contentId, allalbumsongs);
if (index == -1) {
allalbumsongs.push(data[i].contentId);
}
var videoIcon;
if (data[i].videoId == 0) {
videoIcon = "hidden";
} else {
videoIcon = "videoToPlay";
}
var isIdPresent = false;
try {
var likedContent = userProfile.likedContentIdsMap;
var isIdPresent = likedContent ? likedContent[data[i].contentId] : false;
} catch (er) {
}
var thumb = data[i].thumbnailList.square ? data[i].thumbnailList.square : data[i].thumbnailList.square;
if (data.length == 1) {
$("#contentTale").addClass("show_overflow");
}
var proIcon = "hidden";
if (data[i].isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
if (isIdPresent) {
isContentLiked = true;
$(contentTableTemplateLiked({
artsitTitle: data[i].artistTitle,
contentThumb: thumb,
proIcon: proIcon,
id: data[i].contentId,
thumbWebp: thumb.replace(".jpg", ".webp"),
contentFile: "",
videoIcon: videoIcon,
albumTitle: data[i].albumTitle,
released: getReleasedYear(data[i].releasedDate),
isPlaying: "",
released: getReleasedYear(data[i].releasedDate),
duration: secondsTimeSpanToHMS(data[i].duration),
contentTitle: data[i].contentTitle,
link: "/song/" + data[i].contentId + "/" + data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
contextMenuUp: (data.length === (i + 1)) ? "contentMenuUp" : ""
})).data("content", data[i]).appendTo("#content-table");
$(".player_" + data[i].contentId).addClass("active").addClass("liked");
} else {
isContentLiked = false;
$(contentTableTemplate({
artsitTitle: data[i].artistTitle,
contentThumb: thumb,
id: data[i].contentId,
proIcon: proIcon,
thumbWebp: thumb.replace(".jpg", ".webp"),
contentFile: "",
videoIcon: videoIcon,
released: getReleasedYear(data[i].releasedDate),
albumTitle: data[i].albumTitle,
link: "/song/" + data[i].contentId + "/" + data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
isPlaying: "",
duration: secondsTimeSpanToHMS(data[i].duration),
contentTitle: data[i].contentTitle,
contextMenuUp: (data.length === (i + 1)) ? "contentMenuUp" : ""
})).data("content", data[i]).appendTo("#content-table");
}
}
});
$(".tab-loader").remove();
} else {
serverError++;
$(".animated-background").remove();
$(".tab-loader").html(res.msg);
// $("#pl-main-div").hide();
}
$(".loader-generic").hide();
}).fail(function (response) {
$(".loader-generic").hide();
serverError++;
// displayErrorNoty('Internal server error.', false, 1500);
}).always(function () {
isLoading = false;
// loadSimilarAlbums(id, type);
});
}
function loadAllSelectedGenres() {
//// $(".loader-generic").show();
var params = "";
$.ajax({
type: 'POST',
url: '/api/category/preSelGenres?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
}).fail(function (response) {
}).always(function (res) {
$(".loader-generic").hide();
var cats = [];
if (res && res.responseText) {
cats = res.responseText.split("|");
loadAllGenres(cats);
} else {
loadAllGenres([]);
}
});
}
function loadAllGenres(selCat) {
// $(".loader-generic").show();
var params = "";
$.ajax({
type: 'POST',
url: '/api/category/genres?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
$("#genres").html("");
var data = res.respData;
$.each(data, function (i, item) {
if (data[i]) {
$(genreCatgeoryTemplate({
categoryTitle: data[i].categoryTitle,
categoryId: data[i].categoryId,
})).data("content", data[i]).appendTo("#genres");
}
if (data[i].genres.length > 0) {
var subcat = data[i].genres;
var selGenres = "_";
for (var index in selCat) {
if (selCat[index].substring(0, selCat[index].indexOf("=")) == data[i].categoryId) {
selGenres = selCat[index].substring(selCat[index].indexOf("=")).replace("=", "_") + "_";
}
}
$.each(subcat, function (j, item) {
var selClass = "";
if (selGenres.indexOf("_" + subcat[j].id + "_") > -1) {
selClass = "active";
categorySelected(data[i].categoryId, subcat[j].id, "");
}
if (subcat[j]) {
$(genresTemplate({
categoryId: data[i].categoryId,
genreId: subcat[j].id,
selClass: selClass,
thumb: subcat[j].thumbnail,
genreTitle: subcat[j].title
})).data("content", subcat[j]).appendTo("#genre_" + data[i].categoryId);
}
});
}
$("#genre_" + data[i].categoryId).owlCarousel({
loop: false,
margin: 7,
touchDrag: false,
mouseDrag: false,
dots: false,
nav: false,
pagination: false,
responsive: {
0: {
items: 2,
},
480: {
items: 2,
},
600: {
items: 3,
},
700: {
items: 3,
},
768: {
items: 4,
},
1000: {
items: 4,
},
1024: {
items: 4,
},
1280: {
items: 5,
},
1600: {
items: 6,
}
}
});
});
setTimeout(function () {
var genreWidth = $("#genres .owl-item").width();
$("#genres .list-genre-height").css("min-height", genreWidth - 5 + "px");
getheight_genre();
}, 700);
} else {
}
$(".loader-generic").hide();
}).fail(function (response) {
$(".loader-generic").hide();
// displayErrorNoty('Internal server error.', false, 1500);
});
}
var likedArtistIds = [];
function getFavArtist(page) {
$.ajax({
type: 'POST',
url: '/api/user/getLikedList?siteid=' + getParameterByName("siteid"),
async: false
}).done(function (res) {
if (res.respCode == "00") {
var likedArtist = res.respData.artistFollowersCollection;
likedArtistIds = [];
favArtistIds = [];
$.each(likedArtist, function (i, item) {
likedArtistIds.push(likedArtist[i].artistId);
favArtistIds.push(likedArtist[i].artistId);
});
if ($("#allArtist").html() == "") {
loadAllArtsitToSelect(0, 40, page);
}
if ($("#recommendedArtistList").html() == "") {
loadAllRecommendedArtist(0, 40, page);
}
}
}).fail(function (response) {
// console.log('failed');
}).always(function () {
});
}
function loadAllArtsitToSelect(start, end, page) {
isLoading = true;
// $(".loader-generic").show();
var params = "sIndex=" + start + "&fIndex=" + end;
$.ajax({
type: 'POST',
url: '/api/artistToSelect/all?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
// $("#allArtist").html("");
if ($("#allArtist").html() !== "") {
var carousel = $('#allArtist').owlCarousel();
carousel.trigger('destroy.owl.carousel');
carousel.find('.owl-stage-outer').children().unwrap();
carousel.removeClass("owl-center owl-loaded owl-text-select-on");
}
// $('#allArtist').html("");
var data = res.respData;
$.each(data, function (i, item) {
if (data[i]) {
var isIdPresent = false;
try {
isIdPresent = likedArtistIds.includes(data[i].singerId === 0 ? data[i].starId : data[i].singerId);
} catch (er) {
}
var activeClass = "";
if (isIdPresent) {
activeClass = "active";
}
var thumb = data[i].thumbnailList ? data[i].thumbnailList.square : defaultThumbSquare();
$(allArtistTemplate({
title: data[i].title.substring(0, 15) + "..",
thumb: thumb.replace(".webp", ".jpg"),
activeClass: activeClass,
thumbWebp: thumb ? thumb.replace(".jpg", ".webp") : ""
})).data("content", data[i]).appendTo("#allArtist");
}
});
$('#allArtist').addClass("owl-carousel");
if (page == "modal") {
$("#allArtist").owlCarousel({
loop: false,
margin: 10,
dots: false,
nav: false,
touchDrag: false,
mouseDrag: false,
pagination: false,
responsive: {
0: {
items: 3,
margin: 10,
},
480: {
items: 3,
margin: 10,
},
600: {
items: 3,
margin: 15,
},
700: {
items: 3,
margin: 15,
},
768: {
items: 3,
},
1000: {
items: 3,
},
1024: {
items: 3,
},
1200: {
items: 3,
}
}
});
} else {
$("#allArtist").owlCarousel({
loop: false,
margin: 10,
dots: false,
nav: false,
touchDrag: false,
mouseDrag: false,
pagination: false,
responsive: {
0: {
items: 3,
margin: 10,
},
480: {
items: 3,
margin: 10,
},
600: {
items: 4,
margin: 15,
},
700: {
items: 4,
margin: 15,
},
768: {
items: 4,
},
1000: {
items: 4,
},
1024: {
items: 4,
},
1200: {
items: 6,
}
}
});
}
} else {
serverError++;
}
isLoading = false;
$(".loader-generic").hide();
}).fail(function (response) {
$(".loader-generic").hide();
// displayErrorNoty('Internal server error.', false, 1500);
});
}
function loadAllRecommendedArtist(start, end, page) {
// $(".loader-generic").show();
var params = "sIndex=" + start + "&fIndex=" + end;
$.ajax({
type: 'POST',
url: '/api/artist/recommended?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
$("#recommendedArtistList").html("");
var data = res.respData;
$.each(data, function (i, item) {
if (data[i]) {
var isIdPresent = false;
try {
isIdPresent = likedArtistIds.includes(data[i].singerId === 0 ? data[i].starId : data[i].singerId);
} catch (er) {
}
var activeClass = "";
if (isIdPresent) {
activeClass = "active";
}
var thumb = data[i].thumbnailList ? data[i].thumbnailList.square : defaultThumbSquare();
$(recommendedArtistTemplate({
title: data[i].title.substring(0, 15) + "..",
thumb: thumb.replace(".webp", ".jpg"),
activeClass: activeClass,
thumbWebp: thumb ? thumb.replace(".jpg", ".webp") : ""
})).data("content", data[i]).appendTo("#recommendedArtistList");
}
});
if (page == "modal") {
$("#recommendedArtistList").owlCarousel({
loop: false,
margin: 10,
dots: false,
nav: false,
pagination: false,
responsive: {
0: {
items: 3,
stagePadding: 40,
},
480: {
items: 3,
stagePadding: 40,
},
600: {
items: 3,
stagePadding: 40,
},
700: {
items: 3,
stagePadding: 40,
},
768: {
items: 3,
stagePadding: 40,
},
1000: {
items: 3,
stagePadding: 40,
},
1024: {
items: 3,
stagePadding: 40,
},
1200: {
items: 3,
stagePadding: 40,
}
}
});
} else {
$("#recommendedArtistList").owlCarousel({
loop: false,
margin: 10,
dots: false,
nav: false,
pagination: false,
responsive: {
0: {
items: 3,
stagePadding: 20,
margin: 10,
nav: false,
},
480: {
items: 3,
stagePadding: 30,
margin: 10,
nav: false,
},
600: {
items: 4,
stagePadding: 30,
margin: 10,
nav: false,
},
700: {
items: 4,
stagePadding: 20,
margin: 10,
nav: false,
},
768: {
items: 5,
stagePadding: 30,
nav: false,
},
1000: {
items: 5,
stagePadding: 30,
nav: false,
},
1024: {
items: 5,
stagePadding: 30,
nav: false,
},
1200: {
items: 7,
stagePadding: 30,
}
}
});
}
} else {
}
$(".loader-generic").hide();
}).fail(function (response) {
$(".loader-generic").hide();
// displayErrorNoty('Internal server error.', false, 1500);
});
}
function loadAllSearchedArtist(start, end, page, keyword) {
// $(".loader-generic").show();
var params = "sIndex=" + start + "&fIndex=" + end + "&keyword=" + keyword;
$.ajax({
type: 'POST',
url: '/api/artistToSelect/search?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
if ($("#searchedArtistList").html() && $("#searchedArtistList").html != "") {
$("#searchedArtistList").html("");
var carousel = $('#searchedArtistList').owlCarousel();
carousel.trigger('destroy.owl.carousel');
carousel.find('.owl-stage-outer').children().unwrap();
carousel.removeClass("owl-center owl-loaded owl-text-select-on");
}
var data = res.respData;
$.each(data, function (i, item) {
if (data[i]) {
var isIdPresent = false;
try {
var likedContent = userProfile.likedArtistIdsMap;
isIdPresent = likedContent ? likedContent[data[i].singerId === 0 ? content.starId : content.singerId] : false;
} catch (er) {
}
var activeClass = "";
if (isIdPresent) {
activeClass = "true";
}
var thumb = data[i].thumbnailList ? data[i].thumbnailList.square : defaultThumbSquare();
$(recommendedArtistTemplate({
title: data[i].title.substring(0, 15) + "..",
thumb: thumb.replace(".webp", ".jpg"),
activeClass: activeClass,
thumbWebp: thumb ? thumb.replace(".jpg", ".webp") : ""
})).data("content", data[i]).appendTo("#searchedArtistList");
}
});
if (page == "modal") {
$("#searchedArtistList").owlCarousel({
loop: false,
margin: 10,
dots: false,
nav: false,
pagination: false,
responsive: {
0: {
items: 3,
stagePadding: 40,
},
480: {
items: 3,
stagePadding: 40,
},
600: {
items: 3,
stagePadding: 40,
},
700: {
items: 3,
stagePadding: 40,
},
768: {
items: 3,
stagePadding: 40,
},
1000: {
items: 3,
stagePadding: 40,
},
1024: {
items: 3,
stagePadding: 40,
},
1200: {
items: 3,
stagePadding: 40,
}
}
});
} else {
$("#searchedArtistList").owlCarousel({
loop: false,
margin: 10,
dots: false,
nav: false,
pagination: false,
responsive: {
0: {
items: 3,
stagePadding: 20,
margin: 10,
nav: false,
},
480: {
items: 3,
stagePadding: 30,
margin: 10,
nav: false,
},
600: {
items: 4,
stagePadding: 30,
margin: 10,
nav: false,
},
700: {
items: 4,
stagePadding: 20,
margin: 10,
nav: false,
},
768: {
items: 5,
stagePadding: 30,
nav: false,
},
1000: {
items: 5,
stagePadding: 30,
nav: false,
},
1024: {
items: 5,
stagePadding: 30,
nav: false,
},
1200: {
items: 7,
stagePadding: 30,
}
}
});
}
} else {
}
$(".loader-generic").hide();
}).fail(function (response) {
$(".loader-generic").hide();
// displayErrorNoty('Internal server error.', false, 1500);
});
}
//var selectedcats;
function loadSelectedCategories() {
//// $(".loader-generic").show();
var params = "";
$.ajax({
type: 'POST',
url: '/api/selectedcats?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
}).fail(function (response) {
}).always(function (res) {
$(".loader-generic").hide();
loadAllCategories("_" + res.responseText + "_");
});
}
function loadAllCategories(selectedCats) {
//// $(".loader-generic").show();
var params = "";
$.ajax({
type: 'POST',
url: '/api/categories?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
$("#mainCats").html("");
$("#subCats").html("");
var data = res.respData;
$.each(data, function (i, item) {
if (data[i]) {
var hideClass = "hidden";
var activeClass = "";
if (data[i].subCategories.length > 0) {
hideClass = "";
}
var isSelected = "";
if (selectedCats.indexOf("_" + data[i].id + "_") > -1) {
isSelected = "mainCat-selected";
activeClass = "type-category" + (i + 1);
}
$(mainCategoriesTemplate({
title: data[i].title,
id: data[i].id,
activeClass: activeClass,
isSelected: isSelected,
mcatIndex: i + 1,
dropdown: hideClass,
thumb: data[i].thumbnail,
subCatId: "subCat" + data[i].id
})).data("content", data[i]).appendTo("#mainCats");
}
if (data[i].subCategories.length > 0) {
var subcat = data[i].subCategories;
$.each(subcat, function (j, item) {
if (subcat[j]) {
var subSelected = "";
var activeClass = "";
if (selectedCats.indexOf("_" + subcat[j].id + "_") > -1) {
subSelected = "subCat-selected";
activeClass = "type-category" + (j + 1);
}
$(subCategoriesTemplate({
title: subcat[j].title,
id: subcat[j].id,
activeClass: activeClass,
isSelected: subSelected,
mTitle: data[i].title,
scatIndex: j + 1,
thumb: subcat[j].thumbnailSquare
})).data("content", subcat[j]).appendTo("#subCat" + data[i].id + ", #subCats");
}
});
}
if (isSelected !== "") {
$("." + data[i].title).removeClass("hidden");
}
});
setTimeout(function () {
getheight_category();
}, 200);
} else {
}
$(".loader-generic").hide();
}).fail(function (response) {
$(".loader-generic").hide();
// displayErrorNoty('Internal server error.', false, 1500);
});
}
function loadRegionals() {
try {
if ($(".regionalsUl").html().trim() == "") {
var params = "";
$.ajax({
type: 'POST',
url: '/api/categories?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
var data = res.respData;
if ($(".regionalsUl").html().trim() == "") {
$.each(data, function (i, item) {
if (data[i].subCategories.length > 0 && i == 0) {
var subcat = data[i].subCategories;
var li = "";
// $.each(subcat, function (j, item) {
for (var j = subcat.length - 1; j >= 0; j--) {
if (subcat[j]) {
li = '' + subcat[j].title + ' ';
if (j > 0) {
li += '
';
} else {
li += '';
}
$(".regionalsUl").append(li);
}
}
// });
}
});
}
} else {
$(".regionals").hide();
}
}).fail(function (response) {
$(".regionals").hide();
});
}
} catch (er) {
}
}
function loadRegional(subcat, title) {
switchContent("showall/" + subcat + "/" + title);
}
function loadSimilarArtsit(id) {
//// $(".loader-generic").show();
var params = "aId=" + id;
$.ajax({
type: 'POST',
url: '/api/artist/similar?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
var data = res.respData;
$.each(data, function (i, item) {
if (data[i]) {
// console.log(data[i]);
var thumb = data[i].thumbnailList ? data[i].thumbnailList.square : "";
$(artistCarouselTemplate({
title: data[i].title,
link: "/artist/" + data[i].id + "/" + data[i].title.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb ? thumb.replace(".jpg", ".webp") : "",
sectionId: id
})).data("content", data[i]).appendTo("#simArtist");
}
});
$("#simArtist").owlCarousel({
loop: false,
margin: 10,
dots: true,
nav: true,
navText: [" ", " "],
pagination: false,
responsive: {
0: {
items: 3,
stagePadding: 25,
},
480: {
items: 3,
stagePadding: 25,
},
600: {
items: 4,
stagePadding: 30,
},
700: {
items: 4,
stagePadding: 30,
},
768: {
items: 4,
stagePadding: 30,
},
1000: {
items: 5,
stagePadding: 30,
},
1024: {
items: 5,
stagePadding: 30,
},
1200: {
items: 6,
stagePadding: 50,
},
1600: {
items: 6,
stagePadding: 50,
},
1920: {
items: 7,
stagePadding: 50,
}
}
});
$(".loader-generic").hide();
} else {
$("#similar-artists").hide();
$(".loader-generic").hide();
$("#btnSimArtsit").hide();
}
}).fail(function (response) {
$("#similar-artists").hide();
$(".loader-generic").hide();
$("#btnSimArtsit").hide();
// displayErrorNoty('Internal server error.', false, 1500);
});
}
function loadArtistAlbums(id) {
//// $(".loader-generic").show();
var params = "aId=" + id;
$.ajax({
type: 'POST',
url: '/api/artist/albums?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
var data = res.respData;
$.each(data, function (i, item) {
if (data) {
// if (i === 0) {
// $(artistLatestAlbumTemplate({
// thumb: data[i].thumbnailList.square,
// thumbWebp: data[i].thumbnailList.square.replace(".jpg", ".webp"),
// albumTitle: data[i].title,
// artistTitle: "",
// released: getReleasedYear(data[i].releasedDate)
// })).data("content", data[i]).appendTo(".latest-album");
// } else {
$(".artist-albums-").removeClass("hidden");
var count = data[i].totalContent + (data[i].totalContent === 1 ? " track" : " tracks");
var thumb = data[i].thumbnailList ? data[i].thumbnailList.square : defaultThumbSquare();
$(albumSquareCarouselTemplate({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: data[i].title,
contentId: data[i].id,
contentTitle: data[i].title.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
category: count,
sectionId: data[i].id
})).data("content", data[i]).appendTo("#artistAlbums");
// }
}
});
$("#artistAlbums").owlCarousel({
loop: false,
margin: 10,
dots: true,
nav: true,
navText: [" ", " "],
pagination: false,
responsive: {
0: {
items: 3,
stagePadding: 25,
},
480: {
items: 4,
stagePadding: 20,
},
600: {
items: 4,
stagePadding: 70,
},
700: {
items: 4,
stagePadding: 70,
},
768: {
items: 4,
stagePadding: 70,
},
1000: {
items: 5,
stagePadding: 70,
},
1024: {
items: 5,
stagePadding: 70,
},
1280: {
items: 6,
stagePadding: 70,
},
1600: {
items: 7,
stagePadding: 70,
},
1920: {
items: 8,
stagePadding: 70,
}
}
});
$(".loader-generic").hide();
} else {
$(".loader-generic").hide();
$("#latest-release").hide();
$("#btnLatestR").hide();
}
}).fail(function (response) {
$(".loader-generic").hide();
$("#latest-release").hide();
$("#btnLatestR").hide();
// displayErrorNoty('Internal server error.', false, 1500);
});
}
function loadAlbumByAlbumId(id) {
//// $(".loader-generic").show();
var params;
if (id) {
} else {
id = getParameterByName("id");
}
params = "id=" + id;
$.ajax({
type: 'POST',
url: '/api/albums/albumById?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res.respCode === "00" && res.respData !== null) {
var data = res.respData;
//if ($("#pl-title").html().trim() === "") {
currentAlbum = data;
// $("#pl-main-div").css("background-image", "url('" + data.thumbnailList.horizontal + "')");
$("#pl-title").html(data.title);
$("#pl-title").removeClass("animated-background");
$("#pl-followers").html(data.totalFollowers + " Followers");
$("#pl-songs").html(data.totalContent + (data.totalContent === 1 ? " track" : " tracks"));
$(".pl-thumb").attr("src", (data.thumbnailList.square).replace(".jpg", ".webp"));
$(".pl-thumb").attr("srcset", (data.thumbnailList.square).replace(".jpg", ".webp"));
$(".pl-thumb-webp").attr("srcset", (data.thumbnailList.square).replace(".jpg", ".webp"));
//}
}
$(".loader-generic").hide();
}).fail(function (response) {
$(".loader-generic").hide();
}).always(function () {
});
}
var allalbumsongs = [];
function loadContentByAlbumId(id, start, end) {
//// $(".loader-generic").show();
isLoading = true;
var params;
if (id) {
} else {
id = getParameterByName("id");
}
params = "id=" + id + "&sIndex=" + start + "&fIndex=" + end;
$.ajax({
type: 'POST',
url: '/api/albums/contentByAlbum?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res.respCode === "00" && res.respData !== null) {
//$("#content-table").html("");
var data = res.respData;
if ((data && data.length < 7)) {
$("#moreAlbumTd").parent().hide();
}
$.each(data, function (i, item) {
// if ($("#pl-title").html().trim() === "") {
currentAlbum = data[i];
// $("#pl-main-div").css("background-image", "url('" + data[i].thumbnailList.horizontal + "')");
// $("#pl-title").html(data[i].albumTitle);
// $("#pl-followers").html(data[i].totalFollowers + " Likes");
// $("#pl-songs").html(data[i].totalContent + (playlists[j].totalContent === 1 ? " track": " tracks"));
// $(".pl-thumb").attr("src", data[i].thumbnailList.square);
// $(".pl-thumb").attr("srcset", data[i].thumbnailList.square);
// $(".pl-thumb-webp").attr("srcset", (data[i].thumbnailList.square).replace(".jpg", ".webp"));
// }
if (data[i]) {
var index = $.inArray(data[i].contentId, allalbumsongs);
if (index == -1) {
allalbumsongs.push(data[i].contentId);
}
var videoIcon;
if (data[i].videoId == 0) {
videoIcon = "hidden";
} else {
videoIcon = "videoToPlay";
}
var likedContent = userProfile.likedContentIdsMap;
var isIdPresent = likedContent ? likedContent[data[i].contentId] : false;
var thumb = data[i].thumbnailList.square ? data[i].thumbnailList.square : data[i].thumbnailList.square;
if (data.length == 1) {
$("#contentTale").addClass("show_overflow");
}
var proIcon = "hidden";
if (data[i].isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
if (isIdPresent) {
isContentLiked = true;
$(contentTableTemplateLiked({
artsitTitle: data[i].artistTitle,
contentThumb: thumb,
id: data[i].contentId,
thumbWebp: thumb.replace(".jpg", ".webp"),
contentFile: "",
proIcon: proIcon,
videoIcon: videoIcon,
albumTitle: data[i].albumTitle,
released: getReleasedYear(data[i].releasedDate),
isPlaying: "",
duration: secondsTimeSpanToHMS(data[i].duration),
contentTitle: data[i].contentTitle,
link: "/song/" + data[i].contentId + "/" + data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
contextMenuUp: (data.length === (i + 1)) ? "contentMenuUp" : ""
})).data("content", data[i]).appendTo("#content-table");
$(".player_" + data[i].contentId).addClass("active").addClass("liked");
} else {
isContentLiked = false;
$(contentTableTemplate({
artsitTitle: data[i].artistTitle,
contentThumb: thumb,
id: data[i].contentId,
proIcon: proIcon,
thumbWebp: thumb.replace(".jpg", ".webp"),
contentFile: "",
videoIcon: videoIcon,
albumTitle: data[i].albumTitle,
released: getReleasedYear(data[i].releasedDate),
isPlaying: "",
duration: secondsTimeSpanToHMS(data[i].duration),
contentTitle: data[i].contentTitle,
link: "/song/" + data[i].contentId + "/" + data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
contextMenuUp: (data.length === (i + 1)) ? "contentMenuUp" : ""
})).data("content", data[i]).appendTo("#content-table");
}
}
});
$(".tab-loader").remove();
$(".loader-generic").hide();
// if (start == 0 && $("#simSongs").html().trim() == "") {
// if (window.location.href.indexOf("/song/") > -1) {
// loadSimilarSongsForWeb(getPathVariableByIndex(2), "FULLTRACK");
// } else {
// loadSimilarSongsForWeb(data[0].contentId, "FULLTRACK");
// }
// }
} else {
if (start == 0) {
if (res.respCode === "05") {
$(".tab-pane.in .weekly-content-show").html("");
$(".tab-pane.in .weekly-content-show").append("" + res.msg + "
");
}
}
$("#moretd, #moreAlbumTd").parent().hide();
$(".tab-loader").remove();
$(".loader-generic").hide();
// $("#pl-main-div").hide();
$(".loader-generic").hide();
serverError++;
}
}).fail(function (response) {
serverError++;
$(".loader-generic").hide();
// displayErrorNoty('Internal server error.', false, 1500);
}).always(function () {
isLoading = false;
// loadSimilarAlbums(getPathVariableByIndex(2), "ALBUM");
// loadTrendingAlbums(0, 20);
});
}
function loadSimilarAlbums(id, type) {
//// $(".loader-generic").show();
var params = "cId=" + id + "&cType=" + type;
$.ajax({
type: 'POST',
url: 'similarContent?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res.respCode === "00" && res.respData !== null) {
var data = res.respData;
$.each(data, function (i, item) {
if (data) {
var thumb = data[i].thumbnailList.square ? data[i].thumbnailList.square : data[i].thumbnailList.square;
$(albumCarouselTemplate({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: data[i].contentTitle,
category: data[i].releasedYear,
sectionId: "",
count: data[i].releasedYear
})).data("content", data[i]).appendTo("#simAlbums");
}
});
$("#simAlbums").owlCarousel({
loop: false,
margin: 10,
dots: false,
nav: true,
navText: [" ", " "],
pagination: false,
responsive: {
0: {
items: 2,
stagePadding: 50
},
480: {
items: 2,
stagePadding: 50
},
600: {
items: 2,
stagePadding: 100
},
700: {
items: 2,
stagePadding: 100
},
768: {
items: 4,
stagePadding: 100
},
1000: {
items: 4,
stagePadding: 100
},
1024: {
items: 4,
stagePadding: 100
},
1280: {
items: 4,
stagePadding: 100
},
1600: {
items: 6,
stagePadding: 100
}
}
});
$(".loader-generic").hide();
} else {
$("#similar-album").hide();
$(".loader-generic").hide();
}
}).fail(function (response) {
$("#similar-album").hide();
$(".loader-generic").hide();
// displayErrorNoty('Internal server error.', false, 1500);
});
}
function loadTrendingAlbums() {
//// $(".loader-generic").show();
$.ajax({
type: 'POST',
url: 'trendingAlbums?siteid=' + getParameterByName("siteid"),
dataType: "JSON"
}).done(function (res) {
if (res.respCode === "00" && res.respData !== null) {
var data = res.respData;
$.each(data, function (i, item) {
if (data) {
var count = data[i].totalContent + (data[i].totalContent === 1 ? " track" : " tracks");
var thumb = data[i].thumbnailList;
if (windowWidth > widthLimit) {
thumb = thumb && thumb.horizontal ? thumb.horizontal : defaultThumb();
} else {
thumb = thumb && thumb.mobileHorizontal ? thumb.mobileHorizontal : defaultThumb();
}
$(albumCarouselTemplate({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: data[i].albumTitle,
category: count,
sectionId: "",
count: count
})).data("content", data[i]).appendTo("#trendAlbums");
}
});
$("#trendAlbums").owlCarousel({
loop: false,
margin: 10,
dots: false,
nav: true,
navText: [" ", " "],
pagination: false,
responsive: {
0: {
items: 1,
stagePadding: 70
},
480: {
items: 1,
stagePadding: 70
},
600: {
items: 2,
stagePadding: 100
},
700: {
items: 2,
stagePadding: 100
},
768: {
items: 3,
stagePadding: 100
},
1000: {
items: 3,
stagePadding: 100
},
1024: {
items: 3,
stagePadding: 100
},
1280: {
items: 3,
stagePadding: 80
},
1600: {
items: 3,
stagePadding: 80
}
}
});
$(".loader-generic").hide();
} else {
$(".loader-generic").hide();
$("#trend-album").hide();
}
}).fail(function (response) {
$(".loader-generic").hide();
$("#trend-album").hide();
// displayErrorNoty('Internal server error.', false, 1500);
});
}
function likeAlbum() {
if ($(".title-user") && $(".title-user").html().trim() === "LOGIN") {
showLoginMenu();
} else {
// userProfile = "";
// console.log($(".like_album").attr("value"));
var action = "like";
try {
if ($(".like_album").find(".liked").length > 0) {
action = "unlike";
}
} catch (er) {
}
// $(".loader-generic").show();
var albumId = getPathVariableByIndex(2);
var params = "aId=" + albumId + "&pId=&cId=&artId=&action=" + action;
$.ajax({
type: 'POST',
url: '/api/content/like?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
logEvent("album_liked_unliked", albumId);
logDBEvent("album_liked_unliked", "event", albumId);
if (res) {
// getUserProfile();
// var likedContent = userProfile.likedAlbumIdsMap;
// var isIdPresent = likedContent[albumId];
var isLiked = "0";
if (action == "like") {
isLiked = "1";
// displaySuccessNoty("Album Liked", false, 1500);
$(".like_album").html(' ');
} else {
isLiked = "0"
// displaySuccessNoty("Album UnLiked", false, 1500);
$(".like_album").html(' ');
}
/**
* Trigger Like/Follow Artist, Playlist, Album clevertap event
*/
// try {
//
// clevertap.event.push("Like/Follow Artist, Playlist, Album", {
// "Like/UnLike": isLiked,
// "Album Id": albumId,
// "Platform": "WEB"
//
// });
// } catch (er) {
// console.log("Error logging clevertap events" + er);
// }
/**
* end trigger
*/
} else {
}
$(".loader-generic").hide();
}).fail(function (response) {
$(".loader-generic").hide();
displayErrorNoty('Kuch dair bad dobara koshish karein. Shukriya.', false, 1500);
});
}
}
function likeArtist() {
if ($(".title-user") && $(".title-user").html().trim() === "LOGIN") {
showLoginMenu();
} else {
// userProfile = "";
var action = "like";
try {
if ($(".like_album").find(".liked").length > 0) {
action = "unlike";
}
} catch (er) {
}
// $(".loader-generic").show();
var artistId = getPathVariableByIndex(2);
var params = "aId=&pId=&cId=&artId=" + artistId + "&action=" + action;
$.ajax({
type: 'POST',
url: '/api/content/like?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
logEvent("artist_liked_unliked", artistId);
logDBEvent("artist_liked_unliked", "event", artistId);
if (res) {
// getUserProfile();
// var likedContent = userProfile.likedArtistIdsMap;
// var isIdPresent = likedContent[artistId];
var isLiked = "0";
if (action == "like") {
isLiked = "1"
// displaySuccessNoty("Artist Liked", false, 1500);
$(".like_album").html(' ');
} else {
isLiked = "0"
// displaySuccessNoty("Artist UnLiked", false, 1500);
$(".like_album").html(' ');
}
/**
* Trigger Like/Follow Artist, Playlist, Album clevertap event
*/
// try {
//
// clevertap.event.push("Like/Follow Artist, Playlist, Album", {
// "Like/UnLike": isLiked,
// "Artist Id": artistId,
// "Platform": "WEB"
//
// });
// } catch (er) {
// console.log("Error logging clevertap events" + er);
// }
/**
* end trigger
*/
} else {
}
$(".loader-generic").hide();
}).fail(function (response) {
$(".loader-generic").hide();
displayErrorNoty('Kuch dair bad dobara koshish karein. Shukriya.', false, 1500);
});
}
}
function followAlbum() {
if ($(".title-user") && $(".title-user").html().trim() === "LOGIN") {
showLoginMenu();
} else {
$(".btnFollowArtist").prop("disabled", true);
var action = "follow";
try {
if ($(".btnFollowArtist").find(".followed").length > 0) {
action = "unfollow";
}
} catch (er) {
}
// $(".loader-generic").show();
userProfile = "";
// console.log('artistFollowed');
var artistId = getPathVariableByIndex(2);
var params = "aId=" + artistId + "&pId=&cId=&artId=&action=" + action;
//// $(".loader-generic").show();
$.ajax({
type: 'POST',
url: '/api/content/follow?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res.respCode === "00" && res.isSuccess) {
getUserProfile();
// var likedContent = res.respData.followedAlbumIds;
// var isIdPresent = likedContent[artistId];
var isFollow = "0";
if (action == "follow") {
isFollow = "1";
// displaySuccessNoty("Album Followed", false, 1500);
$(".btnFollowArtist").html(' Unfollow');
$(".btnFollowArtist").prop("disabled", false);
var currentText = $("#pl-followers").text();
var currentCount = currentText.split(" ");
$("#pl-followers").html(parseInt(currentCount[0]) + 1 + " followers");
} else {
isFollow = "0";
// displaySuccessNoty("Album UnFollowed", false, 1500);
$(".btnFollowArtist").html('Follow');
$(".btnFollowArtist").prop("disabled", false);
var currentText = $("#pl-followers").text();
var currentCount = currentText.split(" ");
$("#pl-followers").html(parseInt(currentCount[0]) - 1 + " followers");
}
/**
* Trigger Like/Follow Artist, Playlist, Album clevertap event
*/
// try {
//
// clevertap.event.push("Like/Follow Artist, Playlist, Album", {
// "Follow/UnFollow": isFollow,
// "Album Id": artistId,
// "Platform": "WEB"
//
// });
// } catch (er) {
// console.log("Error logging clevertap events" + er);
// }
/**
* end trigger
*/
} else {
}
}).fail(function (response) {
displayErrorNoty('Kuch dair bad dobara koshish karein. Shukriya.', false, 1500);
}).always(function () {
$(".loader-generic").hide();
});
}
}
function loadContentByGenres(id, start, end) {
//// $(".loader-generic").show();
isLoading = true;
var params = "mainCats=" + id + "&sIndex=" + start + "&fIndex=" + end;
$.ajax({
type: 'POST',
url: '/api/genre/content?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
isLoading = false;
if (res.respCode === "00" && res.respData !== null) {
var data = res.respData;
$.each(data, function (i, item) {
if (data) {
var thumb = data[i].thumbnailList ? data[i].thumbnailList.square : data[i].thumbnailList.square;
var disabled = "";
if (data[i].contentId == 0) {
disabled = "disabled-div";
}
var proIcon = "hidden";
if (data[i].isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
$(simContentCarouselTemplate({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb ? thumb.replace(".jpg", ".webp") : "",
title: data[i].contentTitle,
released: data[i].releasedYear,
contentId: data[i].contentId,
contentTitle: data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
sectionId: "",
proIcon: proIcon,
likeId: "like" + data[i].contentId,
album: data[i].albumTitle ? data[i].albumTitle : secondsTimeSpanToHMS(data[i].duration),
artist: data[i].artistTitle
})).data("content", data[i]).addClass(disabled).appendTo("#simVideos");
}
});
$(".playSimContent").addClass("contentToPlay").removeClass("playSimContent");
$(".loader-generic").hide();
} else {
serverError++;
$("#similar-album").hide();
$(".loader-generic").hide();
}
}).fail(function (response) {
isLoading = false;
$("#similar-album").hide();
$(".loader-generic").hide();
// displayErrorNoty("Internal server error.", false, 1500);
});
}
function loadContentByMood(id, start, end) {
//// $(".loader-generic").show();
isLoading = true;
var params = "mood=" + id + "&sIndex=" + start + "&fIndex=" + end;
$.ajax({
type: 'POST',
url: '/api/mood/content?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
isLoading = false;
if (res.respCode === "00" && res.respData !== null) {
var data = res.respData;
$.each(data, function (i, item) {
if (data) {
var thumb = data[i].thumbnailList ? data[i].thumbnailList.square : data[i].thumbnailList.square;
var disabled = "";
if (data[i].contentId == 0) {
disabled = "disabled-div";
}
var proIcon = "hidden";
if (data[i].isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
$(simContentCarouselTemplate({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb ? thumb.replace(".jpg", ".webp") : "",
title: data[i].contentTitle,
released: getReleasedYear(data[i].releasedDate),
sectionId: "",
proIcon: proIcon,
contentId: data[i].contentId,
contentTitle: data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
likeId: "like" + data[i].contentId,
album: data[i].albumTitle ? data[i].albumTitle : secondsTimeSpanToHMS(data[i].duration),
artist: data[i].artistTitle
})).data("content", data[i]).addClass(disabled).appendTo("#simVideos");
}
});
$(".playSimContent").addClass("contentToPlay").removeClass("playSimContent");
$(".loader-generic").hide();
} else {
serverError++;
$("#similar-album").hide();
$(".loader-generic").hide();
}
}).fail(function (response) {
isLoading = false;
$("#similar-album").hide();
$(".loader-generic").hide();
// displayErrorNoty("Internal server error.", false, 1500);
});
}
function loadRecommendedContentForHome() {
// //// $(".loader-generic").show();
$.ajax({
type: 'POST',
url: 'recommendedContent?siteid=' + getParameterByName("siteid"),
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
var data = res.respData[0].contentIds;
$.each(data, function (i, item) {
if (data[i].respData) {
$(smallBannersTemplate({
thumb: data[i].respData.thumbnailList.horizontal,
thumbWebp: data[i].respData.thumbnailList.horizontal.replace(".jpg", ".webp")
})).data("content", data[i]).appendTo("#allproduct-sh-main");
}
});
$("#allproduct-sh-main").owlCarousel({
loop: true,
margin: 10,
autoplayTimeout: 3000,
autoplay: true,
dots: false,
stagePadding: 90,
nav: false,
pagination: false,
responsive: {
0: {
items: 1,
center: true
},
480: {
items: 1,
center: true
},
700: {
items: 2,
center: true
},
768: {
items: 2
},
1200: {
items: 3
},
1600: {
items: 2,
stagePadding: 260
}
}
});
} else {
}
}).fail(function (response) {
// displayErrorNoty("Internal server error.", false, 1500);
});
}
function lazyLoadSections() {
// console.log($(window).scrollTop());
// console.log($(".banner-wrap-on")[0].scrollHeight);
var scrollTopLimit = 200;
if (isMobile) {
scrollTopLimit = 0;
}
if (($(window).scrollTop() >= scrollTopLimit) && !isLoading) {
// loadAllSectionWithContent("home", $(".homesection").length, 20);
}
if (getParameterByName("mood") && getParameterByName("mood") !== "") {
if (($(window).innerHeight() + $(window).scrollTop() + 100) >= ($("#simVideos")[0].scrollHeight) && !isLoading && serverError < 2) {
isLoading = true;
loadContentByMood(getParameterByName("mood"), $(".default-img-similar").length + 1, 20);
}
} else if (getParameterByName("mainCats") && getParameterByName("mainCats") !== "") {
if (($(window).innerHeight() + $(window).scrollTop() + 100) >= ($("#simVideos")[0].scrollHeight) && !isLoading && serverError < 2) {
isLoading = true;
loadContentByGenres(getParameterByName("mainCats"), $(".default-img-similar").length + 1, 20);
}
} else if (getPathVariableByIndex(1) == "showall") {
if (($(window).innerHeight() + $(window).scrollTop() + 100) >= ($("#simVideos")[0].scrollHeight) && !isLoading && serverError < 2) {
isLoading = true;
if (getPathVariableByIndex(3) == "artists") {
loadAllArtists($(".default-img-similar").length + 1, 20);
} else if (getPathVariableByIndex(3) == "albums") {
loadTrendingAlbums($(".default-img-similar").length + 1, 20);
} else if (getPathVariableByIndex(3) == "sections") {
loadSectionAllContent(getPathVariableByIndex(2), $(".default-img-similar").length + 1, 20);
} else {
// loadRegionalAllContent(getPathVariableByIndex(2), $(".default-img-similar").length + 1, 20);
loadRegionalAllSubCategoryContent(getPathVariableByIndex(2), $(".default-img-similar").length + 1, 20);
}
getheight_all();
}
} else if (getPathVariableByIndex(1) == "artist" || getPathVariableByIndex(1) == "artistTab") {
if (($(window).innerHeight() + $(window).scrollTop() + 100) >= ($("#contentTale")[0].scrollHeight) && !isLoading && serverError < 2) {
isLoading = true;
loadContentByArtistId(getPathVariableByIndex(2), $("#contentTale .single-album-playlist").length + 1, 20);
}
} else if (getPathVariableByIndex(1) == "song" || getPathVariableByIndex(1) == "album" || getPathVariableByIndex(1) == "albumTab") {
if (($(window).innerHeight() + $(window).scrollTop() + 100) >= ($("#contentTale")[0].scrollHeight) && !isLoading && serverError < 2) {
isLoading = true;
var id = getPathVariableByIndex(2);
if ($("#currentAlbumId") && $("#currentAlbumId").val()) {
id = $("#currentAlbumId").val();
}
loadContentByAlbumId(id, $("#contentTale .single-album-playlist").length + 1, 7);
}
}
try {
if (isMobile) {
if ($(window).scrollTop() < 70) {
var frame = $("body").find("iframe")[2];
$(frame).show(200);
} else {
var frame = $("body").find("iframe")[2];
$(frame).hide(200);
}
}
// if ($(window).scrollTop() >= 10) {
// $('.gettapp-tophead').addClass('hidden');
// $(".main-wrap").animate({top: 0}, 300);
// } else {
// $('.gettapp-tophead').removeClass('hidden');
// $(".main-wrap").animate({top: 61}, 300);
// }
} catch (er) {
}
}
function loadRecommendedContentForHome() {
// //// $(".loader-generic").show();
$.ajax({
type: 'POST',
url: 'recommendedContent?siteid=' + getParameterByName("siteid"),
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
var data = res.respData[0].contentIds;
$.each(data, function (i, item) {
if (data[i].respData) {
$(smallBannersTemplate({
thumb: data[i].respData.thumbnailList.horizontal,
thumbWebp: data[i].respData.thumbnailList.horizontal.replace(".jpg", ".webp")
})).data("content", data[i]).appendTo("#allproduct-sh-main");
}
});
$("#allproduct-sh-main").owlCarousel({
loop: true,
margin: 10,
autoplayTimeout: 3000,
autoplay: true,
dots: false,
stagePadding: 90,
nav: false,
pagination: false,
responsive: {
0: {
items: 1,
center: true
},
480: {
items: 1,
center: true
},
700: {
items: 2,
center: true
},
768: {
items: 2
},
1200: {
items: 3
},
1600: {
items: 2,
stagePadding: 260
}
}
});
} else {
}
}).fail(function (response) {
// displayErrorNoty("Internal server error.", false, 1500);
});
}
function bannerRatingClicked(rating) {
// console.log(rating);
displaySuccessNoty("Processing", false, 1500);
}
function loadTabSectionContent(type, start, end) {
//// $(".loader-generic").show();
var params = "secType=" + type + "&sIndex=" + start + "&fIndex=" + end;
$.ajax({
type: 'POST',
url: '/api/user/content?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
var data = res.respData;
if ((data && data.length < 50)) {
$("." + type).parent().hide();
}
$("#" + type).empty();
$.each(data, function (i, item) {
// console.log(data[i]);
if (data[i]) {
var videoIcon;
if (data[i].videoId == 0) {
videoIcon = "hidden";
} else {
videoIcon = "videoToPlay";
}
var thumb = data[i].thumbnailList.square ? data[i].thumbnailList.square : data[i].thumbnailList.square;
var likedContent = userProfile.likedContentIdsMap;
var isIdPresent = likedContent ? likedContent[data[i].contentId] : false;
var thumb = data[i].thumbnailList.square ? data[i].thumbnailList.square : data[i].thumbnailList.square;
if (data.length == 1) {
$("#contentTable" + type).addClass("show_overflow");
}
var proIcon = "hidden";
if (data[i].isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
if (isIdPresent) {
isContentLiked = true;
$(contentTableTemplateLiked({
artsitTitle: data[i].artistTitle,
contentThumb: thumb,
id: data[i].contentId,
proIcon: proIcon,
thumbWebp: thumb.replace(".jpg", ".webp"),
contentFile: "",
videoIcon: videoIcon,
albumTitle: data[i].albumTitle,
released: getReleasedYear(data[i].releasedDate),
isPlaying: "",
duration: secondsTimeSpanToHMS(data[i].duration),
contentTitle: data[i].contentTitle,
link: (data[i].contentType != "VIDEO" ? "/song/" : "/video/") + data[i].contentId + "/" + data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
contextMenuUp: (data.length === (i + 1)) ? "contentMenuUp" : ""
})).data("content", data[i]).appendTo("#" + type);
$(".player_" + data[i].contentId).addClass("active").addClass("liked");
} else {
isContentLiked = false;
$(contentTableTemplate({
artsitTitle: data[i].artistTitle,
contentThumb: thumb,
id: data[i].contentId,
thumbWebp: thumb.replace(".jpg", ".webp"),
contentFile: "",
proIcon: proIcon,
videoIcon: videoIcon,
albumTitle: data[i].albumTitle,
released: getReleasedYear(data[i].releasedDate),
isPlaying: "",
duration: secondsTimeSpanToHMS(data[i].duration),
contentTitle: data[i].contentTitle,
link: (data[i].contentType != "VIDEO" ? "/song/" : "/video/") + data[i].contentId + "/" + data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
contextMenuUp: (data.length === (i + 1)) ? "contentMenuUp" : ""
})).data("content", data[i]).appendTo("#" + type);
}
}
});
} else {
if ("" + start == '0') {
$("#" + type).html("" + res.msg + " ");
displayWarningNoty(res.msg, false, 1500);
$("." + type).parent().hide();
}
}
$(".loader-generic").hide();
}).fail(function (response) {
$(".loader-generic").hide();
Noty.closeAll();
if ("" + start == '0') {
$("#" + type).append("No more content Available ");
$("." + type).parent().hide();
}
// displayErrorNoty("Internal server error.", false, 1500);
});
}
function loadPlayListSection() {
// $(".loader-generic").show();
$.ajax({
type: 'POST',
url: '/api/user/playlist?siteid=' + getParameterByName("siteid"),
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null && res.respData.length > 0) {
var data = res.respData;
var carousel = $('#MYLIST').owlCarousel();
carousel.trigger('destroy.owl.carousel');
carousel.find('.owl-stage-outer').children().unwrap();
carousel.removeClass("owl-center owl-loaded owl-text-select-on");
$('#MYLIST').html("");
$('.SomeClass:contains("SomeText")').length > 0
$.each(data, function (i, item) {
if (data[i]) {
var thumb = data[i].thumbnail ? data[i].thumbnail : defaultThumbSquare();
$("#MYLIST").prepend($(myPlaylistCarouselTemplate({
name: data[i].name,
thumb: thumb.replace(".webp", ".jpg"),
count: data[i].contentCount,
playlistId: 'pl_' + data[i].id,
})).data("content", data[i]));
}
});
$('#MYLIST').addClass("owl-carousel");
$("#MYLIST").owlCarousel({
loop: false,
margin: 14,
touchDrag: false,
mouseDrag: false,
dots: false,
nav: false,
pagination: false,
responsive: {
0: {
items: 1,
},
480: {
items: 1,
},
600: {
items: 1,
},
700: {
items: 1,
},
768: {
items: 4,
},
1000: {
items: 5,
},
1024: {
items: 5,
},
1200: {
items: 5,
},
1600: {
items: 6,
},
1920: {
items: 7,
}
}
});
setTimeout(function () {
$(".li-create-newlist").width($(".myplaylistToOpen").width() + "px");
$(".li-create-newlist").height($(".myplaylistToOpen").height() + "px");
}, 500);
$(".loader-generic").hide();
} else {
$("#MYLIST").removeClass("owl-carousel");
$("#MYLIST").html("Mazeed Playlists k liye Home page visit karein.
");
$(".loader-generic").hide();
}
}).fail(function (response) {
$("#MYLIST").removeClass("owl-carousel");
$("#MYLIST").html("Mazeed Playlists k liye Home page visit karein.
");
$(".loader-generic").hide();
});
}
// "secType", required = false) String type,
// @RequestParam(value = "sIndex", required = false, defaultValue = "0") String sIndex,
// @RequestParam(value = "fIndex",
function loadUserFollowedSection(type, start, end) {
// $(".loader-generic").show();
var params = "secType=" + type.replace("F_", "") + "&sIndex=" + start + "&fIndex=" + end;
$.ajax({
type: 'POST',
url: '/api/user/followed?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null && res.respData.length > 0) {
var data = res.respData;
var carousel = $("#" + type).owlCarousel();
carousel.trigger('destroy.owl.carousel');
carousel.find('.owl-stage-outer').children().unwrap();
carousel.removeClass("owl-center owl-loaded owl-text-select-on");
$("#" + type).html("");
$.each(data, function (i, item) {
if (data[i]) {
var thumb = data[i].thumbnailList.square ? data[i].thumbnailList.square : (data[i].playlistImageSquare ? data[i].playlistImageSquare : defaultThumbSquare());
$(myFollowedListCarouselTemplate({
name: data[i].title,
type: type.replace("F_", ""),
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
count: data[i].totalContent,
playlistId: 'pl_' + data[i].id,
})).data("content", data[i]).appendTo("#" + type);
}
});
$("#" + type).addClass("owl-carousel");
$("#" + type).owlCarousel({
loop: false,
margin: 14,
touchDrag: false,
mouseDrag: false,
dots: false,
nav: false,
pagination: false,
responsive: {
0: {
items: 1,
},
480: {
items: 1,
},
600: {
items: 1,
},
700: {
items: 1,
},
768: {
items: 4,
},
1000: {
items: 5,
},
1024: {
items: 5,
},
1200: {
items: 5,
},
1600: {
items: 6,
},
1920: {
items: 7,
},
}
});
$(".loader-generic").hide();
$("#" + type).removeClass("owl-hidden");
} else {
$("#" + type).removeClass("owl-carousel");
$("#" + type + " .mymusicempty-content").removeClass("hidden");
// $("#" + type).html("" + res.msg + "
");
displayWarningNoty(res.msg, false, 1500);
$(".loader-generic").hide();
}
}).fail(function (response) {
$("#" + type).removeClass("owl-carousel")
$("#" + type).html("No Content to show.
");
$(".loader-generic").hide();
});
}
function loadPlayListContentById(id) {
//// $(".loader-generic").show();
var params = "id=" + id;
$.ajax({
type: 'POST',
url: '/api/user/playlist/content?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
var data = res.respData;
$("#pl-title").html(getPathVariableByIndex(3));
$("#pl-followers").hide();
$("#pl-songs").html(getParameterByName("count") + (getParameterByName("count") === 1 ? " track" : " tracks"));
// loadSimilarSongsForWeb(data[0].contentId, "FULLTRACK");
$.each(data, function (i, item) {
if (data[i]) {
var index = $.inArray(data[i].contentId, allalbumsongs);
if (index == -1) {
allalbumsongs.push(data[i].contentId);
}
var videoIcon;
if (data[i].videoId == 0 && data[i].contentType == 'FULLTRACK') {
videoIcon = "hidden";
} else {
videoIcon = "videoToPlay";
}
// console.log('playlist');
var likedContent = userProfile.likedContentIdsMap;
var isIdPresent = likedContent ? likedContent[data[i].contentId] : false;
var thumb = data[i].thumbnailList.square ? data[i].thumbnailList.square : data[i].thumbnailList.square;
if (i === 0) {
$(".pl-thumb").attr("src", thumb);
$(".pl-thumb").attr("srcset", thumb);
}
// console.log('contentIds');
if (data.length == 1) {
$("#contentTale").addClass("show_overflow");
}
var proIcon = "hidden";
if (data[i].isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
if (isIdPresent) {
isContentLiked = true;
$(contentTableTemplateLiked({
artsitTitle: data[i].artistTitle,
contentThumb: thumb,
id: data[i].contentId,
thumbWebp: thumb.replace(".jpg", ".webp"),
contentFile: "",
proIcon: proIcon,
videoIcon: videoIcon,
albumTitle: data[i].albumTitle,
released: getReleasedYear(data[i].releasedDate),
isPlaying: "",
duration: secondsTimeSpanToHMS(data[i].duration),
contentTitle: data[i].contentTitle,
link: "/song/" + data[i].contentId + "/" + data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
contextMenuUp: (data.length === (i + 1)) ? "contentMenuUp" : ""
})).data("content", data[i]).appendTo("#content-table");
$(".player_" + data[i].contentId).addClass("active").addClass("liked");
} else {
isContentLiked = false;
$(contentTableTemplate({
artsitTitle: data[i].artistTitle,
contentThumb: data[i].thumbnailList.square,
id: data[i].contentId,
thumbWebp: data[i].thumbnailList.square.replace(".jpg", ".webp"),
contentFile: "",
proIcon: proIcon,
videoIcon: videoIcon,
albumTitle: data[i].albumTitle,
released: getReleasedYear(data[i].releasedDate),
isPlaying: "",
duration: secondsTimeSpanToHMS(data[i].duration),
contentTitle: data[i].contentTitle,
link: "/song/" + data[i].contentId + "/" + data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
contextMenuUp: (data.length === (i + 1)) ? "contentMenuUp" : ""
})).data("content", data[i]).appendTo("#content-table");
}
}
});
$(".tab-loader").remove();
$(".loader-generic").hide();
$(".btnRemoveFromPlaylist").removeClass("hidden");
$(".addContentToPlaylist").addClass("hidden");
} else {
$("#pl-title").html("No Content to Show.");
$("#pl-followers").hide();
$("#pl-songs").html("0 Songs");
// $("#pl-main-div").hide();
$(".loader-generic").hide();
$("#trend-album").css("margin-top", "75px");
}
}).fail(function (response) {
$(".loader-generic").hide();
$("#pl-main-div").hide();
$("#trend-album").css("margin-top", "75px");
// displayErrorNoty("Internal server error.", false, 1500);
}).always(function () {
// loadSimilarAlbums(id, type);
// loadTrendingAlbums(0, 20);
});
}
var recom;
function loadRecommendedContent() {
$.ajax({
type: 'POST',
url: '/api/home/recommendation?siteid=' + getParameterByName("siteid"),
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
$("#topTabs").html("");
$("#tabContent").html("");
$("#pl-title").html("Made For You");
$("#pl-followers").hide();
$("#pl-songs").html("10 Songs");
var respData = res.respData[0].playLists;
recom = respData;
$.each(respData, function (j, item) {
var dataObj = respData[j].dataList;
var activeTab = "active in";
if (j == 0) {
activeTab = "active in";
} else {
activeTab = "";
}
$("#topTabs").append(' ' + respData[j].title + ' ');
$(recomContentTemplate({
activeTab: activeTab,
tabId: "tab_" + j,
tabHeading: respData[j].title,
tabTableId: "contentTable_" + j,
})).data("content", respData[j]).appendTo("#tabContent");
$.each(dataObj, function (i, item) {
var data = dataObj[i].data;
if (data) {
var index = $.inArray(data.contentId, allalbumsongs);
if (index == -1) {
allalbumsongs.push(data.contentId);
}
var videoIcon;
if (data.videoId == 0 && data.contentType == 'FULLTRACK') {
videoIcon = "hidden";
} else {
videoIcon = "videoToPlay";
}
// console.log('playlist');
var likedContent = userProfile.likedContentIdsMap;
var isIdPresent = likedContent ? likedContent[data.contentId] : false;
var thumb = data.thumbnailList.square ? data.thumbnailList.square : data.thumbnailList.square;
if (i === 0) {
$(".pl-thumb").attr("src", thumb);
$(".pl-thumb").attr("srcset", thumb);
}
// if (data.length == 1) {
// $("#contentTale").addClass("show_overflow");
// }
var proIcon = "hidden";
if (data.isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
if (isIdPresent) {
isContentLiked = true;
$(contentTableTemplateLiked({
artsitTitle: data.artistTitle,
contentThumb: thumb,
id: data.contentId,
thumbWebp: thumb.replace(".jpg", ".webp"),
contentFile: "",
proIcon: proIcon,
videoIcon: videoIcon,
albumTitle: data.albumTitle,
released: getReleasedYear(data.releasedDate),
isPlaying: "",
duration: secondsTimeSpanToHMS(data.duration),
contentTitle: data.contentTitle,
link: "/song/" + data.contentId + "/" + data.contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
contextMenuUp: (data.length === (i + 1)) ? "contentMenuUp" : ""
})).data("content", data).appendTo("#contentTable_" + j);
$(".player_" + data.contentId).addClass("active").addClass("liked");
} else {
isContentLiked = false;
$(contentTableTemplate({
artsitTitle: data.artistTitle,
contentThumb: data.thumbnailList.square,
id: data.contentId,
thumbWebp: data.thumbnailList.square.replace(".jpg", ".webp"),
contentFile: "",
proIcon: proIcon,
videoIcon: videoIcon,
albumTitle: data.albumTitle,
released: getReleasedYear(data.releasedDate),
isPlaying: "",
duration: secondsTimeSpanToHMS(data.duration),
contentTitle: data.contentTitle,
link: "/song/" + data.contentId + "/" + data.contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
contextMenuUp: (data.length === (i + 1)) ? "contentMenuUp" : ""
})).data("content", data).appendTo("#contentTable_" + j);
}
}
});
});
$(".tab-loader").remove();
$(".loader-generic").hide();
$(".weekly-de-title").hide();
} else {
$("#pl-title").html("No Content to Show.");
$("#pl-followers").hide();
$("#pl-songs").html("0 Songs");
// $("#pl-main-div").hide();
$(".loader-generic").hide();
$("#trend-album").css("margin-top", "75px");
}
}).fail(function (response) {
$(".loader-generic").hide();
$("#pl-main-div").hide();
$("#trend-album").css("margin-top", "75px");
// displayErrorNoty("Internal server error.", false, 1500);
}).always(function () {
// loadSimilarAlbums(id, type);
// loadTrendingAlbums(0, 20);
});
}
function loadPlaylistInfo(id, type) {
//// $(".loader-generic").show();
var params = "plId=" + id + "&contentType=" + type;
$.ajax({
type: 'POST',
url: '/api/playlistInfo',
data: params,
dataType: "JSON"
}).done(function (res) {
if (res.respCode === "00" && res.respData) {
currentPlaylist = res.respData;
}
}).fail(function (response) {
$(".loader-generic").hide();
// $("#pl-main-div").hide();
// $("#trend-album").css("margin-top", "75px");
// displayErrorNoty("Internal server error.", false, 1500);
}).always(function () {
// loadSimilarAlbums(id, type);
// loadTrendingAlbums(0, 20);
});
}
function loadPlaylistSectionContentById(id, type) {
//// $(".loader-generic").show();
var params = "plId=" + id + "&contentType=" + type;
$.ajax({
type: 'POST',
url: '/api/playlist/contentByPlaylist?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res.respCode === "00" && res.respData && res.respData.length > 0) {
var data = res.respData;
try {
var thumb = currentPlaylist.thumbnailList.square ? currentPlaylist.thumbnailList.square : (currentPlaylist.playlistImageSquare) ? currentPlaylist.playlistImageSquare : (data[0].thumbnailList.square ? data[0].thumbnailList.square : data[0].thumbnailList.square);
// $("#pl-main-div").css("background-image", "url('" + thumb + "')");
$("#pl-title").html(currentPlaylist.title);
var follwers = currentPlaylist.totalFollowers ? currentPlaylist.totalFollowers : "9";
$("#pl-followers").html(follwers + " Followers");
$("#pl-songs").html(currentPlaylist.totalContent + (currentPlaylist.totalContent === 1 ? " track" : " tracks"));
$(".pl-thumb").attr("src", thumb);
$(".pl-thumb").attr("srcset", thumb);
$(".pl-thumb-webp").attr("srcset", (thumb).replace(".jpg", ".webp"));
} catch (er) {
var thumb = data[0].thumbnailList.square ? data[0].thumbnailList.square : data[0].thumbnailList.square;
// $("#pl-main-div").css("background-image", "url('" + thumb + "')");
$("#pl-title").html(getPathVariableByIndex(3));
var follwers = 100;
$("#pl-followers").html(follwers + " Followers");
$("#pl-songs").html(data.length + (data.length === 1 ? " track" : " tracks"));
$(".pl-thumb").attr("src", thumb);
$(".pl-thumb").attr("srcset", thumb);
$(".pl-thumb-webp").attr("srcset", (thumb).replace(".jpg", ".webp"));
}
currentPlaylist = data;
// loadSimilarSongsForWeb(data[0].contentId, "FULLTRACK");
$.each(data, function (i, item) {
if (data[i]) {
var index = $.inArray(data[i].contentId, allalbumsongs);
if (index == -1) {
allalbumsongs.push(data[i].contentId);
}
var videoIcon;
if (data[i].videoId == 0) {
videoIcon = "hidden";
} else {
videoIcon = "videoToPlay";
}
// console.log('playlist');
var isIdPresent = false;
try {
var likedContent = userProfile.likedContentIdsMap;
isIdPresent = likedContent ? likedContent[data[i].contentId] : false;
} catch (er) {
}
var thumb = data[i].thumbnailList.square ? data[i].thumbnailList.square : data[i].thumbnailList.square;
if (data.length == 1) {
$("#contentTale").addClass("show_overflow");
}
var proIcon = "hidden";
if (data[i].isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
if (isIdPresent) {
isContentLiked = true;
$(contentTableTemplateLikedForContentPlayList({
artsitTitle: data[i].artistTitle,
contentThumb: thumb,
id: data[i].contentId,
cid: "cid-" + data[i].contentId,
thumbWebp: thumb.replace(".jpg", ".webp"),
contentFile: "",
proIcon: proIcon,
videoIcon: videoIcon,
albumTitle: data[i].albumTitle,
released: getReleasedYear(data[i].releasedDate),
isPlaying: "",
duration: secondsTimeSpanToHMS(data[i].duration),
contentTitle: data[i].contentTitle,
link: "/song/" + data[i].contentId + "/" + data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
contextMenuUp: (data.length === (i + 1)) ? "contentMenuUp" : ""
})).data("content", data[i]).appendTo("#content-table");
$(".player_" + data[i].contentId).addClass("active").addClass("liked");
} else {
isContentLiked = false;
$(contentTableTemplateForContentPlayList({
artsitTitle: data[i].artistTitle,
contentThumb: data[i].thumbnailList.square,
id: data[i].contentId,
cid: "cid-" + data[i].contentId,
thumbWebp: data[i].thumbnailList.square.replace(".jpg", ".webp"),
contentFile: "",
proIcon: proIcon,
videoIcon: videoIcon,
albumTitle: data[i].albumTitle,
released: getReleasedYear(data[i].releasedDate),
isPlaying: "",
duration: secondsTimeSpanToHMS(data[i].duration),
contentTitle: data[i].contentTitle,
link: "/song/" + data[i].contentId + "/" + data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
contextMenuUp: (data.length === (i + 1)) ? "contentMenuUp" : ""
})).data("content", data[i]).appendTo("#content-table");
}
}
});
$(".tab-loader").remove();
$(".loader-generic").hide();
const urlParams = new URLSearchParams(window.location.search);
const cid = urlParams.get('cid');
var cPlay = "";
if (cid !== null && cid !== undefined) {
$('.cid-' + cid).click();
}
} else {
$("#moretd").parent().hide();
// $("#pl-main-div").hide();
$(".loader-generic").hide();
// $("#trend-album").css("margin-top", "75px");
}
}).fail(function (response) {
$(".loader-generic").hide();
// $("#pl-main-div").hide();
// $("#trend-album").css("margin-top", "75px");
// displayErrorNoty("Internal server error.", false, 1500);
}).always(function () {
// loadSimilarAlbums(id, type);
// loadTrendingAlbums(0, 20);
});
}
function getSectionInfo(secId, plId) {
var params = "§ionId=" + secId;
$.ajax({
type: 'POST',
url: '/api/sectionInfo/v2?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON",
async: false
}).done(function (res) {
if (res.respCode === "00" && res.respData && res.respData.length > 0) {
var playlist = res.respData[0].playLists;
for (i = 0; i < playlist.length; i++) {
if (playlist[i].id == plId) {
currentPlaylist = playlist[i];
}
}
}
}).fail(function (response) {
currentPlaylist = "";
}).always(function () {
// loadSimilarAlbums(id, type);
// loadTrendingAlbums(0, 20);
});
}
function loadPlaylistSectionContentV2ById(secId, id, type) {
//// $(".loader-generic").show();
var params = "plId=" + id + "&secId=" + secId + "&contentType=" + type;
$.ajax({
type: 'POST',
url: '/api/sections/playlist/v2/content?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res.respCode === "00" && res.respData && res.respData.length > 0) {
var playlist = res.respData;
if (currentPlaylist == "") {
getSectionInfo(secId, id);
}
var thumb = currentPlaylist.thumbnailList.square ? currentPlaylist.thumbnailList.square : (currentPlaylist.playlistImageSquare) ? currentPlaylist.playlistImageSquare : "";
// $("#pl-main-div").css("background-image", "url('" + thumb + "')");
$("#pl-title").html(currentPlaylist.title);
var follwers = currentPlaylist.totalFollowers ? currentPlaylist.totalFollowers : "9";
$("#pl-followers").html(follwers + " Followers");
$("#pl-songs").html(playlist.length + (playlist.length === 1 ? " track" : " tracks"));
$(".pl-thumb").attr("src", (thumb).replace(".jpg", ".webp"));
$(".pl-thumb").attr("srcset", (thumb).replace(".jpg", ".webp"));
$(".pl-thumb-webp").attr("srcset", (thumb).replace(".jpg", ".webp"));
currentPlaylist = playlist;
var data = res.respData;
// loadSimilarSongsForWeb(data[0].contentId, "FULLTRACK");
$.each(data, function (i, item) {
if (data[i]) {
var index = $.inArray(data[i].contentId, allalbumsongs);
if (index == -1) {
allalbumsongs.push(data[i].contentId);
}
var videoIcon;
if (data[i].videoId == 0) {
videoIcon = "hidden";
} else {
videoIcon = "videoToPlay";
}
// console.log('playlist');
var isIdPresent = false;
try {
var likedContent = userProfile.likedContentIdsMap;
isIdPresent = likedContent ? likedContent[data[i].contentId] : false;
} catch (er) {
}
var thumb = data[i].thumbnailList.square ? data[i].thumbnailList.square : data[i].thumbnailList.square;
if (data.length == 1) {
$("#contentTale").addClass("show_overflow");
}
var proIcon = "hidden";
if (data[i].isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
if (isIdPresent) {
isContentLiked = true;
$(contentTableTemplateLiked({
artsitTitle: data[i].artistTitle,
contentThumb: thumb,
id: data[i].contentId,
thumbWebp: thumb.replace(".jpg", ".webp"),
contentFile: "",
proIcon: proIcon,
videoIcon: videoIcon,
albumTitle: data[i].albumTitle,
released: getReleasedYear(data[i].releasedDate),
isPlaying: "",
duration: secondsTimeSpanToHMS(data[i].duration),
contentTitle: data[i].contentTitle,
link: "/song/" + data[i].contentId + "/" + data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
contextMenuUp: (data.length === (i + 1)) ? "contentMenuUp" : ""
})).data("content", data[i]).appendTo("#content-table");
$(".player_" + data[i].contentId).addClass("active").addClass("liked");
} else {
isContentLiked = false;
$(contentTableTemplate({
artsitTitle: data[i].artistTitle,
contentThumb: data[i].thumbnailList.square,
id: data[i].contentId,
thumbWebp: data[i].thumbnailList.square.replace(".jpg", ".webp"),
contentFile: "",
proIcon: proIcon,
videoIcon: videoIcon,
albumTitle: data[i].albumTitle,
released: getReleasedYear(data[i].releasedDate),
isPlaying: "",
duration: secondsTimeSpanToHMS(data[i].duration),
contentTitle: data[i].contentTitle,
link: "/song/" + data[i].contentId + "/" + data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
contextMenuUp: (data.length === (i + 1)) ? "contentMenuUp" : ""
})).data("content", data[i]).appendTo("#content-table");
}
}
});
$(".tab-loader").remove();
$(".loader-generic").hide();
} else {
$("#moretd").parent().hide();
// $("#pl-main-div").hide();
$(".loader-generic").hide();
// $("#trend-album").css("margin-top", "75px");
}
}).fail(function (response) {
$(".loader-generic").hide();
// $("#pl-main-div").hide();
// $("#trend-album").css("margin-top", "75px");
// displayErrorNoty("Internal server error.", false, 1500);
}).always(function () {
// loadSimilarAlbums(id, type);
// loadTrendingAlbums(0, 20);
});
}
function loadSimilarAlbums(id, type) {
//// $(".loader-generic").show();
var params = "cId=" + id + "&cType=" + type;
$.ajax({
type: 'POST',
url: 'similarContent?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res.respCode === "00" && res.respData !== null) {
var data = res.respData;
$.each(data, function (i, item) {
if (data) {
var thumb = data[i].thumbnailList.square ? data[i].thumbnailList.square : data[i].thumbnailList.square;
$(albumCarouselTemplate({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: data[i].contentTitle,
category: data[i].releasedYear,
sectionId: "",
count: data[i].releasedYear
})).data("content", data[i]).appendTo("#simAlbums");
}
});
$("#simAlbums").owlCarousel({
loop: false,
margin: 10,
dots: false,
nav: true,
navText: [" ", " "],
pagination: false,
responsive: {
0: {
items: 2,
stagePadding: 50
},
480: {
items: 2,
stagePadding: 50
},
600: {
items: 2,
stagePadding: 100
},
700: {
items: 2,
stagePadding: 100
},
768: {
items: 4,
stagePadding: 100
},
1000: {
items: 4,
stagePadding: 100
},
1024: {
items: 4,
stagePadding: 100
},
1280: {
items: 4,
stagePadding: 100
},
1600: {
items: 6,
stagePadding: 100
}
}
});
$(".loader-generic").hide();
} else {
$("#similar-album").hide();
$(".loader-generic").hide();
}
}).fail(function (response) {
$("#similar-album").hide();
$(".loader-generic").hide();
// displayErrorNoty("Internal server error.", false, 1500);
});
}
function loadSimilarSongsForWeb(id, type) {
//// $(".loader-generic").show();
var params = "cId=" + id + "&cType=" + type + "&sIndex=0" + "&fIndex=7";
$.ajax({
type: 'POST',
url: '/api/content/similar?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res.respCode === "00" && res.respData !== null) {
var data = res.respData;
// var o = new Array();
// var c = data.length;
// for (var i = 0; i < c; i++) {
// var n = Math.floor(Math.random() * c);
// if (jQuery.inArray(n, o) > 0)
// --i;
// else
// o.push(n);
// }
for (var i = data.length - 1; i >= 0; i--) {
// if (data[o[i]]) {
var thumb = data[i].thumbnailList;
var disabled = "";
if (data[i].contentId == 0) {
disabled = "disabled-div";
}
var proIcon = "hidden";
if (data[i].isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
$(contentCarouselTemplate({
thumb: thumb && thumb.square ? thumb.square.replace(".webp", ".jpg") : "",
thumbWebp: thumb && thumb.square ? thumb.square.replace(".jpg", ".webp") : "",
contentId: data[i].contentId,
contentTitle: data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
title: data[i].contentTitle,
proIcon: proIcon,
category: data[i].artistTitle,
sectionId: data[i].contentId
})).data("content", data[i]).addClass(disabled).appendTo("#simSongs");
// }
}
// });
$("#simSongs").owlCarousel({
loop: false,
margin: 10,
dots: true,
nav: true,
onInitialize: function (element) {
$("#simSongs").children().sort(function () {
return Math.round(Math.random()) - 0.5;
}).each(function () {
$(this).appendTo($("#simSongs"));
});
},
navText: [" ", " "],
pagination: false,
responsive: {
0: {
items: 2,
stagePadding: 65,
},
480: {
items: 3,
stagePadding: 20,
},
600: {
items: 3,
stagePadding: 70,
},
700: {
items: 3,
stagePadding: 70,
},
768: {
items: 3,
stagePadding: 70,
},
1000: {
items: 4,
stagePadding: 70,
},
1024: {
items: 4,
stagePadding: 70,
},
1280: {
items: 4,
stagePadding: 70,
},
1600: {
items: 5,
stagePadding: 70,
},
1920: {
items: 6,
stagePadding: 70,
}
}
});
$(".loader-generic").hide();
} else {
$(".loader-generic").hide();
$("#sim-songs").hide();
}
}).fail(function (response) {
$(".loader-generic").hide();
$("#sim-songs").hide();
// displayErrorNoty("Internal server error.", false, 1500);
}).always(function (response) {
if (!isMobile) {
loadRecommendedContentSide(0, 30);
loadPlayedContent();
}
});
}
function loadTrendingAlbums(start, end) {
//// $(".loader-generic").show();
// $(".loader-generic").show();
isLoading = true;
var params = "sIndex=" + start + "&fIndex=" + end;
$.ajax({
type: 'POST',
url: '/api/albums/trending?siteid=' + getParameterByName("siteid"),
dataType: "JSON",
data: params
}).done(function (res) {
isLoading = false;
$("#m-title").html("Albums");
if (res.respCode === "00" && res.respData !== null) {
var data = res.respData;
// console.log("here");
$.each(data, function (i, item) {
if (data) {
var count = data[i].totalContent + (data[i].totalContent === 1 ? " track" : " tracks");
var thumb = data[i].thumbnailList;
if (windowWidth > widthLimit) {
thumb = thumb && thumb.square ? thumb.square : defaultThumbSquare();
} else {
thumb = thumb && thumb.mobileSquare ? thumb.mobileSquare : defaultThumbSquare();
}
if (getPathVariableByIndex(1) !== "showall") {
$(albumSquareCarouselTemplate({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: data[i].title,
contentId: data[i].id,
contentTitle: data[i].title.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
category: count,
sectionId: data[i].id
})).data("content", data[i]).appendTo("#trendAlbums");
} else {
var disabled = "";
if (data[i].id == 0) {
disabled = "disabled-div";
}
$(allArtistContentCarouselTemplate({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: data[i].title,
released: "",
type: "album",
sectionId: "",
contentId: data[i].id,
contentTitle: data[i].title.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
album: getReleasedYear(data[i].releasedDate),
artist: data[i].totalContent + (data[i].totalContent === 1 ? " track" : " tracks")
})).data("content", data[i]).addClass(disabled).appendTo("#simVideos");
}
}
});
if (getPathVariableByIndex(1) !== "showall") {
$("#trendAlbums").owlCarousel({
loop: false,
margin: 10,
dots: true,
nav: true,
onInitialize: function (element) {
$("#trendAlbums").children().sort(function () {
return Math.round(Math.random()) - 0.5;
}).each(function () {
$(this).appendTo($("#trendAlbums"));
});
},
navText: [" ", " "],
pagination: false,
responsive: {
0: {
items: 2,
stagePadding: 65,
},
480: {
items: 3,
stagePadding: 20,
},
600: {
items: 3,
stagePadding: 70,
},
700: {
items: 3,
stagePadding: 70,
},
768: {
items: 3,
stagePadding: 70,
},
1000: {
items: 4,
stagePadding: 70,
},
1024: {
items: 4,
stagePadding: 70,
},
1280: {
items: 4,
stagePadding: 70,
},
1600: {
items: 5,
stagePadding: 70,
},
1920: {
items: 6,
stagePadding: 70,
}
}
});
} else {
$(".playSimContent").addClass("albumToPlay").removeClass("playSimContent");
}
$(".loader-generic").hide();
} else {
serverError++;
$(".loader-generic").hide();
$("#trend-album").hide();
}
}).fail(function (response) {
isLoading = false;
$(".loader-generic").hide();
$("#trend-album").hide();
// displayErrorNoty("Internal server error.", false, 1500);
});
}
function likePlaylist() {
if ($(".title-user") && $(".title-user").html().trim() === "LOGIN") {
showLoginMenu();
} else {
// userProfile = "";
// console.log('Playlist Liked');
var action = "like";
try {
if ($(".like_album").find(".liked").length > 0) {
action = "unlike";
}
} catch (er) {
}
// $(".loader-generic").show();
var playlistId = getPathVariableByIndex(2);
var params = "aId=&pId=" + playlistId + "&cId=&artId=&action=" + action;
$.ajax({
type: 'POST',
url: '/api/content/like?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res) {
// getUserProfile();
// var likedContent = userProfile.likedPlaylistIdsMap;
// var isIdPresent = likedContent[playlistId];
var isLiked = "0";
if (action == "like") {
isLiked = "1";
// displaySuccessNoty("Playlist Liked", false, 1500);
$(".like_album").html(' ');
} else {
isLiked = "0";
// displaySuccessNoty("Playlist UnLiked", false, 1500);
$(".like_album").html(' ');
}
/**
* Trigger Like/Follow Artist, Playlist, Album clevertap event
*/
// try {
//
// clevertap.event.push("Like/Follow Artist, Playlist, Album", {
// "Like/UnLike": isLiked,
// "Playlist Id": playlistId,
// "Platform": "WEB"
//
// });
// } catch (er) {
// console.log("Error logging clevertap events" + er);
// }
/**
* end trigger
*/
} else {
}
$(".loader-generic").hide();
}).fail(function (response) {
$(".loader-generic").hide();
displayErrorNoty("Kuch dair bad dobara koshish karein. Shukriya.", false, 2000);
});
}
}
function followArtist() {
if ($(".title-user") && $(".title-user").html().trim() === "LOGIN") {
showLoginMenu();
} else {
$(".btnFollowArtist").prop("disabled", true);
var action = "follow";
try {
if ($(".btnFollowArtist").find(".followed").length > 0) {
action = "unfollow";
}
} catch (er) {
}
userProfile = "";
// $(".loader-generic").show();
// console.log('artistFollowed');
var artistId = getPathVariableByIndex(2);
var params = "aId=&pId=&cId=&artId=" + artistId + "&action=" + action;
$.ajax({
type: 'POST',
url: '/api/content/follow?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res.respCode === "00" && res.isSuccess) {
getUserProfile();
// var likedContent = res.respData.followedArtistIds;
// var isIdPresent = likedContent[artistId];
var isFollow = "0";
if (action == "follow") {
isFollow = "1";
$(".btnFollowArtist").html(' Unfollow');
$(".btnFollowArtist").prop("disabled", false);
var currentText = $("#pl-followers").text();
var currentCount = currentText.split(" ");
$("#pl-followers").html(parseInt(currentCount[0]) + 1 + " followers");
// displaySuccessNoty("Artist Followed", false, 1500);
} else {
isFollow = "0";
$(".btnFollowArtist").html('Follow');
$(".btnFollowArtist").prop("disabled", false);
var currentText = $("#pl-followers").text();
var currentCount = currentText.split(" ");
try {
// if ($("#pl-followers").html().indexOf("0 followers") == -1) {
$("#pl-followers").html(parseInt(currentCount[0]) - 1 + " followers");
// }
} catch (er) {
}
// displaySuccessNoty("Artist UnFollowed", false, 1500);
}
/**
* Trigger Like/Follow Artist, Playlist, Album clevertap event
*/
// try {
//
// clevertap.event.push("Like/Follow Artist, Playlist, Album", {
// "Follow/UnFollow": isFollow,
// "Artist Id": artistId,
// "Platform": "WEB"
//
// });
// } catch (er) {
// console.log("Error logging clevertap events" + er);
// }
/**
* end trigger
*/
} else {
}
$(".loader-generic").hide();
}).fail(function (response) {
$(".loader-generic").hide();
displayErrorNoty("Kuch dair bad dobara koshish karein. Shukriya.", false, 2000);
});
}
}
function followPlaylist() {
if ($(".title-user") && $(".title-user").html().trim() === "LOGIN") {
showLoginMenu();
} else {
$(".btnFollowArtist").prop("disabled", true);
var action = "follow";
try {
if ($(".btnFollowArtist").find(".followed").length > 0) {
action = "unfollow";
}
} catch (er) {
}
userProfile = "";
// $(".loader-generic").show();
// console.log('Playlist Liked');
var playlistId = getPathVariableByIndex(2);
var params = "aId=&pId=" + playlistId + "&cId=&artId=&action=" + action;
//// $(".loader-generic").show();
$.ajax({
type: 'POST',
url: '/api/content/follow?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res.respCode === "00" && res.isSuccess) {
getUserProfile();
// var likedContent = res.respData.followedPlaylistIds;
// var isIdPresent = likedContent[playlistId];
var isFollow = "0";
if (action == "follow") {
isFollow = "1";
$(".btnFollowArtist").html(' Unfollow');
$(".btnFollowArtist").prop("disabled", false);
var currentText = $("#pl-followers").text();
var currentCount = currentText.split(" ");
$("#pl-followers").html(parseInt(currentCount[0]) + 1 + " followers");
// displaySuccessNoty("Playlist Followed", false, 1500);
} else {
isFollow = "0";
$(".btnFollowArtist").html('Follow');
$(".btnFollowArtist").prop("disabled", false);
var currentText = $("#pl-followers").text();
var currentCount = currentText.split(" ");
try {
// if ($("#pl-followers").html().indexOf("0 followers") == -1) {
$("#pl-followers").html(parseInt(currentCount[0]) - 1 + " followers");
// }
} catch (er) {
}
// displaySuccessNoty("Playlist UnFollowed", false, 1500);
}
/**
* Trigger Like/Follow Artist, Playlist, Album clevertap event
*/
// try {
//
// clevertap.event.push("Like/Follow Artist, Playlist, Album", {
// "Follow/UnFollow": isFollow,
// "Playlist Id": playlistId,
// "Platform": "WEB"
//
// });
// } catch (er) {
// console.log("Error logging clevertap events" + er);
// }
/**
* end trigger
*/
} else {
}
}).fail(function (response) {
displayErrorNoty("Kuch dair bad dobara koshish karein. Shukriya.", false, 2000);
}).always(function () {
$(".loader-generic").hide();
});
}
}
var oldSearchVal = "";
function searchContent(event, t) {
var searchText = $('#searched_text').val();
var searchText2 = $('#searched_text2').val();
if (!searchText) {
searchText = $('#searched_text2').val();
$('#searched_text').val(searchText);
} else if (searchText2) {
if (searchText !== searchText2) {
if (oldSearchVal == searchText) {
searchText = searchText2;
$('#searched_text').val(searchText);
} else {
searchText2 = searchText;
$('#searched_text2').val(searchText);
}
}
}
if (!searchText) {
} else {
}
oldSearchVal = searchText;
if (event == null || event.key === 'Enter' || t === 'clicked' || event.which === 13) {
if (window.location.href.indexOf("/search") > -1) {
//do on search page
} else {
switchContent("search");
}
// console.log('searched here');
if (searchText.trim() !== "") {
/**
* Trigger Search clevertap event
*/
// try {
//
// clevertap.event.push("Searched", {
// "Keywords": searchText.trim(),
// "Platform": "WEB"
//
// });
// } catch (er) {
// console.log("Error logging clevertap events" + er);
// }
/**
* end trigger
*/
logSearchEvent("search", searchText);
// $(".loader-generic").show();
var params = "txt=" + searchText.trim();
$.ajax({
type: 'POST',
url: '/api/searchContent?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res && res.isSuccess) {
$(".search-header li").show();
var isContentFound = false;
$(".search-header").removeClass("hidden");
$('#searched_content_top').html("");
$('#searched_content_songs').html("");
$('#searched_content_playlists').html("");
$('#searched_content_artist').html("");
$('#searched_content_albums').html("");
if (res.respCode === "00" && res.respData !== null) {
$(".content-line").removeClass("hidden");
var data = res.respData;
var topData;
var songsData;
var sectionData;
var artistData;
var albumData;
$.each(data, function (j, jitem) {
if (data[j].type == "Top") {
topData = data[j].data;
} else if (data[j].type == "Songs") {
songsData = data[j].data;
} else if (data[j].type == "Playlist") {
sectionData = data[j].data;
} else if (data[j].type == "Artists") {
artistData = data[j].data;
} else if (data[j].type == "Albums") {
albumData = data[j].data;
}
// topData = data['top'];
// songsData = data['songs'];
// sectionData = data['sectionPlayList'];
// artistData = data['artist'];
// albumData = data['albums'];
});
if (topData && topData.length > 0) {
$("#resultCount").html('' + topData.length + ' Results found for : ' + searchText + ' ');
isContentFound = true;
$.each(topData, function (i, item) {
if (topData[i]) {
var divClass = "";
if (topData[i].type === "ARTIST") {
divClass = "artistToPlay";
} else if (topData[i].type === "ALBUM") {
divClass = "albumToPlay";
} else if (topData[i].type === "PLAYLIST") {
divClass = "playlistToPlay";
} else if (topData[i].type === "SONG") {
divClass = "contentToPlay";
topData[i].contentId = topData[i].id;
topData[i].contentTitle = topData[i].title;
topData[i].contentType = "FULLTRACK";
topData[i].thumbnailList = [];
topData[i].thumbnailList.vertical = topData[i].thumb;
topData[i].thumbnailList.square = topData[i].thumb;
topData[i].thumbnailList.horizontal = topData[i].thumb;
}
var disabled = "";
if (topData[i].id == 0) {
disabled = "disabled-div";
}
$(searchedTemplate({
description: topData[i].description,
image: topData[i].thumb.replace(".webp", ".jpg"),
imageWebp: topData[i].thumb.replace(".jpg", ".webp"),
id: topData[i].id,
title: topData[i].title,
type: topData[i].type,
divClass: divClass
})).data("content", topData[i]).addClass(disabled).appendTo("#searched_content_top");
}
});
} else {
// $("#searh-tabs1").hide();
$(".search-header > li:nth-child(1)").hide();
}
if (songsData && songsData.length > 0) {
isContentFound = true;
$.each(songsData, function (i, item) {
if (songsData[i]) {
var thumb = songsData[i].thumbnailList.square ? songsData[i].thumbnailList.square : songsData[i].thumbnailList.square;
var disabled = "";
if (songsData[i].contentId == 0) {
disabled = "disabled-div";
}
var proIcon = "hidden";
if (songsData[i].isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
$(searchedSongsTemplate({
description: secondsTimeSpanToHMS(songsData[i].duration),
image: thumb.replace(".webp", ".jpg"),
imageWebp: thumb.replace(".jpg", ".webp"),
id: songsData[i].contentId,
proIcon: proIcon,
contentId: songsData[i].contentId,
contentTitle: songsData[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
likeId: songsData[i].contentId,
title: songsData[i].contentTitle,
type: songsData[i].artistTitle,
divClass: "contentToPlay"
})).data("content", songsData[i]).addClass(disabled).appendTo("#searched_content_songs");
}
});
} else {
// $("#searh-tabs2").hide();
$(".search-header > li:nth-child(2)").hide();
}
if (sectionData && sectionData.length > 0) {
isContentFound = true;
$.each(sectionData, function (i, item) {
if (sectionData[i]) {
$(searchedTemplate({
description: sectionData[i].description,
image: sectionData[i].playlistImageSquare.replace(".webp", ".jpg"),
imageWebp: sectionData[i].playlistImageSquare.replace(".jpg", ".webp"),
id: sectionData[i].id,
title: sectionData[i].title,
type: sectionData[i].type,
divClass: "playlistToPlay"
})).data("content", sectionData[i]).appendTo("#searched_content_playlists");
}
});
} else {
// $("#searh-tabs5").hide();
$(".search-header > li:nth-child(5)").hide();
}
if (artistData && artistData.length > 0) {
isContentFound = true;
$.each(artistData, function (i, item) {
if (artistData[i]) {
var thumb = "";
if (artistData[i].thumbnailList) {
thumb = artistData[i].thumbnailList.square;
}
$(searchedTemplate({
description: artistData[i].totalContent + (artistData[i].totalContent === 1 ? " track" : " tracks"),
image: thumb.replace(".webp", ".jpg"),
imageWebp: thumb.replace(".jpg", ".webp"),
id: artistData[i].id,
title: artistData[i].title,
type: artistData[i].artistType,
divClass: "artistToPlay"
})).data("content", artistData[i]).appendTo("#searched_content_artist");
}
});
} else {
// $("#searh-tabs3").hide();
$(".search-header > li:nth-child(3)").hide();
}
if (albumData && albumData.length > 0) {
isContentFound = true;
$.each(albumData, function (i, item) {
if (albumData[i]) {
var thumb = albumData[i].thumbnailList ? albumData[i].thumbnailList.square : defaultThumbSquare();
$(searchedTemplate({
description: albumData[i].totalContent + (albumData[i].totalContent === 1 ? " track" : " tracks"),
image: thumb.replace(".webp", ".jpg"),
imageWebp: thumb.replace(".jpg", ".webp"),
id: albumData[i].id,
title: albumData[i].title,
type: getReleasedYear(albumData[i].releasedDate),
divClass: "albumToPlay"
})).data("content", albumData[i]).appendTo("#searched_content_albums");
}
});
} else {
// $("#searh-tabs4").hide();
$(".search-header > li:nth-child(4)").hide();
}
$(".loader-generic").hide();
if (!isContentFound) {
$("#resultCount").html('0 Results found for : ' + searchText + ' ');
displayErrorNoty("" + $('#searched_text').val() + " Search karne k liye sahi alfaaz ka indraj karein.", true, 2000);
}
} else {
$(".loader-generic").hide();
}
} else {
$(".loader-generic").hide();
$("#resultCount").html('0 Results found for : ' + searchText + ' ');
displayErrorNoty("" + searchText + " Search karne k liye sahi alfaaz ka indraj karein.", true, 2000);
}
}).fail(function (response) {
$(".loader-generic").hide();
// displayErrorNoty("Internal server error.", false, 1500);
}).always(function () {
$(".loader-generic").hide();
});
}
}
$(".drop-down-searchhistry").fadeOut(400);
}
function rotatePlayer(player) {
window.addEventListener("orientationchange", function () {
if (90 === window.orientation || -90 === window.orientation) {
if (player) {
if (!player.renderers.html5.player.isFullScreen) {
// player.renderers.html5.player.enterFullScreen();
}
}
}
}, false);
}
function getVideoStreamLink(id) {
try {
if (isMobile) {
if ($(".contro-up-player").hasClass("contro_show")) {
$(".contro-up-player").trigger("click");
// $(".footer-player").css("top", "auto");
// $(".footer-player").addClass("contro-play");
}
}
// ga('send', {
// hitType: 'event',
// eventCategory: 'Video',
// eventAction: 'play',
// eventLabel: ''
// });
} catch (er) {
}
var likedContent = userProfile.likedContentIdsMap;
var isIdPresent = likedContent ? likedContent[id] : false;
var isLiked = "0";
if (isIdPresent) {
isLiked = "1";
// $(".likeCurrentContent").html(' ');
$(".likeCurrentContent").addClass("active");
} else {
isLiked = "0";
$(".likeCurrentContent").removeClass("active");
// $(".likeCurrentContent").html(' ');
}
var params = "vdoId=" + id;
$.ajax({
type: "POST",
data: params,
url: "/api/video/stream?siteid=" + getParameterByName("siteid"),
dataType: 'json'
}).done(function (response) {
if (response && response !== undefined && response !== "-1") {
fbq('trackCustom', 'Stream');
/**
* Trigger Play Video Song clevertap event
*/
// try {
//
// clevertap.event.push("Play Video Song", {
// "Content Name": response.respData.contentTitle,
// "Type": response.respData.contentType,
// "Platform": "WEB",
// "Is Liked": isLiked
//
// });
// } catch (er) {
// console.log("Error logging clevertap events" + er);
// }
/**
* end trigger
*/
isContinueLis = false;
isRqtSent = 0;
// if ((response.isSuccess && response.respData && response.respData.length > 0)
// || (response.respData[0] && response.respData[0].isFree)) {
if ((response && response.respData)) {
var content = response.respData;
$('#contentTitle').html(content.contentTitle);
$('#artistTitle').html(content.artistTitle);
$('#albumTitle').html(content.albumTitle);
$('#fanHits').html(content.fanHits + 12);
$('#streamCount').html(content.streamCount);
$('#vdoPlayer').attr('poster', content.thumbnailList.horizontal);
logEvent("play_video", "Video - " + content.contentTitle);
logDBEvent("play_video", "event", content.contentTitle);
document.title = "Watch " + content.contentTitle + "by " + content.artistTitle + " Online Only On | Bajao";
currentVideo = content;
$("#auto").attr("src", content.adaptiveStreamLink);
if (content.standardStreamLinks.http.p144) {
$("#p144").attr("src", content.standardStreamLinks.http.p144);
} else {
$("#p144").remove();
}
if (content.standardStreamLinks.http.p240) {
$("#p240").attr("src", content.standardStreamLinks.http.p240);
} else {
$("#p240").remove();
}
if (content.standardStreamLinks.http.p360) {
$("#p360").attr("src", content.standardStreamLinks.http.p360);
} else {
$("#p360").remove();
}
if (content.standardStreamLinks.http.p480) {
$("#p480").attr("src", content.standardStreamLinks.http.p480);
} else {
$("#p480").remove();
}
if (content.standardStreamLinks.http.p720) {
$("#p720").attr("src", content.standardStreamLinks.http.p720);
} else {
$("#p720").remove();
}
if (content.standardStreamLinks.http.p1080) {
$("#p1080").attr("src", content.standardStreamLinks.http.p1080);
} else {
$("#p1080").remove();
}
if (isMobile) {
$("#p1080").remove();
$("#p480").remove();
$("#p144").remove();
}
// console.log('image');
$("#vdoPlayer").removeClass("hidden");
if (!mediaElement) {
$('#vdoPlayer').mediaelementplayer();
mediaElement = true;
var player = document.getElementById('vdoPlayer');
// player.setSrc(content.adaptiveStreamLink);
player.setSrc(content.adaptiveStreamLink);
player.load();
player.play();
} else {
// $("#video-mainshow").scrollTop(300);
$('html, body').animate({
scrollTop: 0
}, 700);
var player = document.getElementById('vdoPlayer');
if (player) {
player.setSrc(content.adaptiveStreamLink);
player.load();
player.play();
loadSimilarContent(getPathVariableByIndex(2), "VIDEO");
rotatePlayer(player);
} else {
$('#vdoPlayer').mediaelementplayer();
mediaElement = true;
var player = document.getElementById('vdoPlayer');
player.setSrc(content.adaptiveStreamLink);
player.load();
player.play();
var mediaElements = document.querySelectorAll('video, audio');
for (var i = 0, total = mediaElements.length; i < total; i++) {
new MediaElementPlayer(mediaElements[i], {
// features: ['playpause', 'current', 'progress', 'duration', 'volume', 'quality', 'fullscreen'],
features: ['playpause', 'current', 'progress', 'duration', "quality", 'volume', 'fullscreen'],
});
}
rotatePlayer(player);
}
setTimeout(function () {
try {
setTimeout(function () {
}, 500);
var player = document.getElementById('vdoPlayer');
player.play();
} catch (er) {
}
}, 1000);
// $('.mejs__poster').css("background-image", "url(" + content.thumbnailList.horizontal + ")");
// $('.mejs__poster').css("display", "block");
// $('.mejs__poster-img').attr("src", content.thumbnailList.horizontal);
// player.poster(content.thumbnailList.horizontal);
}
// player.poster(content.thumbnailList.horizontal);
} else {
$(".videoshow-content").hide();
if (response.respCode == "01") {
if ($(".title-user") && $(".title-user").html().trim() === "LOGIN") {
showLoginMenu();
}
}
if (response.respCode == "03") {
$(".btnSubscribe").trigger("click");
}
if (response.respCode == "05") {
displayErrorNoty(response.msg, false, 1500);
} else {
if ($(".title-user") && $(".title-user").html().trim() === "LOGIN") {
showLoginMenu();
} else {
$(".btnSubscribe").trigger("click");
}
// displayWarningNoty("Login Music sun nay k liye apnay number se login karein. Shukriya", false, 1500);
}
}
} else {
// window.location = window.location.pathname.substring(0, window.location.pathname.indexOf("/", 2)) + "/login";
if ($(".title-user") && $(".title-user").html().trim() === "LOGIN") {
showLoginMenu();
}
}
}).fail(function (error) {
displayErrorNoty("Error Please check your internet connection.", false, 1500);
// $(".btnSubscribe").trigger("click");
});
}
function playLiveStream() {
try {
if (isMobile) {
if ($(".contro-up-player").hasClass("contro_show")) {
$(".contro-up-player").trigger("click");
// $(".footer-player").css("top", "auto");
// $(".footer-player").addClass("contro-play");
}
}
var pageUrl = window.location.pathname;
// ga('send', {
// hitType: 'event',
// eventCategory: 'Live_Stream',
// eventAction: 'play',
// eventLabel: ''
// });
} catch (er) {
}
// getLiveActiveStreams();
$.ajax({
type: 'POST',
url: '/api/activestreams?siteid=' + getParameterByName("siteid"),
async: false
}).done(function (response) {
if (response && response.respCode == "00" && response.respData) {
isContinueLis = false;
isRqtSent = 0;
if (response.respData[0]) {
liveEvent = response.respData[0];
var content = response.respData[0];
insertEventHistoryStreams(content.id);
$("#liveEventTitle").html(content.description);
$("#liveEventTitle").attr("eventId", content.id);
$('#vdoPlayer').attr('poster', content.artistImage);
logEvent("live_stream_playing", "Live Stream - " + content.description);
document.title = content.description + " Online Only On | Bajao";
currentVideo = content;
$("#vdoPlayer").attr("src", content.streamUrl);
$("#vdoPlayer").removeClass("hidden");
if (!mediaElement) {
$('#vdoPlayer').mediaelementplayer();
mediaElement = true;
var player = document.getElementById('vdoPlayer');
// player.setSrc(content.adaptiveStreamLink);
player.setSrc(content.streamUrl);
player.load();
player.play();
} else {
// $("#video-mainshow").scrollTop(300);
$('html, body').animate({
scrollTop: 0
}, 700);
var player = document.getElementById('vdoPlayer');
if (player) {
player.setSrc(content.streamUrl);
player.load();
player.play();
// loadSimilarContent(getPathVariableByIndex(2), "VIDEO");
rotatePlayer(player);
} else {
$('#vdoPlayer').mediaelementplayer();
mediaElement = true;
var player = document.getElementById('vdoPlayer');
player.setSrc(content.streamUrl);
player.load();
player.play();
var mediaElements = document.querySelectorAll('video, audio');
for (var i = 0, total = mediaElements.length; i < total; i++) {
new MediaElementPlayer(mediaElements[i], {
// features: ['playpause', 'current', 'progress', 'duration', 'volume', 'quality', 'fullscreen'],
features: ['playpause', 'current', 'progress', 'duration', 'volume', 'fullscreen'],
});
}
rotatePlayer(player);
}
setTimeout(function () {
try {
setTimeout(function () {
}, 500);
var player = document.getElementById('vdoPlayer');
player.play();
} catch (er) {
}
}, 1000);
// $('.mejs__poster').css("background-image", "url(" + content.thumbnailList.horizontal + ")");
// $('.mejs__poster').css("display", "block");
// $('.mejs__poster-img').attr("src", content.thumbnailList.horizontal);
// player.poster(content.thumbnailList.horizontal);
}
getLiveStreamStatus();
loadArtistAlbums(content.artistId);
// player.poster(content.thumbnailList.horizontal);
} else {
if ($(".title-user") && $(".title-user").html().trim() === "LOGIN") {
showLoginMenu();
}
// $(".videoshow-content").hide();
// if (response.respCode == "01") {
// if ($(".title-user") && $(".title-user").html().trim() === "LOGIN") {
// showLoginMenu();
// }
// }
// if (response.respCode == "03") {
// $(".btnSubscribe").trigger("click");
// } else {
// if ($(".title-user") && $(".title-user").html().trim() === "LOGIN") {
// showLoginMenu();
// } else {
// $(".btnSubscribe").trigger("click");
// }
//// displayWarningNoty("Login Music sun nay k liye apnay number se login karein. Shukriya", false, 1500);
// }
}
} else {
// window.location = window.location.pathname.substring(0, window.location.pathname.indexOf("/", 2)) + "/login";
if ($(".title-user") && $(".title-user").html().trim() === "LOGIN") {
showLoginMenu();
}
}
}).fail(function (error) {
displayErrorNoty("Error Please check your internet connection.", false, 1500);
// $(".btnSubscribe").trigger("click");
});
}
function loadSimilarContent(id, type, sIndex, fIndex) {
//// $(".loader-generic").show();
var params = "cId=" + id + "&cType=" + type + "&sIndex=" + sIndex + "&fIndex=" + fIndex;
$.ajax({
type: 'POST',
url: '/api/content/similar?siteid=' + getParameterByName("siteid"),
data: params,
dataType: "JSON"
}).done(function (res) {
if (res.respCode === "00" && res.respData !== null && res.respData.length > 0) {
var data = res.respData;
$("#simVideos").html("");
$.each(data, function (i, item) {
if (data) {
var thumb = data[i].thumbnailList;
if (windowWidth > widthLimit) {
thumb = thumb && thumb.horizontal ? thumb.horizontal : defaultThumb();
} else {
thumb = thumb && thumb.mobileHorizontal ? thumb.mobileHorizontal : defaultThumb();
}
var disabled = "";
if (data[i].contentId == 0) {
disabled = "disabled-div";
}
var proIcon = "hidden";
if (data[i].isFree == 0 && (userProfile == "" || userProfile.status == 0)) {
proIcon = "";
}
$(simContentCarouselTemplateHorizontal({
thumb: thumb.replace(".webp", ".jpg"),
thumbWebp: thumb.replace(".jpg", ".webp"),
title: data[i].contentTitle,
released: secondsTimeSpanToHMS(data[i].duration),
likeId: "like" + data[i].contentId,
contentId: data[i].contentId,
contentTitle: data[i].contentTitle.replace(/\s+/g, '-').replace(/[^\w\s]/gi, '-'),
sectionId: "",
proIcon: proIcon,
album: "",
artist: data[i].artistTitle
})).data("content", data[i]).addClass(disabled).appendTo("#simVideos");
}
});
$("#simVideos").owlCarousel({
loop: false,
margin: 13,
dots: false,
nav: false,
pagination: false,
responsive: {
0: {items: 1},
480: {items: 1},
600: {items: 1},
700: {items: 2},
768: {items: 3},
1000: {items: 3},
1024: {items: 3},
1200: {items: 4},
1440: {items: 4},
1600: {items: 5}
}
});
// $("#simVideos").shuffleChildren();
$(".loader-generic").hide();
} else {
$("#similar-album").hide();
$(".sim-videos-sec").hide();
$(".loader-generic").hide();
}
}).fail(function (response) {
$("#similar-album").hide();
$(".loader-generic").hide();
$(".sim-videos-sec").hide();
// displayErrorNoty("Internal server error.", false, 1500);
});
}
function fix_height() {
var winheight = $(window).height();
$('.main-wrap').css("min-height", winheight + "px");
// $('.main-wrap .banner-wrap-on').css("min-height", winheight + "px");
}
//call first load owl-nav image height
//function getHeight_owl() {
// var imgHeight2 = $('.height-img-owl').parent().parent().height();
// var imgHeight2 = imgHeight2 + 4;
// var imgHeight3 = $('.height-img-owl2').parent().parent().height();
// var imgHeight3 = imgHeight3 + 3;
// $('.custome-carousel .owl-nav div').css('height', imgHeight2 + 'px');
//// $('.custome-carousel .owl-nav div').css('height', imgHeight2 + 'px');
// $('.custome-carousel-big .owl-nav div').css('height', imgHeight3 + 'px');
// if ($('.height-img-owl2').parent().parent().height() < 30 || $('.height-img-owl').parent().parent().height() < 30) {
// $('.default-img').css('height', "auto");
//// $('.default-img').css('width', $('.height-img-owl2').parent().parent().width() + 2);
// $('.default-img-square').css('height', "auto");
//// $('.default-img-square').css('width', $('.height-img-owl').parent().parent().width() + 2);
// } else {
// $('.default-img').css('height', $('.height-img-owl2').parent().parent().height() + 'px');
//// $('.default-img').css('width', $('.height-img-owl2').parent().parent().width() + 2);
// $('.default-img-square').css('height', $('.height-img-owl').parent().parent().height() + 'px');
//// $('.default-img-square').css('width', $('.height-img-owl').parent().parent().width() + 2);
// }
//
//}
// .each(function() {
// if(this.complete) {
// $(this).load(); // For jQuery < 3.0
// // $(this).trigger('load'); // For jQuery >= 3.0
// }
//});
function getHeight_owl() {
var imgHeightHori = $('img.height-img-owl2').height();
if (imgHeightHori > 130) {
$('img.height-img-owl2').css("min-height", imgHeightHori + 'px');
}
$('.custome-carousel .owl-nav div').css('height', imgHeightHori + 'px');
imgHeightHori = $('img.height-img-owl').height();
if (imgHeightHori > 130) {
var imgWidth = imgHeightHori = $('img.height-img-owl').width();
if (imgWidth > 50) {
$('img.height-img-owl').css("min-height", imgWidth + 'px');
// $('#isDoubleCarousel-53 img.height-img-owl').css("min-height", imgWidthDouble + 'px');
}
$('.custome-carousel .owl-nav div').css('height', imgHeightHori + 'px');
var imgWidthDouble = imgHeightHori = $('#isDoubleCarousel-53 .height-img-owl').width();
if (imgWidthDouble > 50) {
// $('img.height-img-owl').css("min-height", imgWidth + 'px');
$('#isDoubleCarousel-53 img.height-img-owl').css("min-height", imgWidthDouble + 'px');
}
}
imgHeightHori = $('img.default-img-circle').height();
if (imgHeightHori > 130) {
$('img.default-img-circle').css("min-height", imgHeightHori + 'px');
}
$('.custome-carousel-default .owl-nav div').css('height', imgHeightHori + 'px');
imgHeightHori = $(".sim-videos-img").height();
if (imgHeightHori > 50) {
$(".simAlbumVideos .sim-videos-img").css("min-height", imgHeightHori + 'px');
}
}
// get .custome-carousel3 image height
function getHeight_customecarousel3() {
var imgHeight2 = $('img.height-img-owl').parent().parent().height();
var imgHeight2 = (imgHeight2 / 2) - 15;
$('.custome-carousel3 .owl-nav div').css('top', imgHeight2 + 'px');
}
//get item-box image height
function getHeight_itembox() {
// var imgHeight = $('.item-box-height').parent().parent().height();
// var imgHeight = imgHeight - 30;
// $('.custome-carousel-default .owl-nav div').css('height', imgHeight + 'px');
//// $('.default-img-circle').css('height', $('.item-box-height').parent().parent().height() === 0 ? "auto" : $('.item-box-height').parent().parent().height() - 30);
// $('.default-img-circle').css('width', $('.item-box-height').parent().parent().width() + 2);
//// if ($('.default-img-circle').height() < 100) {
// $('.default-img-circle').css('height', $('.default-img-circle').width() < 30 ? "auto" : ($('.default-img-circle').width() + 'px'));
// }
}
//get list-genre-select image height
function getheight_genre() {
var genimgHeight = $('.list-genre-select-content .list-genre-height').height();
$('.list-genre-select .list-genre-de').css('height', genimgHeight + 'px');
}
function getheight_moods() {
var genreWidth = $(".list-genre-select-content .list-genre-height").width();
$("#mood-select .list-genre-height").css("min-height", genreWidth + "px");
// var genimgHeight = $('.list-genre-select-content .list-genre-height').height();
$('#mood-select .list-genre-height').css('min-width', genreWidth + 'px');
}
function getheight_all() {
var genreWidth = $("#simVideos .default-img-similar").width();
if (genreWidth > 10) {
$("#simVideos .default-img-similar").css("min-height", genreWidth + "px");
$('#simVideos .default-img-similar').css('min-width', genreWidth + 'px');
}
}
function getheight_category() {
var genimgHeight = $('.img-circle-category ').height();
$('.category-select-con h3').css('padding-top', (genimgHeight / 2) - 10 + 'px');
}
function getheight_home() {
var genreWidth = $(".custome-carousel-big .images-active-video").width();
$(".custome-carousel-big .images-active-video").css("min-height", genreWidth - 4 + "px");
}
function getheight_cat() {
var catWidth = $(".subcats .img-responsive").width();
var catHeight = $(".subcats .img-responsive").height();
if (catWidth > 20) {
$(".subcats .img-responsive").css("min-width", catWidth + "px");
}
if (catHeight > 20) {
$(".subcats .img-responsive").css("min-height", catHeight + "px");
} else {
$(".subcats .img-responsive").css("min-height", catWidth + "px");
}
}
//var timerStart = 0;
jQuery(function ($) {
//smoothScroll starting
try {
smoothScroll.init({
selector: '[data-scroll]', // Selector for links (must be a class, ID, data attribute, or element tag)
speed: 1000, // Integer. How fast to complete the scroll in milliseconds
easing: 'easeInOutCubic', // Easing pattern to use
});
} catch (er) {
}
});
function moveToNext(e, that) {
var keynum;
var index = $('.pincode').index(that);
if (window.event) { // IE
keynum = e.keyCode;
} else if (e.which) { // Netscape/Firefox/Opera
keynum = e.which;
}
// if (keynum == 8) {
// index = index - 1;
// $('.pincode').eq(index).focus();
//// $(this).prev('.inputs').focus();
// }
// if (that.value.length == that.maxLength) {
// index = index + 1;
// $('.pincode').eq(index).focus();
// }
// var pinCode = $(".pincode");
// var pin = "";
// for (var i = 0; i < pinCode.length; i++) {
// pin = pin + $(pinCode[i]).val();
// }
var pin = $('.pincode').val();
// console.log(pin);
if (pin.length > 2) {
$("#submit_pin").attr("disabled", false);
} else {
$("#submit_pin").attr("disabled", true);
}
if (keynum == 13) {
$("#submit_pin").trigger("click");
return true;
}
}
function validateInput(e, that) {
var input = $(that).val();
if ((input.startsWith("03") && input.length > 10)
|| (input.startsWith("3") && input.length > 9)
|| (input.startsWith("923") && input.length > 11)) {
$("#gen_pin").attr("disabled", false);
$('#gen_pin').focus();
} else {
$("#gen_pin").attr("disabled", true);
}
var keynum;
if (window.event) { // IE
keynum = e.keyCode;
} else if (e.which) { // Netscape/Firefox/Opera
keynum = e.which;
}
if (keynum == 13) {
e.preventDefault();
// e.stoppropagation();
$("#gen_pin").trigger("click");
return true;
}
}
function downloadApp() {
if (isIphone) {
window.location = "https://apps.apple.com/pk/app/bajao/id1084322801";
} else {
window.location = "https://play.google.com/store/apps/details?id=bajao.music";
}
}
function dismissAppBanner() {
$(".gettapp-tophead").hide(300);
$(".main-wrap").animate({top: 0}, 300);
}
function neverShowAppModal() {
hideAppModalAndBanner(8760);
$(".gettapp-tophead").attr("style", "display: none");
$(".main-wrap").css("top", "0");
$('.footer-player').find('audio').each(function () {
var _player;
if (typeof (this.player) === 'undefined') {
_player = this;
} else {
_player = this.player;
}
_player.play();
});
}
function getCookie(name) {
var pattern = RegExp(name + "=.[^;]*")
matched = document.cookie.match(pattern)
if (matched) {
var cookie = matched[0].split('=')
return true;
}
return false;
}
function hideAppModalAndBanner(hours) {
try {
var expDate = new Date();
expDate.setTime(expDate.getTime() + (hours * 60 * 60 * 1000)); // add hours
$.cookie('showAppModal', '0', {expires: expDate, path: '/'});
} catch (e) {
}
}
function hidePWAModalAndBanner(hours) {
try {
var expDate = new Date();
expDate.setTime(expDate.getTime() + (hours * 60 * 60 * 1000)); // add hours
$.cookie('showPWAModal', '0', {expires: expDate, path: '/'});
} catch (e) {
}
}
//
//function HandleBackFunctionality() {
//// if (window.event) //Internet Explorer
//// {
//// alert("Browser back button is clicked on Internet Explorer...");
//// } else //Other browsers e.g. Chrome
//// {
//// alert("Browser back button is clicked on other browser...");
//// }
//// console.log(sessionStorage.getItem("lastpage"));
//
// window.event.preventDefault();
// window.event.stopPropagation();
// window.history.pushState("", "Bajao Music", sessionStorage.getItem("prevpage"));
// location.reload();
//}
function getNumber() {
// var res = sessionStorage.getItem("msisdn");
// if (res) {
// var params = "ip=&countryName=" + res;
// $.ajax({
// type: 'POST',
// url: '/setNumber',
// data: params,
// async: false
// });
// } else {
$.ajax({
type: 'GET',
url: 'http://bajao.pk/number/json',
async: false
}).done(function (res) {
if (res) {
if (res.msisdn) {
// sessionStorage.setItem("cCode", res.msisdn);
var msisdn = (res.msisdn + "").substring(2);
$("#msisdn_entered").val(msisdn);
}
// var params = "ip=" + res.ip + "&countryName=" + res.countryCode;
// $.ajax({
// type: 'POST',
// url: '/setNumber',
// data: params,
// async: false
// }).done(function (res) {
// }).fail(function (response) {
// }).always(function () {
// });
}
}).fail(function (response) {
// console.log('failed');
}).always(function () {
});
// }
}
function getLastLoggedNumber() {
$.ajax({
type: 'POST',
url: '/api/user/getLoggedInUser?siteid=' + getParameterByName("siteid"),
async: false
}).done(function (res) {
if (res) {
$("#msisdn_entered").val(res);
} else {
// getNumber();
}
}).fail(function (response) {
// getNumber();
}).always(function () {
});
// }
}
function getSearchedHistory() {
$(".searchHistory").html("");
$.ajax({
type: 'POST',
url: '/api/search/history?siteid=' + getParameterByName("siteid"),
async: false,
dataType: "JSON"
}).done(function (res) {
try {
if (res && res.respCode == "00" && res.respData != null) {
var data = res.respData;
$.each(data, function (i, item) {
$(searchHistoryTemplate({
title: data[i].keyword
})).data("content", data[i]).appendTo(".searchHistory");
});
} else {
$(".searchHistory").remove();
}
} catch (er) {
}
}).fail(function (response) {
// getNumber();
$(".searchHistory").remove();
}).always(function () {
});
// }
}
function checkForGAConversion() {
if (getParameterByName("clickcode")) {
try {
firebaseObj.analytics()
.logEvent("cmp_page_view", {
description: "" + window.location.pathname,
clickCode: getParameterByName("clickcode")
});
} catch (er) {
}
} else {
logEvent("page_view", "Song-" + getPathVariableByIndex(3));
}
if (getParameterByName("sub") && getParameterByName("sub") == "true") {
if ($("#packgText").html().trim() == "") {
loadPackages();
}
$("#subcribemodal2").modal("show");
replaceParameterByName("sub", "");
} else if (getParameterByName("gsub") && getParameterByName("gsub") == "true") {
replaceParameterByName("gsub", "");
if (!sessionStorage.getItem("gsub")) {
// gtag_report_conversion("");
sessionStorage.setItem("gsub", true);
}
} else if (getParameterByName("gpsub") && getParameterByName("gpsub") == "true") {
if ($("#packgText").html().trim() == "") {
loadPackages();
}
$("#subcribemodal2").modal("show");
replaceParameterByName("gpsub", "");
sessionStorage.setItem("gpsub", "true");
}
}
//function getMCPValidated() {
// isMCPValidated = true;
// var params = "siteid=" + getParameterByName("siteid") + "&uniqid=" + $("#uniqid").val();
// $.ajax({
// type: 'POST',
// url: '/mcpHit',
// data: params,
// dataType: "JSON"
// }).done(function (res) {
// }).fail(function (response) {
//// getNumber();
// $(".searchHistory").remove();
// }).always(function () {
// });
//// }
//}
//var respo;
function getValidated(token) {
isEMPValidated = true;
// if (!userProfile) {
var dt = new Date();
try {
dt = dt.toIsoString();
} catch (er) {
dt = "";
}
var clickcode = getParameterByName("clickcode") ? getParameterByName("clickcode") : "";
$.ajax({
type: 'POST',
url: '/api/user/loaded?siteid=' + getParameterByName("siteid"),
data: {
token: token,
timestamp: dt,
cc: clickcode
},
async: false
}).done(function (res) {
// console.log('emp success');
}).fail(function (response) {
// console.log('failed');
}).always(function () {
});
// }
}
function logDBEvent(page, type, content) {
var clickcode = getParameterByName("clickcode") ? getParameterByName("clickcode") : "";
$.ajax({
type: 'POST',
url: '/api/logVisit?siteid=' + getParameterByName("siteid"),
data: {
page: page,
clickcode: clickcode,
category: type,
content: content
},
async: true
});
// }
}
function getAndRenderPaymentMethods() {
// console.log('getAllPaymentMethods');
// $(".loader-generic").show();
$.ajax({
type: 'POST',
url: '/api/paymentMethods',
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
var data = res.respData;
$.each(data, function (i, item) {
if (data[i]) {
var icon;
if (data[i][0].type == "Mobile_Billing") {
icon = "https://vidly.tv/image/logos/circle-option-icon.png"
} else {
icon = "https://vidly.tv/image/logos/Mobile-Wallets.png";
}
if (i.toLowerCase() != 'paypal') {
$(paymentsTypeTemplateNew({
paymentTypeIcon: icon,
paymentType: data[i][0].type.toLowerCase(),
paymentTypeTitle: i.replace("_", " ")
})).data("content", data[i]).appendTo(".allpayments");
}
if (i.toLowerCase() == "wallet") {
$(paymentsEmailNumberFormTemplate({})).appendTo(".allpayments");
}
if (i.toLowerCase() == 'paypal') {
$(paypalTypeTemplate({
paymentTypeIcon: data[i].image,
paymentType: data[i].type.toLowerCase(),
paymentTypeTitle: data[i].name
})).data("content", data[i]).appendTo(".allpayments");
var payments = data[i].dataList;
$.each(payments, function (j, item) {
$(paypalOptionTemplate({
payOptionIcon: payments[j].image
})).data("content", payments[j]).appendTo(".type_" + data[i].type.toLowerCase());
renderPaypalButtons();
});
} else if (i.toLowerCase() == 'card') {
var payments = data[i].dataList;
$.each(payments, function (j, item) {
$(cardOptionTemplate({
payOptionIcon: payments[j].image
})).data("content", payments[j]).appendTo(".type_" + data[i].type.toLowerCase());
});
var pack = payments[0].packages[0];
$("#cardPkgName").val(pack.name);
$("#cardDescription").val(pack.description);
$("#cardAmount").val(pack.price * 100);
$("#cardAmountFormatted").val("$" + pack.price);
} else {
var payments = data[i];
$.each(payments, function (j, item) {
if (payments[j].id == 64) { //Jazz
$(telcoPaymentsOptionTemplate({
payOptionIcon: payments[j].image,
paymentMethodId: payments[j].id,
payOptionDesc: payments[j].description
})).data("content", payments[j]).appendTo(".type_" + payments[j].type.toLowerCase());
$(paymentsPackTemplate({
paymentName: payments[j].name.toLowerCase().replace(" ", "_")
})).data("content", data[i]).appendTo(".allpayments");
var isChecked = "checked";
var pack = payments[j].paymentPackagesMappingCollection;
$.each(pack, function (k, item) {
selectedPackageForTelco = pack[0].packages.id;
packageDescription = pack[0].packages.description;
selectedTelco = payments[j].name.toLowerCase().replace(" ", "_");
$(telcoPackagesTemplate({
description: pack[k].packages.description,
pkgDesc: pack[k].packages.description,
id: pack[k].packages.id,
name: pack[k].packages.name,
cid: pack[k].packages.id,
checked: isChecked
})).data("content", pack[k].packages).appendTo("#package_" + payments[j].name.toLowerCase().replace(" ", "_"));
isChecked = "";
});
var userMsisdn = userProfile.msisdn ? userProfile.msisdn : "";
// $("#package_" + payments[j].name.toLowerCase().replace(" ", "_")).prepend(
// '
');
} else if (payments[j].id == 78) { //Telenor
$(telcoPaymentsOptionTemplate({
payOptionIcon: payments[j].image,
paymentMethodId: payments[j].id,
payOptionDesc: payments[j].description
})).data("content", payments[j]).appendTo(".type_" + payments[j].type.toLowerCase());
$(paymentsPackTemplate({
paymentName: payments[j].name.toLowerCase().replace(" ", "_")
})).data("content", data[i]).appendTo(".allpayments");
var isChecked = "checked";
var pack = payments[j].paymentPackagesMappingCollection;
$.each(pack, function (k, item) {
selectedPackageForTelco = pack[0].packages.id;
packageDescription = pack[0].packages.description;
selectedTelco = payments[j].name.toLowerCase().replace(" ", "_");
$(telcoPackagesTemplate({
description: pack[k].packages.description,
pkgDesc: pack[k].packages.description,
id: pack[k].packages.id,
name: pack[k].packages.name,
cid: pack[k].packages.id,
checked: isChecked
})).data("content", pack[k].packages).appendTo("#package_" + payments[j].name.toLowerCase().replace(" ", "_"));
isChecked = "";
});
var userMsisdn = userProfile.msisdn ? userProfile.msisdn : "";
// $("#package_" + payments[j].name.toLowerCase().replace(" ", "_")).prepend(
// '
');
} else if (payments[j].id == 9999) { //boku
$(telcoPaymentsOptionTemplate({
payOptionIcon: payments[j].image,
paymentMethodId: payments[j].id,
payOptionDesc: payments[j].description
})).data("content", payments[j]).appendTo(".type_" + data[i].type.toLowerCase());
$(paymentsPackTemplate({
paymentName: payments[j].name.toLowerCase().replace(" ", "_")
})).data("content", data[i]).appendTo(".allpayments");
var isChecked = "checked";
var pack = payments[j].packages;
$.each(pack, function (k, item) {
selectedPackageForTelco = pack[0].packages.id;
packageDescription = pack[0].packages.description;
selectedTelco = payments[j].name.toLowerCase().replace(" ", "_");
$(telcoPackagesTemplate({
description: pack[k].packages.description,
pkgDesc: pack[k].packages.description,
id: pack[k].packages.id,
name: pack[k].packages.name,
cid: pack[k].packages.id,
checked: isChecked
})).data("content", pack[k].packages).appendTo("#package_" + payments[j].name.toLowerCase().replace(" ", "_"));
isChecked = "";
});
} else {
$(paymentsOptionTemplateNew({
payOptionIcon: payments[j].image,
paymentMethodId: payments[j].id
})).data("content", payments[j]).appendTo(".type_" + payments[j].type.toLowerCase());
$(paymentsPackTemplateNew({
paymentName: payments[j].name.toLowerCase().replace(" ", "_")
})).data("content", data[i]).appendTo(".allpayments");
var isChecked = "checked";
var pack = payments[j].paymentPackagesMappingCollection;
$.each(pack, function (k, item) {
selectedPackageForTelco = pack[k].packages.id;
selectedTelco = payments[j].name.toLowerCase().replace(" ", "_");
$(packagesTemplate({
description: pack[k].packages.description,
id: pack[k].packages.id,
name: pack[k].packages.name,
cid: pack[k].packages.id,
checked: isChecked
})).data("content", pack[k].packages).appendTo("#package_" + payments[j].name.toLowerCase().replace(" ", "_"));
isChecked = "";
});
//Etisalat terms and conditions
if (payments[j].name.toLowerCase() == "etisalat") {
$("#package_" + payments[j].name.toLowerCase().replace(" ", "_")).prepend(
'
');
$("#package_" + payments[j].name.toLowerCase().replace(" ", "_")).append(
'After 1 Day FREE Trial you will be charged as per your selected package, VAT Included. '
+ 'EXIT ');
}
if (payments[j].name.toLowerCase() == "du") {
$("#package_" + payments[j].name.toLowerCase().replace(" ", "_")).prepend(
'
');
$("#package_" + payments[j].name.toLowerCase().replace(" ", "_")).append(
'You will be charged as per your selected package, VAT Included. '
+ 'EXIT ');
}
}
});
}
var userMsisdn = userProfile.msisdn ? userProfile.msisdn : "";
$("#msisdn").val(userMsisdn);
}
});
} else {
displayErrorNoty(res.msg);
}
$(".loader-generic").hide();
}).fail(function (response) {
$(".loader-generic").hide();
});
}
function renderPaypalButtons() {
try {
paypal.Buttons({
style: {
color: 'gold',
shape: 'pill',
layout: 'vertical',
label: 'subscribe',
},
createSubscription: function (data, actions) {
return actions.subscription.create({
'plan_id': 'P-1MX19879595394740L5ZOSHI'
});
},
// Finalize the transaction
onApprove: function (data, actions) {
$(".loader-generic").show();
var params = data.subscriptionID;
$.ajax({
type: 'POST',
url: '/api/user/subscribePaypal',
data: params,
dataType: "JSON"
}).done(function (response) {
$(".loader-generic").hide();
if (response.respCode === '00') {
try {
firebaseObj.analytics().logEvent("subscribe", {
package: 9,
operator: 1,
description: "success"
});
} catch (er) {
}
logDBEvent("subscribe", "event", 9 + "_success");
try {
fbq('track', 'Subscribe', {value: '4.99', currency: 'USD', predicted_ltv: '0.00'});
} catch (er) {
// console.log("Error fb track subscribe" + er);
}
displaySuccessNoty("Subscription " + response.msg, true, 3500);
setTimeout(function () {
window.location.href = "/home";
}, 3000);
} else {
try {
logEvent("subscription_failed", "subscription failed - " + response.msg);
} catch (er) {
}
logDBEvent("subscribe", "event", "failed");
displayErrorNoty("Subscription " + response.msg, true, 2500);
}
}).fail(function (response) {
logEvent("subscription_failed", "subscription failed due to network error.");
logDBEvent("subscribe", "event", "failed, subscription failed due to network error.");
$(".loader-generic").hide();
displayErrorNoty("Something went wrong", false, 1500);
});
}
}).render('#paypal-button-container');
} catch (e) {
displayErrorNoty("Something went wrong.");
}
}
function getAndRenderPaymentMethodsNew() {
// console.log('getAllPaymentMethods');
// $(".loader-generic").show();
var showPaypal = "0";
$.ajax({
type: 'POST',
url: '/api/paymentMethods',
dataType: "JSON"
}).done(function (res) {
if (res && res.respData !== null) {
var data = res.respData;
$.each(data, function (i, item) {
if (data[i]) {
var icon;
if (data[i][0].type == "Mobile_Billing") {
icon = "https://vidly.tv/image/logos/circle-option-icon.png"
} else {
icon = "https://vidly.tv/image/logos/Mobile-Wallets.png";
}
if (i.toLowerCase() != 'paypal') {
$(paymentsTypeTemplateNew({
paymentTypeIcon: icon,
paymentType: data[i][0].type.toLowerCase(),
paymentTypeTitle: i.replace("_", " ")
})).data("content", data[i]).appendTo(".allpayments");
}
if (i.toLowerCase() == "wallet") {
$(paymentsEmailNumberFormTemplate({})).appendTo(".allpayments");
}
if (i.toLowerCase() == 'paypal') {
showPaypal = "1";
$(paypalTypeTemplate({
paymentTypeIcon: data[i][0].image,
paymentType: data[i][0].type.toLowerCase(),
paymentTypeTitle: data[i][0].name
})).data("content", data[i]).appendTo(".allpaymentsPaypal");
$(paymentsOptionTemplatePaypal({
payOptionIcon: data[i][0].image,
paymentMethodId: data[i][0].id
})).data("content", data[i]).appendTo(".type_" + data[i][0].type.toLowerCase());
$(paymentsPackTemplatePaypal({
paymentName: data[i][0].name.toLowerCase().replace(" ", "_")
})).data("content", data[i]).appendTo(".allpaymentsPaypal");
var isChecked = "checked";
var pack = data[i][0].paymentPackagesMappingCollection;
$.each(pack, function (k, item) {
selectedPackageForTelco = pack[k].packages.id;
selectedTelco = data[i][0].name.toLowerCase().replace(" ", "_");
$(packagesTemplatePaypal({
description: pack[k].packages.description,
id: pack[k].packages.id,
name: pack[k].packages.name,
cid: pack[k].packages.id,
checked: isChecked
})).data("content", pack[k].packages).appendTo("#package_" + data[i][0].name.toLowerCase().replace(" ", "_"));
isChecked = "";
});
var payments = data[i];
$.each(payments, function (j, item) {
$(paypalOptionTemplate({
payOptionIcon: payments[j].image
})).data("content", payments[j]).appendTo(".paypalButtons");
renderPaypalButtons();
});
} else if (i.toLowerCase() == 'card') {
var payments = data[i].dataList;
$.each(payments, function (j, item) {
$(cardOptionTemplate({
payOptionIcon: payments[j].image
})).data("content", payments[j]).appendTo(".type_" + data[i].type.toLowerCase());
});
var pack = payments[0].packages[0];
$("#cardPkgName").val(pack.name);
$("#cardDescription").val(pack.description);
$("#cardAmount").val(pack.price * 100);
$("#cardAmountFormatted").val("$" + pack.price);
} else {
var payments = data[i];
$.each(payments, function (j, item) {
if (payments[j].id == 64) { //Jazz
$(telcoPaymentsOptionTemplate({
payOptionIcon: payments[j].image,
paymentMethodId: payments[j].id,
payOptionDesc: payments[j].description
})).data("content", payments[j]).appendTo(".type_" + payments[j].type.toLowerCase());
$(paymentsPackTemplate({
paymentName: payments[j].name.toLowerCase().replace(" ", "_")
})).data("content", data[i]).appendTo(".allpayments");
var isChecked = "checked";
var pack = payments[j].paymentPackagesMappingCollection;
$.each(pack, function (k, item) {
selectedPackageForTelco = pack[0].packages.id;
packageDescription = pack[0].packages.description;
selectedTelco = payments[j].name.toLowerCase().replace(" ", "_");
$(telcoPackagesTemplate({
description: pack[k].packages.description,
pkgDesc: pack[k].packages.description,
id: pack[k].packages.id,
name: pack[k].packages.name,
cid: pack[k].packages.id,
checked: isChecked
})).data("content", pack[k].packages).appendTo("#package_" + payments[j].name.toLowerCase().replace(" ", "_"));
isChecked = "";
});
var userMsisdn = userProfile.msisdn ? userProfile.msisdn : "";
// $("#package_" + payments[j].name.toLowerCase().replace(" ", "_")).prepend(
// '
');
} else if (payments[j].id == 78) { //Telenor
$(telcoPaymentsOptionTemplate({
payOptionIcon: payments[j].image,
paymentMethodId: payments[j].id,
payOptionDesc: payments[j].description
})).data("content", payments[j]).appendTo(".type_" + payments[j].type.toLowerCase());
$(paymentsPackTemplate({
paymentName: payments[j].name.toLowerCase().replace(" ", "_")
})).data("content", data[i]).appendTo(".allpayments");
var isChecked = "checked";
var pack = payments[j].paymentPackagesMappingCollection;
$.each(pack, function (k, item) {
selectedPackageForTelco = pack[0].packages.id;
packageDescription = pack[0].packages.description;
selectedTelco = payments[j].name.toLowerCase().replace(" ", "_");
$(telcoPackagesTemplate({
description: pack[k].packages.description,
pkgDesc: pack[k].packages.description,
id: pack[k].packages.id,
name: pack[k].packages.name,
cid: pack[k].packages.id,
checked: isChecked
})).data("content", pack[k].packages).appendTo("#package_" + payments[j].name.toLowerCase().replace(" ", "_"));
isChecked = "";
});
var userMsisdn = userProfile.msisdn ? userProfile.msisdn : "";
// $("#package_" + payments[j].name.toLowerCase().replace(" ", "_")).prepend(
// '
');
} else if (payments[j].id == 9999) { //boku
$(telcoPaymentsOptionTemplate({
payOptionIcon: payments[j].image,
paymentMethodId: payments[j].id,
payOptionDesc: payments[j].description
})).data("content", payments[j]).appendTo(".type_" + data[i].type.toLowerCase());
$(paymentsPackTemplate({
paymentName: payments[j].name.toLowerCase().replace(" ", "_")
})).data("content", data[i]).appendTo(".allpayments");
var isChecked = "checked";
var pack = payments[j].packages;
$.each(pack, function (k, item) {
selectedPackageForTelco = pack[0].packages.id;
packageDescription = pack[0].packages.description;
selectedTelco = payments[j].name.toLowerCase().replace(" ", "_");
$(telcoPackagesTemplate({
description: pack[k].packages.description,
pkgDesc: pack[k].packages.description,
id: pack[k].packages.id,
name: pack[k].packages.name,
cid: pack[k].packages.id,
checked: isChecked
})).data("content", pack[k].packages).appendTo("#package_" + payments[j].name.toLowerCase().replace(" ", "_"));
isChecked = "";
});
} else {
$(paymentsOptionTemplateNew({
payOptionIcon: payments[j].image,
paymentMethodId: payments[j].id
})).data("content", payments[j]).appendTo(".type_" + payments[j].type.toLowerCase());
$(paymentsPackTemplateNew({
paymentName: payments[j].name.toLowerCase().replace(" ", "_")
})).data("content", data[i]).appendTo(".allpayments");
var isChecked = "checked";
var pack = payments[j].paymentPackagesMappingCollection;
$.each(pack, function (k, item) {
selectedPackageForTelco = pack[k].packages.id;
selectedTelco = payments[j].name.toLowerCase().replace(" ", "_");
$(packagesTemplate({
description: pack[k].packages.description,
id: pack[k].packages.id,
name: pack[k].packages.name,
cid: pack[k].packages.id,
checked: isChecked
})).data("content", pack[k].packages).appendTo("#package_" + payments[j].name.toLowerCase().replace(" ", "_"));
isChecked = "";
});
//Etisalat terms and conditions
if (payments[j].name.toLowerCase() == "etisalat") {
$("#package_" + payments[j].name.toLowerCase().replace(" ", "_")).prepend(
'
');
$("#package_" + payments[j].name.toLowerCase().replace(" ", "_")).append(
'After 1 Day FREE Trial you will be charged as per your selected package, VAT Included. '
+ 'EXIT ');
}
if (payments[j].name.toLowerCase() == "du") {
$("#package_" + payments[j].name.toLowerCase().replace(" ", "_")).prepend(
'
');
$("#package_" + payments[j].name.toLowerCase().replace(" ", "_")).append(
'You will be charged as per your selected package, VAT Included. '
+ 'EXIT ');
}
}
});
const urlParams = new URLSearchParams(window.location.search);
const app = urlParams.get('app');
if (app == 'ANDROID' || app == 'IOS') {
$("#mBill").removeClass("active");
$("#wBill").addClass("active");
$("#mob_billing_tab").removeClass("active");
$("#mob_link_tab").removeClass("active");
$("#wallet_billing").addClass("active");
$("#wallet_74").trigger("click");
}
}
var userMsisdn = userProfile.msisdn ? userProfile.msisdn : "";
$("#msisdn").val(userMsisdn);
}
});
} else {
displayErrorNoty(res.msg);
}
$(".loader-generic").hide();
if (showPaypal === '0') {
$("#ppBill").removeClass("active");
$("#ppBill").addClass("hidden");
}
}).fail(function (response) {
$(".loader-generic").hide();
});
}
function downloadApk(redownload) {
var path = "/" + window.location.pathname.substr(0, window.location.pathname.lastIndexOf("/"));
// return;
// document.cookie.indexOf("apkAlreadyDownloaded") > 0
$.ajax({
type: "POST",
url: "/api/home/downloadApk",
dataType: 'json',
crossDomain: true,
data: {
is_redownload: redownload ? "1" : "0"
},
success: function (response) { // console.log(response + " : and path : " + path);
setCookie("apkAlreadyDownloaded", "1", 7, path);
// response.redownloadCount = response.redownloadCount === "-1" ? "1" : response.redownloadCount;
// $("a[rel=downloadapk]").html("Redownload APK? (" + response.redownloadCount + ") ");
// $(".hamburger.is-open").trigger("click");
if (response.msg.length > 0) {
window.location = response.msg;
} else {
// window.location = window.location.pathname.substring(0, window.location.pathname.indexOf("/", 2)) + "/home.jsp";
}
},
error: function (jqXHR, textStatus, error) {
// console.log(textStatus);
// showNoty("Oops! Something went wrong.", "error");
}
});
}
function setCookie(name, value, expiresInDays, path, domain, secure) {
var date = new Date();
date.setTime(+date + (expiresInDays * 86400000)); //60 * 60 * 1000
document.cookie = name + "=" + escape(value) +
((expiresInDays) ? "; expires=" + date.toGMTString() : "") +
("; path=/") + //you having wrong quote here
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
function whetherApkToDownload() {
// if (isMobile && !isIphone && !isSafari) {
// var liAPK = ""
// + ''
// + ''
// + ''
// + ''
// + ' '
// + ' '
// + ' '
// + 'Download APK '
// + " "
// + " ";
// $(".side-menu-ul").append(liAPK);
//
// if (document.cookie.indexOf("apkAlreadyDownloaded") > -1) {
// console.log("No Auto Trigger Downloaded APK");
// } else {
// console.log("Auto trigger Download APK");
// downloadApk(false);
// }
// }
}
/**
* Define the version of the Google Pay API referenced when creating your
* configuration
*
* @see {@link https://developers.google.com/pay/api/web/reference/request-objects#PaymentDataRequest|apiVersion in PaymentDataRequest}
*/
const baseRequest = {
apiVersion: 2,
apiVersionMinor: 0
};
/**
* Card networks supported by your site and your gateway
*
* @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}
* @todo confirm card networks supported by your site and gateway
*/
const allowedCardNetworks = ["MASTERCARD", "VISA"];
/**
* Card authentication methods supported by your site and your gateway
*
* @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}
* @todo confirm your processor supports Android device tokens for your
* supported card networks
*/
const allowedCardAuthMethods = ["PAN_ONLY", "CRYPTOGRAM_3DS"];
/**
* Identify your gateway and your site's gateway merchant identifier
*
* The Google Pay API response will return an encrypted payment method capable
* of being charged by a supported gateway after payer authorization
*
* @todo check with your gateway on the parameters to pass
* @see {@link https://developers.google.com/pay/api/web/reference/request-objects#gateway|PaymentMethodTokenizationSpecification}
*/
const tokenizationSpecification = {
type: 'PAYMENT_GATEWAY',
parameters: {
'gateway': 'example',
'gatewayMerchantId': 'exampleGatewayMerchantId'
}
};
/**
* Describe your site's support for the CARD payment method and its required
* fields
*
* @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}
*/
const baseCardPaymentMethod = {
type: 'CARD',
parameters: {
allowedAuthMethods: allowedCardAuthMethods,
allowedCardNetworks: allowedCardNetworks
}
};
/**
* Describe your site's support for the CARD payment method including optional
* fields
*
* @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}
*/
const cardPaymentMethod = Object.assign(
{},
baseCardPaymentMethod,
{
tokenizationSpecification: tokenizationSpecification
}
);
/**
* An initialized google.payments.api.PaymentsClient object or null if not yet set
*
* @see {@link getGooglePaymentsClient}
*/
let paymentsClient = null;
/**
* Configure your site's support for payment methods supported by the Google Pay
* API.
*
* Each member of allowedPaymentMethods should contain only the required fields,
* allowing reuse of this base request when determining a viewer's ability
* to pay and later requesting a supported payment method
*
* @returns {object} Google Pay API version, payment methods supported by the site
*/
function getGoogleIsReadyToPayRequest() {
return Object.assign(
{},
baseRequest,
{
allowedPaymentMethods: [baseCardPaymentMethod]
}
);
}
/**
* Configure support for the Google Pay API
*
* @see {@link https://developers.google.com/pay/api/web/reference/request-objects#PaymentDataRequest|PaymentDataRequest}
* @returns {object} PaymentDataRequest fields
*/
function getGooglePaymentDataRequest() {
const paymentDataRequest = Object.assign({}, baseRequest);
paymentDataRequest.allowedPaymentMethods = [cardPaymentMethod];
paymentDataRequest.transactionInfo = getGoogleTransactionInfo();
paymentDataRequest.merchantInfo = {
// @todo a merchant ID is available for a production environment after approval by Google
// See {@link https://developers.google.com/pay/api/web/guides/test-and-deploy/integration-checklist|Integration checklist}
merchantId: '12345678901234567890',
merchantName: 'Example Merchant'
};
return paymentDataRequest;
}
/**
* Return an active PaymentsClient or initialize
*
* @see {@link https://developers.google.com/pay/api/web/reference/client#PaymentsClient|PaymentsClient constructor}
* @returns {google.payments.api.PaymentsClient} Google Pay API client
*/
function getGooglePaymentsClient() {
if (paymentsClient === null) {
paymentsClient = new google.payments.api.PaymentsClient({environment: 'TEST'});
}
return paymentsClient;
}
/**
* Initialize Google PaymentsClient after Google-hosted JavaScript has loaded
*
* Display a Google Pay payment button after confirmation of the viewer's
* ability to pay.
*/
function onGooglePayLoaded() {
const paymentsClient = getGooglePaymentsClient();
paymentsClient.isReadyToPay(getGoogleIsReadyToPayRequest())
.then(function (response) {
if (response.result) {
addGooglePayButton();
// @todo prefetch payment data to improve performance after confirming site functionality
// prefetchGooglePaymentData();
}
})
.catch(function (err) {
// show error in developer console for debugging
console.error(err);
});
}
/**
* Add a Google Pay purchase button alongside an existing checkout button
*
* @see {@link https://developers.google.com/pay/api/web/reference/request-objects#ButtonOptions|Button options}
* @see {@link https://developers.google.com/pay/api/web/guides/brand-guidelines|Google Pay brand guidelines}
*/
function addGooglePayButton() {
if ($(".google-pay").children().length == 0) {
const paymentsClient = getGooglePaymentsClient();
const button =
paymentsClient.createButton({onClick: onGooglePaymentButtonClicked});
// document.getElementsByClassName('allpayments').appendChild(button);
$(".google-pay").append(button);
}
}
/**
* Provide Google Pay API with a payment amount, currency, and amount status
*
* @see {@link https://developers.google.com/pay/api/web/reference/request-objects#TransactionInfo|TransactionInfo}
* @returns {object} transaction info, suitable for use as transactionInfo property of PaymentDataRequest
*/
function getGoogleTransactionInfo() {
return {
countryCode: 'PK',
currencyCode: 'PKR',
totalPriceStatus: 'FINAL',
// set to cart total
totalPrice: '10.00'
};
}
/**
* Prefetch payment data to improve performance
*
* @see {@link https://developers.google.com/pay/api/web/reference/client#prefetchPaymentData|prefetchPaymentData()}
*/
function prefetchGooglePaymentData() {
const paymentDataRequest = getGooglePaymentDataRequest();
// transactionInfo must be set but does not affect cache
paymentDataRequest.transactionInfo = {
totalPriceStatus: 'NOT_CURRENTLY_KNOWN',
currencyCode: 'PKR'
};
const paymentsClient = getGooglePaymentsClient();
paymentsClient.prefetchPaymentData(paymentDataRequest);
}
/**
* Show Google Pay payment sheet when Google Pay payment button is clicked
*/
function onGooglePaymentButtonClicked() {
const paymentDataRequest = getGooglePaymentDataRequest();
paymentDataRequest.transactionInfo = getGoogleTransactionInfo();
const paymentsClient = getGooglePaymentsClient();
paymentsClient.loadPaymentData(paymentDataRequest)
.then(function (paymentData) {
// handle the response
processPayment(paymentData);
})
.catch(function (err) {
// show error in developer console for debugging
console.error(err);
});
}
/**
* Process payment data returned by the Google Pay API
*
* @param {object} paymentData response from Google Pay API after user approves payment
* @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentData|PaymentData object reference}
*/
function processPayment(paymentData) {
// show returned data in developer console for debugging
// console.log(paymentData);
// @todo pass payment token to your gateway to process payment
paymentToken = paymentData.paymentMethodData.tokenizationData.token;
}
/////////////////SOCIAL LOGIN/////////////////////////
function checkLoginState() { // Called when a person is finished with the Login Button.
FB.getLoginStatus(function (response) { // See the onlogin handler
statusChangeCallback(response);
});
}
function statusChangeCallback(response) { // Called with the results from FB.getLoginStatus().
// console.log('statusChangeCallback');
// console.log(response); // The current login status of the person.
if (response.status === 'connected') { // Logged into your webpage and Facebook.
//testAPI();
// console.log(response.authResponse.accessToken);
sendTokenToServerSocial(response.authResponse.accessToken, "", "FACEBOOK");
// window.location.href = "/";
} else { // Not logged into your webpage or we are unable to tell.
// document.getElementById('status').innerHTML = 'Please log ' +
// 'into this webpage.';
}
}
function statusChangeCallbackMsisdnToSocial(response) { // Called with the results from FB.getLoginStatus().
// console.log('statusChangeCallback');
// console.log(response); // The current login status of the person.
if (response.status === 'connected') { // Logged into your webpage and Facebook.
//testAPI();
// console.log(response.authResponse.accessToken);
sendTokenToServerSocialMsisdnToSocial(response.authResponse.accessToken, "", "FACEBOOK");
// window.location.href = "/";
} else { // Not logged into your webpage or we are unable to tell.
// document.getElementById('status').innerHTML = 'Please log ' +
// 'into this webpage.';
}
}
function testAPI() { // Testing Graph API after login. See statusChangeCallback() for when this call is made.
// console.log('Welcome! Fetching your information.... ');
FB.api('/me?scope=email', function (response) {
var myUserEntity = {};
myUserEntity.Id = response.id;
myUserEntity.Name = response.name;
sessionStorage.setItem('myUserEntity', JSON.stringify(myUserEntity));
// console.log('Successful login for: ' + response.name);
// console.log(response);
});
var fProfile = JSON.parse(sessionStorage.getItem('myUserEntity'));
FB.api('/' + fProfile.Id + '/picture?redirect=0', 'GET', {}, function (response) {
var fProfile = JSON.parse(sessionStorage.getItem('myUserEntity'));
if (response && response.data) {
fProfile.Image = response.data.url;
sessionStorage.setItem('myUserEntity', JSON.stringify(fProfile));
}
}
);
}
//////google//////
function displayGoogleNameAndImage() {
try {
if (sessionStorage.getItem('myUserEntity') !== null) {
var gProfile = JSON.parse(sessionStorage.getItem('myUserEntity'));
$(".thumb-welc").find("img").attr("src", gProfile.Image);
if ($(".about-us") && $(".about-us").html().trim() === "") {
$(".title-user").html(gProfile.Email);
}
$(".account-email-heading").html(gProfile.Email);
}
} catch (er) {
}
}
function onSignIn(googleUser) {
var id_token = googleUser.getAuthResponse().id_token;
var profile = googleUser.getBasicProfile();
// console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
// console.log('Name: ' + profile.getName());
// console.log('Image URL: ' + profile.getImageUrl());
// console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
sendTokenToServerSocial(id_token, profile.getEmail(), "GMAIL");
var myUserEntity = {};
myUserEntity.Id = profile.getId();
myUserEntity.Name = profile.getName();
myUserEntity.Email = profile.getEmail();
myUserEntity.Image = profile.getImageUrl();
sessionStorage.setItem('myUserEntity', JSON.stringify(myUserEntity));
}
function msisdnToSocial(googleUser) {
var id_token = googleUser.getAuthResponse().id_token;
var profile = googleUser.getBasicProfile();
// console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
// console.log('Name: ' + profile.getName());
// console.log('Image URL: ' + profile.getImageUrl());
// console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
sendTokenToServerSocialMsisdnToSocial(id_token, profile.getEmail(), "GMAIL");
var myUserEntity = {};
myUserEntity.Id = profile.getId();
myUserEntity.Name = profile.getName();
myUserEntity.Email = profile.getEmail();
myUserEntity.Image = profile.getImageUrl();
sessionStorage.setItem('myUserEntity', JSON.stringify(myUserEntity));
}
function sendTokenToServerSocialMsisdnToSocial(token, username, platform) {
if (token !== "") {
var params = "id=" + token + "&username=" + username + "&platform=" + platform;
$.ajax({
type: 'POST',
url: '/api/regsiterSocialAccountWithMsisdn',
data: params,
dataType: "JSON"
}).done(function (response) {
if (response && response.respCode !== "00") {
displayErrorNoty(response.msg, false, 1500);
} else {
window.location.href = "/";
}
}).fail(function (response) {
displayErrorNoty("Someting went wrong.", false, 1500);
}).always(function () {
});
} else {
// displayErrorNoty("Please Enter Valid pin", false, 1500);
}
}
function sendTokenToServerSocial(token, username, platform) {
if (token !== "") {
var params = "id=" + token + "&username=" + username + "&platform=" + platform;
$.ajax({
type: 'POST',
url: '/api/user/sociallogin/verify',
data: params,
dataType: "JSON"
}).done(function (response) {
if (response && response.respCode !== "00") {
displayErrorNoty(response.msg, false, 1500);
} else {
window.location.href = "/";
}
}).fail(function (response) {
displayErrorNoty("Someting went wrong.", false, 1500);
}).always(function () {
});
} else {
// displayErrorNoty("Please Enter Valid pin", false, 1500);
}
}
var googleUser = {};
var auth2;
var startApp = function () {
gapi.load('auth2', function () {
// Retrieve the singleton for the GoogleAuth library and set up the client.
auth2 = gapi.auth2.init({
// client_id: '957297453451-hmi4tl4tjmealkteo70vlut5ldb5sl63.apps.googleusercontent.com',
client_id: '992465485198-ppcqpm4qekc27qu505o1c56baqisntki.apps.googleusercontent.com',
cookiepolicy: 'single_host_origin',
// Request scopes in addition to 'profile' and 'email'
//scope: 'additional_scope'
});
attachSignin(document.getElementById('googleSignInButton'));
});
};
var googleUserLink = {};
var startAppMsisdnToSocial = function () {
gapi.load('auth2', function () {
// Retrieve the singleton for the GoogleAuth library and set up the client.
auth2 = gapi.auth2.init({
// client_id: '957297453451-hmi4tl4tjmealkteo70vlut5ldb5sl63.apps.googleusercontent.com',
client_id: '992465485198-ppcqpm4qekc27qu505o1c56baqisntki.apps.googleusercontent.com',
cookiepolicy: 'single_host_origin',
// Request scopes in addition to 'profile' and 'email'
//scope: 'additional_scope'
});
attachSigninMsisdnToSocial(document.getElementById('googleSignInButton'));
});
};
function attachSignin(element) {
// console.log(element.id);
auth2.attachClickHandler(element, {},
function (googleUser) {
// document.getElementById('name').innerText = "Signed in: " +
// googleUser.getBasicProfile().getName();
onSignIn(googleUser);
}, function (error) {
// alert(JSON.stringify(error, undefined, 2));
}
);
}
function attachSigninMsisdnToSocial(element) {
// console.log(element.id);
auth2.attachClickHandler(element, {},
function (googleUser) {
// document.getElementById('name').innerText = "Signed in: " +
// googleUser.getBasicProfile().getName();
msisdnToSocial(googleUser);
}, function (error) {
// alert(JSON.stringify(error, undefined, 2));
}
);
}
function socialLogout() {
//Don't forget to clear sessionStorage when user logs out
sessionStorage.clear();
try {
FB.logout(function (response) {
// user is now logged out
// console.log("FB logout");
});
} catch (er) {
}
try {
FB.logout(function (response) {
// user is now logged out
// console.log("FB logout");
});
} catch (er) {
}
try {
signOutGmail();
} catch (er) {
}
}
function signOutGmail() {
var auth2 = gapi.auth2.getAuthInstance();
auth2.signOut().then(function () {
// console.log('User signed out.');
});
}
function searchArtist(event, t) {
var keyword = $("#searchArtistInput").val();
if (keyword !== "") {
if (event == null || event.key === 'Enter' || t === 'clicked' || event.which === 13) {
$(".searched-artist-div").removeClass("hidden");
$(".searched-artist-title").html(keyword);
loadAllSearchedArtist(0, 20, "modal", keyword);
return false;
}
}
}
function searchArtistPage(event, t) {
var keyword = $("#searchArtistInput").val();
if (keyword !== "") {
if (event == null || event.key === 'Enter' || t === 'clicked' || event.which === 13) {
$(".searched-artist-div").removeClass("hidden");
$(".searched-artist-title").html(keyword);
loadAllSearchedArtist(0, 20, "page", keyword);
return false;
}
}
}