var urlParams = {}; var e, a = /\+/g, // Regex for replacing addition symbol with a space r = /([^&=]+)=?([^&]*)/g, d = function (s) { return decodeURIComponent(s.replace(a, " ")); }, q = window.location.search.substring(1); while(e = r.exec(q)) urlParams[d(e[1])] = d(e[2]); function convertQueryString(str) { var vars = str.split('&'), obj = {}, pair, i; for(i = 0; i < vars.length; i++) { pair = vars[i].split('='); obj[pair[0]] = pair[1]; } return obj; } // URL Decode function URLDecode(encodedString) { var output = encodedString; var binVal, thisString; var myregexp = /(%[^%]{2})/; while ((match = myregexp.exec(output)) != null && match.length > 1 && match[1] != '') { binVal = parseInt(match[1].substr(1),16); thisString = String.fromCharCode(binVal); output = output.replace(match[1], thisString); } return output; } (function($) { $.activityrez = function(element, options) { var r2_id = (urlParams.resellerID) ? urlParams.resellerID : 0; var defaults = { reseller1_id: 0, reseller2_id: r2_id, wb_slug: '', env: 'dev', lang: '' }; var plugin = this; plugin.settings = {}; var $element = $(element); plugin.init = function() { plugin.settings = $.extend({}, defaults, options); var env = (plugin.settings.env === 'live') ? '' : plugin.settings.env + '.', arezURL = 'https://' + env + 'activityrez.com', src = arezURL + '/wb/' + plugin.settings.wb_slug, isSafari = (/Safari/.test(navigator.userAgent)), firstTimeSession = 0, if_height = 0; if(urlParams.activity_slug) { src += '/' + urlParams.activity_slug; } if(r2_id > 0) { src += '?resellerID=' + r2_id; } if (plugin.settings.lang){ if(r2_id > 0){ src += '&i18N=' + plugin.settings.lang; } else { src += '?i18N=' + plugin.settings.lang; } } var iframe = $( '
'); submitSessionForm(); } function submitSessionForm() { if (firstTimeSession == 0) { firstTimeSession = 1; $("#activityrez-sessionform").submit(); } } } plugin.init(); }; $.fn.activityrez = function(options) { return this.each(function() { if(undefined == $(this).data('activityrez')) { var plugin = new $.activityrez(this, options); $(this).data('activityrez', plugin); } }); }; })(jQuery);