/* Minification failed. Returning unminified contents.
(2358,6): run-time error JS1004: Expected ';'
(2360,35): run-time error JS1004: Expected ';'
(2362,26): run-time error JS1004: Expected ';'
(3469,25-33): run-time error JS1006: Expected ')': function
(3469,36): run-time error JS1004: Expected ';'
(3472,25): run-time error JS1004: Expected ';'
(4055,2-3): run-time error JS1195: Expected expression: )
*/
/*
Copyright 2013 - SmartAdmin Template
* This script is part of an item on wrapbootstrap.com
* https://wrapbootstrap.com/user/myorange
*
* * *
* For more information please contact info@myorange.ca
* * */
$.sound_path = "/themes/new/content/sound/";
$.sound_on = true; // turn off sound if you are having issues with Safari.
jQuery(document).ready(function () {
// Plugins placing
$("body").append("
");
$("body").append("");
});
//Closing Rutine for Loadings
function SmartUnLoading() {
$(".divMessageBox").fadeOut(300, function () {
$(this).remove();
});
$(".LoadingBoxContainer").fadeOut(300, function () {
$(this).remove();
});
}
// Messagebox
var ExistMsg = 0,
SmartMSGboxCount = 0,
PrevTop = 0;
$.SmartMessageBox = function (settings, callback) {
var SmartMSG, Content;
settings = $.extend({
title: "",
content: "",
NormalButton: undefined,
ActiveButton: undefined,
buttons: undefined,
input: undefined,
inputValue: undefined,
placeholder: "",
options: undefined
}, settings);
var PlaySound = 0;
PlaySound = 1;
//Messagebox Sound
// SmallBox Sound
if (isIE8orlower() == 0) {
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', $.sound_path + 'messagebox.mp3');
//$.get();
audioElement.addEventListener("load", function () {
audioElement.play();
}, true);
audioElement.pause();
audioElement.play();
}
SmartMSGboxCount = SmartMSGboxCount + 1;
if (ExistMsg == 0) {
ExistMsg = 1;
SmartMSG = "";
$("body").append(SmartMSG);
if (isIE8orlower() == 1) {
$("#MsgBoxBack").addClass("MessageIE");
}
}
var InputType = "";
var HasInput = 0;
if (settings.input != undefined) {
HasInput = 1;
settings.input = settings.input.toLowerCase();
switch (settings.input) {
case "text":
settings.inputValue = $.type(settings.inputValue) === 'string' ? settings.inputValue.replace(/'/g, "'") : settings.inputValue;
InputType = "
";
break;
case "password":
InputType = "
";
break;
case "select":
if (settings.options == undefined) {
alert("For this type of input, the options parameter is required.");
} else {
InputType = ""
}
break;
default:
alert("That type of input is not handled yet");
}
}
Content = "
');
}
$('#msg_panel_pip').css("width", $('#slidescreen img').width());
}
function alertEmpty() {
if ($('#msg_panel').length > 0 && $('#msg_panel').html() != undefined && $('#msg_panel').html().length > 0) {
return false;
} else {
return true;
}
}
var getRightOffset = function (childElement) {
return ($(mainViewColumn).width() - $(childElement).outerWidth()) - ($(childElement).offset().left - $(mainViewColumn).offset().left);
}
var getBottomOffset = function (childElement) {
return ($(mainViewColumn).height() - $(childElement).outerHeight()) - ($(childElement).offset().top - $(mainViewColumn).offset().top);
}
function adjustPIPHeight() {
//For adjust alert height
if (toggleBtn2 != null && $(toggleBtn2).closest('li').hasClass('active')) {
VideoWidgetPIP();
} else if (toggleBtn1 != null && $(toggleBtn1).closest('li').hasClass('active')) {
SlideWidgetPIP();
} else if (toggleBtn3 != null && $(toggleBtn3).closest('li').hasClass('active')) {
toggleBtn3ToggleVideoSlide();
} else {
adjustPartcipationCode();
}
adjustAlert();
}
function adjustPartcipationCode() {
if (vidPlayer && vidPlayer.isFullscreen()) {
$("#slidescreen .lc_panel").hide();
$("#media-video .lc_panel").css('display', "table");
} else {
$("#slidescreen .lc_panel").css('display', '');
$("#media-video .lc_panel").css('display', '');
if (!$("#media-panel").hasClass("PIPV")) {
$("#media-panel #mainView .row").css("max-width", "");
}
}
if ($("#media-video").length > 0 && $("#media-video .lc_panel").length > 0) {
var leftPostion = $("#media-video").offset().left + 20;
$("#media-video .lc_panel").css('left', leftPostion);
}
if ($("#slidescreen img").length > 0 && $("#slidescreen .lc_panel").length > 0) {
var leftPostion = $("#slidescreen img").offset().left + 20;
$("#slidescreen .lc_panel").css('left', leftPostion);
}
}
function removeActivePIPFunctions() {
//For adjust alert height
if (toggleBtn2 != null && $(toggleBtn2).closest('li').hasClass('active')) {// $(toggleBtn2).hasClass('btn-success')
$(toggleBtn2).trigger('click');
} else if (toggleBtn1 != null && $(toggleBtn1).closest('li').hasClass('active')) {
$(toggleBtn1).trigger('click');
} else if (toggleBtn3 != null && $(toggleBtn3).closest('li').hasClass('active')) {
$(toggleBtn3).trigger('click');
}
}
function loadAttendanceHistory() {
$("#btnRestartSeminarHistory").closest('div > #grid-list').load('/Items/GetAttendanceHistory?entityId=' + Entityid + '&customerId=' + CustomerId + '&programRegistrantId=' + ProgramRegistrantId + '&IsFromViewer=true', function () {
});
}
// #7808: Viewer Activity Confirmation - "Are you still there?"
var globalIdleTime = 0;
var idleInterval;
jQuery(document).ready(function () {
setIdleTime(0, true);
//Increment the idle time counter every minute.
idleInterval = setInterval(timerIncrement, 60000); // 1 minute
//Zero the idle timer on mouse movement.
jQuery(this).mousemove(function (e) {
setIdleTime(0, true);
});
jQuery(this).keypress(function (e) {
setIdleTime(0, true);
});
});
function timerIncrement() {
var idleTime = getIdleTime() + 1;
setIdleTime(idleTime, false);
if (idleTime >= 120 && new Date().getHours() == 1) { // 120 minutes //And Close at 01:00 AM as per mantis ticket #7808: Viewer Activity Confirmation - "Are you still there?"
promptForSession();
}
}
var setIdleTime = function (count, forcefully) {
try {
//console.log('Idle Time Called');
if (typeof (localStorage) == undefined || typeof (localStorage) == "undefined") {
globalIdleTime = count;
} else if (allowToSetIdleTime() || forcefully == true) {
localStorage.setItem('idleTime', JSON.stringify({
time: new Date(),
count: count
}));
// console.log('Idle Time Updated');
}
} catch (e) {
}
}
var allowToSetIdleTime = function () {
if (typeof (localStorage) == undefined || typeof (localStorage) == "undefined") {
return true;
}
else {
if (localStorage.getItem('idleTime') != null) {
var diffSeconds = (new Date() - new Date(JSON.parse(localStorage.getItem('idleTime')).time)) / 1000;
return diffSeconds > 55;
} else {
return true;
}
}
}
var getIdleTime = function () {
if (typeof (localStorage) == undefined || typeof (localStorage) == "undefined") {
return globalIdleTime;
} else {
if (localStorage.getItem('idleTime') != null) {
return JSON.parse(localStorage.getItem('idleTime')).count;
} else {
return 0;
}
}
}
function promptForSession() {
var counter = 300;
// ask verification
$.SmartMessageBox({
title: " Are you still there ?",
content: "
To protect your account information, when too much time passes with no activity, we schedule an automatic logout.
A logout is scheduled in 300 seconds.
To remain logged in, select OK.
",
buttons: '[OK]'
}, function (ButtonPressed) {
if (ButtonPressed == "OK") {
clearInterval(countdown);
//continue session
setIdleTime(0, true);
idleInterval = setInterval(timerIncrement, 60000); // 1 minute
}
});
var countdown = setInterval(function () {
counter--;
if (counter >= 0) {
$("#timeCounter").html(counter);
}
// Display 'counter' wherever you want to display it.
if (counter === 0) {
clearInterval(countdown);
clearInterval(idleInterval);
//alert('To protect your account information, you are now automatically logged out of your account due to 5 minutes of inactivity.');
window.location.href = "/account/logoff?returnUrl=" + location.pathname;
}
}, 1000);
}
// Forum load more
$('body').on('click', '.clsLoadMoreForum', function () {
var lastDiv = $(this).closest('div').prev(".divForumWidgetPost:last");
var currentElemet = $(this);
if (lastDiv.length > 0) {
var previousProductForumId = $(lastDiv).attr("data-ProductForumId");
var forumSettingType = $(this).attr("data-ForumSettingType");
//mantis item : #14531
var fTimeId = e;
var fSeminarId = s;
//mantis item : #14531
if (forumSettingType === "Product") {
fTimeId = pe;
fSeminarId = ps;
}
var PageWidgetID = $(this).attr("data-PageWidgetID");
var entityId = $(this).attr("data-entityId");
//var url = '/showtimewidget/forumwidget?PageWidgetID=' + PageWidgetID + '&SeminarId=' + s + '&TimeId=' + e + '&CustomerId=' + u + '&ParentForumId=0&forumSettingType=' + forumSettingType + '&entityId=' + entityId + "&PreviousProductForumId=" + previousProductForumId;
//manits item : #14531
$.get('/showtimewidget/forumwidget', { PageWidgetID: PageWidgetID, SeminarId: fSeminarId, TimeId: fTimeId, CustomerId: u, ParentForumId: 0, forumSettingType: forumSettingType, entityId: entityId, PreviousProductForumId: previousProductForumId, parentSeminarId: ps, parentTimeId: pe }, function (result) {
if (result.length > 0) {
$($(result).filter("#hdnDatetimeUtcNow")).remove();
$(lastDiv).after($(result));
if (Number($(result).filter("#hdnRemainingPreviousPostCount").val()) > 0) {
currentElemet.closest('div').show();
}
else {
currentElemet.closest('div').hide();
}
}
else {
currentElemet.closest('div').hide();
}
});
}
});
$('.navbar-toggle, .info-toggle-nav').click(function () {
$(window).trigger('resize');
});
$(document).on('click', '.expandCollapseInfo', function () {
if ($(this).find('i').hasClass('fa-plus')) {
$(this).html(' Event Log');
if ($('#divEventLogs').length > 0 && $('#UlEventLogs').length > 0) {
$('#UlEventLogs').html($('#divEventLogs').html());
}
$(this).closest('#eventlog').find('.HidedInformationPanel').show('slow');
} else {
$(this).html(' Event Log');
$(this).closest('#eventlog').find('.HidedInformationPanel').hide('slow');
}
});
$(document).on('click', '.navbar-toggle[data-target=".navbar-collapse"]', function () {
setTimeout(function () { navBarForSmallScreen(); }, 300);
});
$(document).on('click', '#btnHelpReloadViewer,#btnReloadViewer', function () {
if (typeof (compositionComplete) == "function" && vidPlayer) {
if (curMediaClip && seminar.IsArchive == false && (seminar.IsLive || seminar.IsReplay)) {
//curMediaClip = null;
GetLatestSeminarMedia();
}
else {
var video = videojs('media-video');
video.pause();
var currentTime = video.currentTime();
video.load();
video.one(video, "canplay", () => {
video.currentTime(currentTime);
video.play();
});
}
} else {
location.reload();
}
});
// get the latest medias #9776
function GetLatestSeminarMedia() {
$.ajax({
type: 'GET',
url: '/showtimewidget/getseminarmedia',
dataType: 'json',
data: {
'SeminarId': s
},
success: function (currSeminar) {
seminar.MediaClips = currSeminar.MediaClips;
curMediaClip = null;
},
});
}
function navBarForSmallScreen() {
if ($(window).width() < 768) {
var isVisible = $('.navbar.navbar-fixed-top .navbar-collapse').is(':visible');
console.log(isVisible)
if (isVisible === true) {
var height = $('.navbar-collapse').closest('.navbar.navbar-fixed-top').outerHeight() + 10 + "px !important;";
$('#mobileCss').html('#info-panel{margin-bottom:' + height + '}');
} else {
$('#mobileCss').html('');
}
} else {
$('#mobileCss').html('');
}
}
function scrollOnSpecificDiv(divid) {
if ($(window).width() < 992) {
$(window).scrollTop($(divid).offset().top);
}
}
$(document).on('click', '#btnHelpReloadWholeViewer', function () {
location.reload(); //mantis #8479
});
// new Forum Start
$('body').on("keydown", ".postcom, .txtCommentBox", function () {
autosize($(this))
});
function autosize(el) {
setTimeout(function () {
$(el).css({ 'height': 'auto' });
$(el).css({ 'height': parseInt($(el)[0].scrollHeight) + 10 + 'px' });
}, 0);
}
$("body").on("click", ".clsExpandAllComment", function () {
var ele = $(this);
var forumWidget = $(ele).closest('.ForumWidget');
var divId = $(this).attr("data-value");
var forumWidgetMain = $(ele).closest('.ForumWidgetMain');
if ($(ele).attr("data-Expanded") == "false") {
if ($(forumWidget).find("#" + divId).length > 0 && $(forumWidget).find("#" + divId).html().length == 0) {
expandComments(ele);
}
$(ele).text("Close previous comments");
$(forumWidget).find("#" + divId).show('slow');
$(ele).attr("data-Expanded", "true");
$(ele).closest(".divForumWidgetPost").attr("data-Expanded", "true");
$(forumWidgetMain).find(forumWidget).find('.viewcomment #divNewComments' + divId + ' .singlereply[data-replyid]').show();
} else {
$(ele).text("View previous comments");
$(forumWidget).find("#" + divId).hide('slow');
$(ele).attr("data-Expanded", "false");
$(ele).closest(".divForumWidgetPost").attr("data-Expanded", "false");
if ($(forumWidgetMain).find(forumWidget).find('#divNewComments' + divId + ' .singlereply[data-replyid]').length > 1) {
$(forumWidgetMain).find(forumWidget).find('#divNewComments' + divId + ' .singlereply[data-replyid]').not(':last').hide();
}
}
});
$("body").on("click", ".clsCommentShow", function () {
var ele = $(this);
var forumWidget = $(ele).closest('.ForumWidget');
var divId = $(this).attr("data-value");
var forumWidgetMain = $(ele).closest('.ForumWidgetMain');
if ($(forumWidget).find("#" + divId).length > 0 && $(forumWidget).find("#" + divId).html().length == 0) {
expandComments(ele);
}
$(forumWidget).find("#" + divId).show('slow');
$(ele).attr("data-Expanded", "true");
$(ele).closest(".divForumWidgetPost").attr("data-Expanded", "true");
$(ele).closest(".divForumWidgetPost").find(".clsExpandAllComment").text("Close previous comments");
$(ele).closest(".divForumWidgetPost").find(".clsExpandAllComment").attr("data-Expanded", "true");
$(forumWidgetMain).find(forumWidget).find('.viewcomment .divNewComments .singlereply[data-replyid]').show();
});
function expandComments(element) {
var productForumId = element.closest(".divForumWidgetPost").attr('data-ProductForumId');
var forumWidgetMain = $(element).closest('.ForumWidgetMain');
var forumSettingId = $(forumWidgetMain).attr('data-forumSettingId');
var forumSettingType = $(forumWidgetMain).attr('data-forumSettingType');
var ForumWidgetPostId = '.ForumWidgetPost' + productForumId;
var forumWidget = $(element).closest('.ForumWidget');
// for integrated forum dropdown
var isIntegratedForum = false;
if ($(forumWidgetMain).attr('data-isintegratedfroum') == "true") {
isIntegratedForum = true;
}
var isDisplayAllComment = true;
var url = "/showtimewidget/forumwidgetsingle?ParentForumId=" + productForumId + "&forumSettingId=" + forumSettingId + "&isIntegratedForum=" + isIntegratedForum + "&isDisplayAllComments=" + isDisplayAllComment;
var updatedDiv = ".ForumWidgetPost" + productForumId;
$.get(url, function (result) {
//$(forumWidget).find(updatedDiv).html($(result).filter(updatedDiv).html());
$(forumWidget).find(updatedDiv).find('.viewcomment').replaceWith($(result).filter(updatedDiv).find('.viewcomment'));
$(forumWidget).find(updatedDiv).find('.socialPost').replaceWith($(result).filter(updatedDiv).find('.socialPost'));
});
}
$("body").on('focus', '.clstextForumWidgetPost', function () {
$(this).closest('.ForumWidgetMain').find(".clsForumWidgetPostBottom").show();
});
function showReplytBox(element) {
var productForumId = $(element).attr('data-val');
var settingId = $(element).attr('data-SettingId');
$('#txtProductForumComment' + productForumId + '[data-settingid="' + settingId + '"]').focus();
}
function showPreview(objFileInput) {
if (objFileInput.files[0]) {
var forumWidgetMain = $(objFileInput).closest('.ForumWidgetMain');
var fileExtension = ['gif', 'jpeg', 'jpg', 'png', 'ico', 'bmp','webp','avif'];
var File = objFileInput.files[0];
var FileName = File.name;
if ($.inArray(FileName.split('.').pop().toLowerCase(), fileExtension) == -1) {
alert("Only the following formats are allowed: .jpg, .jpeg, .png, .gif, .bmp, .webp or .avif");
removepostedFile(forumWidgetMain);
return;
}
else {
var fileSize = objFileInput.files[0].size;
if (fileSize > (1048576 * 5)) {
alert("Maximum file size is 5 MB");
removepostedFile(forumWidgetMain);
return;
}
else {
var fileReader = new FileReader();
fileReader.onload = function (e) {
$(forumWidgetMain).find(".targetLayer").find('img').attr('src', e.target.result);
displayPostedFile(forumWidgetMain);
}
fileReader.readAsDataURL(objFileInput.files[0]);
}
}
}
}
$('body').on('click', '.removePostedFile', function () {
var element = $(this);
var forumWidgetMain = $(element).closest('.ForumWidgetMain');
removepostedFile(forumWidgetMain);
});
function removepostedFile(forumWidgetMain) {
$(forumWidgetMain).find(".uploadImage").val('');
$(forumWidgetMain).find(".divForumPostedFile").hide('');
$(forumWidgetMain).find(".divForumPostedFilebtn").show('');
}
function displayPostedFile(forumWidgetMain) {
$(forumWidgetMain).find(".divForumPostedFile").show('');
$(forumWidgetMain).find(".divForumPostedFilebtn").hide('');
}
$('body').on('click', '.lnkForumPostFile', function () {
var element = $(this);
var forumWidgetMain = $(element).closest('.ForumWidgetMain');
$(forumWidgetMain).find(".uploadImage").trigger('click');
});
$('body').on('change', '.clstextForumWidgetPost', function () {
bindUrlDetails($(this));
});
// pasting any data.
$(".clstextForumWidgetPost").bind("paste", function () {
var element = $(this);
setTimeout(function () {
bindUrlDetails(element)
}, 1000);
});
// if press enter,space or tab
$('body').on('keyup', '.clstextForumWidgetPost', function (e) {
var element = $(this);
var code = e.which || e.keyCode || 0; // recommended to use e.which, it's normalized across browsers
if (code == 13) e.preventDefault();
if (code == 32 || code == 13 || code == 9) {
bindUrlDetails(element);
}
});
function bindUrlDetails(element) {
var forumWidgetMain = $(element).closest('.ForumWidgetMain');
var words = $(element).val().replace(/(?:\r\n|\r|\n)/g, ' ');
words = words.trim().split(' ');
var link = '';
$.each(words, function (i, l) {
if (l.match(/\b(http|https)(:\/\/)?(\S*)\.(\w{2,4})(.*)/g)) {
link = l;
}
});
if ($(forumWidgetMain).find('.hdnLink').length > 0 && $(forumWidgetMain).find('.hdnLink').val() == link) {
return;
}
if (link != undefined && link != '') {
if ($(forumWidgetMain).find(".embedLinkDetail").length > 0) {
$(forumWidgetMain).find(".embedLinkDetail").remove();
}
if ($(forumWidgetMain).find(".clsLoadPreview").length == 0) {
$(forumWidgetMain).find(".clstextForumWidgetPost").closest('div').append('
Fetching preview....
');
}
var url1 = "/ShowTimeWidget/GetUrlDetail";
$.ajax({
type: 'POST',
url: url1,
data: {
'url': link
},
global: false,
success: function (data) {
$(forumWidgetMain).find(".clsLoadPreview").remove();
if (data != undefined && data != '') {
$(forumWidgetMain).find(".embedLinkDetail").remove();
$(forumWidgetMain).find(".clstextForumWidgetPost").closest('div').append(data);
$(forumWidgetMain).find('.hdnLink').val(link);
}
},
});
}
else if ($(forumWidgetMain).find(".embedLinkDetail").length > 0) {
$(forumWidgetMain).find(".embedLinkDetail").remove();
}
}
$('body').on('click', '.closeLinkDiv', function () {
$(this).closest('.embedLinkDetail').remove();
});
//START: #9068: Viewer > Move countdown from footer to header (see comment of this ticket)
function countDownShowHideWithResizeWindow() {
var headerHeight = 0;
headerHeight = $('.navbar-fixed-top').height();
if (headerHeight && headerHeight >= 51) {
// $('body').addClass('hideMenuCounter');
return false;
} else {
$('body').removeClass('hideMenuCounter');
}
}
//END: #9068: Viewer > Move countdown from footer to header (see comment of this ticket)
$("body").on('click', '.popUploadImage', function () {
$.magnificPopup.open({
items: {
src: $(this).attr("href")
},
type: 'iframe',
closeOnBgClick: false,
enableEscapeKey: false,
mainClass: 'popUploadImageMainClass'
});
return false;
});
function ProfilePicUpdatedSuccess() {
$.magnificPopup.close();
iniForumWidget();
changeParticipantProfile(Number(u));
}
// Pin to Top Forum
$('body').on('click', '.popPinForum', function () {
var element = $(this);
var forumWidgetMain = $(element).closest('.ForumWidgetMain');
var forumSettingId = $(forumWidgetMain).attr('data-forumsettingid');
var productForumId = $(element).attr('data-productforumid');
var url = '/ShowtimeWidget/PintoTopForum?forumSettingId=' + forumSettingId + '&productForumId=' + productForumId;
$.magnificPopup.open({
items: {
src: url
},
type: 'iframe',
closeOnBgClick: false,
mainClass: 'popPinForum'
});
});
function PinForumSuccess(ProductForumId) {
$.magnificPopup.close();
$('.ForumWidgetPost' + ProductForumId).each(function (index, fourmWidget) {
var forumWidgetMain = $(this).closest('.ForumWidgetMain');
//var newDiv = $(this).html();
$(forumWidgetMain).find('.ForumWidget').prepend($(forumWidgetMain).find('.ForumWidgetPost' + ProductForumId));
});
$('.clsPin' + ProductForumId).removeClass('popPinForum').addClass('unpinForum').text('Unpin Forum');
}
$('body').on('click', '.unpinForum', function () {
var element = $(this);
var forumWidgetMain = $(element).closest('.ForumWidgetMain');
var forumSettingId = $(forumWidgetMain).attr('data-forumsettingid');
var productForumId = $(element).attr('data-productforumid');
if (confirm('Are you sure to unpin this forum?')) {
$.ajax({
type: 'POST',
url: '/ShowtimeWidget/UnpinForumPost',
data: {
'productForumId': productForumId
},
global: false,
async: false,
success: function (data) {
if (data != undefined && data == "") {
$('.clsPin' + productForumId).addClass('popPinForum').removeClass('unpinForum').text('Pin to Top');
}
},
error: function (jqXHR, textStatus, errorThrown) {
$("#divProgress").hide();
//$(element).html('Submit My Browser Info').prop('disabled', false);
}
});
}
});
// Forum Notification start
$('body').on('click', '.popForumNotifySetting', function () {
var element = $(this);
var forumWidgetMain = $(element).closest('.ForumWidgetMain');
var forumSettingId = $(forumWidgetMain).attr('data-forumsettingid');
var productForumId = $(element).attr('data-productforumid');
if (Number(ProgramRegistrantId) > 0) {
var url = '/ShowtimeWidget/ForumPostNotifySetting?programRegId=' + ProgramRegistrantId;
$.magnificPopup.open({
items: {
src: url
},
type: 'iframe',
closeOnBgClick: false,
mainClass: 'popForumNotifySettingMainClass'
});
}
});
// Forum Notification end
// Upload video Start
$('body').on('click', '.aForumVideoUpload', function () {
var element = $(this);
var forumWidgetMain = $(element).closest('.ForumWidgetMain');
var forumSettingId = $(forumWidgetMain).attr('data-forumsettingid');
var isIntegratedForum = $(forumWidgetMain).attr('data-isintegratedfroum')
var url = '/ShowtimeWidget/UploadVideoPost?productId=' + ps + "&TimeId=" + pe + "&ForumSettingId=" + forumSettingId + "&isIntegratedForum=" + isIntegratedForum;
$.magnificPopup.open({
items: {
src: url
},
type: 'iframe',
closeOnBgClick: false,
mainClass: 'popForumVideoUploadMainClass'
});
});
function VideoUploadSuccess(parentForumId, forumSettingId, isIntegratedForum) {
$.magnificPopup.close();
var forumWidgetMain = $(".ForumWidgetMain[data-forumsettingid=" + forumSettingId + "]")
removepostedFile(forumWidgetMain);
var url = "/showtimewidget/forumwidgetsingle?ParentForumId=" + parentForumId + "&forumSettingId=" + forumSettingId + "&isIntegratedForum=" + isIntegratedForum;
$(forumWidgetMain).find('#txtForumWidgetPost').val('');
$(forumWidgetMain).find('#divAppendPost').load(url, function () {
var newPost = $(forumWidgetMain).find('#divAppendPost').html();
$(forumWidgetMain).find('#divAppendPost').children().remove();
// $(forumWidgetMain).find('.ForumWidget').children(ForumWidgetPostId).remove();
$(forumWidgetMain).find('.ForumWidget').prepend(newPost);
$("#divProgress").hide();
editProductForumId = '';
sendForumData("newforum", forumSettingId, parentForumId);
});
if ($(forumWidgetMain).find(".embedLinkDetail").length > 0) {
$(forumWidgetMain).find(".embedLinkDetail").remove();
}
}
// Upload video End
//delete forum comment start
$("body").on("click", ".deleteForumComment", function () {
var element = $(this);
var productForumId = element.attr('data-ProductForumId');
var ParentForumId = element.attr('data-parentforumid');
var ProductWidgetForumSettingId = element.attr('data-val');
var ProductForumSettingId = element.attr('data-ProductForumSettingId');
var forumSettingId = $(element).closest('.ForumWidgetMain').attr('data-forumSettingId');
var forumSettingType = $(element).closest('.ForumWidgetMain').attr('data-forumSettingType');
var isIntegratedForum = false;
if ($(element).closest('.ForumWidgetMain').attr('data-isintegratedfroum') == "true") {
isIntegratedForum = true;
}
var isDisplayAllComment = false;
isDisplayAllComment = $(element).closest('.divForumWidgetPost').attr("data-Expanded") == "false" ? false : true;
$("#divProgress").show();
$.ajax({
type: 'POST',
url: '/ShowtimeWidget/DeleteForumPost',
dataType: 'json',
data: {
'ProductForumId': productForumId
},
success: function (Data) {
loadSingleForumPost(ParentForumId, forumSettingId, isIntegratedForum, isDisplayAllComment);
sendForumData("deleteforumData", forumSettingId, productForumId, ParentForumId);
},
error: function (data) {
alert('Error! Please try again later.');
}
});
});
function loadSingleForumPost(ParentForumId, forumSettingId, isIntegratedForum, isDisplayAllComment) {
var updatedDiv = ".ForumWidgetPost" + ParentForumId;
url = "/showtimewidget/forumwidgetsingle?ParentForumId=" + ParentForumId + "&forumSettingId=" + forumSettingId + "&isIntegratedForum=" + isIntegratedForum + "&isDisplayAllComments=" + isDisplayAllComment;
$.ajax({
type: 'Get',
url: url,
global: false,
success: function (result) {
$(updatedDiv).html($(result).filter(updatedDiv).html());
},
});
}
//delete forum comment end
//Turn Off notifications start
$('body').on('click', '.clsTurnOnOffNotification', function () {
var element = $(this);
var turnOff = $(element).attr('data-enabledNofication') == 'true' ? true : false;
$.ajax({
type: 'POST',
url: '/ShowtimeWidget/TurnoffNotifacionofPost',
dataType: 'json',
data: {
'productForumId': $(element).attr('data-ProductForumId'),
'turnOffNotifications': turnOff
},
success: function (Data) {
if (Data != undefined && Data) {
if (turnOff == true) {
$(element).attr('data-enabledNofication', false);
$(element).html('Turn on notifications for this post');
} else {
$(element).attr('data-enabledNofication', true);
$(element).html('Turn off notifications for this post');
}
}
},
error: function (data) {
alert('Error! Please try again later.');
}
});
});
//Turn Off notifications end
// get broswerInfo
var infoSubmittedFrom = '';
var browserElement;
function getBrowserInfo(submittedVia, element) {
infoSubmittedFrom = submittedVia;
browserElement = element;
if (typeof (browserReport) == "function" && Number(ProgramRegistrantId) > 0) {
if (infoSubmittedFrom == "Submit Browser") {
$(browserElement).html(' Processing...').prop('disabled', true);
}
browserReport(function (err, report) {
if (err) {
throw err;
}
ViewerSettings.BrowserInfo = JSON.stringify(report);
//if (infoSubmittedFrom == "Launch Viewer") {
// addViewerLaunchLog("Open");
//}
if (isImpersonateSession()) return;
$.get("/showtimewidget/getcurrurntdatetimewithtimezone", function (data) {
if (data != undefined) {
report.consoleErrorList = consoleErrorList;
report.jwplayerProcess = vidPlayerProcess;
report.submittedVia = infoSubmittedFrom;
report.SubmmitedDate = data;
$.ajax({
type: 'POST',
url: '/showtimewidget/submitbrowser',
dataType: 'json',
data: {
'programRegistrantId': ProgramRegistrantId, 'settings': JSON.stringify(report)
},
success: function (Data) {
if (infoSubmittedFrom == "Submit Browser") {
$(browserElement).html('Submit My Browser Info').prop('disabled', false);
alert('Browser info submitted successfully.');
}
ViewerAnalyticsId = Data;
},
error: function (jqXHR, textStatus, errorThrown) {
if (infoSubmittedFrom == "Submit Browser") {
$(browserElement).html('Submit My Browser Info').prop('disabled', false);
}
}
});
}
else if (infoSubmittedFrom == "Submit Browser") {
$(browserElement).html('Submit My Browser Info').prop('disabled', false);
}
});
});
}
}
//9152: Presenter > Live Webcast Presenter > Ability to change a slides program into Video Only sections
function applySlideScreenStatus() {
if (checkSlideScreeenIsVisible() == false) {
//$(window).trigger('resize');
onLoadMediaSlide();
}
}
//START:: onload viewer if ie8,ie9(all OS),safari<7.1(MAC os) show popup #9261
function onLoadBrowserUpgradePopup() {
if ($('#upgradeBrowserPop').length > 0 && NewViewer == true && (checkBrowserIEBelowTen() || checkBrowserSafariBelowSevenPointOneOnMacOS())) {
$.magnificPopup.open({
items: {
src: '#upgradeBrowserPop'
},
type: 'inline',
closeOnBgClick: false,
});
}
}
function checkBrowserIEBelowTen() {
if (((xBrowser === "ie") || (xBrowser === "internetexplorer")) && xVersion <= 9) {
return true;
} else {
return false;
}
}
function checkBrowserSafariBelowSevenPointOneOnMacOS() {
if ((xBrowser === "safari") && xVersionWithDouble <= 7 && (navigator.platform.toLowerCase() == "macintel" || navigator.platform.toLowerCase() == "macintosh")) {
return true;
} else {
return false;
}
}
//END:: onload viewer if ie8,ie9(all OS),safari<7.1(MAC os) show popup #9261
// making extension methods for show hide by check if visible or not
jQuery.fn.extend({
showIfNotVisible: function () {
if (this.is(':visible') == false) {
this.show();
}
},
hideIfVisible: function () {
if (this.is(':visible') == true) {
this.hide();
}
}
});
$('body').on('click', '.btnGetMobileApp,.linkPagerDutySubmit', function () {
$.magnificPopup.open({
items: {
src: $(this).attr("data-href")
},
type: 'iframe',
closeOnBgClick: false,
callbacks: {
close: function () {
//do stuff
}
},
mainClass: 'popPagerDuty'
});
return false;
});
// initiliging reload video button pop over on document ready #9776
function InitilizeReloadVideoPopover() {
if ($("#btnReloadViewer").length > 0) {
$('#btnReloadViewer').popover({ trigger: 'hover' })
.on("show.bs.popover", function () {
return $(this).data("bs.popover").tip().css({
width: "200px",
left: "50px !important"
})
});
}
}
////START::>> 0010030: Classrooms -> Viewer -> Adding a, 'Return to Classroom,' Link
function BacktoClassroomScheduletab() {
var tabName = getParameterByName("ClassroomTab");
if (tabName != null && tabName != undefined && tabName != '' && isFromClassroomScheduleTab != null && isFromClassroomScheduleTab != undefined && isFromClassroomScheduleTab != '' && $('.clsReturnToClassroom').length == 1 && $('.viewerHeaderTemporary').length == 1) {
var array = tabName.split('_');
var name = array[0];
var id = array[1];
var sc = 0;
if (array.length >= 4) {
sc = array[3];
}
var item = '/viewer/classroom/' + id + "?InnerTab=" + name + "&sc=" + sc;
$('.clsReturnToClassroom').attr('href', item).attr('target', 'ce21_classroom_' + id);
$('.returnToClassroom').attr('href', item).attr('target', 'ce21_classroom_' + id);
$('.clsReturnToClassroomFromCertWidget').attr('href', item).attr('target', 'ce21_classroom_' + id);
$('.viewerHeaderTemporary').show();
//in mobile view= on load viewer page(not for resize)
onloadBacktoClassroomScheduletab();
//when resizing the window
ResizeBacktoClassroomtab();
$('body').addClass('isFromClassroomScheduleTab');
} else {
$('.viewerHeaderTemporary').hide();
$('body').removeClass('isFromClassroomScheduleTab');
}
}
$('body').on('click', '.clsReturnToClassroom, .returnToClassroom, .clsReturnToClassroomFromCertWidget', function () {
setTimeout(function () { window.close() }, 500);
});
function ResizeBacktoClassroomtab() {
$(window).resize(function () {
onloadBacktoClassroomScheduletab();
})
}
function onloadBacktoClassroomScheduletab() {
if ($(window).width() <= 991) {
$('.viewerHeaderTemporary').removeClass('cssForHeaderTop').addClass('cssForHeaderBottom');
$('.clsReturnToClassroom').css('padding', '3px 0px 12px 10px').css('font-size', '13px');
$('.viewerHeaderOriginal').addClass('clsViewerHeaderMargin');
$('#info-panel').css('padding-top', '10px').css('margin-bottom', '84px');
$('.clsReturnIcon').css('font-size', '19px');
} else {
$('.viewerHeaderTemporary').addClass('cssForHeaderTop').removeClass('cssForHeaderBottom');
$('.clsReturnToClassroom').css('padding', '6px 0 5px 10px').css('font-size', '16px');
$('.viewerHeaderOriginal').removeClass('clsViewerHeaderMargin').css('margin-top', '33px');
$('#info-panel').css('padding-top', '83px').css('margin-bottom', '0px');
$('.clsReturnIcon').css('font-size', '22px');
}
}
////END::>> 0010030: Classrooms -> Viewer -> Adding a, 'Return to Classroom,' Link
// as per mantis #10767 //"Support Questions? Please click here." When that phrase is clicked on - a user should be directed to the Help tab.
$('body').on('click', "#btnSupportQuestion", function () {
$("a[data-href='SupportWidget']").trigger("click");
});
function checkArchivePopup() {
if (seminar.ArchivePopup != null && seminar.ArchivePopup.IsComplete == false) {
//Check from storage based on popup type.
var alreadyDisplayedArchive = checkPrepostPopupComplete(seminar.ArchivePopup.PopUpType);
if (alreadyDisplayedArchive)
return;
$.magnificPopup.close();
if (vidPlayer) {
vidPlayer.pause();
if (vidPlayer.isFullscreen()) {
vidPlayer.isFullscreen(false);
}
}
$("#lblPrePostTitle").html(seminar.ArchivePopup.PopupTitle);
$("#lblPrePostBody").html(seminar.ArchivePopup.PopupBody);
$("#btnPrePost").html(seminar.ArchivePopup.PopupButtonText);
$(".clsPrePostPopUp").show();
$.magnificPopup.open({
items: {
src: '#prePostPopUp'
},
type: 'inline',
closeOnBgClick: false,
enableEscapeKey: false,
showCloseBtn: false,
beforeOpen: function () {
vidPlayer.pause();
},
callbacks: {
afterClose: function () {
seminar.ArchivePopup.IsComplete = true;
//Save in local storage
if (typeof (localStorage) != "undefined") {
var key = 'PopUp' + seminar.ArchivePopup.PopUpType + '-' + ProgramRegistrantId + '-' + e;
localStorage.setItem(key, 'true');
}
vidPlayer.play();
}
}
});
$('.mfp-content').css('width', 600);
$('.mfp-content > .white-popup').css('min-width', '600px');
}
}
function setRelativeTime() {
if (curRelativeTime && seminar.SeminarTypeId == 4) {
$("#hdnRelativeTime").val(Math.round(curRelativeTime / 1000));
}
}
// make the viewer close entry for this registrant
window.addEventListener("beforeunload", function (e) {
//mantis item #18684: Viewer: Time Tracking NOT getting recognized until CE21 check
if (seminar.PresenterDuration > 0
&& Math.round(curRelativeTime / 1000) > 60
&& typeof updateCertCompletionStatus === "function") {
updateCertCompletionStatus(true);
}
// saving currenttextdocument duration #0019645
if (IsTextBasedViewer) {
saveCurrentTextPageDuration();
}
// save logout date #20525
if (Number(ProgramRegistrantId) > 0) {
$.ajax({
type: 'POST',
url: '/ShowtimeWidget/SubmitLogOutDate',
data: {
'viewerAnalyticsId': ViewerAnalyticsId,
}
});
}
//#14143: Viewer > Notes Tab > Prevent users from forgetting to click on "Save Note" to save notes
ManageNotes('SetItem');
//#22227
if ($("a[data-href='ChatWidget']").length > 0) {
UpdateChatUserOnlineStatus(0); //Offline
}
});
function addViewerLaunchLog(entityType) {
if (Number(ProgramRegistrantId) > 0) {
var relativeTime = curRelativeTime ? Math.round(curRelativeTime / 1000) : null;
$.ajax({
type: 'POST',
url: '/ShowtimeWidget/AddViewerLaunchLog',
dataType: 'json',
data: {
'programRegistrantId': ProgramRegistrantId,
'entityType': entityType,
"relativeTime": relativeTime,
"browserInfo": ViewerSettings.BrowserInfo
},
success: function () {
},
error: function () {
}
});
}
}
//#13253: Unauthenticated link to viewer > Give feedback that some features will not show in this view
function onLoadBrowserShowFeedbackFeatures() {
if ($('#ShowFeedBackFeaturesPopUp').length > 0) {
$.magnificPopup.open({
items: {
src: '#ShowFeedBackFeaturesPopUp'
},
type: 'inline',
closeOnBgClick: false
});
setTimeout(function () {
$.magnificPopup.close();
}, 10000);
}
}
//#12919: Viewer > Bottom end of Scrollbar partially hidden / Feedback Widget - don't overlay on scroll bar area
function setFeedbackWidgetButtonOffset() {
if ($('.ticket-button.ticket-btn-right').length > 0 && $('.layout-2').length > 0) {
var div = document.getElementById('info-panel-content');
var hasVerticalScrollbar = div.scrollHeight > div.clientHeight;
if (hasVerticalScrollbar) {
$('.ticket-btn-right .ticketwidget-theme').css('right', '0.8%');
}
else
$('.ticket-btn-right .ticketwidget-theme').css('right', '0');
}
}
//#region #11807: Viewer > Ability to Expand Slides to Full Screen View w/ Video in small PIP
$('body').on('click', '.btnSlideFullScreen, .btnSlideExitFullScreen', function (e) {
e.preventDefault();
$('body').toggleClass('slidefullscreen');
var isSlideFullScreen = $('body').hasClass('slidefullscreen');
if (isSlideFullScreen) {
GoInFullscreen($("body").get(0));
enterSlideFullScreen();
setTimeout(enterSlideFullScreen, 500);
}
else {
GoOutFullscreen();
//Default View
exitSlideFullScreen();
}
});
function GoInFullscreen(element) {
if (element.requestFullscreen)
element.requestFullscreen();
else if (element.mozRequestFullScreen)
element.mozRequestFullScreen();
else if (element.webkitRequestFullscreen)
element.webkitRequestFullscreen();
else if (element.msRequestFullscreen)
element.msRequestFullscreen();
}
function GoOutFullscreen() {
if (document.exitFullscreen)
document.exitFullscreen();
else if (document.mozCancelFullScreen)
document.mozCancelFullScreen();
else if (document.webkitExitFullscreen)
document.webkitExitFullscreen();
else if (document.msExitFullscreen)
document.msExitFullscreen();
}
function IsFullScreenCurrently() {
var full_screen_element = document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement || null;
if (full_screen_element === null)
return false;
else
return true;
}
$(document).on('fullscreenchange webkitfullscreenchange mozfullscreenchange MSFullscreenChange', function () {
if (!seminar || (typeof (seminar) != "undefined" && seminar && seminar.Slides.length == 0)) {
return;
}
if (!IsFullScreenCurrently()) {
$('body').removeClass('activeFullScreen');
$('body').removeClass('slidefullscreen');
//Default View
exitSlideFullScreen();
} else {
$('body').addClass('activeFullScreen');
}
});
function enterSlideFullScreen() {
//Vertically centering slide
var slideHeight = (document.querySelector('#slidescreen img') || {}).height || (maxWidgetHeight + 125);
$('.slidefullscreen #slidescreen img').css('margin-top', 'calc(50vh - ' + slideHeight + 'px/2)');
//Video PIP
if ($(toggleBtn2).closest('li').hasClass('active')) {
adjustPIPHeight();
} else {
toggleVideoSlide("#video-toggle", true, false);
}
if ($("#media-panel").hasClass("showinfo")) {
$("#media-panel").removeClass("col-md-7").addClass("col-md-12");
}
//Default Video PIP Size to small
if (!$('body').hasClass('activeFullScreen')) {
$('#mediaView').removeClass('pip-small pip-medium pip-large').addClass('pip-small');
$('.pip-tools .pip-small, .pip-tools .pip-medium, .pip-tools .pip-large').removeClass('active');
$('.pip-tools .pip-small').addClass('active');
}
}
function slideImageLoad() {
if ($('body').hasClass('slidefullscreen')) {
enterSlideFullScreen();
}
$('#slidescreen a[href="javascript:void(0)"],.SlideThumbsWidget a[href="javascript:void(0)"]').removeAttr('href');
}
function exitSlideFullScreen() {
toggleVideoSlide("#default-view", true, false);
$('#slidescreen img').css('margin-top', '');
onLoadMediaSlide(); //#0016822
if ($("#media-panel").hasClass("showinfo")) {
$("#media-panel").removeClass("col-md-12").addClass("col-md-7");
}
}
//#endregion #11807
//#region 15037 - Custom Fields Multi-Select DropDown - START
$("body").on('change', '.chkSelecAllCustomFields', function () {
checkUncheckAllCustomCheckBox(this);
});
$("body").on('click', '.btnClearCustomFields', function () {
var txtSearch = $(this).closest('th').find('input[type="text"]');
$(txtSearch).val('');
searchCustomFieldCheckBox(txtSearch);
});
function checkUncheckAllCustomCheckBox(ele) {
if ($(ele).prop('checked') === true) {
$(ele).closest("table").find('input[type="checkbox"]:visible').prop('checked', true);
}
else {
$(ele).closest("table").find('input[type="checkbox"]').prop('checked', false);
}
}
function searchCustomFieldCheckBox(txtSearch) {
if (txtSearch) {
$(txtSearch).closest("table").find("tbody>tr").filter(function () {
$(this).toggle($(this).text().toLowerCase().indexOf($(txtSearch).val().toLowerCase()) > -1)
});
}
}
function checkMultiChoiceValidation(isValid) {
//Required validation if all rows rows are hidden
$(".tblCustomFieldMultiSelect").each(function () {
var table = $(this);
if ($(table).find("tbody>tr:visible").length == 0) {
if ($(table).find("tbody>tr:hidden").find('input[type="checkbox"]:required').length > 0 && $(table).find("tbody>tr:hidden").find('input[type="checkbox"]:checked').length == 0) {
$(table).find("tbody>tr").show();
isValid = false;
}
}
});
return isValid;
}
//#endregion
//#region #15102: Viewer > Audio Only programs allow download despite setting.
function disableRightClickForAudioStream() {
if (typeof (seminar) != "undefined" && seminar != null && seminar.IsOtherDigital && seminar.SeminarTypeId === 4) {
$('div#mediaView video#media-video_Html5_api').bind("contextmenu", function () {
return false;
});
}
}
//#endregion
//#region #13489: Refreshing the viewer
function reInitViewer() {
Helper.VIDEOJS.disposePlayer(vidPlayer);
Helper.Interval.clear("VIEWER_CHECKTRIGGERTIMES");
if (curMediaClip) curMediaClip = null;
if (typeof (videoEl) != "undefined") videoEl = null;
getSeminar();
}
//#endregion
//#region #15901: Certificate Link
function redirectToCertificateTab() {
closepopup();
$("#navlist a").each(function () {
var id = $(this).attr("data-href");
var navSelector = '#' + id;
$(navSelector).hide();
$(this).parent().removeClass("active");
if (id === "CertificationWidget") {
$(navSelector).show();
$(this).parent().addClass("active");
setTimeout(function () {
if ($("#CertificationWidget").html().trim().length == 0) {
if (typeof (RefreshCertificate) == "function") {
RefreshCertificate(undefined, true);
}
}
else {
openInComleteAccordion();
}
}, 1500);
}
});
}
function openInComleteAccordion() {
if ($("h5.popCertificationSuccess[data-entityType='Download certificate']").length > 0) {
$("h5.popCertificationSuccess[data-entityType='Download certificate']").click();
$("h5.popCertificationSuccess[data-entityType='Download certificate']").next().removeClass('collapse');
}
else if ($(".popCertificationDanger").length > 0) {
$(".popCertificationDanger:first").click();
}
}
//#endregion
function getNewProductForums(forumSettingId, productForumId, parentEventTimeId) {
$('.ForumWidgetMain').each(function () {
var forumWidgetMain = $(this);
lastForumSyncTime = $(this).find('.hdnDatetimeUtcNow').val();
var forumSettingType = $(this).attr('data-forumSettingType');
if ((forumSettingId == $(this).attr('data-forumSettingId') || parentEventTimeId == $(this).attr('data-mainparenteventtimeid'))) {
$.ajax({
type: 'POST',
url: '/Forum/ProductForumGetById',
data: {
'timeId': pe, 'CustomerId': u,
'forumSettingId': forumSettingId,
'forumSettingType': forumSettingType,
'productForumId': productForumId,
'LastSyncTime': lastForumSyncTime
},
global: false,
async: false,
success: function (Data) {
if (Data != null) {
var currentDate = $(Data).filter('.hdnDatetimeUtcNow').val();
var productForumIdsToRemove = $(Data).filter('.hdnProductForumIdsToRemove').val().split(',');
$(forumWidgetMain).find('.hdnDatetimeUtcNow').val(currentDate);
var forumIds = $(Data).filter('.divForumWidgetPost').map(function () { return Number($(this).attr('data-ProductForumId')) }).get();
if (forumIds != null && forumIds.length > 0) {
// find its own post forumIds
var LoggingUserforumIds = $(Data).filter('.divForumWidgetPost').map(function (a, b) {
if (u == $(this).attr("data-postCustomerId")) {
return Number($(this).attr('data-ProductForumId'));
}
}).get();
var forumCommentMsgTimeOut;
$.each(forumIds, function (index, forumId) {
var child = '.ForumWidgetPost' + forumId;
var newDiv = $(Data).filter(child)
var commentBox = '#txtProductForumComment' + forumId;
var currentText = $(commentBox).val();
// display alert when another user has replied to a Post that they CREATED.
if (provideViewerAlert && LoggingUserforumIds.indexOf(forumId) != -1) {
var lastComment = newDiv.find('.viewcomment .singlereply[data-replyId]:last');
var lastCommentUserName = lastComment.find('div.media-body p strong').text();
var lastcommentUserId = $(lastComment).attr("data-commentedCustomerId");
if (lastCommentUserName != "" && lastCommentUserName != undefined && u != lastcommentUserId) { // for exclude own comments
if ($(forumWidgetMain).find('.ForumWidget').children(child).find('.viewcomment .singlereply[data-replyId=' + lastComment.attr('data-replyid') + ']').length == 0) {
$("#Forummsg_panel").html("
" + lastCommentUserName + " has responded to your forum post!
").show();
// clear old timeout and add new one
if (forumCommentMsgTimeOut) {
clearTimeout(forumCommentMsgTimeOut);
}
forumCommentMsgTimeOut = setTimeout(function () {
$("#Forummsg_panel").empty().hide();
}, 10 * 1000);
}
}
}
var currentDiv = $('.ForumWidget').children(child).html();
if (currentDiv != '' && currentDiv != null && currentDiv != undefined) {
var commentsExpanded = $(forumWidgetMain).find('.ForumWidget').children(child).attr('data-Expanded') == "true";
//$(forumWidgetMain).find('.ForumWidget').children(child).replaceWith(newDiv);
//459: Forums - don't refresh comments area - just append to the bottom with Javascript start
//$(forumWidgetMain).find('.ForumWidget').children(child).find('.viewcomment').replaceWith($(newDiv).find('.viewcomment'));
$(forumWidgetMain).find('.ForumWidget').children(child).find('.socialPost').replaceWith($(newDiv).find('.socialPost'));
$(forumWidgetMain).find('.ForumWidget').children(child).find('.midcont').replaceWith($(newDiv).find('.midcont')); //post update
//if (commentsExpanded) {
// $(forumWidgetMain).find('.ForumWidget').children(child).find('.clsExpandAllComment').click();
//}
if ($(forumWidgetMain).find('.ForumWidget').children(child).find('.viewcomment .singlereply[data-replyId]').length > 0) {
$(newDiv).find('.viewcomment .singlereply[data-replyId]').each(function (i, e) {
if ($(forumWidgetMain).find('.ForumWidget').children(child).find('.viewcomment .singlereply[data-replyId=' + $(e).attr('data-replyid') + ']').length == 0) {
$(forumWidgetMain).find('.ForumWidget').children(child).find('.viewcomment .singlereply[data-replyId]').last().after($(newDiv).find('.viewcomment .singlereply[data-replyId=' + $(e).attr('data-replyid') + ']'))
} else {
$(forumWidgetMain).find('.ForumWidget').children(child).find('.viewcomment .singlereply[data-replyId=' + $(e).attr('data-replyid') + ']').replaceWith($(newDiv).find('.viewcomment .singlereply[data-replyId=' + $(e).attr('data-replyid') + ']'));
}
});
var cntComment = $(forumWidgetMain).find('.ForumWidget').children(child).find('.viewcomment .singlereply[data-replyId]').length;
if (cntComment > 1) {
$(forumWidgetMain).find('.ForumWidget').children(child).find('.clsPreviousCommentLink').show();
}
}
else {
$(forumWidgetMain).find('.ForumWidget').children(child).find('.viewcomment').replaceWith($(newDiv).find('.viewcomment'));
}
// hide other comments
if (!commentsExpanded && $(forumWidgetMain).find('.ForumWidget').children(child).find('.divNewComments .singlereply[data-replyid]').length > 1) {
$(forumWidgetMain).find('.ForumWidget').children(child).find('.divNewComments .singlereply[data-replyid]').not(':last').hide();
}
//459: Forums - don't refresh comments area - just append to the bottom with Javascript End
}
else {
$(forumWidgetMain).find('.ForumWidget').prepend(newDiv);
}
$(commentBox).val(currentText);
if (currentText != '' && currentText != null && currentText != undefined) {
$('#divProductForumComment' + forumId).show();
$(commentBox).focus();
}
});
}
if (productForumIdsToRemove != null && productForumIdsToRemove.length > 0)//Remove deleted or rejected product forums
{
$.each(productForumIdsToRemove, function (index, productForumId) {
var child = '.ForumWidgetPost' + productForumId;
$('.ForumWidget').children(child).remove();
});
}
$("#divProgress").hide();
var cntNewForums = Number($(Data).filter('.hdnNewForumsCounts').val());
updateNewForumCount(cntNewForums)
}
},
error: function (jqXHR, textStatus, errorThrown) {
$("#divProgress").hide();
//$(element).html('Submit My Browser Info').prop('disabled', false);
}
});
}
});
}
function updateNewForumCount(cnt) {
if (Number(cnt) > 0) {
var oldCount = Number($(".baseForumWidget").text() || '');
if (!$("#ForumWidget").is(':visible')) {
$(".baseForumWidget").text("New");
}
if (typeof notifyForumInApp == "function") {
notifyForumInApp();
}
}
}
function sendForumData(action, forumSettingId, productForumId, parentProductForumId) {
var forumData = {
"Action": action,
"Data": {
"forumSettingId": forumSettingId,
"productForumId": productForumId,
"customerId": u,
"parentEventTimeid": $('.ForumWidgetMain').attr('data-mainparenteventtimeid'),
"parentProductForumId": parentProductForumId
}
}
CE21Forum.sendAction(forumSettingId, forumData);
}
function deleteProductForums(productForumId, parentProductForumId, forumSettingId) {
if (parentProductForumId > 0) {
var forumPost = '.ForumWidgetPost' + parentProductForumId;
if ($('.ForumWidget').children(forumPost).find(".singlereply[data-replyid=" + productForumId + "]").length > 0) {
$('.ForumWidget').children(forumPost).find(".singlereply[data-replyid=" + productForumId + "]").remove();
var isIntegratedForum = false;
if ($('.ForumWidgetMain').attr('data-isintegratedfroum') == "true") {
isIntegratedForum = true;
}
var isDisplayAllComment = false;
isDisplayAllComment = $('.ForumWidget').children(forumPost).attr("data-Expanded") == "false" ? false : true;
loadSingleForumPost(parentProductForumId, forumSettingId, isIntegratedForum, isDisplayAllComment);
}
}
else {
var forumPost = '.ForumWidgetPost' + productForumId;
if ($('.ForumWidget').children(forumPost).length > 0) {
$('.ForumWidget').children(forumPost).remove();
}
}
}
CE21SignalR.onReady(function () {
CE21Forum.connectAll();
//CE21Chat.connectAll();
});
function validateEmail(email) {
var expr = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,}|[0-9]{1,3})(\]?)$/;
return expr.test(email);
};
var isImpersonateSession = function () {
return document.cookie.indexOf('ImpersonateId=') != -1;
}
$("body").on("click", ".supoortSolutionPopup", function () {
$.magnificPopup.open({
items: {
src: '/Tickets/TicketEmailPopup?isViewer=true'
},
type: 'iframe',
closeOnBgClick: false,
mainClass: 'popSupoortSolution'
});
$(".popSupoortSolution").find('iframe').attr("id", "ifrSupportSolution");
$(".popSupoortSolution").attr("data-html2canvas-ignore", "true");
return false;
});
function validateBrowserCustomer() {
var customerId = Helper.Viewer.getCustomerId() || 0;
if (customerId === -1) {
return;
}
$.getJSON('/showtimewidget/validatebrowsercustomer?customerId=' + customerId, function (result) {
result = result || false;
if (!result) {
if (typeof (newChatWindow) !== "undefined" && newChatWindow) {
newChatWindow.close();
}
location.reload();
}
});
}
//#region #0017665: Viewer > Classroom > End of programs
function triggerClassroomEndActions() {
if (!isFromClassroomScheduleTab || !seminar || seminar.IsArchive || seminar.PresenterDuration <= 0 || !curRelativeTime) return false;
var seminarcurTime = Math.round((curRelativeTime) / 1000),
secondsToShowColor = (seminar.IsLive ? 120 : 5) * 60,
backgroundColor = 'black',
fontweight = 'normal';
if (seminar.PostRollMediaDuration > 0 && seminarcurTime.between(seminar.PresenterDuration, seminar.PresenterDuration + seminar.PostRollMediaDuration)) {
setTimeout(triggerClassroomEndActions, seminar.PostRollMediaDuration * 1000);
return false;
}
if ((!seminar.IsLive || (seminar.IsLive && !isGoLiveOn))
&& seminarcurTime.between(seminar.PresenterDuration, seminar.PresenterDuration + secondsToShowColor)) {
backgroundColor = '#670101';
fontweight = 'bold';
$('.returnToClassroomOverlay').attr('data-iscomplete', true);
}
$('.viewerHeaderTemporary').css('background-color', backgroundColor);
$('.clsReturnToClassroom').css("font-weight", fontweight);
}
$('body').on('click', '.returnToClassroomOverlay #btnCloseOverlay', function () {
$('.returnToClassroomOverlay').attr('data-isclosed', true);
});
//#endregion
//#region #0017681: Preview viewer
function initializePreview() {
if (IsTextBasedViewer) {
ViewerCountDown.element.hide();
$('a[data-href="eventlog"]').parent().hide();
$("#info-toggle-btn").closest('li').hide();
//add style to clock message
$('#pTextBasedCeClock').closest('li').css({ 'margin-left': '10px', 'margin-top': '5px' });
showHideNext(true);
showHidePrev(true);
return false;
}
if (isAudtioVideoWidget != "True") return false;
seminar = {
IsLive: false,
IsReplay: false,
AspectRatio: '16:9',
PresenterStatusList: [],
Alerts: [],
MediaClips: [],
Slides: []
}
compositionComplete();
onLoadMediaSlide();
// collapse side panel #8416#c6417 :Let's operate off the checkboxes for now - thus "Start with tabbed panel collapsed" UNchecked would show tabs even if the program has slides.
// here condition --$('.viewerHeaderOriginal li.info-toggle-nav').length == 0-- is for, --mantis-- #0010060
if (IsTabPanelCollapsed == "True" || $('.viewerHeaderOriginal li.info-toggle-nav').length == 0) {
setTimeout(function () { $('#info-toggle').trigger('click'); $(window).trigger('resize'); }, 500);
if ($('.viewerHeaderOriginal li.info-toggle-nav').length == 0) { //--mantis #0010060
$('#sideBarStatustext').hide();
$('#info-toggle').css('color', 'transparent');
}
}
if (showinfo) {
$('#mediaView').addClass('collapseView').removeClass('expandView');
$('#slideView').addClass('collapseView').removeClass('expandView');
}
}
//#endregion
//#region #0018272: Snapshot Preview
function isSnapshotWidget(widgetName) {
return $.inArray(widgetName, ['CertificationWidget', 'ChatWidget', 'ForumWidget', 'TwitterWidget']) > -1;
}
function manageSnapshotPreviewWidgets(actionName) {
if (!isSnapshotWidget(actionName)) return false;
$("#divProgress").show();
var actionUrl = '/ShowtimeWidget/SnapshotWidget?productId=' + Number(s) + '&actionName=' + actionName;
$('#' + actionName).load(actionUrl, function () {
$("#divProgress").hide();
});
}
function convertToArchiveMode() {
if (!seminar || !seminar.IsReplay) return false;
seminar.IsArchive = true;
seminar.IsLive = false;
seminar.IsReplay = false;
}
//#endregion
//mantis item #17430
function forceReloadViewer() {
location.reload(); //mantis #8479
}
$("body").on('click', '.popCertificationPreview', function () {
$.magnificPopup.open({
items: {
src: $(this).attr("href")
},
type: 'iframe',
closeOnBgClick: false,
mainClass: 'popCertificationPreviewMainClass'
});
return false;
});
$('body').on('click', '.previewInfo', function () {
$.alert({
title: 'Preview Viewer',
content: $(".clsPreviewTextModel").html(),
useBootstrap: false,
boxWidth: '800px',
backgroundDismiss: true,
buttons: {
cancel: {
text: 'Close',
btnClass: 'btn-default'
}
}
});
});
/*#19688*/
function toggleNavbarForSmallView() {
if ($(window).width() < 992) {
setTimeout(function () {
$(".navbar-toggle").trigger('click');
}, 500);
}
}
function edgeBrowserLuanch() {
window.location = 'microsoft-edge:' + window.location;
setTimeout(function () {
window.location = 'https://www.microsoft.com/en-us/edge?browser=Chrome&FORM=MG0AU2';
}, 5000);
}
/*#19708*/
$('body').on('click', '.btnmobileFullScreenClose', function () {
$('body').removeClass('chat-fullscreen');
});
$('body').on('click', '.btnmobileFullScreenOpen', function () {
$('body').addClass('chat-fullscreen');
});
//mantis item #21326
function isPopUpAlertAvailableToOpen() {
if (!seminar || !(seminar.IsArchive || seminar.SeminarTypeId == 3 || seminar.SeminarTypeId == 4) || seminar.PopUpAlerts.length <= 0)
return false;
if (seminar.IsArchive && !seminar.IsAllowCreditForArchive)
return false;
var seminarcurTime = Math.round((curRelativeTime) / 1000);
if (seminarcurTime <= 0)
return false;
//var archiveDiff = seminar.PresenterDuration - seminarcurTime;
//if (!archiveDiff.between(5, -5))
// return false;
//ViewerPopupType == 3 Show as a popup after the program
var listAvailablePopups = $.grep(seminar.PopUpAlerts, function (element) { return (element.ViewerPopupType == 3 && element.IsCompleted == false); });
return listAvailablePopups.length > 0;
}
//#21422
function adjustAlert() {
$("#msg_panel").css("max-width", "");
$("#msg_panel_pip").css("max-width", "");
if ($('#media-panel').hasClass('PIPR')) {
$("#msg_panel").css("max-width", $("#media-container.clsmediapanelViewer").width());
}
if ($('#media-panel').hasClass('PIPV')) {
$("#msg_panel_pip").css("max-width", $("#slidescreen img").width());
}
}
function adjustSlide() {
if ($(".PIPV").length > 0) {
$(".PIPV #mainView .row").css("max-width", $("#slidescreen img").width() + 40 + "px");
}
else {
$(".PIPV #mainView .row").css("max-width", "");
}
}
//#21560
function SetForumWigdetTitle() {
if ($("#ForumWidget").length > 0 && seminar != null && (seminar.SeminarTypeId == 2 || seminar.SeminarTypeId == 3 || seminar.SeminarTypeId == 4 || (seminar.SeminarTypeId == 8 && seminar.IsArchive))) {
$("#forumTitle").text($("a[data-href='ForumWidget']").attr("data-text"));
}
}
//#14143: Viewer > Notes Tab > Prevent users from forgetting to click on "Save Note" to save notes
$('body').on('focusout', '#form-notes textarea', function () { ManageNotes('SetItem'); });
function ManageNotes(operationType) {
if (!$("#form-notes textarea").length) {
return;
}
var notesKeyName = "Notes_Text_" + s;
if (operationType === 'SetItem') {
if (localStorage.getItem(notesKeyName) != $('#form-notes textarea').val()) {
localStorage.setItem(notesKeyName, $("#form-notes textarea").val());
}
}
else if (operationType === 'GetItem') {
if (localStorage.getItem(notesKeyName)) {
$("#form-notes textarea").val(localStorage.getItem(notesKeyName));
}
}
else {
localStorage.removeItem(notesKeyName);
}
}
//End #14143
//#22036
$('body').on('click', '.aForumDocumentUpload', function () {
var element = $(this);
var forumWidgetMain = $(element).closest('.ForumWidgetMain');
var forumSettingId = $(forumWidgetMain).attr('data-forumsettingid');
var isIntegratedForum = $(forumWidgetMain).attr('data-isintegratedfroum')
var url = '/ShowtimeWidget/UploadDocumentPost?productId=' + ps + "&timeId=" + pe + "&forumSettingId=" + forumSettingId + "&isIntegratedForum=" + isIntegratedForum;
$.magnificPopup.open({
items: {
src: url
},
type: 'iframe',
closeOnBgClick: false,
mainClass: 'popForumVideoUploadMainClass'
});
});
//Start #22112
$("body").on("click", "#largeSideBarStatustext", function () {
//change icon
var isArrowFromLeft = $(this).find('i').hasClass("fa-arrow-from-left");
$('#largeSideBarStatustext i').toggleClass("fa-arrow-from-right", isArrowFromLeft).toggleClass("fa-arrow-from-left", !isArrowFromLeft);
//update view
var isExpnadSidePanel = $("#media-panel").hasClass("col-md-7") && $("#info-panel").hasClass("col-md-5");
$("#media-panel").toggleClass("col-md-5", isExpnadSidePanel).toggleClass("col-md-7", !isExpnadSidePanel);
$("#info-panel").toggleClass("col-md-7", isExpnadSidePanel).toggleClass("col-md-5", !isExpnadSidePanel);
$("#sideBarStatustext").toggleClass("hidden", isExpnadSidePanel);
$("#largeSideBarStatustext i").attr("data-content", isExpnadSidePanel ? "Decrease side panel size" : "Increase side panel size");
$('#bottomNavDiv').toggleClass("col-md-7", isExpnadSidePanel).toggleClass("col-md-5", !isExpnadSidePanel);
$("#bottomNavDivRight").toggleClass("col-md-5", isExpnadSidePanel).toggleClass("col-md-7", !isExpnadSidePanel);
$("#bottomNavDivCenter").find("#largeSideBarStatustext").css("float", isExpnadSidePanel ? "left" : "right");
if (seminar != null && seminar.Slides !== undefined && seminar.Slides != null && seminar.Slides.length > 0) {
//default to vertical view
if (isExpnadSidePanel) {
if ($(toggleBtn3).closest('li').hasClass('active')) $(toggleBtn3).closest('li').removeClass("active");
toggleVideoSlide("#video-resize", false, false);
}
//get last remember view
if (!isExpnadSidePanel) {
var currentVideoSlideView = sessionStorage.getItem('Viewer_Video_Slide_View' + ProgramRegistrantId);
if (currentVideoSlideView) {
toggleVideoSlide("#default-view", true, false);
$("#" + currentVideoSlideView).click();
}
}
}
});
function InitilizeSideBarBtnPopover() {
if ($("#sideBarStatustext i").length > 0) {
$('#sideBarStatustext i').popover({ trigger: 'hover' })
.on("show.bs.popover", function () {
return $(this).data("bs.popover").tip().css({
width: "155px",
color: $("#largeSideBarStatustext").attr('data-color')
})
});
}
if ($("#largeSideBarStatustext i").length > 0) {
$('#largeSideBarStatustext i').popover({ trigger: 'hover' })
.on("show.bs.popover", function () {
return $(this).data("bs.popover").tip().css({
width: "190px",
color: $("#largeSideBarStatustext").attr('data-color')
})
});
}
}
function SetCurrentVideoSlideView(currentVideoSlideViewId) {
if (!($("#media-panel").hasClass("col-md-5") && $("#info-panel").hasClass("col-md-7")))
sessionStorage.setItem('Viewer_Video_Slide_View' + ProgramRegistrantId, currentVideoSlideViewId);
}
//End #22112
//#22227
function UpdateChatUserOnlineStatus(onlineStatus) {
if (!CE21SignalR.isConnected() && !onlineStatus && !u && !e) return;
$.post("/Chat/UpdateChatUserOnlineStatus", { 'customerId': u, 'chatRoomentityId': e, 'chatRoomId': chatRoomId, 'onlineStatus': onlineStatus }, function (data) {
chatRoomId = data > 0 ? data : 0;
});
isUnloadPage = (onlineStatus == 0) ? true : false;
}
$("body").on('click', '.pop700', function () {
$.magnificPopup.open({
items: {
src: $(this).attr("href")
},
type: 'iframe',
closeOnBgClick: false,
enableEscapeKey: false,
mainClass: 'pop700MainClass'
});
return false;
});
function UpdateActiveTabHighlightColor() {
$("#navlist li").css("border-top", "");
var activeTabHighlightColor = $("#ActiveTabHighlightColor").val();
$("#navlist li.active").css("border-top", "2px solid " + activeTabHighlightColor);
}
/* Starts #23057 */
function QuickPurchase() {
var productId = $("#quickPurchase").attr("data-productId");
var email = $("#quickPurchase").attr("data-value");
var message = '
The staff registration will be completed under your customer account email ' + email + '. If there isn\'t a customer or speaker account that exists on this tenant with this email currently, a customer account will be autocreated.
All staff registrations will ensure the customer account is marked as Test Account in order to keep finances proper.
';
var quickPurchase = "/showtime/OpenQuickPurchase";
var launchViewerURL, myAccountUrl;
var isViewer = $("#quickPurchase").attr('data-viewer');
$('#divProgress').show();
$.ajax({
type: "GET",
url: quickPurchase,
dataType: "json",
data: {
'productId': productId,
'email': email
},
success: function (data) {
$('#divProgress').hide();
if (data.errorMessage) {
alert(data.errorMessage);
}
else {
$.confirm({
title: ' Staff Register',
boxWidth: '550px',
useBootstrap: false,
type: 'red',
content: message,
buttons: {
LaunchViewer: {
text: 'LAUNCH VIEWER',
btnClass: 'btn-info ' + (isViewer == 'True' ? (data.QuickPurchasebtn == "disabled" ? "" : "hidden") : "hidden"),
action: function () {
if (!launchViewerURL) {
var data = QuickpurchaseAlert(productId, email, false);
if (data && data.errorMessage) {
alert(data.errorMessage);
} else {
launchViewerURL = data.ViewerUrl;
}
}
window.open(launchViewerURL, '_blank');
},
},
LaunchAccount: {
text: 'LAUNCH ACCOUNT',
btnClass: 'btn-info ' + (data.QuickPurchasebtn == "disabled" ? "" : "hidden"),
action: function () {
if (!myAccountUrl) {
var data = QuickpurchaseAlert(productId, email, false);
if (data && data.errorMessage) {
alert(data.errorMessage);
} else {
myAccountUrl = data.MyAccountUrl;
}
}
window.open(myAccountUrl, '_blank');
},
},
ok: {
text: data.QuickPurchasebtn == "disabled" ? 'Registered' : 'STAFF REGISTER',
btnClass: 'btn-success btnQuickPurchase ' + data.QuickPurchasebtn,
autoClose: false,
action: function () {
var data = QuickpurchaseAlert(productId, email);
if (data && data.errorMessage) {
alert(data.errorMessage);
}
else {
this.buttons.LaunchViewer.removeClass("hidden");
launchViewerURL = data.ViewerUrl
myAccountUrl = data.MyAccountUrl
if (data.LaunchViewerbtn) {
this.buttons.LaunchViewer.addClass(data.LaunchViewerbtn);
}
this.buttons.LaunchAccount.removeClass("hidden");
this.buttons.ok.hide();
this.buttons.cancel.hide();
this.buttons.close.removeClass("hidden");
return false;
}
}
},
cancel: {
text: 'Cancel',
btnClass: 'btn-default',
action: function () {
}
},
close: {
text: 'CLOSE',
btnClass: 'btn-default hidden',
action: function () {
}
},
},
onContentReady: function () {
$(".btnQuickPurchase.disabled").css('pointer-events', 'auto');
$(".btnQuickPurchase.disabled").attr({
"disabled": true,
'title': 'Quick purchased on ' + data.QuickPurchasedDate,
});
},
});
}
}
});
function QuickpurchaseAlert(productId, userEmail, isPurchasedProduct) {
var quickPurchase = "/showtime/QuickPurchase";
var returndata;
$.ajax({
type: "GET",
url: quickPurchase,
dataType: "json",
async: false,
data: {
'productId': productId,
'email': userEmail,
'isPurchasedProduct': isPurchasedProduct
},
success: function (data) {
returndata = data;
}
});
return returndata;
};
}
function UpdateTabColorForUnauthViewer() {
var viewerTitleColor = $("#ViewerTitleColor").val();
var isCleanUnathViewer = $("#CleanUnathViewer").val();
if (isCleanUnathViewer.toLowerCase() == "true") {
$("#navlist li a").css("color", "#fff");
$("#navlist li.active a").css("color", viewerTitleColor);
}
}
/* End #23057 */
// Screen reader navigation helper for side panel
$("#sidePanelShowAll").click(function (e) {
e.preventDefault();
sidePanelShowAll = true;
$("#navlist a:visible").each(function (_, e) {
$(e).click();
});
$("#navlist").hide();
$("#sidePanelShowAll").hide();
});
;
var trackingFailedTime = 0;
//define(["durandal/events"], function (events) {
//#region Helpers
function setHeader(xhr) {
xhr.setRequestHeader("x-ms-version", "2013-08-15");
xhr.setRequestHeader("MaxDataServiceVersion", "3.0");
xhr.setRequestHeader("Accept", "application/json;odata=nometadata");
xhr.setRequestHeader("Content-Type", "application/json;odata=nometadata");
}
function padLeft(nr, n, str) {
return Array(n - String(nr).length + 1).join(str || "0") + nr;
}
Array.prototype.unique = function () {
var a = this.concat();
for (var i = 0; i < a.length; ++i) {
for (var j = i + 1; j < a.length; ++j) {
if (a[i] === a[j])
a.splice(j--, 1);
}
}
return a;
};
//#endregion
//#region Time Sync
var curServerTime = null;
var curRelativeTime = null;
var orignalRelativeTime = null;
var curVidDelay = 0;
var curMediaClip = null;
var certCount = 0, refreshedCertificate = false;
var T_ERROR_KEY = "track-" + padLeft(t, 6) + "-" + padLeft(s, 9);
// update serverTime
function serverTimeUpdate() {
//console.log("startTimeUtc " + seminar.StartTimeUtc);
var timeNow = new Date();
var viewerServerOffset = (window.vd - window.sd);
// time now adjusted by offset between viewer client time and server time.
curServerTime = timeNow - viewerServerOffset;
// current duration from beginning of seminar
// This is the duration that will be used to determine when to show slides/messages and such.
//console.log("curServerTime " + curServerTime);
//console.log("curRelativeTime " + curServerTime - seminar.StartTimeUtc);
if (seminar.IsLive) {
curRelativeTime = (curServerTime - seminar.StartTimeUtc);
} else if (seminar.IsReplay) {
orignalRelativeTime = Math.round((curServerTime - seminar.StartTimeUtc) / 1000);
if (orignalRelativeTime <= seminar.MinimumTriggerTime || !curMediaClip) {
curRelativeTime = orignalRelativeTime * 1000;
} else {
curRelativeTime = calculateRelativeTime();
}
} else {
if (curMediaClip != null) {
curRelativeTime = calculateRelativeTime();
}
}
if (seminar.IsLive || seminar.IsReplay) {
var seminarcurTime = Math.round((curRelativeTime) / 1000);
if (certCount == 0) {
//if time tracking enable then refresh 91% else 75%
var percentage = (seminar.TimeTrackingEnabled ? 91 : 75);
//get certificate refresh time
var seminarPassTime = (((seminar.SeminarMinutes * percentage) / 100) * 60);
if ((seminarcurTime > seminarPassTime) && (seminarcurTime < (seminarPassTime + 5))) {
RefreshCertificate();
certCount = 1;
}
}
//100% duration then refresh certificate
if (refreshedCertificate == false && seminar != null && seminar.SeminarMinutes != undefined && seminar.TimeTrackingEnabled
&& (Math.round((curRelativeTime) / 1000) > (seminar.SeminarMinutes * 60)) && (Math.round((curRelativeTime) / 1000) < (seminar.SeminarMinutes * 60) + 5)
&& $('div.CertificationWidget h5.ui-accordion-header:visible').hasClass('ui-state-active') === false) {
refreshedCertificate = true;
if ($("#CertificationWidget").length == 0 && typeof updateCertCompletionStatus === "function") {
//mantis item #18216
updateCertCompletionStatus();
}
else {
RefreshCertificate();
}
}
//When seminar starts then we need to refresh certificate [call: starttime + 5 ]
if (seminarcurTime === 5) {
RefreshCertificate();
}
//After 10 second of seminar end - need to refresh certificate
if (seminar.PresenterDuration && seminarcurTime === (seminar.PresenterDuration + 10)
&& $('div.CertificationWidget h5.ui-accordion-header:visible').hasClass('ui-state-active') === false) {
RefreshCertificate();
}
//#13709
if (seminar && seminar.IsReplay && seminar.IsArchive === false && seminar.PresenterDuration
&& Math.round(curRelativeTime / 1000).between(seminar.PresenterDuration, seminar.PresenterDuration + 5)
&& vidPlayer && typeof (vidPlayer.isFullscreen) === "function" && vidPlayer.isFullscreen()) {
vidPlayer.exitFullscreen()
}
//After 2 second of seminar end - trigger post roll video #13488
if (seminar != null && (seminar.IsReplay || seminar.IsLive)
&& seminar.PresenterDuration > 0 && seminarcurTime == (seminar.PresenterDuration + 5)) {
if (seminar.IsReplay && typeof (reInitViewer) === 'function') {
reInitViewer();
}
else if (seminar.IsLive && typeof (currentLiveStatus) !== 'undefined' && seminar.PostRollMediaSource) {
currentLiveStatus = undefined;
}
}
}
//#0017665: Viewer > Classroom > End of programs
if (curRelativeTime && seminar && seminar.PresenterDuration > 0
&& Math.round(curRelativeTime / 1000) == seminar.PresenterDuration) {
if (seminar.IsLive && typeof (currentLiveStatus) !== 'undefined') {
currentLiveStatus = undefined;
} else if (typeof (triggerClassroomEndActions) === 'function') {
triggerClassroomEndActions();
}
}
//console.log("curRelativeTime " + curRelativeTime);
checkCertAlertIcon();
}
function triggerPostRoll() {
if (seminar.IsReplay && orignalRelativeTime > 0
&& orignalRelativeTime >= seminar.PresenterDuration && !showPostRollVideoOrNot()
&& seminar.IsArchive === false && typeof (reInitViewer) === 'function') {
reInitViewer();
}
}
function calculateRelativeTime() {
var vtc = curVidTimeCode == null ? 0 : curVidTimeCode;
var tt = curMediaClip.TriggerTime == null ? 0 : Number(curMediaClip.TriggerTime);
var ip = curMediaClip.InPoint == null ? 0 : Number(curMediaClip.InPoint);
return (vtc - ip + tt) * 1000;
}
function vidDelayUpdate() { //Only gets called if IsLive/IsReplay
if (seminar.IsReplay) {
//var div = Math.floor(y/x);
//var rem = y % x;
//var tTime = am.curMediaClip().triggerTime();
//var inTime = am.curMediaClip().inPoint();
//var d = am.curRelativeTime() - (am.curVidTimeCode() * 1000) - tTime - inTime;
curVidDelay = 0; //0s for now
} else {
curVidDelay = 40000; //40s default for now
}
}
//#endregion
//#region Actions
// Actions are basically a link for events between the presenter and the viewer.
// An event can be thrown in the presenter (viewer:media:changeAspectRatio) and
// it will be caught passed over to the viewer and re-thrown on a delay based on
// the delay of the streaming media. You can then catch the event (media:changeAspectRatio)
// in the viewer and do whatever needs to be done.
var actions = [];
var actionDelay = 100000; //100s default for now
var listActions = [];
var tableSasActionUri, tableSasActionTimeout, lastActionQueryTime;
function queryActionTable(tableSasUrl) {
if (tableSasUrl !== undefined && tableSasUrl != null) {
//Use SasActionUrl to query the actions table and store in memory for later use
if (!lastActionQueryTime) {
lastActionQueryTime = curRelativeTime - curVidDelay;
}
//var q = tableSasUrl + "&$filter=PartitionKey eq '" + padLeft(t, 6) + "-" + padLeft(s, 9) + "-" + padLeft(e, 9) + "'and RowKey ge '" + padLeft(lastActionQueryTime + 100000000000, 12) + "'";
var rowKey = padLeft(lastActionQueryTime + 100000000000, 12);
var partitionKey = padLeft(pt, 6) + "-" + padLeft(ps, 9) + "-" + padLeft(pe, 9);
var q = tableSasUrl + "&$filter=PartitionKey eq '" + partitionKey + "'and RowKey ge '" + rowKey + "'";
lastActionQueryTime = curRelativeTime - actionDelay;
// if (!oldIE) {
if (browserSupportsCors()) {
$.ajax({
type: "GET",
datatype: "json",
url: q,
beforeSend: setHeader,
// Render the table with all the entities if the request succeeds
success: function (res, status, xhr) {
//console.log("Got Actions");
//If action aleready executed then remove
if (res.value != null && res.value.length > 0) {
var responceLength = res.value.length;
for (var key = 0; key < responceLength; key++) {
var lasAction = jQuery.grep(listActions, function (n, i) {
return n.RowKey == res.value[key].RowKey;
})[0];
if (lasAction == null || lasAction == undefined) {
listActions.push(res.value[key]);
} else {
//console.log("removed");
res.value.splice(key, 1);
responceLength = res.value.length;
key = key - 1;
}
}
}
actions = actions.concat(res.value).unique();
},
error: function (res, status, xhr) {
lastActionQueryTime = curRelativeTime - 60000;
console.log("Error: Get Actions");
//store in elmah
var objErrorDetail = '[Status]= ' + res.status;
objErrorDetail += ',[TableSasUrl]= ' + q;
objErrorDetail += ',[Navigator]= ' + navigator.userAgent;
objErrorDetail += ',[ResponseText]= ' + res.responseText;
objErrorDetail += ',[statusText]= ' + res.statusText;
objErrorDetail += ',[FunctionName]= queryActionTable';
$.post("/ShowtimeWidget/WriteToElmah", { message: 'Error: Get Actions', errorDetail: objErrorDetail });
}
});
}
else {
$.ajax({
type: "POST",
datatype: "json",
data: {
//'tstore': encodeURIComponent(tableSasUrl),
'tstore': tableSasUrl,
'partitionKey': partitionKey,
'rowKey': rowKey
},
url: '/ShowtimeWidget/QueryTableSaas',
// Render the table with all the entities if the request succeeds
success: function (res, status, xhr) {
//console.log("Got Actions");
//If action aleready executed then remove
if (res.value != null && res.value.length > 0) {
var responceLength = res.value.length;
for (var key = 0; key < responceLength; key++) {
var lasAction = jQuery.grep(listActions, function (n, i) {
return n.RowKey == res.value[key].RowKey;
})[0];
if (lasAction == null || lasAction == undefined) {
listActions.push(res.value[key]);
} else {
//console.log("removed");
res.value.splice(key, 1);
responceLength = res.value.length;
key = key - 1;
}
}
}
actions = actions.concat(res.value).unique();
},
error: function (res, status, xhr) {
lastActionQueryTime = curRelativeTime - 60000;
var responseText = $(res.responseText).filter('title').text();
if (res.status == 403 || responseText.indexOf('403') > -1) {
tableSasActionUri = null;
}
console.log("Error: Get Actions");
}
});
}
}
}
function actionsUpdate() {
//Check if SasActionUrl is stale and update if needed
if (tableSasActionUri != null && tableSasActionTimeout > moment()) {
queryActionTable(tableSasActionUri);
} else {
$.ajax({
type: "GET",
url: "/showtimewidget/getactiontablecustomersasurl?tenantid=" + pt + "&seminarid=" + ps + "&timeid=" + pe + "",
headers: { "Authorization": "Bearer " + x },
success: function (res, status, xhr) {
// Use the table SAS url to query windows azure storage.
//console.log("Got Action SAS");
tableSasActionTimeout = moment().add(25, "m");
tableSasActionUri = xhr.responseText.replace(/"/g, "");
queryActionTable(tableSasActionUri);
},
error: function (res, status, xhr) {
console.log("Error: SAS Actions");
}
});
}
}
function actionCheck() {
if (actions && actions.length > 0) {
if (seminar.IsReplay) {
jQuery.each(actions, function (index, value) {
if (value !== undefined && Number(value.ProductTime) < Math.round((curRelativeTime - curVidDelay) / 1000)) {
var data = JSON.parse(value.Data);
//am.trigger(value.Action, data);
triggerActions(value.Action, data);
actions.splice(index, 1);
}
});
//Cleanout past actions
jQuery.each(actions, function (index, value) {
if (value !== undefined && Number(value.ProductTime) < Math.round((curRelativeTime - curVidDelay) / 1000)) {
actions.splice(index, 1);
}
});
} else {
jQuery.each(actions, function (index, value) {
//if (value !== undefined && Number(value.ProductTime) === Math.round((curRelativeTime - curVidDelay) / 1000)) {
// var data = JSON.parse(value.Data);
// //am.trigger(value.Action, data);
// triggerActions(value.Action, data);
// actions.splice(index, 1);
//}
if (value !== undefined && Number(value.ProductTime) >= Math.round(((curRelativeTime - curVidDelay) / 1000) - 5) &&
Number(value.ProductTime) <= Math.round(((curRelativeTime - curVidDelay) / 1000) + 5)) {
//console.log('triggered ' + value.RowKey);
var data = JSON.parse(value.Data);
//am.trigger(value.Action, data);
triggerActions(value.Action, data);
//if action is excuted succesfull then set IsExecuted = true http://mantis.ce21.com/view.php?id=4518
setActionExecuted(value.RowKey);
actions.splice(index, 1);
}
});
}
}
}
function triggerActions(actionName, data) {
switch (actionName) {
case "media:gotoMediaPos":
media_gotoMediaPos(data.mediaClipid, data.postime);
break;
case "media:changeMedia":
media_changeMedia(data);
break;
case "certCode:showCertCode":
certCode_showCertCode(data);
break;
case "alert:showAlert":
alert_showAlert(data);
break;
case "alert_clearAlerts":
alert_clearAlerts(data);
case "alert:showSpeakerGraphicAlert": //#10505
alert_showSpeakerGraphicAlert(data);
break;
case "alert_clearSpeakerGraphicAlert"://#10505
alert_clearSpeakerGraphicAlert(data);
break;
case "slide:changeSlide":
slide_changeSlide(data);
break;
case "slide:addSlide":
slide_addSlide(data);
break;
case "slide:changeOrder":
slide_changeOrder(data);
break;
//case "media:ShowMedia":
// media_ShowMedia(data);
// break;
case "slide:ShowSlide":
slide_ShowSlide(data);
case "golive:ShowLive":
show_LiveMedia(data);
break;
case "slide:DeleteSlideSet":
slide_DeleteSlideSet(data);
break;
case "polling:changeTime":
polling_changeTime(data);
break;
case "polling:hideQuestion":
polling_hideQuestion(data);
break;
case "polling:resetPoll":
polling_resetPoll();
break;
case "seminar:audioOnly":
seminar_audioOnly(data);
break;
case "slide:HideSlide":
slide_HideSlides(data);
break;
case "certificate:Reload":
ReloadCertificate();
break;
case "alert:forceReload":
forceReloadViewer();//mantis item #17430
break;
default:
break;
}
}
function setActionExecuted(rowKey) {
jQuery.each(listActions, function (index, value) {
if (value !== undefined && value.RowKey == rowKey) {
value.IsExecuted = true;
}
});
}
function executeMissedAction() {
try {
if (listActions != null && listActions.length > 0) {
//Get action is not executed
var listMissedActions = jQuery.grep(listActions, function (n, i) {
return (n != undefined) && (n.IsExecuted == undefined || n.IsExecuted == null || n.IsExecuted == false);
});
if (listMissedActions != null && listMissedActions.length > 0) {
jQuery.each(listMissedActions, function (index, value) {
if (Number(value.ProductTime) < Math.round((curRelativeTime - curVidDelay) / 1000) && (value.Action == "media:changeMedia" || value.Action == "alert:showAlert" || value.Action == "golive:ShowLive" || value.Action == "alert:showSpeakerGraphicAlert")) {
var data = JSON.parse(value.Data);
triggerActions(value.Action, data);
//if action is excuted succesfull then set IsExecuted = true http://mantis.ce21.com/view.php?id=4518
setActionExecuted(value.RowKey);
console.log('missed action executed');
}
});
}
}
} catch (e) {
}
}
//#endregion
//#region Medias
var curVidState;
var curVidTimeCode = 0;
var curVidMediaClipId = 0;
var curMediaClip;
//#endregion
//#region Tracking
function trackLocal() {
//Record tracking info to local storage
updateState();
if (curVidState === "PLAYING") {
if (typeof (Storage) !== "undefined") {
var uPadded;
if (isNaN(u)) uPadded = u;
else uPadded = padLeft(u, 9);
var tKey = padLeft(t, 6) + "-" + padLeft(s, 9) + "-" + uPadded + "-" + padLeft(curVidMediaClipId, 9);
var posTime = curVidTimeCode;
var maxTime = posTime;
if (localStorage.getItem(tKey)) {
maxTime = Math.max(JSON.parse(localStorage.getItem(tKey)).MaxTime, posTime);
}
var dict = {};
dict["TenantId"] = parseInt(t);
dict["ProductId"] = parseInt(s);
dict["ProductTime"] = Math.round((curRelativeTime - curVidDelay) / 1000); //Time from the seminar start time.
dict["MediaClipId"] = curVidMediaClipId; //Id of the current media clip.
dict["MediaTime"] = posTime; //Time from the beginning of the current media clip.
dict["MaxMediaTime"] = maxTime;
dict["UserId"] = u;
localStorage.setItem(tKey, JSON.stringify(dict));
}
}
}
var tableSasTrackingUri, tableSasTrackingTimeout;
var lastTrackMediaTime = 0; // used for onDemand User Time Tracking
var trackingClipId = 0;
function writeTrackingDb(tableSasUrl) {
var mediaTime = curVidTimeCode;
if (mediaTime >= lastTrackMediaTime) {
lastTrackMediaTime = mediaTime;
}
if (isNaN(mediaTime)) mediaTime = 0;
var productTime = Math.round((curRelativeTime - curVidDelay) / 1000);
if (seminar != undefined && seminar != null && seminar.MaxRelativeTime != undefined && productTime >= seminar.MaxRelativeTime) {
seminar.MaxRelativeTime = productTime;
}
var rowTime = seminar.IsLive ? productTime : mediaTime;
var uPadded;
if (isNaN(u)) uPadded = u;
else uPadded = padLeft(u, 9);
if (trackingClipId == 0) {
trackingClipId = curVidMediaClipId;
}
var dict = {};
dict["PartitionKey"] = padLeft(t, 6) + "-" + padLeft(s, 9) + "-" + uPadded;
dict["RowKey"] = padLeft(trackingClipId, 9) + "-" + padLeft(Math.round(rowTime * 10000000), 18);
dict["TenantId"] = parseInt(t);
dict["ProductId"] = parseInt(s);
dict["ProductTime"] = productTime; //Time from the seminar start time.
dict["MediaClipId"] = trackingClipId; //Id of the current media clip.
dict["MediaTime"] = mediaTime; //Time from the beginning of the current media clip.
dict["UserId"] = u;
dict["UserAgent"] = navigator.userAgent;
dict["IPAddress"] = seminar.ClientIp;
dict["ProgramRegistrantId"] = parseInt(ProgramRegistrantId);
var trackingData = JSON.stringify(dict);
//if (!oldIE) {
if (browserSupportsCors() && trackingFailedTime <= 3) {
$.ajax({
type: "POST",
datatype: "json",
data: trackingData,
url: tableSasUrl,
beforeSend: setHeader,
success: function (res, status, xhr) {
//console.log("Write Traking");
calculateTimeTrackingPercentage(mediaTime);
lastTrackTime = new Date();
},
error: function (res, status, xhr) {
if (res && res.status && res.status != 409) {
trackingFailedTime += 1;
tableSasTrackingUri = null;
console.log("Error: Write Traking- Code:" + res.status);
AddToTrackingErrordData(dict);
WriteElmahError(res, navigator, "writeTrackingDb_If");
}
console.log("Error: Write Traking");
}
});
}
else {
console.log("Write: C# Traking");
//$.ajax({
// type: "POST",
// datatype: "json",
// data: {
// 'tstore': tableSasUrl,
// //'tstore': encodeURIComponent(tableSasUrl),
// //'trackingData': encodeURIComponent(trackingData)
// 'trackingData': trackingData
// },
// url: '/ShowtimeWidget/WriteToTracking',
// success: function (res, status, xhr) {
// console.log("Write Traking");
// calculateTimeTrackingPercentage(mediaTime);
// },
// error: function (res, status, xhr) {
// var responseText = $(res.responseText).filter('title').text();
// if (res.status == 403 || responseText.indexOf('403') > -1) {
// tableSasTrackingUri = null;
// }
// AddToTrackingErrordData(dict);
// console.log("Error: Write Traking");
// }
//});
$.ajax({
type: "POST",
datatype: "json",
data: {
'trackingData': trackingData
},
url: '/ShowtimeWidget/WriteToTrackingStorage',
success: function () {
console.log("Write Traking");
calculateTimeTrackingPercentage(mediaTime);
lastTrackTime = new Date();
},
error: function () {
tableSasTrackingUri = null;
AddToTrackingErrordData(dict);
console.log("Error: Write Traking");
}
});
}
//TODO: Look into doing upsert for table storage.
if (seminar.SeminarTypeId == 4) {
onDemandVideoCompletion(Number(mediaTime));
}
}
var totalRequiredDuration = null, lastMediaTime = null;
function calculateTimeTrackingPercentage(mediaTime) {
if ($('.timetrackingPercentange').length > 0) {
if (lastMediaTime == null) {
lastMediaTime = mediaTime - 50;
}
var totalPercentageViewed = Number($('.timetrackingPercentange').text().replace('%', ''));
if (totalRequiredDuration == null && totalPercentageViewed <= 100) {
//Get Required duration
$.ajax({
type: "GET",
async: false,
url: "/showtimewidget/getrequiredduration?tenantId=" + pt + "&productId=" + ps,
success: function (data) {
totalRequiredDuration = data;
}
});
}
var productTime = Math.round((curRelativeTime - curVidDelay) / 1000);
if ((mediaTime - lastMediaTime) > 0 && seminar.LastRelativeTime != null && productTime > seminar.LastRelativeTime && totalRequiredDuration > 0 && totalPercentageViewed <= 100 && curMediaClip != null && curMediaClip.Required == true) {
seminar.LastRelativeTime = productTime;
//Get total duration viewed
var totalViewedDuration = Math.round((totalPercentageViewed * totalRequiredDuration) / 100);
totalViewedDuration += (mediaTime - lastMediaTime);
//console.log('Diffrence ' + (mediaTime - lastMediaTime));
//console.log('Percentage ' + Math.round((totalViewedDuration * 100) / totalRequiredDuration) + '%')
var percentage = Math.round((totalViewedDuration * 100) / totalRequiredDuration);
if (percentage <= 0 || percentage >= 100) {
} else {
//Referesh certficate tab #4849
if (percentage >= 95 && !isRefreshedCertificated) {
if (typeof (RefreshCertificate) == "function") {
RefreshCertificate();
isRefreshedCertificated = true;
}
}
$('.timetrackingPercentange').text(percentage + '%');
}
}
lastMediaTime = mediaTime;
}
}
var isRefreshedCertificated = false;
function getTimeTrackingPercentage() {
updateState();
if ($('.timetrackingPercentange').length > 0 && seminar.IsLive == false && Number(u) != -1 && curVidState === "PLAYING") {
$.ajax({
type: "GET",
async: false,
url: "/showtimewidget/gettimetrackingpercentage?tenantId=" + t + "&productId=" + s + "&customerId=" + u + "&eventTimeId=" + e + "&programRegistrantId=" + ProgramRegistrantId,
success: function (data) {
$('.timetrackingPercentange').text(Math.round(data) + '%');
//Referesh certficate tab #4849
if (data >= 90 && !isRefreshedCertificated) {
if (typeof (RefreshCertificate) == "function") {
RefreshCertificate();
isRefreshedCertificated = true;
}
}
}
});
}
}
function trackDb(forcefullyUpdate) { //10210 add forcefullyUpdate
trackingClipId = curVidMediaClipId;
updateState();
if (curVidState === "PLAYING" || (forcefullyUpdate && forcefullyUpdate == true)) {
//Update track details for on demand
if (typeof (updateMediaTrackDetails) == "function") {
updateMediaTrackDetails(curVidTimeCode);
}
if (tableSasTrackingUri != null && tableSasTrackingTimeout > moment()) {
writeTrackingDb(tableSasTrackingUri);
} else {
$.ajax({
type: "GET",
url: "/showtimewidget/gettrackingtablecustomersasurl?tenantid=" + t + "&seminarid=" + s + "&userid=" + u + "",
//headers: { "Authorization": "Bearer " + x },
success: function (res, status, xhr) {
if (xhr && xhr.responseText) {
// Use the table SAS url to query windows azure storage.
console.log("Got Tracking SAS");
tableSasTrackingTimeout = moment().add(25, "m");
tableSasTrackingUri = xhr.responseText.replace(/"/g, "");
writeTrackingDb(tableSasTrackingUri);
}
},
error: function (res, status, xhr) {
console.log("Error: SAS Traking");
WriteElmahError(res, navigator, "trackDb");
}
});
}
}
}
var tableSasTrackingIxUri, tableSasTrackingIxTimeout;
function writeTrackingIxDb(tableIxSasUrl) {
var uPadded;
if (isNaN(u)) uPadded = u;
else uPadded = padLeft(u, 9);
var ticks = ((Date.now() * 10000) + 621355968000000000);
var dict = {};
dict["PartitionKey"] = padLeft(t, 6) + "-" + padLeft(s, 9);
dict["RowKey"] = padLeft(ticks, 19);
dict["OriginalPartitionKey"] = padLeft(t, 6) + "-" + padLeft(s, 9) + "-" + uPadded;
dict["ProgramRegistrantId"] = ProgramRegistrantId;
var trackingData = JSON.stringify(dict);
//if (!oldIE) {
if (browserSupportsCors()) {
$.ajax({
type: "POST",
datatype: "json",
data: trackingData,
url: tableIxSasUrl,
beforeSend: setHeader,
success: function (res, status, xhr) {
console.log("Write Traking");
},
error: function (res, status, xhr) {
console.log("Error: Write Traking");
}
});
}
else {
$.ajax({
type: "POST",
datatype: "json",
data: {
'tstore': tableIxSasUrl,
'trackingData': trackingData
},
url: '/ShowtimeWidget/WriteToTracking',
success: function (res, status, xhr) {
console.log("Write Traking");
},
error: function (res, status, xhr) {
var responseText = $(res.responseText).filter('title').text();
if (res.status == 403 || responseText.indexOf('403') > -1) {
tableSasTrackingIxUri = null;
}
console.log("Error: Write Traking");
}
});
}
}
function trackIxDb() {
updateState();
if (curVidState === "PLAYING") {
if (tableSasTrackingIxUri != null && tableSasTrackingIxTimeout > moment()) {
writeTrackingIxDb(tableSasTrackingIxUri);
} else {
$.ajax({
type: "GET",
url: "/showtimewidget/gettrackingixtablecustomersasurl?tenantid=" + t + "&seminarid=" + s + "",
headers: { "Authorization": "Bearer " + x },
success: function (res, status, xhr) {
// Use the table SAS url to query windows azure storage.
console.log("Got TrackingIx SAS");
tableSasTrackingIxTimeout = moment().add(25, "m");
tableSasTrackingIxUri = xhr.responseText.replace(/"/g, "");
writeTrackingIxDb(tableSasTrackingIxUri);
},
error: function (res, status, xhr) {
console.log("Error: SAS TrakingIx");
}
});
}
}
}
function finalTrack() {
//curVidState = "PLAYING";
//trackLocal();
trackDb(true);
//curVidState = "IDLE";
}
//#endregion
var lastTrackTime = null;
var initTrackingInterval = function () {
Helper.Interval.set("VIEWER_TRACKING", trackDb, 60);
}
function setIntervals() {
serverTimeUpdate();
Helper.Interval.set("VIEWER_SERVERTIMEUPDATE", function () {
try { serverTimeUpdate(); } catch (e) { }
try { actionCheck(); } catch (e) { }
if (seminar.IsArchive == false && seminar.PrePostPopUp != null && seminar.PrePostPopUp.length > 0) {
try { checkPrePostPopUp(); } catch (e) { }
}
}, 1);
//Init Tracking
initTrackingInterval();
Helper.Interval.set("VIEWER_TRACKINGVALIDATE", function () {
trackIxDb();
// if last 3 minutes tracking not done then Init tracking again
if (lastTrackTime && ((new Date() - lastTrackTime) / 1000) > 180) {
initTrackingInterval();
}
}, 5 * 60);
if (seminar.IsReplay) {
vidDelayUpdate();
//setInterval(function () { vidDelayUpdate(); }, 300000); //5m
//actionsUpdate(); //Kiran: added for Mantis #1682
//setInterval(function () { actionsUpdate(); }, 30000); //Kiran: added for Mantis #1682
}
if (seminar.IsLive) {
vidDelayUpdate();
//setInterval(function () { vidDelayUpdate(); }, 300000); //5m
//actionsUpdate();
//setInterval(function () { actionsUpdate(); }, 30000);
//setInterval(function () { executeMissedAction() }, 10000); //10s // check any missed action #9650
}
initSlides();
//// Attendance requirment
//if (seminar.SeminarTypeId == 4 && seminar.AttendanceRequirements != null && seminar.AttendanceRequirements.length > 0) {
// setInterval(function () { checkAttendance(); }, 1000); //1s
//}
////Pre post Popups
//if (seminar.IsArchive == false && seminar.PrePostPopUp != null && seminar.PrePostPopUp.length > 0) {
// setInterval(function () { checkPrePostPopUp(); }, 1000); //1s
//}
if (!seminar.IsLive) {
Helper.Interval.set("VIEWER_GETTIMETRACKINGPERCENTAGE", getTimeTrackingPercentage, 10 * 60);
}
if ((seminar.IsArchive == false || seminar.IsAllowCreditForArchive) && (seminar.SeminarTypeId == 4 || seminar.SeminarTypeId == 3 || seminar.SeminarTypeId == 2) && seminar.PopUpAlerts != null && seminar.PopUpAlerts.length > 0) { //#11525 show quiz popup for archive If, 'Allow registrants to view archive for credit' is selected
Helper.Interval.set("VIEWER_CHECKPOPUPALERTS", checkPopUpAlerts, 1);
}
if (seminar.IsArchive == false) {
Helper.Interval.set("VIEWER_SHOWPOPUPPOLLINGQUESTION", showPopUpPollingQuestion, 1);
}
Helper.Interval.set("VIEWER_CHECKVIEWERPOPUPS", checkViewerPopUps, 1);
// checck if any time tracking entry in local storage then update it
UpdateLocalTrackingToServer();
Helper.Interval.set("VIEWER_UPDATELOCALTRACKINGTOSERVER", UpdateLocalTrackingToServer, 5 * 60);
}
function initActions() {
setIntervals();
}
//#region Slides
var slides = [];
var slideTimes = [];
var slideIsSynch = true;
var curSlide = null;
var preSlide = null;
var curSlideId = 0;
function checkSlideTimes() {
// If live webcast then no need to use delay because in live webcast it is not calling intervally.
var delay = seminar && seminar.IsLive && !seminar.IsArchive ? 0 : curVidDelay;
var slideTimes = [];
$.each(seminar.Slides, function (outerIndex, outerElement) {
if (outerElement.SlideTimes != null && outerElement.SlideTimes.length > 0) {
$.each(outerElement.SlideTimes, function (innerIndex, innerElement) {
if (innerElement.ProductTime && innerElement.ProductTime <= Math.round((curRelativeTime - delay) / 1000)) {
slideTimes.push(innerElement);
}
});
}
});
if (slideTimes.length > 0) {
var maxSlideTimes = slideTimes.sort(function (a, b) {
return (a.ProductTime - b.ProductTime);
}).pop();
if (maxSlideTimes) {
if ((Number(seminar.SeminarTypeId) == 4 || Number(seminar.SeminarTypeId) == 3) || ((Number(seminar.SeminarTypeId) == 2 || Number(seminar.SeminarTypeId) == 8) && seminar.IsArchive == true)) {
if (curSlideId != Number(maxSlideTimes.SlideId)) {
if ($("#SlideThumbsWidget").css("display") == "none") {
$(".SlideThumbsWidget a img").removeClass("selected");
if ($("#btnSyncSlide").attr("data-issync") == "true") {
$("#slidescreen img").attr('src', maxSlideTimes.Slide.Source);
$("#slidescreen a").attr('href', getSlideMarketingUrl(maxSlideTimes.Slide.MarketingUrl)).attr('title', maxSlideTimes.Slide.HoverText).attr("target", getSlideTarget(maxSlideTimes.Slide.MarketingUrl));
}
}
else {
changeSlide(Number(maxSlideTimes.SlideId), maxSlideTimes.Slide.Source, maxSlideTimes.Slide.MarketingUrl, maxSlideTimes.Slide.HoverText);
}
curSlideId = Number(maxSlideTimes.SlideId);
}
else {
$(".SlideThumbsWidget a[data-slideid='" + curSlideId + "'] img").addClass("selected");
}
}
else {
curSlideId = maxSlideTimes.Slide.SlideId;
if ($("#SlideThumbsWidget").css("display") == "none") {
$(".SlideThumbsWidget a img").removeClass("selected");
$("#slidescreen img").attr('src', maxSlideTimes.Slide.Source);
$("#slidescreen a").attr('href', getSlideMarketingUrl(maxSlideTimes.Slide.MarketingUrl)).attr('title', maxSlideTimes.Slide.HoverText).attr("target", getSlideTarget(maxSlideTimes.Slide.MarketingUrl));
}
else {
changeSlide(Number(maxSlideTimes.SlideId), maxSlideTimes.Slide.Source, maxSlideTimes.Slide.MarketingUrl, maxSlideTimes.Slide.HoverText);
}
}
}
}
else {
if (seminar.Slides.length > 0 && seminar.IsLive) {
changeSlide(Number(seminar.Slides[0].SlideId), seminar.Slides[0].Source, seminar.Slides[0].MarketingUrl, seminar.Slides[0].HoverText);
} else if (seminar.Slides.length > 0) {
slideTimes = [];
//If Ondemand,Replay or IsArchive
$.each(seminar.Slides, function (outerIndex, outerElement) {
if (outerElement.SlideTimes != null && outerElement.SlideTimes.length > 0) {
$.each(outerElement.SlideTimes, function (innerIndex, innerElement) {
slideTimes.push(innerElement);
});
}
});
var firstSlideTimes = slideTimes.sort(function (a, b) {
return (b.ProductTime - a.ProductTime);
}).pop();
if (firstSlideTimes) {
if (curSlideId != Number(firstSlideTimes.SlideId)) {
curSlideId = firstSlideTimes.Slide.SlideId;
changeSlide(Number(firstSlideTimes.SlideId), firstSlideTimes.Slide.Source, firstSlideTimes.Slide.MarketingUrl, firstSlideTimes.Slide.HoverText);
}
} else {
if (curSlideId != Number(seminar.Slides[0].SlideId)) {
curSlideId = seminar.Slides[0].SlideId;
changeSlide(Number(seminar.Slides[0].SlideId), seminar.Slides[0].Source, seminar.Slides[0].MarketingUrl, seminar.Slides[0].HoverText);
}
}
}
}
if ($("#main-panel").css("display") != "none") {
$("#slidescreen img").width('100%');
}
if (seminar != null && seminar.IsLive) {
onLoadMediaSlide();
}
}
function getSlideMarketingUrl(marketingUrl) {
return marketingUrl != undefined && marketingUrl != null && marketingUrl != "" ? marketingUrl : "javascript:void(0)";
}
function getSlideTarget(marketingUrl) {
return marketingUrl != undefined && marketingUrl != null && marketingUrl != "" ? "_blank" : "";
}
function changeSlide(slideId, source, MarketingUrl, HoverText) {
if (slideId !== undefined && slideId != null) {
if ($("#SlideThumbsWidget").css("display") == "none") {
if ($("#btnSyncSlide").attr("data-issync") == "true") {
$("#slidescreen img").attr('src', source);
$("#slidescreen a").attr('href', getSlideMarketingUrl(MarketingUrl)).attr('title', HoverText).attr("target", getSlideTarget(MarketingUrl));
}
}
else {
$(".SlideThumbsWidget a img").removeClass("selected");
$(".SlideThumbsWidget a[data-slideid='" + slideId + "'] img").addClass("selected");
if ($("#btnSyncSlide").attr("data-issync") == "true") {
$(".SlideThumbsWidget a img").removeClass("preview");
$(".SlideThumbsWidget a[data-slideid='" + slideId + "'] img").addClass("preview");
$("#slidescreen img").attr('src', $(".SlideThumbsWidget a[data-slideid='" + slideId + "']").attr('data-href'));
var slideThumb = $(".SlideThumbsWidget a[data-slideid='" + slideId + "']");
if (slideThumb.length > 0) {
$("#slidescreen a").attr('href', getSlideMarketingUrl(slideThumb.attr('data-marketingurl'))).attr('title', slideThumb.attr('data-hovertext')).attr("target", getSlideTarget(slideThumb.attr('data-marketingurl')));
}
autoScrollSlide();
}
}
}
onLoadMediaSlide();
}
// slide:changeSlide
function slide_changeSlide(data) {
var data = data != null ? data.SlideId : 0;
var objSlideTime = {
SlideTimeId: 0,//Number(data.slideTimeId),
ProductTime: Math.round((curRelativeTime - curVidDelay) / 1000),
MediaId: 0,
MediaTime: 0,
SlideId: Number(data),//Number(data.slideId),
Slide: null
};
// check for log duplication
var slideTimesList = [];
$.each(seminar.Slides, function (i, slideElement) {
if (slideElement.SlideTimes !== undefined && slideElement.SlideTimes != null && slideElement.SlideTimes.length > 0) {
slideTimesList.push.apply(slideTimesList, slideElement.SlideTimes);
}
});
var alertLog = null;
//var alertLog = $.grep(slideTimesList, function (n, i) {
// return Number(n.SlideTimeId) == Number(data.slideTimeId);
//}).pop();
//$.each(seminar.Slides, function (outerIndex, outerElement) {
// if (Number(outerElement.SlideId) == Number(data.slideId)) {
// objSlideTime.Slide = outerElement;
// outerElement.SlideTimes.push(objSlideTime);
// }
//});
$.each(seminar.Slides, function (outerIndex, outerElement) {
if (Number(outerElement.SlideId) == Number(data)) {
objSlideTime.Slide = outerElement;
outerElement.SlideTimes.push(objSlideTime);
}
});
//changeSlide(Number(data.slideId), objSlideTime.Slide.Source);
if (objSlideTime.Slide) {
curSlideId = data;
changeSlide(Number(data), objSlideTime.Slide.Source, objSlideTime.Slide.MarketingUrl, objSlideTime.Slide.HoverText);
}
if (alertLog === undefined || alertLog == null) {
// set event log
var log = {
time: formatDuration(Math.round((curRelativeTime - curVidDelay) / 1000)),
timestr: Math.round((curRelativeTime - curVidDelay) / 1000),
full: "Set (slideId: " + data + ")",
log: "Set (slideId: " + data + ")"
};
if (ListEventLogs !== undefined && ListEventLogs != null) {
ListEventLogs.push(log);
callEventLogs();
}
}
}
//slide:changeOrder
function slide_changeOrder(productslidesetIds) {
var slideSetOrder = $('img.slideThumb').closest('a').map(function () { return Number($(this).attr('data-productSlideSetId')); }).get().unique().join(",");
if (slideSetOrder != productslidesetIds) {
var pageWidgetId = $("a[data-href='SlideThumbsWidget']").attr("data-pagewidgetid");
if (pageWidgetId !== undefined && pageWidgetId != null) {
$("#SlideThumbsWidget").load("/showtimewidget/slidethumbswidget?PageWidgetID=" + pageWidgetId + "&SeminarId=" + seminar.SeminarId + "&TimeId=" + e + "&CustomerId=" + u + "&ProgramRegistrantId=" + ProgramRegistrantId, function () {
ZoomSlides();
checkSlideTimes();
if (isMobileOrIpad.toLowerCase() == "true") {
handlePortraitLandscape();
}
});
}
}
}
// slide:addSlide
function slide_addSlide(data) {
var slideSetId = 0;
if (data && data.slideSetId) {
slideSetId = data.slideSetId;
}
var pageWidgetId = $("a[data-href='SlideThumbsWidget']").attr("data-pagewidgetid");
if (pageWidgetId !== undefined && pageWidgetId != null) {
$("#SlideThumbsWidget").load("/showtimewidget/slidethumbswidget?PageWidgetID=" + pageWidgetId + "&SeminarId=" + seminar.SeminarId + "&TimeId=" + e + "&CustomerId=" + u + "&ProgramRegistrantId=" + ProgramRegistrantId, function () {
ZoomSlides();
checkSlideTimes();
if (isMobileOrIpad.toLowerCase() == "true") {
handlePortraitLandscape();
}
});
$.ajax({
type: "GET",
url: "/showtimewidget/getslidelist?SlideSetId=" + slideSetId + "&ProductId=" + seminar.SeminarId,
data: { 'SlideSetId': slideSetId, 'ProductId': seminar.SeminarId },
success: function (data) {
if (data !== undefined && data != null && data.length > 0) {
//When a customer has a live webcast viewer open and goes full screen on the video and then *initial slides* are added into the program, is it possible to force the viewer to exit full screen mode #4398
if (seminar.Slides != null && seminar.Slides.length == 0) {
vidPlayer.exitFullscreen();
if ($('#slideSync').length > 0) {
$('#btnSyncSlide').attr("data-issync", true);
applySlideScreenStatus();
}
$(window).trigger('resize');
}
seminar.Slides = seminar.Slides.filter(function (n) {
return Number(n.SlideSetId) != Number(slideSetId);
});
seminar.Slides.push.apply(seminar.Slides, data);
console.log("Add new slides");
if (seminar.Slides.length > 0) {
slideExists();
onLoadMediaSlide();
//$("#navbar-slide-btn").show();
}
else {
//$("#navbar-slide-btn").hide();
}
if (isMobileOrIpad.toLowerCase() == "true") {
handlePortraitLandscape();
}
}
setSlideCount(seminar.Slides.length);
getAllSlideTimes();
// show notification on new slide come
$(".alertSlideThumbsWidget").show();
},
error: function (res, status, xhr) {
console.log("Error: Getting New Slides");
}
});
}
}
// slide:ShowSlide
function slide_ShowSlide(showSlide) {
if (showSlide !== undefined && showSlide != null) {
if (showSlide.IsActive == true) {
$("#slidescreen").show();
slideExists();
onLoadMediaSlide();
}
else {
$("#slidescreen").hide();
//noSlides();
}
var alertLog = $.grep(seminar.PresenterStatusList, function (n, i) {
return n.PresenterStatusId == showSlide.PresenterStatusId;
}).pop();
seminar.PresenterStatusList.push(showSlide);
if (alertLog === undefined || alertLog == null) {
//Push in eventlog
var log = {
time: formatDuration(Math.round((curRelativeTime - curVidDelay) / 1000)),
timestr: Math.round((curRelativeTime - curVidDelay) / 1000),
full: (showSlide.IsActive ? "Show " : "Hide ") + (showSlide.EntityType == 1 ? "Video" : "Slide"),
log: (showSlide.IsActive ? "Show " : "Hide ") + (showSlide.EntityType == 1 ? "Video" : "Slide"),
};
if (ListEventLogs !== undefined && ListEventLogs != null) {
ListEventLogs.push(log);
callEventLogs();
}
}
}
}
//show_LiveMedia
function show_LiveMedia(data) {
if (data !== undefined && data != null) {
var presenterStatus = $.grep(seminar.PresenterStatusList, function (n, i) {
return Number(n.PresenterStatusId) == Number(data.PresenterStatusId);
}).pop();
if (presenterStatus == null || presenterStatus == undefined) {
seminar.PresenterStatusList.push(data);
}
}
}
// manager slides and media show/hide
function checkshowHideMediaSlideTime() {
//var casMedia = [];
//var casSlide = [];
//$.each(seminar.PresenterStatusList, function (outerIndex, element) {
// if (Number(element.EntityType) == 1) {
// casMedia.push(element);
// }
// else if (Number(element.EntityType) == 2) {
// casSlide.push(element);
// }
// //if (element.TriggerTime && Number(element.TriggerTime) <= Math.round((curRelativeTime - curVidDelay) / 1000)) {
// // if (Number(element.EntityType) == 1) {
// // casMedia.push(element);
// // }
// // else if (Number(element.EntityType) == 2) {
// // casSlide.push(element);
// // }
// //}
//});
// show/hide media
//if (casMedia.length > 0) {
// var maxMedia = casMedia.sort(function (a, b) { return (Number(a.TriggerTime) - Number(b.TriggerTime)); }).pop();
// if (maxMedia) {
// if (maxMedia.IsActive == true) {
// curMediaClip = null;
// vidPlayer.play();
// $("#main-panel").show();
// }
// else {
// vidPlayer.stop();
// curMediaClip = null;
// $("#main-panel").hide()
// }
// }
//}
//if (casSlide.length > 0) {
// var maxSlide = casSlide.sort(function (a, b) { return (Number(a.TriggerTime) - Number(b.TriggerTime)); }).pop();
// if (maxSlide) {
// if (maxSlide.IsActive == true) {
// $("#slidescreen").show();
// }
// else {
// $("#slidescreen").hide()
// }
// }
//}
var maxMedia = jQuery.grep(seminar.PresenterStatusList, function (n, i) {
return n.EntityType && n.EntityType == 1;
}).sort(function (a, b) { return (a.TriggerTime - b.TriggerTime); }).pop();
if (maxMedia) {
if (maxMedia.IsActive == true) {
curMediaClip = null;
vidPlayer.play();
$("#main-panel").show();
//$("#slidescreen img").width('50%');
}
else {
vidPlayer.pause();
curMediaClip = null;
$("#main-panel").hide();
$("#slidescreen img").width('100%');
}
}
var maxSlide = jQuery.grep(seminar.PresenterStatusList, function (n, i) {
return n.EntityType && n.EntityType == 2;
}).sort(function (a, b) { return (a.TriggerTime - b.TriggerTime); }).pop();
if (maxSlide) {
if (maxSlide.IsActive == true) {
$("#slidescreen").show();
//$("#slidescreen img").width('50%');
slideExists();
}
else {
$("#slidescreen").hide();
$("#slidescreen img").width('100%');
//noSlides();
}
}
if ($("#slidescreen img").attr("src") === undefined) {
//$("#mediaView").removeClass("col-md-6").addClass("col-md-12");
//$("#mediaView").removeClass("col-lg-6").addClass("col-lg-12");
}
}
// delete slide set
function slide_DeleteSlideSet(data) {
var slideSetId = 0;
if (data && data.slideSetId) {
slideSetId = data.slideSetId;
}
var pageWidgetId = $("a[data-href='SlideThumbsWidget']").attr("data-pagewidgetid");
if (pageWidgetId !== undefined && pageWidgetId != null) {
$("#SlideThumbsWidget").load("/showtimewidget/slidethumbswidget?PageWidgetID=" + pageWidgetId + "&SeminarId=" + seminar.SeminarId + "&TimeId=" + e + "&CustomerId=" + u + "&ProgramRegistrantId=" + ProgramRegistrantId, function () {
ZoomSlides();
console.log("Delete slides");
seminar.Slides = seminar.Slides.filter(function (n) {
return Number(n.SlideSetId) != Number(slideSetId);
});
if (seminar.Slides.length > 0) {
slideExists();
isRefreshResize = false;
//$("#navbar-slide-btn").show();
}
else {
//$("#navbar-slide-btn").hide();
if (playerInitialized && vidPlayer.isFullscreen()) {
isRefreshResize = true;
}
$(window).trigger('resize');
}
$("#slidescreen img").attr('src', "");
checkSlideTimes();
setSlideCount(seminar.Slides.length);
// show notification on new slide come
$(".alertSlideThumbsWidget").show();
onLoadMediaSlide();
if (isMobileOrIpad.toLowerCase() == "true") {
handlePortraitLandscape();
}
});
}
}
function initSlides() {
if (seminar.Slides.length > 0) {
checkSlideTimes();
if (Number(seminar.SeminarTypeId) == 4 || Number(seminar.SeminarTypeId) == 3 || seminar.IsArchive) {
Helper.Interval.set("VIEWER_CHECKSLIDETIMES", checkSlideTimes, 1);
}
$("#navbar-slide-btn").show();
$("#navbar-video-resize-btn").show();
syncSlides();
$("#btnSyncSlide").attr("data-issync", true);
applySlideScreenStatus();
}
else {
//noSlides();
$("#navbar-slide-btn").hide();
$("#navbar-video-resize-btn").hide();
syncSlides();
}
}
function slideExists() {
//$("#mediaView").removeClass("col-md-12").addClass("col-md-6");
//$("#mediaView").removeClass("col-lg-12").addClass("col-lg-6");
}
function polling_changeTime(data) {
if (data != null) {
var pollQuestionId = data.PollQuestionId;
var autoDisplayTime = data.AutoDisplayTime;
$.each(seminar.PopUpPollingQuestions, function (outerIndex, outerElement) {
if (Number(outerElement.PollQuestionId) == pollQuestionId) {
outerElement.AutoDisplayTime = Number(autoDisplayTime);
outerElement.DisplayResultTime = data.DisplayResultTime;
}
});
}
}
function polling_hideQuestion(data) {
if (data != null) {
polling_changeTime(data);
if (Number(data.AutoDisplayTime) > 0 && Number(data.DisplayResultTime) > -1) {
displayPollQuestionResult(data.PollQuestionId, data.DoNotDisplayPollResults);
}
else if (Number(data.AutoDisplayTime) == 0 && seminar.SeminarTypeId == 2 && Number(data.ProductTime) > 0) { //#17856
displayPollQuestionResult(data.PollQuestionId, data.DoNotDisplayPollResults);
}
}
}
function polling_resetPoll() {
//delete any stored poll question times and allow you to manually control display of poll questions. #4856
if (seminar.PopUpPollingQuestions != null && seminar.PopUpPollingQuestions.length > 0 && u != "-1") {
$.each(seminar.PopUpPollingQuestions, function (outerIndex, outerElement) {
outerElement.AutoDisplayTime = null;
outerElement.DisplayResultTime = -1;
});
getPollingResult();
}
}
//#endregion
//});
function browserSupportsCors() {
//Detect browser support for CORS
if ('withCredentials' in new XMLHttpRequest()) {
/* supports cross-domain requests */
return true;
}
else if (typeof XDomainRequest !== "undefined") {
//Use IE-specific "CORS" code with XDR
console.log("IE8 & IE9")
return false;
} else {
//Time to retreat with a fallback or polyfill
return false;
}
}
function seminar_audioOnly(data) {
if (seminar.IsAudioOnly != data) {
seminar.IsAudioOnly = data;
$(window).trigger('resize')
if (data == false) {
location.reload();
}
}
}
// Hide show Slides
function slide_HideSlides(data) {
//push to presenterStatus
if (data !== undefined && data != null) {
var presenterStatus = $.grep(seminar.PresenterStatusList, function (n, i) {
return Number(n.PresenterStatusId) == Number(data.PresenterStatusId);
}).pop();
if (presenterStatus == null || presenterStatus == undefined) {
seminar.PresenterStatusList.push(data);
}
}
}
//11387: Presenter > Mark Early Ending > Change to Reset > Live Webcast Viewer doesn't get info in Certificate Tab until reload viewer
function ReloadCertificate() {
if (typeof (RefreshCertificate) == "function") {
RefreshCertificate();
}
}
//Start : handing the tracking data when error occured and not track it
// set array of tracking data to local storage when get tracking error in tracking
function AddToTrackingErrordData(dict) {
if (!dict) { return; }
var trackingErrorData = [];
if (localStorage.getItem(T_ERROR_KEY)) {
trackingErrorData = JSON.parse(localStorage.getItem(T_ERROR_KEY));
}
trackingErrorData.push(dict);
localStorage.setItem(T_ERROR_KEY, JSON.stringify(trackingErrorData));
}
// check if any error data available of tracking : if available then insert it to tracking
function UpdateLocalTrackingToServer() {
if (T_ERROR_KEY && localStorage.getItem(T_ERROR_KEY)) {
var trackingErrorData = JSON.parse(localStorage.getItem(T_ERROR_KEY));
// check any record in list and internet connected then insert it manually to tracking table
if (trackingErrorData && doesConnectionExist() && tableSasTrackingUri) {
var arrayRawKey = [];
for (var i = 0; i < trackingErrorData.length; i++) {
var dict = trackingErrorData[i];
var trackingData = JSON.stringify(dict);
if (browserSupportsCors()) {
$.ajax({
type: "POST",
datatype: "json",
data: trackingData,
url: tableSasTrackingUri,
beforeSend: setHeader,
success: function (res, status, xhr) {
},
error: function (res, status, xhr) {
AddToTrackingErrordData(dict);
}
});
}
else {
$.ajax({
type: "POST",
datatype: "json",
data: {
'trackingData': trackingData
},
url: '/ShowtimeWidget/WriteToTrackingStorage',
success: function () {
},
error: function () {
AddToTrackingErrordData(dict);
}
});
}
}
}
localStorage.removeItem(T_ERROR_KEY);
}
}
function doesConnectionExist() {
var xhr = new XMLHttpRequest();
var file = "/Images/noPerson.png";
var randomNum = Math.round(Math.random() * 10000);
xhr.open('HEAD', file + "?rand=" + randomNum, false);
try {
xhr.send();
if (xhr.status >= 200 && xhr.status < 304) {
return true;
} else {
return false;
}
} catch (e) {
return false;
}
}
//End : handing the tracking data when error occured and not track it
function WriteElmahError(res, navigator, functionName) {
var objErrorDetail = '[Status]= ' + res.status;
objErrorDetail += ',[Navigator]= ' + navigator.userAgent;
objErrorDetail += ',[ResponseText]= ' + res.responseText;
objErrorDetail += ',[statusText]= ' + res.statusText;
objErrorDetail += ',[FunctionName]=' + functionName;
$.post("/ShowtimeWidget/WriteToElmah", { message: 'Error: Tracking', errorDetail: objErrorDetail });
}
;
var actionHub = {},
hubName = 'chatHub';
CE21SignalR.onReady(function () {
setSignalRStateMessage('Status: Connected!');
connectGroup();
checkSignalRConnected();
});
CE21SignalR.onStateChange(function () {
checkSignalRConnected();
});
CE21SignalR.onConnectionFail(function () {
checkSignalRConnected();
});
var GROUP_KEY = padLeft(pt, 6) + "-" + padLeft(ps, 9) + "-" + padLeft(pe, 9);
function initsignalR() {
if ($("#hdnChatHubUrl").length == 0) return
CE21SignalR.setUrl($("#hdnChatHubUrl").val());
CE21SignalR.on(hubName, 'receiveAction', function (Jdict) {
console.log('action received');
if (Jdict) {
var value = JSON.parse(Jdict);
if (value.Action == "alert:showAlert" || value.Action == "alert_clearAlerts" || value.Action == "media:changeAspectRatio" || value.Action == "alert:forceReload" || value.Action == "alert:showSpeakerGraphicAlert" || value.Action == "alert_clearSpeakerGraphicAlert") {
var data = JSON.parse(value.Data);
triggerActions(value.Action, data);
}
else {
actions.push(value);
}
}
});
CE21SignalR.on(hubName, 'newHandouts', function () {
if (typeof (getMetarials) != "undefined") getMetarials();
});
CE21SignalR.on(hubName, 'updateCertCodes', function () {
if (typeof (certCode_updateCertCodes) != "undefined") certCode_updateCertCodes();
});
viewerChatWidget();
if (typeof (CE21Forum) != "undefined") {
CE21Forum.bindListner();
}
if (typeof (CE21Chat) != "undefined") {
CE21Chat.bindListner();
}
CE21SignalR.start()
}
//Connect group by partition key
function connectGroup() {
if (CE21SignalR.getHub(hubName)) {
CE21SignalR.getHub(hubName).connectGroup(GROUP_KEY);
}
}
//Disconnect group by partition key
function disconnectGroup() {
if (CE21SignalR.getHub(hubName)) {
CE21SignalR.getHub(hubName).disconnectGroup(GROUP_KEY);
}
}
function viewerChatWidget() {
actionHub.addNewMessageToPage = function (name, message, chatTime, seminarId, customerId, profileImage, parentSeminarId, chatId, chatUserImageColor, IsModerator, responseData) {
// Add the message to the page.
if (chatTime !== undefined && chatTime != null && chatTime.length > 0) {
chatTime = new Date(chatTime + ' UTC');
}
if (Number(seminarId) == Number(seminar.SeminarId) || (Number(parentSeminarId) > 0 && Number(seminar.SeminarId) == Number(parentSeminarId)) || Number(seminar.ParentSeminarId) == Number(seminarId) || (seminar.IsDistributed == false && Number(seminar.ParentSeminarId) == Number(parentSeminarId) && Number(parentSeminarId) > 0)) {
//moment().format("M/D/YYYY hh:mm:ss");
//if (Number(customerId) == seminar.Customer.CustomerId) {
// profileImage = seminar.Customer.SeoFilename;
//}
var isAppendFirstChatMessage = (Number(customerId) == seminar.Customer.CustomerId && responseData && responseData.isFirstChat) || false;
if ($("#chatDivWidget .clsChatDIv[data-chatid='" + Number(chatId) + "']") === undefined || $("#chatDivWidget .clsChatDIv[data-chatid='" + Number(chatId) + "']") == null
|| $("#chatDivWidget .clsChatDIv[data-chatid='" + Number(chatId) + "']").length == 0) {
//var htmlChatBody = "
');
}
};
//get updated chat events
actionHub.updateChatEventsRecieve = function (chatId, status, count, customerId, isRevert) {
if (status && status == "MarkImportant") {
$(".importantChatCount[data-chatId=" + chatId + "]").text(Number(count));
if (Number(count) > 0) {
$(".importantChatCount[data-chatId=" + chatId + "]").removeClass('hidden');
} else {
$(".importantChatCount[data-chatId=" + chatId + "]").addClass('hidden');
}
if (parseInt(u) === customerId) {
if (isRevert) {
$(".btnMarkChatImportant[data-chatId=" + chatId + "]").removeClass('active');
}
else {
$(".btnMarkChatImportant[data-chatId=" + chatId + "]").addClass('active');
}
}
}
}
actionHub.updateChatProfilePicReceive = function (customerId, url) {
if (customerId === u) return; //No need to update in same customer as it will update by other method.
var classNames, title, imageTag;
//Update image in participants panel.
$(".chat-sidebar-nav li[data-customerid='" + customerId + "'] img.chat-message-user-image").attr("src", url);
if ($(".chat-sidebar-nav li[data-customerid='" + customerId + "'] .chatParticipantNoImage").length > 0) {
classNames = "CE21Chat_participantimage chat-message-user-image";
title = "";
if ($(".chat-sidebar-nav li[data-customerid='" + customerId + "'] .chatParticipantNoImage").hasClass("Moderator")) {
classNames += " Moderator";
title = "Moderator / speaker";
}
imageTag = "";
$(".chat-sidebar-nav li[data-customerid='" + customerId + "'] .chatParticipantNoImage").replaceWith(imageTag);
}
//Update image in chat bubbles.
$(".chat-main-message-container.clsChatDIv[data-CustomerId='" + customerId + "'] .chat-message-user-image-container img").attr("src", url);
if ($(".chat-main-message-container.clsChatDIv[data-CustomerId='" + customerId + "'] .chat-message-user-image-container .userCommentNoImage").length > 0) {
classNames = "CE21Chat_image chat-message-user-image";
if ($(".chat-main-message-container.clsChatDIv[data-CustomerId='" + customerId + "'] .chat-message-user-image-container .userCommentNoImage").last().hasClass("Moderator")) {
classNames += " Moderator";
}
imageTag = "";
$(".chat-main-message-container.clsChatDIv[data-CustomerId='" + customerId + "'] .chat-message-user-image-container .userCommentNoImage").replaceWith(imageTag);
}
}
for (key in actionHub) {
CE21SignalR.on(hubName, key, actionHub[key])
}
}
$(function () {
initsignalR(); // commented beacuse of it is called from checkSignalRConnected() undefinded state
setInterval(function () {
checkSignalRConnected();
}, 15 * 1000);
checkSignalRConnected();
});
function checkSignalRConnected() {
if ($.connection.hub.state == $.signalR.connectionState.connected) {
setSignalRStateMessage('Status: Connected!');
$(".chatWifi").attr("title", "Connected!");
$(".chatWifi").removeClass("chatDisconnected");
return;
}
else if ($.connection.hub.state == $.signalR.connectionState.connecting) {
setSignalRStateMessage("Status: Connecting.. ");
$(".chatWifi").attr("title", "Connecting..");
$(".chatWifi").addClass("chatDisconnected");
return;
} else if ($.connection.hub.state == $.signalR.connectionState.reconnecting) {
setSignalRStateMessage("Status: Reconnecting.. ");
$(".chatWifi").attr("title", "Reconnecting..");
$(".chatWifi").addClass("chatDisconnected");
return;
}
else if ($.connection.hub.state == $.signalR.connectionState.disconnected || $.connection.hub.state == undefined) {
setSignalRStateMessage("Status: Disconnected!");
$(".chatWifi").attr("title", "Disconnected!");
$(".chatWifi").addClass("chatDisconnected");
}
}
function setSignalRStateMessage(message) {
var $signalRState = $('#signalRState');
if ($signalRState.length == 1) {
//$('#navbar-slide-btn').closest('li').after('
')
$('#signalRState').show();
}
$('#signalRState').html(message);
}
//Before leave remove connection from group
$(window).bind('beforeunload', function () {
if (navigator.userAgent.match('Firefox/')) {
disconnectGroup();
}
});
$(window).on('unload', function () {
disconnectGroup();
});
$(window).on('close', function () {
disconnectGroup();
});
function UpdateParticipantStatus(tenantId, entityId, customerId, updateStatus, chatUsername) {
CE21SignalR.getHub(hubName).updateChatParticipantStatus(GROUP_KEY, tenantId, entityId, Number(e), customerId, updateStatus, chatUsername);
}
function UpdateChatStatusById(chatEntityId, chatId, status) {
CE21SignalR.getHub(hubName).updateChatStatus(GROUP_KEY, Number(t), chatId, status);
}
function UpdateChatEventsByIdSend(chatId, status, isRevert) {
CE21SignalR.getHub(hubName).updateChatEventsSend(GROUP_KEY, Number(t), seminar.Customer.CustomerId, chatId, status, isRevert);
}
function updateChatProfilePic(customerId, url) {
CE21SignalR.getHub(hubName).updateChatProfilePicSend(GROUP_KEY, customerId, url);
};
var SyncViewer = function (seminar) {
var self = this;
self.seminar = seminar;
self.interval = null;
self.init = function () {
if (self.interval) {
clearInterval(self.interval);
}
self.interval = setInterval(self.sync, 420 * 1000);// 7 minute
}
self.sync = function () {
if (!self.seminar.IsLive) {
return;
}
// getting latest on air Status
var maxLiveStatus = jQuery.grep(self.seminar.PresenterStatusList, function (n, i) {
return n.EntityType && n.EntityType == 3;
}).sort(function (a, b) { return (a.TriggerTime - b.TriggerTime); }).pop();
$.ajax({
type: 'POST',
url: '/ShowTimeWidget/SyncViewer',
data: {
CurrentMediaClipId: (curMediaClip || {}).MediaClipId,
PresenterStatusId: (maxLiveStatus || {}).PresenterStatusId,
ParentTenantId: pt,
ParentProductId: ps,
ParentEventTimeId: pe,
CurrentRelativeTime: Math.round((curRelativeTime - curVidDelay)/ 1000),
CurrentSlideId: typeof (curSlideId) != 'undefined' ? curSlideId : 0
},
success: function (data) {
if (data) {
// If Current media Clip and latest clip not matched then add it in medias
if (data.ClipMismatched && data.ClipMismatched == true && data.LatestmediaClip) {
self.seminar.MediaClips.push(data.LatestmediaClip);
}
// If Current air status and latest air status not matched then add it in presenterStatusList
if (data.AirMismatched && data.AirMismatched == true && data.LatestAirStatus) {
self.seminar.PresenterStatusList.push(data.LatestAirStatus);
}
// If Current slide and latest Slide not matched then call the silde data
if (data.SlideMismatched) {
self.getSildes();
}
}
},
error: function (jqXHR, textStatus, errorThrown) {
}
});
};
self.getSildes = function () {
$.ajax({
type: 'POST',
url: '/ShowTimeWidget/GetSlides',
data: {
'SeminarId': s
},
success: function (data) {
if (data) {
// If Current slide Clip and latest clip not matched then add it in slide
if (data && data.length > 0) {
self.seminar.Slides = data;
if (typeof (initSlides) == 'function') {
initSlides();
}
}
}
},
error: function (jqXHR, textStatus, errorThrown) {
}
});
};
self.init();
};
;
//#region Media Clip Control
var participationAudio1 = document.getElementById("audioCode1"); // this both used for aloud the participant code
var participationAudio2 = document.getElementById("audioCode2");
var isGoLiveOn = true;
var isShowSlideScreen = true;//#9152
var currentSlideScreenStatus = null;//#9152
var isRefreshResize = false;
var isPlayFullTimeLine = false;
var curVidTimeCode = 0;
var playerInitialized = false;
var togoPos = null;
var seekBlock = false;
var isCurrentLiveStream = false;
var curDemoMsg = " ";
var currentLiveStatus = undefined;
var allmediaTotalDuration = 0;
var vidPlayerProcess = [];
var isEnableSeekForOnDemand = false;
var vidPlayer;
var videoEl;
var isFocePlay = true;
//var isFlash = ((xBrowser === "ie") || (xBrowser === "internetexplorer") || (xUserAgent.indexOf("edge/") > 0) || (xBrowser === "firefox") || (xBrowser === "chrome" && xVersion < 37) || (xBrowser === "safari" && xUserAgent.indexOf('windows') > -1));
var isFlash = false;
var iOsDevice = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
var androidDevice = /Android|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
$("#divEventLogs").append('