(function($) { //safe way to use console.log $.log = function(logvar) { if ((window.console !== 'undefined')) { console.log(logvar); } }; //DOM ready body class var DOMready = (function() { $(function() { $('body').addClass('dom-ready ehome'); }); }()); $(function() { // Remove Prototype $('script[src="/include/scripts/prototype.js"]').remove(); }); /* ================================================================================================== */ /* Preloader */ /* ================================================================================================== */ $(window).load(function() { if (!$('.custom-speakers').length > 0 && !$('.custom-speakers-promo').length > 0) { $('.loader').fadeOut(); $('.page-loader').delay(350).fadeOut('slow'); } }); /* ================================================================================================== */ /* HELP Module */ /* ================================================================================================== */ var HELP = (function() { var pub = {}, ua = navigator.userAgent, msie = ua.indexOf("MSIE "); pub.isTouchDevice = ('ontouchstart' in document.documentElement); pub.isiPad = (ua.match(/iPad/i) !== null); pub.isiPhone = (navigator.platform.indexOf('iPhone') !== -1) || (navigator.platform.indexOf('iPod') !== -1); pub.isAndroid = (ua.indexOf('Android') !== -1); pub.isAndroidVersion = ((pub.isAndroid) ? parseFloat(ua.match(/Android\s+([\d\.]+)/)[1]) : false); pub.isIE = (ua.indexOf('MSIE ') !== -1 || ua.match(/Trident/)); //Trident is for IE11 pub.ieVersion = (parseInt(ua.substring(msie + 5, ua.indexOf(".", msie)))) || false; return pub }()); /* ================================================================================================== */ /* Inject Class Module */ /* ================================================================================================== */ var injectClass = (function() { $(function() { $('.ehtm, #inner_content, .linkSnippetVersion, #orig-nav').addClass('container'); }); }()); /* ================================================================================================== */ /* Modify eHome Module */ /* ================================================================================================== */ var modifyEhome = (function() { $(function() { $('.ehtm .register').closest('li').addClass('last-nav'); }); }()); /* ================================================================================================== */ /* eHome Page Helper Class Module */ /* ================================================================================================== */ var ehomePageHelperClass = (function() { $(function() { var customClass = $("meta[property='og:title']").attr("content", document.title); customClass = customClass[0].content.toLowerCase(); $('body').addClass('eh-custom-' + customClass); }); }()); /* ================================================================================================== */ /* Mobile Toggle Module */ /* ================================================================================================== */ var mobileToggle = (function() { $(function() { var $mobileToggle = $('.mobile-toggle'); // Toggle mobile nav $mobileToggle.on('click', function() { $('body').toggleClass('show-nav'); $mobileToggle.toggleClass('active'); }); }); }()); /* ================================================================================================== */ /* Content Type Class Module */ /* ================================================================================================== */ var contentTypeClass = (function() { // Settings var gridSystem = true; // Turn grid system usage on/off $(function() { init(); }); var init = function() { getClasses(); }; // Get classes from each content block header var getClasses = function() { $('#main_section > div').each(function() { var $this = $(this), $header = $this.find('.header:first'), classes = $header.text(); // Add classes and remove childrens inline styles $this.addClass(classes).children().removeAttr('style'); // Hide header $header.hide(); }); // If using for grid system wrap relevant HTML if (gridSystem) { wrapContentBlocks(); } else { // If not using for a grid system inject any HTML class wrappers here. For example: $('#main_section').wrapInner('
'); // Change if required } }; var wrapContentBlocks = function() { var current = $(), sectionClasses = [], newItems; // Find start and end points for each row $('.row-start, .row-end, .row-mid').each(function() { var $this = $(this); // If starting new row call wrap function and reset variables if ($this.hasClass('row-start')) { doTheWrap(current, sectionClasses); current = $(); sectionClasses = []; } current = current.add(this); newItems = $this.attr('class').match(/\S*-section\w*/g); // Get section classes from content block and add to sectionClasses array if (newItems !== null && newItems !== undefined) { sectionClasses = addToArray(sectionClasses, newItems); } // Remove section classes from content blocks once they've $this.attr('class', function(i, c) { return c.replace(/\S*-section\w*/g, ''); }); }); doTheWrap(current, sectionClasses); }; var doTheWrap = function(d, sectionClasses) { var sectionId = ''; // If sectionClasses contains a hashed class then make it the id for this section and remove from main class list for (var i = 0; i < sectionClasses.length; i++) { if (sectionClasses[i].match(/#\w*-section\w*/g)) { sectionId = 'id="' + sectionClasses[i].replace('#', '') + '"'; sectionClasses.splice(i, 1); } } // If classes exist convert array to string and remove commas else set to an empty string if (sectionClasses !== null && sectionClasses !== undefined) { sectionClasses = sectionClasses.join(' '); } else { sectionClasses = ''; } // Wrap content block with the required HTML and classes d.wrapAll('
'); } // Loop through regex returned array and add to sectionClass array if not already present var addToArray = function(arr, newItems) { for (var i = 0; i < newItems.length; i++) { if ($.inArray(newItems[i], arr) === -1) { arr.push(newItems[i]); } } return arr; }; }()); /* ================================================================================================== */ /* Modify Sponsors Page Module */ /* ================================================================================================== */ var modifySponsorsPage = (function() { $(function() { $('.sponsors-section img').wrap(''); }); }()); /* ================================================================================================== */ /* Custom Speaker Module */ /* ================================================================================================== */ var customSpeakers = (function() { // Settings var accountId = '562', // Add account ID. eventId; $(function() { if ($('.custom-speakers').length > 0) { init(); } }); var init = function() { eventId = $('.custom-speakers').data('event-id'); getData(); }; var getData = function() { var getSpeakerList = $.ajax({ url: 'https://hmv2v1moqe.execute-api.us-east-1.amazonaws.com/common/ereg/listspeakers?eventid=' + eventId + '&accountid=' + accountId, dataType: 'json' }), getSpeakers = getSpeakerList.then(function(data) { // Map returned deferred objects var deferreds = $(data).map(function() { var ajax = $.ajax({ url: 'https://hmv2v1moqe.execute-api.us-east-1.amazonaws.com/common/ereg/getspeaker?eventid=' + eventId + '&accountid=' + accountId + '&speakerid=' + $(this)[0].speakerid, method: 'get' }); return ajax; }); // Use .apply onto array from deferreds $.when.apply($, deferreds.get()).then(function() { // Things to do when all is done createSpeakerData(deferreds); }); }); }; var createSpeakerData = function(deferreds) { deferreds = sortArray(deferreds); $.each(deferreds, function(index, value) { if (value.responseJSON.error) { return; } var target = value.responseJSON, fname = target.fname, lname = target.lname, title = target.title, company = target.company.length > 0 ? ', ' + target.company : '', speakerCat = Array.isArray(target.custom2) ? target.custom2.eng : target.custom2, bios = target.bios !== null ? target.bios.eng : '', image = target.image !== '0' ? 'https://www.eiseverywhere.com/image.php?acc=' + accountId + '&id=' + target.image : 'https://www.eiseverywhere.com/image.php?acc=914&id=846624', advisoryData = '

' + fname + ' ' + lname + '

' + title + company + '
', speakerData = '

' + fname + ' ' + lname + '

' + title + company + '
' + bios + '
'; if (speakerCat == undefined) { speakerCat = 'speaker'; } else { speakerCat = speakerCat.toLowerCase(); } if (speakerCat.indexOf('speaker') !== -1 || speakerCat == undefined) { $('.speaker-page').append(speakerData); } if (speakerCat.indexOf('advisory') !== -1) { $('.advisory-page').append(advisoryData); } }); // detect when new images from api call are loaded and then remove loader $('.custom-speakers').imagesLoaded() .always(function(instance) { $('.loader').fadeOut(); $('.page-loader').delay(350).fadeOut('slow'); let advisoryHeight = 0; $('.advisory').each(function() { let getHeight = $(this).height(); if (getHeight > advisoryHeight) { advisoryHeight = getHeight; console.log(advisoryHeight); } $('.advisory').css('height', advisoryHeight); }); }); }; var sortArray = function(newArray) { // sort by last name newArray.sort(function(a, b) { var lNameA = a.responseJSON.lname.toUpperCase(); // ignore upper and lowercase var lNameB = b.responseJSON.lname.toUpperCase(); // ignore upper and lowercase if (lNameA < lNameB) { return -1; } if (lNameA > lNameB) { return 1; } // names must be equal return 0; }); return newArray; }; }()); /* ================================================================================================== */ /* Custom Speaker Promo Module */ /* ================================================================================================== */ var customSpeakersPromo = (function() { // Settings var accountId = '562', // Add account ID. eventId; $(function() { if ($('.custom-speakers-promo').length > 0) { init(); } }); var init = function() { eventId = $('.custom-speakers-promo').data('event-id'); getData(); }; var getData = function() { var getSpeakerList = $.ajax({ url: 'https://hmv2v1moqe.execute-api.us-east-1.amazonaws.com/common/ereg/listspeakers?eventid=' + eventId + '&accountid=' + accountId, dataType: 'json' }), getSpeakers = getSpeakerList.then(function(data) { // Map returned deferred objects var deferreds = $(data).map(function() { var ajax = $.ajax({ url: 'https://hmv2v1moqe.execute-api.us-east-1.amazonaws.com/common/ereg/getspeaker?eventid=' + eventId + '&accountid=' + accountId + '&speakerid=' + $(this)[0].speakerid, method: 'get' }); return ajax; }); // Use .apply onto array from deferreds $.when.apply($, deferreds.get()).then(function() { // Things to do when all is done createSpeakerData(deferreds); }); }); }; var createSpeakerData = function(deferreds) { deferreds = sortArray(deferreds); $.each(deferreds, function(index, value) { if (value.responseJSON.error) { return; } var target = value.responseJSON, fname = target.fname, lname = target.lname, title = target.title, company = target.company.length > 0 ? '
' + target.company : '', image = target.image !== '0' ? 'https://www.eiseverywhere.com/image.php?acc=' + accountId + '&id=' + target.image : 'https://www.eiseverywhere.com/image.php?acc=914&id=846624', keySpeaker = Array.isArray(target.custom1) ? target.custom1.eng : target.custom1, speakerData; if (keySpeaker === '1') { speakerData = '

' + fname + ' ' + lname + '

' + title + company + '
'; } $('.custom-speakers-promo').append(speakerData); }); // detect when new images from api call are loaded and then remove loader $('.custom-speakers-promo').imagesLoaded() .always(function(instance) { $('.loader').fadeOut(); $('.page-loader').delay(350).fadeOut('slow'); }); }; var sortArray = function(newArray) { // sort by last name newArray.sort(function(a, b) { var lNameA = a.responseJSON.lname.toUpperCase(); // ignore upper and lowercase var lNameB = b.responseJSON.lname.toUpperCase(); // ignore upper and lowercase if (lNameA < lNameB) { return -1; } if (lNameA > lNameB) { return 1; } // names must be equal return 0; }); return newArray; }; }()); /* ================================================================================================== */ /* Custom Agenda Module */ /* ================================================================================================== */ var customAgenda = (function() { // Settings var accountId = '562', // Add account ID. eventId, sessionSpeakers = []; $(function() { if ($('.tab-content').length > 0) { init(); } }); var init = function() { eventId = $('.tab-content').data('event-id'); getData(); }; var getData = function() { var getSessionList = $.ajax({ url: 'https://hmv2v1moqe.execute-api.us-east-1.amazonaws.com/common/ereg/listsessions?eventid=' + eventId + '&accountid=' + accountId, dataType: 'json' }), getSessions = getSessionList.then(function(data) { // Map returned deferred objects var deferreds = $(data).map(function() { var ajax = $.ajax({ url: 'https://hmv2v1moqe.execute-api.us-east-1.amazonaws.com/common/ereg/getsession?eventid=' + eventId + '&accountid=' + accountId + '&sessionid=' + $(this)[0].sessionid + '&sessionkey=' + $(this)[0].sessionkey + '&showhidden=1', method: 'get' }); return ajax; }); // Use .apply onto array from deferreds $.when.apply($, deferreds.get()).then(function() { // Things to do when all is done createAgendaData(deferreds); }); }); }; var createAgendaData = function(deferreds) { var currentDate, firstDay = true, currentStartTime, currentEndTime, differentTime, sessionBreakClass, sessionHeading, agendaData = '', currentSessionId, headingSessionId1, headingSessionId2; $.each(deferreds, function(index, value) { if (value.responseJSON.error || value.responseJSON.publicagenda === '0') { return; } $.log(value.responseJSON); var target = value.responseJSON, reportname = target.reportname, descriptions = target.descriptions !== undefined ? target.descriptions.eng : '', starttime = target.starttime, endtime = target.endtime, date = target.date, heading = target.sessionheading !== undefined ? target.sessionheading.eng : '', location = target.location !== undefined ? 'Location: ' + target.location : ' ', speakers = target.speakers.length > 0 ? '' : '', sessionId = target.sessionid, sponsorLogo = target.custom1, sessionkey = target.choicekey, newTarget = sessionId + '_' + sessionkey; if (target.speakers.length > 0) { $.each(target.speakers, function(index, value) { if (notInArray(value.speakerid, sessionSpeakers)) { sessionSpeakers.push(value.speakerid); } }); } // If session times are different from the previous session set differentTime variable and create class if (currentSessionId !== sessionId) { differentTime = true; sessionBreakClass = 'event'; } else { differentTime = false; sessionBreakClass = 'event'; } // If session date is different to previous session include opening html if (currentDate !== date) { // If this is the very first session, update the firstDay variable, else include closing divs if (firstDay === true) { agendaData += '
' + convertDate(date) + '
' + convertDate(date) + '
'; $('.tab-content').append(agendaData); var getSampleValue = $('#sample-site').val(); console.log(getSampleValue); if (getSampleValue == 'Yes') { $('.date-ruler').hide(); } $('.loader').fadeOut(); $('.page-loader').delay(350).fadeOut('slow'); createSpeakerData(sessionSpeakers); }; var createSpeakerData = function(sessionSpeakers) { for (var i = 0; i < sessionSpeakers.length; i++) { $.ajax({ url: 'https://hmv2v1moqe.execute-api.us-east-1.amazonaws.com/common/ereg/getspeaker?eventid=' + '&eventid=' + eventId + '&accountid=' + accountId + '&speakerid=' + sessionSpeakers[i], method: 'get' }).done(function(data) { for (var j = 0; j < data.sessions.length; j++) { var name = data.fname + ' ' + data.lname, fname1 = data.fname, lname1 = data.lname, title = data.title.length > 0 ? ', ' + data.title : '', company = data.company.length > 0 ? ', ' + data.company : '', target = data.sessions[j].sessionid + '_' + data.sessions[j].sessionkey, image = data.image, bios = typeof data.bios.eng !== 'undefined' ? data.bios.eng : ' ', accountId = '562', moderator = data.custom9, inlineSpeakers = '
  • ' + '' + name.replace(",", "") + ', ' + '' + title.replace(",", "") + ', ' + '' + company.replace(",", "") + '
    X' + '
    ' + '

    ' + name.replace(",", "") + ', ' + title.replace(",", "") + ', ' + company.replace(",", "") + '

    ' + bios + '
  • '; if (moderator == 1) { $('#session-' + target + ' .moderator-speakers').append(inlineSpeakers); } else { $('#session-' + target + ' .inline-speakers').append(inlineSpeakers); } $('#session-' + target + ' .inline-speakers').html( $('#session-' + target + ' .inline-speakers').children('li').sort(function (a, b) { return $(a).attr('data-order').toUpperCase().localeCompare($(b).attr('data-order').toUpperCase()); }) // End Sort ); // End HTML /*$('#session-' + target + ' .inline-speakers').html( $('#session-' + target + ' .inline-speakers').children('li').sort(function (a, b) { return $(a).attr('data-order').toUpperCase().localeCompare($(b).attr('data-order').toUpperCase()); }) // End Sort );*/ } }); } }; // Check if object is not in array already var notInArray = function(obj, arr) { return ($.inArray(obj, arr) === -1) ? true : false; }; // Convert 24 hour format time to 12 hour format var convertTime = function(time) { time = time.toString().match(/^([01]\d|2[0-3])(:)([0-5]\d)(:[0-5]\d)?$/); var h = time[1] % 12, m = time[3]; if (h === 0) { h = 12; } return h + ':' + m + (time[1] < 12 ? ' AM' : ' PM'); }; // Convert etouches api date format to 'day, month date'. var convertDate = function(date) { var d = new Date(date), month = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], weekday = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; d.setTime(d.getTime() + d.getTimezoneOffset() * 60 * 1000); return weekday[d.getDay()] + ', ' + month[d.getMonth()] + ' ' + d.getDate(); }; }()); /* ================================================================================================== */ /* Map Widget */ /* ================================================================================================== */ var mapWidget = (function() { $(function() { var checkPage = document.getElementById("event-location"); if (checkPage) { var getEventName = $('#event-location').val().replace(/ /g, "%20"); var getAddress = $('#event-address').val().replace(/ /g, "%20"); var getCity = $('#event-city').val().replace(/ /g, "%20"); var mapData = getEventName + '%20' + getAddress + '%20' + getCity; $('.mapouter').append('
    '); } }); }()); /* ================================================================================================== */ /* Video Widget */ /* ================================================================================================== */ var videoWidget = (function() { $(function() { var checkPage2 = document.getElementById("event-video"); if (checkPage2) { var getEventVideo = $('#event-video').val().split('?v=')[1]; console.log(getEventVideo); $('.video-player').append('
    '); } }); }()); /* ================================================================================================== */ /* Photogallery Hack */ /* ================================================================================================== */ var photogalleryHack = (function() { $(function() { let checkForSponsors = document.getElementById('sponsor-section'); if (checkForSponsors) { $('.sponsor-section a').each(function() { let getImage = $(this).attr('href'); $(this).children().children().attr('src', getImage); }); } }); }()); /* ================================================================================================== */ /* Print Button */ /* ================================================================================================== */ var printButton = (function() { $(function() { $('.print-agenda').click(function() { $('body').addClass('agenda-page'); window.print(); }); }); }()); }(jQuery));