Free javascript Hosting


online-js.js

Uploaded on Oct 18 2021 10:47 by vishweshnavtake

/*
-
- Copyright(c) 1997-2008 Satmetrix Systems, Inc. All rights reserved.
-
- @author
- @version $Id$
-
*/

if (typeof jQuery != 'undefined') {} else {
document.body.appendChild(jquerySrc('https://code.jquery.com/jquery-3.4.1.min.js'));
document.body.appendChild(jquerySrc('https://code.jquery.com/jquery-migrate-3.0.0.min.js'));
}
function jquerySrc(url){
var jquerySrc = document.createElement("script");
jquerySrc.type = "text/javascript";
jquerySrc.src = url;
return jquerySrc;
}
var popupSurveyId = 8768;
var widgetShownCookie = 'smxSlideupSurveyWidget8768';
var smxContainerEl = document.createElement("div");
var smxDivEl = document.createElement("div");
var smxIframeEl = document.createElement("iframe");
var showPopupPref = "ALWAYS";
var isAlreadyShown = false;
var loopCounter = 0;
var samplePercentage = 100;
var isinvitationModelShown = false;
var oncePerVisitDays = 1;
var popupDelay = 1;
var urlParams = '';
var PAGE_VARIABLE = 'page_variable';
var COOKIE = 'cookie';
var URLCONST = 'url';
var surveyUrl = "https://qa13app.pune.nice.com/app/datacollection/datacollection/dynaSurvey.jsp?p=MTYAAAAAAAAAACejbJNKhT5BiYJgZUOcSxOXeNDR3%2FcYKb4Q387jPXjLUbQa6opGrGFNYxSmyyS9vLkjU9efp%2BL1kOEUpFIQvaFBO%2B1z%2BYdwfKXivtQBWFRs3goaH1b37htMt8FZp2W%2FrkJ8wYnbBA85ar94TEP0D0uMZmbTi4GJ8CRsHoFQWBSQC3S%2F71c3AOZrKeZ5ipPwZmOFfFYF%2BDK%2BSkMaZozXz7VNbc3IPNKQEAHMpl4QQgXUqoCaFLoCvspB4ZAy1OdCqg%3D%3D&id=1189700544&peid=QA13MULTI4&collectorType=SLIDEUP";

checkJqueryAndLoadPopupSurvey();

function checkJqueryAndLoadPopupSurvey() {

if (typeof jQuery != 'undefined') {
loadPopupSurvey();
} else {
if (loopCounter < 25) {
setTimeout("checkJqueryAndLoadPopupSurvey()", 1000);
loopCounter++;
}
}
}
window.addEventListener("message", receiveMessage, 0);
function receiveMessage(e) {
if(e && e.data)
{
if(e.data.frame_height && e.data.frame_height>0)
{
jQuery('#smx_iframe').prop("height",e.data.frame_height);
}
else if('display_frame'==e.data)
{
jQuery('#smx_iframe').show();
}
else if('close_frame'==e.data)
{
jQuery('#smx_iframe').hide();
}
else
{
var exdays = 30;
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+ d.toUTCString();
document.cookie = e.data + expires + ";path=/; secure";
}
}
}
function isPopupSurveyWidgetNotYetShown() {
var cookies = document.cookie;
var cookiesArr = cookies.split(';');
for (var i = 0; i < cookiesArr.length; i++) {
var cookieData = cookiesArr[i];
var cookieDataArr = cookieData.split('=');
if (cookieDataArr.length > 1 && cookieDataArr[0].trim() == widgetShownCookie && cookieDataArr[1].trim() == 'Y') {
return false;
}
}
return true;
}

function isAlreadySubmitted()
{
var cookies = document.cookie;
var cookiesArr = cookies.split(';');

for (var i = 0; i < cookiesArr.length; i++) {
var cookieData = cookiesArr[i];
var cookieDataArr = cookieData.split('=');
if (cookieDataArr.length > 1 && cookieDataArr[0].trim() == "slideup_never_showagain_"+popupSurveyId && cookieDataArr[1].trim() == 'Y' ) {
return true;
}
}
return false;
}

function loadPopupSurvey() {
var isLaunchedInPreviewMode = false;
var queryPValue = getQueryStringValue('testWidget');
isLaunchedInPreviewMode = (queryPValue!=null && queryPValue!=undefined && 'Y'==queryPValue);
var randomNum = Math.random();
var slideupLogic = {};
var isShowSlideup = true;
if(queryPValue == 'N' && isAlreadySubmitted())
{
return;
}
if(jQuery.isNumeric(popupDelay) && popupDelay>0)
{
popupDelay = popupDelay * 1000;
}
else
{
popupDelay = -1;
}
setTimeout(function(){
if(!jQuery.isEmptyObject(slideupLogic) && !isLaunchedInPreviewMode)
{
isShowSlideup = isToShowSlideUp(slideupLogic);
}
if(!isShowSlideup)
{
return;
}
if (showPopupPref == 'ONCE') {
if (samplePercentage < 100 && randomNum > (samplePercentage / 100)) {
return;
}
var showPopupSurveyWidget = true;
showPopupSurveyWidget = isPopupSurveyWidgetNotYetShown();
if (!showPopupSurveyWidget) {
return;
} else {
var date = new Date();
date.setTime(date.getTime() + (oncePerVisitDays * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
document.cookie = widgetShownCookie + '=Y' + expires + '; path=/; secure';
}
}
else if (showPopupPref == 'ALWAYS') {
if (samplePercentage < 100 && randomNum > (samplePercentage / 100)) {
return;
}
if (jQuery('#smx_iframe').is(':visible')) {
return;
}
}
var selectedFields = [{"attr_code":"PERSON_F_NAME_T","mandatory_yn":"Y"},{"attr_code":"PERSON_L_NAME_T","mandatory_yn":"Y"},{"attr_code":"PRIMARY_EMAIL_ADDR_TEXT","mandatory_yn":"Y"},{"attr_code":"PRIMARY_PHONE_NO","mandatory_yn":"Y"}];
jQuery.each(selectedFields,function(i,item){
var source = item.EXT_VAR_SOURCE || '';
var name = item.EXT_VAR_NAME || '';
if(source=='' || name=='')
{
return;
}
var attrCode = item.attr_code;
if(PAGE_VARIABLE == source.toLowerCase())
{
if(window[name]!=undefined)
urlParams += '&'+ attrCode + '=' + window[name];
}
else if(COOKIE == source.toLowerCase())
{
var cookies = document.cookie;
var cookiesArr = cookies.split(';');
for (var i = 0; i < cookiesArr.length; i++) {
var cookieData = cookiesArr[i];
var cookieDataArr = cookieData.split('=');
if (cookieDataArr.length > 1 && cookieDataArr[0].trim() == name) {
urlParams += '&'+ attrCode + '=' + cookieDataArr[1].trim();
break;
}
}
}
else if(URLCONST == source.toLowerCase())
{
var npxUrl = window.location.search.substring(1);
var params = npxUrl.split('&');
for (var i = 0; i < params.length; i++) {
var paramVales = params[i].split('=');
if (paramVales[0] == name) {
urlParams += '&'+ attrCode + '=' + paramVales[1];
break;
}
}
}
});

if(!((surveyUrl.includes('&anms=Y'))||(urlParams.includes('&anms=Y')))){
surveyUrl += '&anms=Y';
}

setIframeAttributes();
smxDivEl.appendChild(smxIframeEl);

setDivElementAttributes();
jQuery(smxContainerEl).append(jQuery(smxDivEl));

setContainerAttributes();
jQuery(document.body).append(jQuery(smxContainerEl));

smxIframeEl.setAttribute("src",surveyUrl+urlParams+"&testWidget="+queryPValue);
},popupDelay);
}

function setIframeAttributes() {
smxIframeEl.setAttribute("id", "smx_iframe");
smxIframeEl.setAttribute("frameborder", "0");
smxIframeEl.setAttribute("name", "uvw-iframe-smx");
smxIframeEl.setAttribute("class", "uvw-dialog-iframe");
smxIframeEl.setAttribute("allowtransparency","true");
smxIframeEl.setAttribute("scrolling","no");
smxIframeEl.setAttribute("style", "z-index:9999; position:fixed; display: none; border: none; -moz-border-radius: 3px; -webkit-border-radius: 3px; padding: none; right: 0; bottom: 0; left: 0; width: 100%; -webkit-transform: translate3d(0,0,0);");
}

function setDivElementAttributes() {
smxDivEl.setAttribute('id', "comments-stream-main-content-container");
//TODO set hieght dynamically
//smxDivEl.setAttribute("style", 'height: 325px !important;');
}

function setContainerAttributes() {
//smxContainerEl.setAttribute("style", "position:fixed;right:0;bottom:0;left:0;z-index:4451;display: block;");
}

function isPageVariableValid(conditionItem) {
var pageVarValue = window[conditionItem["variable_name"]] || '';
var respValue = conditionItem["response_value"] || '';
if (conditionItem["ignorecase"]) {
pageVarValue = pageVarValue.toLowerCase();
respValue = respValue.toLowerCase();
}
if ((conditionItem["evalue"] == "equal" && (pageVarValue === respValue))
|| (conditionItem["evalue"] == "not equal" && (pageVarValue != respValue))) {
return true;
}
return false;
}

function isCookieValid(conditionItem) {
var cookieValue = this.getCookie(conditionItem["variable_name"]) || '';
var varValue = conditionItem["response_value"] || '';
if (conditionItem["ignorecase"]) {
cookieValue = cookieValue.toLowerCase();
varValue = varValue.toLowerCase();
}
if (!cookieValue) return false;
if ((conditionItem["evalue"] == "equal" && (varValue == cookieValue))
|| (conditionItem["evalue"] == "not equal" && (varValue != cookieValue))) {
return true;
}
return false;
}

function isUrlValid(conditionItem) {
var varName = document.location.href || '';
var varValue = conditionItem["response_value"] || '';
if (conditionItem["ignorecase"]) {
varName = varName.toLowerCase();
varValue = varValue.toLowerCase();
}
if ((conditionItem["evalue"] == "contains" && (varName.indexOf(varValue) != -1))
|| (conditionItem["evalue"] == "not contains" && (varName.indexOf(varValue) == -1))) {
return true;
}
return false;
}

function isToShowSlideUp(logics){
var self = this;
var valid = false;
var connection = logics.conditions[0].setConnection.toLowerCase();
if(connection == "all") valid = true;
jQuery.each(logics.conditions[0].conditionalSet, function(index, conditionItem){
if (conditionItem.source_type == PAGE_VARIABLE) {
if (connection == "all") {
valid = self.isPageVariableValid(conditionItem) && valid;
}else if (connection == "any") {
valid = self.isPageVariableValid(conditionItem) || valid;
}
}else if (conditionItem.source_type == COOKIE) {
if (connection == "all") {
valid = self.isCookieValid(conditionItem) && valid;
}else if (connection == "any") {
valid = self.isCookieValid(conditionItem) || valid;
}
}else if (conditionItem.source_type == URLCONST) {
if (connection == "all") {
valid = self.isUrlValid(conditionItem) && valid;
}else if (connection == "any") {
valid = self.isUrlValid(conditionItem) || valid;
}
}
});
return valid;
}

function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function getQueryStringValue (key)
{
var rVal = "";
var paramString = npxUrl.split('?')[1] || '';
var params = paramString.split('&');
for (var i = 0; i < params.length; i++) {
var paramVales = params[i].split('=');
if (paramVales[0] == key) {
rVal = paramVales[1];
break;
}
}
return rVal;
}

Back to list