var vsl_percentage_tags = {
0 : { 'is_set' : false },
1 : { 'is_set' : false },
20 : { 'is_set' : false },
40 : { 'is_set' : false },
60 : { 'is_set' : false },
80 : { 'is_set' : false },
95 : { 'is_set' : false },
}
var vsl_cta_tags = {
}
var popins = [
{
divId: "order-frame",
showAt: time_delay_of,
hideAt: 99999,
tagId: tag_id_of,
ctaGoal: "Saw CTA - Order Form"
},
{
divId: "arrow-scroll-down",
showAt: time_delay_of,
hideAt: 99999
},
];
//-----------------------------------------------------------------------
if (typeof is_ha_webinar === 'undefined') {
var is_ha_webinar = false;
var webinar = {
'JIT' : false
};
}
//-----------------------------------------------------------------------
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
//-----------------------------------------------------------------------
var popinController = {};
popinController.tagsSet = {};
popinController.goalsFired = {};
popinController.playerdivName = "playerdiv";
popinController.resume_cookie_name = 'vsl_resume_' + 'ha1';
popinController.lastShowHide = -1;
popinController.popins = popins;
popinController.lastGoodPlaySecond = 0;
popinController.position_from_cookies = 0;
//-----------------------------------------------------------------------
if (typeof VDL_EMBED_CODE_ID != 'string') {
VDL_EMBED_CODE_ID = 'vidalytics_embed_xVoRpaSS7N5aTs76';
}
var PLAYER_VENDOR = 'vidalytics';
popinController.vidalyticsCountFindPlayerAttempts = 0;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
popinController.activate_resume = function(position) {
createCookie(this.resume_cookie_name,position,7); //one week
}
//-----------------------------------------------------------------------
popinController.timeMonitor = function(position, pctWatched) {
if ( Math.abs( position - this.lastShowHide ) >= 1 ) {
this.showHidePopins(position);
this.setPlaybackTags(position, pctWatched);
jQuery("video").attr("title", "HousingAlerts Webinar");
//if (! is_ha_webinar ) {
this.activate_resume(position);
//}
this.lastShowHide = position;
// if (this.video.inSilentPlaybackMode()) {
// jQuery("#silentModeMessage").show();
// } else {
// jQuery("#silentModeMessage").hide();
// }
}
}
//-----------------------------------------------------------------------
popinController.showHidePopin = function(divId,show) {
if (show) {
jQuery("#" + divId).show();
} else {
jQuery("#" + divId).hide();
}
}
//-----------------------------------------------------------------------
popinController.setPercentageTag = function(pct) {
console.log("setting_percentage_tag" + pct);
email = '';
if (typeof(currentUserEmail) == 'string') email = currentUserEmail;
jQuery.ajax({ url: "/ifsapi/?action=addvslpcttag&pct=" + pct + "&email=" + email + "&page_style=webinar&webinar_class=ha1&jit=" + webinar.JIT + "&replay=" + webinar.is_replay});
}
//-----------------------------------------------------------------------
popinController.setCTATag = function(time) {
console.log("setting_cta_tag" + time);
email = '';
if (typeof(currentUserEmail) == 'string') email = currentUserEmail;
jQuery.ajax({ url: "/ifsapi/?action=addvslctatag&time=" + time + "&email=" + email + "&page_style=webinar&webinar_class=ha1&jit=" + webinar.JIT + "&replay=" + webinar.is_replay});
}
//-----------------------------------------------------------------------
popinController.addTag = function(tag) {
console.log("setting_tag" + tag);
email = '';
if (typeof(currentUserEmail) == 'string') email = currentUserEmail;
jQuery.ajax({ url: "/ifsapi/?action=addtag&tag=" + tag + "&email=" + email});
}
//-----------------------------------------------------------------------
popinController.setPlaybackTags = function(position, pctWatched) {
var pct_watched = -1;
if (isNaN(pctWatched)) {
pct_watched = this.video.percentWatched() * 100;
} else {
pct_watched = pctWatched;
}
//console.log("pctw: " + pct_watched);
for (pct_key in vsl_percentage_tags) {
pct = parseInt(pct_key);
if ( pct_watched >= pct ) {
if (!vsl_percentage_tags[pct].is_set) {
vsl_percentage_tags[pct].is_set = true;
this.setPercentageTag(pct);
}
}
}
for (pct_key in vsl_cta_tags) {
time = parseInt(pct_key);
if ( position >= time ) {
if (!vsl_cta_tags[time].is_set) {
vsl_cta_tags[time].is_set = true;
this.setCTATag(time);
}
}
}
if (is_ha_webinar) {
if ( pct_watched > 1 ) {
// Set attendance tag and goal
if (typeof(this.tagsSet[39082]) == 'undefined') {
//Set 'attendance' tags
this.tagsSet[39082] = true;
this.addTag(39082);
if (typeof(webinar_viewed_tag) != 'undefined') {
this.tagsSet[webinar_viewed_tag] = true;
this.addTag(webinar_viewed_tag);
}
if (webinar.is_public_replay) {
this.addTag(39376);
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
this.setAttendanceFields();
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
}
var schedule_type = webinar.Type;
if ( webinar.is_replay ) schedule_type = 'Replay';
if ( webinar.is_public_replay ) schedule_type = 'Replay';
if ( webinar.is_yesterday_replay ) schedule_type = 'Replay';
var goal_name_attended = 'Show-' + schedule_type;
// if ( video_enable_controls ) goal_name_attended = goal_name_attended + '-Controls'; // Controls should now be just "replay"
this.fireImprovelyGoal(goal_name_attended);
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if ( pct_watched > 40 ) {
this.fireImprovelyGoal('40-' + schedule_type);
}
if ( pct_watched > 80 ) {
this.fireImprovelyGoal('80-' + schedule_type);
}
}
}
}
//-----------------------------------------------------------------------
popinController.fireImprovelyGoal = function(goalName) {
return false; // Do Not use Improvely!
if (typeof this.goalsFired[goalName] != 'undefined') return 0;
this.goalsFired[goalName] = true;
var event_code = 'HAL-';
var goalNameFull = 'HA1-' + event_code + goalName;
console.log("Setting Improvely Goal:[" + goalNameFull + "]");
improvely.init('housingalerts', 12); // REMEMBER: Update this # per client Project and in the below.
improvely.goal({
type: goalNameFull, // Types: sale or optin and Add -[Product] or -[Detail] as needed to string values.
revenue: 0,
reference: currentUserEmail
});
}
//-----------------------------------------------------------------------
popinController.setAttendanceFields = function() {
if (!webinar.is_replay) {
jQuery.ajax({ url: "/ifsapi/?action=set_attendace_time&webinar_class=ha1&email=" + currentUserEmail });
}
}
//-----------------------------------------------------------------------
popinController.showHidePopins = function(position) {
jQuery("#debug_div").html("Position:" + position);
for (key in this.popins) {
var popin = this.popins[key];
var show = false;
if ( ( position >= popin.showAt ) && ( position <= popin.hideAt ) ) show = true;
if ( show != popin.shown ) {
if ((typeof(popin.tagId) != 'undefined') && popin.tagId > 0) {
this.addTag(popin.tagId);
}
if ((typeof(popin.ctaGoal) != 'undefined') && popin.ctaGoal.length > 0) {
//this.fireImprovelyGoal(popin.ctaGoal); // Commented out... ( https://realtyalerts.slack.com/archives/D6QE58WD9/p1563982054012500 )
}
this.showHidePopin( popin.divId, show );
popin.shown = show;
}
}
}
//-----------------------------------------------------------------------
popinController.initPlayerJW = function() {
jwplayer.key="CdB25rr1XmmsCIVCJ/PgbXxG7cvoCmC1vcan3g==";
jwplayer(this.playerdivName).setup({
"file": "//d3cboxrrizd66h.cloudfront.net/training/160929_FINAL_Markets_Page_video-HB720RF30.mp4",
//"file": "//localhost:8888/160929_FINAL_Markets_Page_video-HB720RF30.mp4",
//"image": "http://example.com/myImage.png",
// "height": 360,
// "width": 640,
width: "50%",
aspectratio: "16:9",
});
jwplayer(this.playerdivName).on('time', function(e) {
popinController.timeMonitor(e.position);
});
}
//-----------------------------------------------------------------------
popinController.injectWebinarVideo = function() {
jQuery(".wistia_responsive_wrapper").html("