PageSourceSearch

https://www.newvistalive.com/wp-content/themes/newvista-v2/js/src/main.js?ver=638

js newvistalive.com collected 2026-10-06 09:56:51 UTC 40,838 bytes, 1,472 lines download raw bytes

1$ = jQuery;
2// import "./events.js";
3
4// get all posts rest API - this can be used to add frame work like react to wordpress
5// fetch("/wp-json/wp/v2/posts")
6//   .then(response => response.json())
7//   .then(posts => console.log(posts));
8
9checkCookieMessageCookie();
10
11// my profile stuff
12$("#update-profile-form .submit-btn").on("click", function () {
13  updateProfile();
14});
15
16// console.log(ajax);
17
18function updateProfile() {
19  // $.post(
20  //   ajax_url,
21  //   {
22  //     action: "updateProfileValues",
23  //     security: ajax.ajax_security,
24  //     // email: emailfield,
25  //     // password: passwordfield,
26  //   },
27  //   function (response) {
28  //     console.log(response);
29  //   }
30  // );
31
32  var dataString = {
33    email: $("#email input").val(),
34    firstName: $("#name input").val(),
35    action: "updateProfileValues",
36    security: ajax.ajax_security,
37  };
38  $.ajax({
39    url: ajax.ajax_url,
40    type: "POST",
41    "data": dataString,
42    success: function (data) {
43      // console.log(data);
44    },
45    error: function () {
46      console.log("Error");
47    },
48  });
49}
50
51// login stuff
52
53function formError(container) {
54  $("." + container + " #errors").show();
55  $("." + container + " #errors")
56    .delay(2000)
57    .fadeOut(500);
58  $("." + container + " .formholder").addClass("shake");
59  setTimeout(function () {
60    $("." + container + " .formholder").removeClass("shake");
61  }, 1000);
62}
63
64$("#login").on("click", function () {
65  checkemptyfields();
66});
67
68$(document).on("keypress", ".rightnv-login.open", function (e) {
69  var key = e.keyCode || e.which;
70  if (key == 13 || key == 3) {
71    checkemptyfields();
72  }
73});
74
75function checkemptyfields() {
76  let emailfield = $("#email").val();
77  let passwordfield = $("#password").val();
78
79  if (emailfield == "" || passwordfield == "") {
80    $(".rightnv-login #errors").html("Please fill both fields in");
81    formError("rightnv-login");
82
83    return false;
84  }
85
86  ValidateEmail(emailfield, passwordfield);
87}
88
89function ValidateEmail(emailfield, passwordfield) {
90  // trim spaces off start and end of email
91  let trimmedEmail = emailfield.trim();
92  var mailformatOld = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,5})+$/;
93  let mailformat =
94    /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
95  if (trimmedEmail.match(mailformat)) {
96    gettoken(trimmedEmail, passwordfield);
97  } else {
98    $("#errors").html("Incorrect email format");
99    formError("rightnv-login");
100
101    return false;
102  }
103}
104
105function gettoken(emailfield, passwordfield) {
106  $.post(
107    ajax.ajax_url,
108    {
109      action: "gettoken",
110      security: ajax.ajax_security,
111      email: emailfield,
112      password: passwordfield,
113    },
114    function (response) {
115      console.log(response);
116
117      let responseJson = JSON.parse(response);
118
119      if (responseJson.type == "error") {
120        $("#errors").html("Password or email incorrect");
121        // $("#errors").html(responseJson.data.ErrorMessage);
122        formError("rightnv-login");
123
124        return false;
125      } else {
126        // var obj = JSON.parse(response);
127        // if (obj.key == "undefined" || obj.secret == "undefined") {
128        //   alert("tokens not set");
129        //   gettoken();
130        //   return false;
131        // }
132        // setCookie("accesstoken", obj.key, 2);
133        // setCookie("secretkey", obj.secret, 2);
134
135        $("#loginform").hide("300", function () {
136          /*This triggers the call for the user to save password*/
137          history.replaceState({ success: true }, "", "");
138          location.replace("members-area");
139        });
140      }
141    },
142  );
143}
144
145console.log(location.hostname);
146console.log(window.location.href);
147
148// if (
149//   window.location.href ==
150//   ("http://" || "https://") + location.hostname + "/members-area/"
151// )
152if (
153  window.location.href == "https://" + location.hostname + "/members-area/" ||
154  window.location.href == "http://newvistadev4.local/members-area/" ||
155  window.location.href == "http://newvistadev.local/members-area/" ||
156  window.location.href == "http://localhost:10010/"
157) {
158  // getPanelistsHistory();
159  loadPanelistData();
160  console.log("1");
161} else {
162  console.log("0");
163}
164
165// end login stuff
166
167//cookie stuff
168function hideCookiePolicy() {
169  setCookie("cookie_message", 1, 8760);
170  $(".cookie-message").removeClass("active");
171  /*setTimeout(function() {
172          $('.cookie-message').css('display', 'none');
173      }, 1000);*/
174  $(".cookie-message").fadeOut("800");
175}
176
177function checkCookieMessageCookie() {
178  if (getCookie("cookie_message") != 1) {
179    $(".cookie-message").css("display", "block");
180    setTimeout(function () {
181      $(".cookie-message").addClass("active");
182    }, 1);
183  }
184}
185
186function setCookie(cname, cvalue, hours) {
187  var now = new Date();
188  now.setTime(now.getTime() + hours * 3600 * 1000);
189
190  var expires = "; expires=" + now.toGMTString();
191  document.cookie = cname + "=" + cvalue + expires + ";path=/";
192}
193
194function getCookie(cname) {
195  var name = cname + "=";
196  var decodedCookie = decodeURIComponent(document.cookie);
197  var ca = decodedCookie.split(";");
198  for (var i = 0; i < ca.length; i++) {
199    var c = ca[i];
200    while (c.charAt(0) == " ") {
201      c = c.substring(1);
202    }
203    if (c.indexOf(name) == 0) {
204      return c.substring(name.length, c.length);
205    }
206  }
207  return "";
208}
209
210// forgot password
211$("#resetpasswordform #submitpasswordreset").on("click", function () {
212  let emailaddress = $("#passwordreset").val();
213  let mailformat =
214    /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
215  if (emailaddress.match(mailformat)) {
216    sendpasswordreset(emailaddress);
217    $(".forgotpassword #errors").html(
218      "<div style='font-size: 16px;'>If you have not received an a password reset email within 30 minutes, please contact support.</div>",
219    );
220  } else {
221    $(".forgotpassword #errors").html("Please enter a valid email address");
222    formError("forgotpassword");
223  }
224});
225
226function sendpasswordreset(emailaddress) {
227  $.post(
228    ajax.ajax_url,
229    {
230      action: "sendResetPasswordMail",
231      security: ajax.ajax_security,
232      targetaddress: emailaddress,
233    },
234    function (response) {
235      console.log(response);
236      if (response == "false0") {
237        // console.log("Error with email address");
238      }
239      // $(".cancel").trigger("click");
240      $(".forgotpassword .resetsuccess").removeClass("hidden");
241      $(".forgotpassword #resetpasswordform").addClass("hidden");
242    },
243  );
244}
245
246function checkResetPassword(password) {
247  // uppercase
248  uppercasePattern = /[A-Z]/;
249  let checkUppercase = uppercasePattern.test(password);
250
251  // special characters
252  let specialCharsPattern = /[!@#$%^]/;
253  let checkSpecialChars = specialCharsPattern.test(password);
254
255  // 8 characters
256  let checkLength;
257  if (password.length > 7) {
258    checkLength = true;
259  } else {
260    checkLength = false;
261  }
262
263  // 1 number
264  numberPattern = /\d/;
265  let checkNumber = numberPattern.test(password);
266
267  let passwordChecker = {
268    "uppercase": checkUppercase,
269    "special": checkSpecialChars,
270    "length": checkLength,
271    "number": checkNumber,
272  };
273
274  return passwordChecker;
275}
276
277$("#newpasswordform #newpass").on("keyup", function () {
278  let password = $("#newpass").val();
279  let passwordValues = checkResetPassword(password);
280  // console.log(passwordValues);
281
282  // uppercase
283  if (passwordValues.uppercase == true) {
284    $("#newpasswordform #uppercaseCheck i").addClass("pass fa-circle-check");
285    $("#newpasswordform #uppercaseCheck i").removeClass("fa-circle-xmark");
286  } else {
287    $("#newpasswordform #uppercaseCheck i").removeClass("pass fa-circle-check");
288    $("#newpasswordform #uppercaseCheck i").addClass("fa-circle-xmark");
289  }
290  // special
291  if (passwordValues.special == true) {
292    $("#newpasswordform #specialCheck i").addClass("pass fa-circle-check");
293    $("#newpasswordform #specialCheck i").removeClass("fa-circle-xmark");
294  } else {
295    $("#newpasswordform #specialCheck i").removeClass("pass fa-circle-check");
296    $("#newpasswordform #specialCheck i").addClass("fa-circle-xmark");
297  }
298  // length
299  if (passwordValues.length == true) {
300    $("#newpasswordform #lengthCheck i").addClass("pass fa-circle-check");
301    $("#newpasswordform #lengthCheck i").removeClass("fa-circle-xmark");
302  } else {
303    $("#newpasswordform #lengthCheck i").removeClass("pass fa-circle-check");
304    $("#newpasswordform #lengthCheck i").addClass("fa-circle-xmark");
305  }
306  // number
307  if (passwordValues.number == true) {
308    $("#newpasswordform #numberCheck i").addClass("pass fa-circle-check");
309    $("#newpasswordform #numberCheck i").removeClass("fa-circle-xmark");
310  } else {
311    $("#newpasswordform #numberCheck i").removeClass("pass fa-circle-check");
312    $("#newpasswordform #numberCheck i").addClass("fa-circle-xmark");
313  }
314});
315
316$("#newpasswordform #resetpassword").on("click", function () {
317  let password = $("#newpass").val();
318  let passwordValues = checkResetPassword(password);
319  //console.log(passwordValues);
320  if (password.indexOf("&") !== -1) {
321    $(".change-password #errors").html("Invalid Character");
322    formError("change-password");
323    return;
324  }
325  if (
326    passwordValues.uppercase == true &&
327    passwordValues.special == true &&
328    passwordValues.length == true &&
329    passwordValues.number == true
330  ) {
331    resetpassword();
332  } else {
333    $(".change-password #errors").html("Invalid Password");
334    formError("change-password");
335  }
336});
337
338function resetpassword() {
339  if ($("#confirmpass").val() != $("#newpass").val()) {
340    $(".change-password #errors").html("Passwords do not match");
341    formError("change-password");
342    return;
343  }
344
345  let newpass = $("#confirmpass").val();
346
347  $.post(
348    ajax.ajax_url,
349    {
350      action: "resetPassword",
351      security: ajax.ajax_security,
352      newpassword: newpass,
353      passwordkey: getQueryVariable("PasswordKey"),
354    },
355    function (response) {
356      console.log(response);
357      if (response.indexOf("ErrorMessage") !== -1) {
358        var trim = response.slice(0, -1);
359        var parsed = JSON.parse(trim);
360        //console.log("The Error message is" + parsed.ErrorMessage );
361
362        // console.log(parsed);
363
364        $(".change-password #errors").html(parsed.ErrorMessage);
365        formError("change-password");
366      } else {
367        location.replace("/");
368      }
369    },
370  );
371}
372
373function validatepasswordstrength() {
374  if (
375    $("#confirmpass").val() === $("#newpass").val() &&
376    $(".validpassword").is(":visible")
377  ) {
378    return true;
379  } else {
380    if ($("#confirmpass").val() != $("#newpass").val()) {
381      $(".change-password #errors").html("Passwords do not match");
382      formError("change-password");
383      return false;
384    }
385  }
386}
387
388function getQueryVariable(variable) {
389  var query = window.location.search.substring(1);
390  var vars = query.split("&");
391  for (var i = 0; i < vars.length; i++) {
392    var pair = vars[i].split("=");
393    if (pair[0] == variable) {
394      return pair[1];
395    }
396  }
397  return false;
398}
399
400// end change password
401
402// update profile - not used
403function getProfile() {
404  // checkCookie();
405
406  $.when(getPanelistDetails()).then(function () {
407    // console.log(panelistDetails);
408
409    $("#update-profile-form #name input").val(
410      panelistDetails.PanelistVariables.PanelistVariable[1].Value,
411    );
412
413    // hide preloader
414    $(".cover").addClass("fadeout");
415    $(".preloader").addClass("dataloaded");
416  });
417}
418
419// end update profile
420
421function getPanelistDetails(type) {
422  // return Promise.resolve(
423
424  return new Promise(function (resolve, reject) {
425    $.post(
426      ajax.ajax_url,
427      {
428        action: "getPanelist",
429        security: ajax.ajax_security,
430        type: type,
431        // accesstoken: getCookie("accesstoken"),
432        // secretkey: getCookie("secretkey"),
433      },
434      function (response) {
435        // console.log(response);
436        panelistDetails = JSON.parse(response);
437
438        // console.log(panelistDetails);
439
440        let firstName = findInArray(
441          panelistDetails.data.PanelistVariables.PanelistVariable,
442          "FirstName",
443        ).Value;
444
445        localStorage.setItem("firstName", firstName);
446      },
447    ).done(function (response) {
448      let parsedData = JSON.parse(response);
449      resolve(parsedData);
450    });
451  });
452}
453
454function checkCookie() {
455  // checkHere;
456  if (getCookie("loggedIn") === "false") {
457    $(".no-session").fadeIn(300);
458    logout(false);
459    setTimeout(function () {
460      location.replace("/");
461    }, 112000);
462    // make ajax call to change session var loggedin to false
463
464    return;
465  } else {
466    $(".preloader").fadeIn(300);
467  }
468}
469
470function getPanelistSurveys() {
471  /*Get panelist surveys - only shows friday fun quiz*/
472  $.post(
473    ajax.ajax_url,
474    {
475      action: "getSurveyList",
476      security: ajax.ajax_security,
477      // accesstoken: getCookie("accesstoken"),
478      // secretkey: getCookie("secretkey"),
479    },
480    function (response) {
481      // console.log(response);
482      let parsedResponse = JSON.parse(response);
483      // console.log(parsedResponse);
484      // console.log(
485      //   "This is the length " + panelistSurveyHistory.Surveys.length
486      // );
487    },
488  );
489}
490
491function getPanelistsHistory() {
492  // clear old table data
493  $(".history-container").empty();
494  localStorage.historyTable = "";
495
496  // get Credit Transactions
497  $.post(
498    ajax.ajax_url,
499    {
500      action: "getCreditTransaction",
501      security: ajax.ajax_security,
502      accesstoken: getCookie("accesstoken"),
503      secretkey: getCookie("secretkey"),
504    },
505    function (response) {
506      // console.log(response);
507      let parsedResponse = JSON.parse(response);
508      // console.log(parsedResponse);
509
510      var historyList = "";
511
512      var transactionlength =
513        parsedResponse.CreditTransactions.CreditTransaction.length;
514
515      for (i = 0; i < transactionlength; i++) {
516        var dateFinish = new Date(
517          parsedResponse.CreditTransactions.CreditTransaction[i].Created,
518        );
519        var oddoreven;
520        if (i % 2) {
521          oddoreven = "even";
522        } else {
523          oddoreven = "odd";
524        }
525        historyList +=
526          '<div class="history-item ' +
527          oddoreven +
528          '"><div class="column">' +
529          parsedResponse.CreditTransactions.CreditTransaction[i].Comment +
530          " " +
531          // p.CreditTransactions.CreditTransaction[i].SurveyId +
532          '</div><div class="column">' +
533          getFormattedDate(dateFinish) +
534          '</div><div class="column">' +
535          parsedResponse.CreditTransactions.CreditTransaction[i].Credits +
536          "</div></div>";
537      }
538      // $(".history-container").html(historyList);
539      // $(".history-row").fadeIn(500);
540
541      // add survey history to local storage to take out of function
542      localStorage.historyTable = historyList;
543    },
544  );
545}
546
547// function timeoutPromise(ms) {
548//   return new Promise(resolve => setTimeout(resolve, ms));
549// }
550
551async function loadPanelistData() {
552  // check if user logged in
553  console.log("123333");
554
555  checkCookie();
556
557  // load basic user info on page
558  let panelistDetailsBasic = await getPanelistDetails("basic");
559  addPanelistInfo(panelistDetailsBasic);
560
561  $(".cover").addClass("fadeout");
562  $(".preloader").addClass("dataloaded");
563  // timeoutPromise(100);
564
565  // load full user data
566  let panelistDetails = await getPanelistDetails("full");
567  // console.log(panelistDetails);
568  // console.log(panelistDetailsBasic);
569  getLucidAllowed(panelistDetails);
570
571  showPanelShareTakePart(panelistDetails);
572
573  getPanelistsHistory();
574
575  getPanelistSurveys();
576}
577
578// logged in panel data
579function addPanelistInfo(panelist) {
580  let name = findInArray(
581    panelist.data.PanelistVariables.PanelistVariable,
582    "FirstName",
583  ).Value;
584  let cashOutLimit = 5000;
585
586  let progressPercent = Math.round(
587    (panelist.data.Credits / cashOutLimit) * 100,
588  );
589  if (progressPercent > 100) {
590    progressPercent = 100;
591  }
592  if (progressPercent < 0) {
593    progressPercent = 0;
594  }
595
596  $(".progress-bar").css("width", progressPercent + "%");
597
598  $(".progress-percent").text(progressPercent + "%");
599
600  $(".points-away span").text(cashOutLimit - panelist.data.Credits);
601
602  $(".points-total").html(panelist.data.Credits);
603  if (panelist.data.Credits >= cashOutLimit) {
604    $(".enough").css("display", "block");
605    $(".not-enough").css("display", "none");
606  }
607
608  $(".loggedin-intro").html(
609    "Good " +
610      getDayStage() +
611      " " +
612      name +
613      ", welcome to the newvista members area",
614  );
615}
616
617// find keys in PanelistVariables object
618function findInArray(array, arrayKey) {
619  let findArrayValues = array.find(function (item) {
620    return item.Name === arrayKey;
621  });
622  return findArrayValues;
623}
624
625function getLucidAllowed(panelistDetails) {
626  // console.log(panelistDetails);
627  let vLucidAllowedValue = findInArray(
628    panelistDetails.data.PanelistVariables.PanelistVariable,
629    "lucidPanel",
630  ).Answers.Answer.Code;
631
632  let vLucidSurveyCount = findInArray(
633    panelistDetails.data.PanelistVariables.PanelistVariable,
634    "lucidCompletes",
635  ).Value;
636
637  // console.log(vLucidAllowedValue);
638
639  if (vLucidSurveyCount < 10) {
640    lucidCompleteOK = true;
641  } else {
642    lucidCompleteOK = false;
643  }
644
645  if (vLucidAllowedValue == 1) {
646    lucidNew = true;
647    lucidAllowed = false;
648    lucidBanned = false;
649  } else if (vLucidAllowedValue == 2) {
650    lucidNew = false;
651    lucidAllowed = true;
652    lucidBanned = false;
653  } else if (vLucidAllowedValue == 3) {
654    lucidNew = false;
655    lucidAllowed = false;
656    lucidBanned = true;
657  } else {
658    lucidNew = false;
659    lucidAllowed = false;
660    lucidBanned = true;
661  }
662
663  $("body").on("click", "#lucidLinkForm .survey-btn", function () {
664    let name = $(this).attr("data-length");
665    $("#surveyLength").val(name);
666    $("#lucidLinkForm").submit();
667  });
668  $(document).on("submit", "form#lucidLinkForm", function (e) {
669    // e.preventDefault();
670    $(this).find(":input[type=image]").prop("disabled", true);
671    setTimeout(() => {
672      $(this).find(":input[type=image]").prop("disabled", false);
673    }, 10000);
674  });
675}
676
677// log out stuff
678$(".log-out").on("click", function () {
679  logout(true);
680});
681
682function logout(logoutButton) {
683  $.ajax({
684    type: "POST",
685    url: ajax.ajax_url,
686    data: {
687      action: "logOut",
688    },
689
690    success: function (response) {
691      if (logoutButton == true) {
692        $(".cover").removeClass("fadeout");
693        $(".cover").css({
694          transition: "opacity 500ms",
695        });
696        $(".logged-out").fadeIn("1000");
697      }
698
699      deleteCookie("accessToken");
700      deleteCookie("secretKey");
701
702      setTimeout(function () {
703        location.replace("/");
704      }, 2000);
705    },
706  });
707  return;
708}
709
710function deleteCookie(name) {
711  setCookie(name, "", -1);
712}
713// js cookie check
714function loggedInHeaderCheck() {
715  let loggedIn = getCookie("loggedIn");
716  // console.log(loggedIn + "1233333");
717
718  if (loggedIn === "false" || loggedIn === "") {
719    $(".top-menu .login").removeClass("hide");
720    $(".top-menu .register").removeClass("hide");
721  } else {
722    $(".top-menu .log-out").removeClass("hide");
723    $(".header .menu-head").removeClass("hidden");
724  }
725}
726
727loggedInHeaderCheck();
728
729// header
730
731// scrollToDiv("news", "loggedin-intro");
732scrollToDiv("points", "points-history");
733scrollToDiv("earn-points", "admin-row");
734scrollToDiv("surveys", "profile-surveys");
735
736scrollToDiv("gift-cards", "brands");
737
738// points reward, unsubscibe and profiler stuff
739$("body").on(
740  "click",
741  ".survey > img, .unsubscribe, .rewardbutton",
742  function () {
743    editProfileSurvey(this);
744    // logout();
745  },
746);
747
748function editProfileSurvey(event) {
749  var surveyid = $(event.parentElement).data("surveyid");
750
751  // console.log(surveyid);
752
753  $.post(
754    ajax.ajax_url,
755    {
756      action: "editProfileSurvey",
757      security: ajax.ajax_security,
758      // accesstoken: getCookie("accesstoken"),
759      // secretkey: getCookie("secretkey"),
760      profilerid: surveyid,
761    },
762    function (response) {
763      // console.log(response);
764
765      var trim = response.slice(0, -1);
766      var parsed = JSON.parse(trim);
767
768      // console.log(event);
769      let rewardClass = $(event).hasClass("rewardbutton");
770
771      location.replace(parsed[0]);
772
773      // window.open(parsed[0], "_blank").focus();
774
775      // console.log(parsed);
776    },
777  );
778}
779
780// [Error] TypeError: null is not an object (evaluating 'window.open(parsed[0], "_blank").focus')
781// 	(anonymous function) (main.js:768)
782// 	c (jquery.min.js:2:25310)
783// 	fireWith (jquery.min.js:2:26055)
784// 	l (jquery.min.js:2:77794)
785// 	(anonymous function) (jquery.min.js:2:80267)
786
787function showPanelShareTakePart(panelistDetails) {
788  // console.log(lucidNew);
789  // console.log(lucidAllowed);
790  // console.log(lucidBanned);
791  // console.log(lucidCompleteOK);
792
793  if (lucidBanned == true) {
794    $("#partner-surveys").attr("data-status", "3");
795    $("#partner-surveys").html(
796      "\
797    <p>\
798      There are no newvista partner surveys eligible for your account at this time.\
799    </p>",
800    );
801    return;
802  }
803  if (lucidNew == true) {
804    $("#partner-surveys").attr("data-status", "1");
805    $("#partner-surveys").html(
806      "\
807    <p>\
808      There are no newvista partner surveys eligible for your account at this time.\
809    </p>\
810    <p>\
811      New partners are added periodically, so please check back later.\
812    </p>",
813    );
814    return;
815  }
816  if (lucidAllowed == true) {
817    $("#partner-surveys").attr("data-status", "2");
818    if (lucidCompleteOK == false) {
819      $("#partner-surveys").html(
820        "\
821        <p>\
822          You have hit the limit to the number of panel partner surveys you can take today.\
823        </p>\
824        <p>\
825          Check your email to see if you have any invites for newvista surveys that you can complete.\
826        </p>\
827        <p>\
828        Otherwise, come back tomorrow to get access to more opportunities to complete surveys from our partners.\
829        </p>",
830      );
831      return;
832    }
833    // function to build parner survey buttons and form
834    $("#partner-surveys").html(
835      "\
836      <div id='partner-tabs' class='tab-group rounded-lg border border-slate-900 bg-slate-200'>\
837        <div class='tab-list flex justify-around bg-slate-300 border-0 border-b-2 border-b-black rounded-t-lg'>\
838          <span href='' class='tab flex-auto font-bold p-4 hover:cursor-pointer data-[active=true]:bg-nv-primary data-[active=true]:text-white' data-active='true'>\
839            Samplicio.us\
840          </span>\
841        </div>\
842        <div class='tab-panels p-4'>\
843          <div data-tab='tab1' class='tab-panel'>\
844            <form method='post' id='lucidLinkForm' action='/lucidstart/' target='_blank'>\
845              <div class='form-inner grid lg:grid-cols-4 md:grid-cols-2 gap-4'>\
846              </div>\
847            </form>\
848          </div>\
849        </div>\
850      </div>\
851      <div class='mt-4'>\
852        <button class='open-modal btn btn-black' data-title='Survey Information' data-type='text'>\
853          Survey Information\
854        </button>\
855      </div>\
856      ",
857    );
858    buildLucidForm(panelistDetails);
859    return;
860  }
861}
862
863function buildLucidForm(panelistDetails) {
864  // lucid MID
865  let lucidCompleteCount = findInArray(
866    panelistDetails.data.PanelistVariables.PanelistVariable,
867    "lucidCompletes",
868  ).Value;
869
870  var currentdate = new Date();
871  var currentYear = currentdate.getFullYear();
872  var currentMonth = currentdate.getMonth() + 1;
873  var currentDate = currentdate.getDate();
874  var currentHours = currentdate.getHours();
875  var currentMinutes = currentdate.getMinutes();
876  var currentSeconds = currentdate.getSeconds();
877  var middatetime =
878    currentYear.toString() +
879    currentMonth.toString() +
880    currentDate.toString() +
881    currentHours.toString() +
882    currentMinutes.toString() +
883    currentSeconds.toString();
884  var lucidMIDValue =
885    panelistDetails.data.ResponseId +
886    "_" +
887    middatetime +
888    "_" +
889    lucidCompleteCount;
890
891  // lucid gender
892  let lucidGender = findInArray(
893    panelistDetails.data.PanelistVariables.PanelistVariable,
894    "gender",
895  ).Answers.Answer.Code;
896  let lucidgenderValue;
897  if (lucidGender == "1" || lucidGender == "2") {
898    lucidgenderValue = lucidGender;
899  }
900  // lucid gender plus
901  let lucidgenderPlusValue;
902  if (lucidGender == "96") {
903    lucidgenderPlusValue = "4";
904  } else {
905    lucidgenderPlusValue = lucidGender;
906  }
907
908  // lucid parental status
909  let lucidParentalStatus = findInArray(
910    panelistDetails.data.PanelistVariables.PanelistVariable,
911    "lucidParentalStatus",
912  );
913  let lucidParental_1 = "";
914  let lucidParental_2 = "";
915  let lucidParental_3 = "";
916  let lucidParental_4 = "";
917  if (lucidParentalStatus.Answers.length > 0) {
918    var lucidParentalStatusArray = lucidParentalStatus.Answers;
919    var lucidParentalStatusSize = Object.keys(
920      lucidParentalStatusArray.Answer,
921    ).length;
922  } else {
923    lucidParentalStatusSize = 0;
924    lucidParentalStatusArray = "";
925  }
926  if (lucidParentalStatusSize > 0) {
927    lucidParental_1 = "0";
928    lucidParental_2 = "0";
929    lucidParental_3 = "0";
930    lucidParental_4 = "0";
931
932    for (var i = 0; i < lucidParentalStatusSize; i++) {
933      if (lucidParentalStatusArray.Answer[i].Code == "1") {
934        lucidParental_1 = "1";
935      } else if (lucidParentalStatusArray.Answer[i].Code == "2") {
936        lucidParental_2 = "1";
937      } else if (lucidParentalStatusArray.Answer[i].Code == "3") {
938        lucidParental_3 = "1";
939      } else if (lucidParentalStatusArray.Answer[i].Code == "4") {
940        lucidParental_4 = "1";
941      }
942    }
943  }
944
945  // lucid HH Income
946  let lucidHHIncomeValue = "";
947  let lucidHHIncome = findInArray(
948    panelistDetails.data.PanelistVariables.PanelistVariable,
949    "lucidHHIncome",
950  ).Answers.Answer.Code;
951
952  if (lucidHHIncome == "96") {
953    lucidHHIncomeValue = "-3105";
954  } else {
955    lucidHHIncomeValue = lucidHHIncome;
956  }
957
958  // lucid soical grade
959  let lucidSocialGradeValue = "";
960  let lucidSocialGrade = findInArray(
961    panelistDetails.data.PanelistVariables.PanelistVariable,
962    "lucidSocialGrade",
963  ).Answers.Answer.Code;
964
965  if (lucidSocialGrade == "99") {
966    lucidSocialGradeValue = "-3105";
967  } else {
968    lucidSocialGradeValue = lucidSocialGrade;
969  }
970
971  let hiddenInputs = [
972    {
973      name: "lucidBaseLink",
974      value: "https://www.samplicio.us/s/default.aspx?",
975    },
976    { name: "lucidPID", value: panelistDetails.data.ResponseId },
977    { name: "lucidCID", value: "8" },
978    { name: "lucidMID", value: lucidMIDValue },
979    { name: "lucidLOIVS", value: "5" },
980    { name: "lucidCPIVS", value: "0.4" },
981    { name: "lucidLOIS", value: "10" },
982    { name: "lucidCPIS", value: "1.30" },
983    { name: "lucidLOIM", value: "20" },
984    { name: "lucidCPIM", value: "1.76" },
985    { name: "lucidLOIL", value: "120" },
986    { name: "lucidCPIL", value: "3.25" },
987    {
988      name: "lucidAge",
989      value: findInArray(
990        panelistDetails.data.PanelistVariables.PanelistVariable,
991        "age",
992      ).Value,
993    },
994    { name: "lucidGender", value: lucidgenderValue },
995    {
996      name: "lucidWorkStatus",
997      value: findInArray(
998        panelistDetails.data.PanelistVariables.PanelistVariable,
999        "lucidWorkStatus",
1000      ).Answers.Answer.Code,
1001    },
1002    { name: "lucidParentalStatus_1", value: lucidParental_1 },
1003    { name: "lucidParentalStatus_2", value: lucidParental_2 },
1004    { name: "lucidParentalStatus_3", value: lucidParental_3 },
1005    { name: "lucidParentalStatus_4", value: lucidParental_4 },
1006    {
1007      name: "lucidRegionNUTSI",
1008      value: findInArray(
1009        panelistDetails.data.PanelistVariables.PanelistVariable,
1010        "lucidRegionNUTSI",
1011      ).Answers.Answer.Code,
1012    },
1013    {
1014      name: "lucidRegionNUTSII",
1015      value: findInArray(
1016        panelistDetails.data.PanelistVariables.PanelistVariable,
1017        "lucidRegionNUTSII",
1018      ).Answers.Answer.Code,
1019    },
1020    {
1021      name: "lucidEthnicity",
1022      value: findInArray(
1023        panelistDetails.data.PanelistVariables.PanelistVariable,
1024        "lucidEthnicity",
1025      ).Answers.Answer.Code,
1026    },
1027    { name: "lucidHHIncome", value: lucidHHIncomeValue },
1028    { name: "lucidSocialGrade", value: lucidSocialGradeValue },
1029    {
1030      name: "lucidCountry",
1031      value: findInArray(
1032        panelistDetails.data.PanelistVariables.PanelistVariable,
1033        "lucidCountry",
1034      ).Answers.Answer.Code,
1035    },
1036    {
1037      name: "lucidCounty",
1038      value: findInArray(
1039        panelistDetails.data.PanelistVariables.PanelistVariable,
1040        "lucidCounty",
1041      ).Answers.Answer.Code,
1042    },
1043    {
1044      name: "lucidPostCode",
1045      value: findInArray(
1046        panelistDetails.data.PanelistVariables.PanelistVariable,
1047        "lucidPostCode",
1048      ).Value,
1049    },
1050    {
1051      name: "lucidRegion",
1052      value: findInArray(
1053        panelistDetails.data.PanelistVariables.PanelistVariable,
1054        "lucidRegion",
1055      ).Answers.Answer.Code,
1056    },
1057    { name: "lucidGenderPlus", value: lucidgenderPlusValue },
1058    {
1059      name: "lucidJobTitle",
1060      value: findInArray(
1061        panelistDetails.data.PanelistVariables.PanelistVariable,
1062        "lucidJobTitle",
1063      ).Answers.Answer.Code,
1064    },
1065    {
1066      name: "lucidNoEmployees",
1067      value: findInArray(
1068        panelistDetails.data.PanelistVariables.PanelistVariable,
1069        "lucidNoEmployees",
1070      ).Answers.Answer.Code,
1071    },
1072    { name: "surveyLength", value: "" },
1073  ];
1074
1075  let lucidButtons = [
1076    {
1077      imgPath: "/wp-content/themes/newvista/images/Timer1.png",
1078      durationText: "Up to 5 minutes",
1079      dataLength: "submitLinkVShort",
1080      points: "Up to 25",
1081    },
1082    {
1083      imgPath: "/wp-content/themes/newvista/images/Timer2.png",
1084      durationText: "Up to 10 minutes",
1085      dataLength: "submitLinkShort",
1086      points: "Up to 50",
1087    },
1088    {
1089      imgPath: "/wp-content/themes/newvista/images/Timer3.png",
1090      durationText: "Up to 20 minutes",
1091      dataLength: "submitLinkMedium",
1092      points: "Up to 75",
1093    },
1094    {
1095      imgPath: "/wp-content/themes/newvista/images/Timer4.png",
1096      durationText: "Over 20 minutes",
1097      dataLength: "submitLinkLong",
1098      points: "Up to 100",
1099    },
1100  ];
1101
1102  // append hidden values from object
1103  $.each(hiddenInputs, function (index, item) {
1104    $("#lucidLinkForm").append(
1105      "\
1106      <input type='hidden' name='" +
1107        item.name +
1108        "' id='" +
1109        item.name +
1110        "' value='" +
1111        item.value +
1112        "' />\
1113    ",
1114    );
1115  });
1116
1117  // append buttons from object
1118  $.each(lucidButtons, function (index, item) {
1119    $("#lucidLinkForm .form-inner").append(
1120      "\
1121      <div data-length='" +
1122        item.dataLength +
1123        "' class='survey-btn p-4 border border-slate-800 cursor-pointer'>\
1124        <img class='m-auto' src='" +
1125        item.imgPath +
1126        "' />\
1127        <div class='mt-2 font-bold'>\
1128          Duration: " +
1129        item.durationText +
1130        "\
1131        </div>\
1132        <div class='font-bold'>\
1133          Points: " +
1134        item.points +
1135        "\
1136        </div>\
1137      </div>\
1138      ",
1139    );
1140  });
1141}
1142
1143function getDayStage() {
1144  var d = new Date();
1145  var n = d.getHours();
1146
1147  var stage;
1148  stage = "day";
1149  if (n >= 0 && n < 12) {
1150    stage = "morning";
1151  }
1152  if (n >= 12 && n < 17) {
1153    stage = "afternoon";
1154  }
1155  if (n >= 17 && n < 24) {
1156    stage = "evening";
1157  }
1158
1159  //console.log(stage);
1160  return stage;
1161}
1162
1163function getFormattedDate(date) {
1164  function addZero(val) {
1165    if (val < 10) {
1166      val = "0" + val;
1167    }
1168    return val;
1169  }
1170
1171  formatted_date =
1172    date.getDate() +
1173    "/" +
1174    (date.getMonth() + 1) +
1175    "/" +
1176    date.getFullYear() +
1177    " - " +
1178    addZero(date.getHours()) +
1179    ":" +
1180    addZero(date.getMinutes());
1181
1182  return formatted_date;
1183}
1184
1185// add class to links on page scroll
1186if ($("body").hasClass("page-template-loggedin-template")) {
1187  window.addEventListener("scroll", scrollLinkHighlight);
1188}
1189function scrollLinkHighlight() {
1190  let scroll_top = $(document).scrollTop();
1191  let div_one_top = $(".points-history").position().top - 160;
1192  let div_two_top = $(".admin-row").position().top - 160;
1193  let div_three_top = $(".profile-surveys").position().top - 160;
1194
1195  if (scroll_top > div_one_top && scroll_top < div_two_top) {
1196    $(".menu-head .menu-item").eq(1).removeClass("showing");
1197    $(".menu-head .menu-item").eq(2).removeClass("showing");
1198    $(".menu-head .menu-item").eq(3).removeClass("showing");
1199
1200    $(".menu-head .menu-item").eq(0).addClass("showing");
1201  } else if (scroll_top > div_two_top && scroll_top < div_three_top) {
1202    $(".menu-head .menu-item").eq(0).removeClass("showing");
1203    $(".menu-head .menu-item").eq(2).removeClass("showing");
1204    $(".menu-head .menu-item").eq(3).removeClass("showing");
1205
1206    $(".menu-head .menu-item").eq(1).addClass("showing");
1207  } else if (scroll_top > div_three_top) {
1208    $(".menu-head .menu-item").eq(0).removeClass("showing");
1209    $(".menu-head .menu-item").eq(1).removeClass("showing");
1210
1211    $(".menu-head .menu-item").eq(2).addClass("showing");
1212  }
1213}
1214
1215// scroll to page of page on button click function
1216function scrollToDiv(buttonDiv, targetDiv) {
1217  $("." + buttonDiv).on("click", function () {
1218    $("html, body").animate(
1219      {
1220        scrollTop: $("." + targetDiv).offset().top - 100,
1221      },
1222      1000,
1223    );
1224  });
1225}
1226
1227// intro row scroll to contact form on click
1228
1229// login, sign in and reset password
1230$("body").on("click", ".login", function () {
1231  $(".rightnv-login").addClass("open");
1232});
1233$(".register").on("click", function () {
1234  $(".rightnv-register").addClass("open");
1235});
1236$(".registercancel").on("click", function () {
1237  $(".rightnv-register").removeClass("open");
1238});
1239$(".logincancel, #loginform .cancel").on("click", function () {
1240  $(".rightnv-login").removeClass("open");
1241});
1242
1243$(".forgot-password").on("click", function () {
1244  $(".rightnv-login").removeClass("open");
1245  $(".forgotpassword").addClass("open");
1246  // change forgot password model text back to default
1247  $(".forgotpassword .resetsuccess").addClass("hidden");
1248  $(".forgotpassword #resetpasswordform").removeClass("hidden");
1249});
1250
1251$("#resetpasswordform .cancel, .forgotpassword .closeform").on(
1252  "click",
1253  function () {
1254    $(".forgotpassword").removeClass("open");
1255    $(".rightnv-login").addClass("open");
1256  },
1257);
1258
1259//close cookie message
1260$(".cookie-message .close-cookie-message").on("click", function () {
1261  hideCookiePolicy();
1262});
1263
1264//   show / hide password
1265$(".togglepasswordview").on("click", function () {
1266  var x = document.getElementById("password");
1267  if (x.type === "password") {
1268    x.type = "text";
1269  } else {
1270    x.type = "password";
1271  }
1272  $(this).toggleClass("fa-eye fa-eye-slash");
1273});
1274
1275// toggle rewards row display
1276$("#show-all-rewards").on("click", function () {
1277  $(".rewards-list2").toggleClass("show-all");
1278  if ($(".rewards-list2").hasClass("show-all")) {
1279    $(this).text("Hide Full List");
1280  } else {
1281    $(this).text("See Full List");
1282  }
1283});
1284
1285// partner tabs
1286$("#partner-tabs a").on("click", function (e) {
1287  e.preventDefault();
1288  $("#partner-tabs a").attr("data-active", "");
1289  $(this).attr("data-active", "true");
1290
1291  let href = $(this).attr("href");
1292  $(".tab-panel").addClass("hidden");
1293  $(".tab-panel[data-tab='" + href + "']").removeClass("hidden");
1294});
1295
1296// dynamic model
1297$("body").on("click", ".open-modal", function () {
1298  let title = $(this).attr("data-title");
1299  let type = $(this).attr("data-type");
1300  openModal(title, type);
1301});
1302
1303$("body").on("click", "#modal .close", function () {
1304  $("#modal").addClass("hidden");
1305  $("body").removeClass("modal-show");
1306});
1307
1308let modal2 = document.getElementById("modal");
1309window.onclick = function (event) {
1310  if (event.target == modal2) {
1311    $("#modal").addClass("hidden");
1312    $("body").removeClass("modal-show");
1313  }
1314};
1315
1316function openModal(title, type) {
1317  $("#modal .title").html("");
1318  $("#modal .modal-content").html("");
1319
1320  if (type == "text") {
1321    $("#modal .title").html(title);
1322    $("#modal .modal-content").html(
1323      "\
1324      <h2>How it works...</h2>\
1325      <ul style='margin-bottom: 20px'>\
1326        <li>When you complete a survey you will be sent back to newvista and have the option to try to take another available survey.</li>\
1327        <li>If there are no surveys available you will see a message asking you to try again later.</li>\
1328        <li>These partner surveys cannot show the points for each survey at the start - this is calculated based on length of survey and will be sent to us to credit to your account.</li>\
1329        <li>If you fail to get through a survey, our partner will route you to another survey (if one is available).</li>\
1330      </ul>\
1331      <h2>Your data</h2>\
1332      <ul style='margin-bottom: 20px'>\
1333        <li>In order for you to have the best chance of being offered surveys that you will qualify for, we need to share some of your profile data with our partners. By accessing the survey offerings below, you are giving consent for your data to be shared with our partners.</li>\
1334        <li>If you want to know more about how your data is utilised, please refer to our <a href='https://www.newvistalive.com/privacy-cookie-policy' target='_blank'>privacy policy</a>. You can also access it from the footer of this page.</li>\
1335      </ul>\
1336      <h2>Samplicio.us</h2>\
1337      <ul style='margin-bottom: 20px'>\
1338        <li>Why not try a survey from samplicio.us? A choice of length of surveys are available, with points to match.</li>\
1339        <li>To find out more about how samplicio.us utilise your data, please read their <a href='https://www.samplicio.us/s/privacy-policy?hl=en' target='_blank'>privacy policy</a>.</li>\
1340      </ul>\
1341    ",
1342    );
1343  }
1344
1345  if (type == "table") {
1346    $("#modal .title").html(title);
1347    $("#modal .modal-content").html(
1348      "\
1349      <div class='history-heading'>\
1350        <div class='column'>Description</div>\
1351        <div class='column'>Date Added</div>\
1352        <div class='column'>Points</div>\
1353      </div>\
1354      <div class='history-container'>\
1355        " +
1356        localStorage.historyTable +
1357        "\
1358      </div>\
1359    ",
1360    );
1361  }
1362  if (type == "voucher") {
1363    $("#modal .title").html(title);
1364    let surveyId = $(".open-reward-modal").attr("data-surveyid");
1365
1366    $("#modal .modal-content").html(
1367      "\
1368    <strong>Congratulations on reaching 5000 points!</strong>\
1369    <p>Select 'Yes' on the next page to be taken straight to the website to claim your voucher or if you're not sure yet select 'No' and 
1369you will be emailed a link that you can follow later. </p>\
1370    <p>Once you have redeemed your points you have 30 days to claim your voucher.</p>\
1371    <p>Thank you for your time!</p>\
1372    <div class='mt-4' data-surveyid='" +
1373        surveyId +
1374        "'>\
1375    <div class='btn btn-black rewardbutton'>\
1376    Redeem\
1377    </div>\
1378    <div class='btn btn-white close'>\
1379    Cancel\
1380    </div>\
1381    </div>\
1382    ",
1383    );
1384  }
1385  $("body").addClass("modal-show");
1386  $("#modal").removeClass("hidden");
1387}
1388
1389function postsSorting(sortValue, tagValue) {
1390  console.log(sortValue);
1391  console.log(tagValue);
1392
1393  let catValue = $("#category-header").attr("data-category");
1394  let sortby = "";
1395  let sort = "";
1396
1397  if (sortValue == "date-asc") {
1398    sortby = "date";
1399    sort = "ASC";
1400  } else if (sortValue == "date-desc") {
1401    sortby = "date";
1402    sort = "DESC";
1403  } else if (sortValue == "title-asc") {
1404    sortby = "title";
1405    sort = "ASC";
1406  } else if (sortValue == "title-desc") {
1407    sortby = "title";
1408    sort = "DESC";
1409  } else {
1410    sortby = "date";
1411    sort = "ASC";
1412  }
1413
1414  $.ajax({
1415    type: "POST",
1416    url: ajax.ajax_url,
1417    // dataType: "json", // remove this to show console logs
1418    data: {
1419      action: "discussion_post_sort",
1420      // paged: filterNew,
1421      cat: catValue,
1422      sortby: sortby,
1423      sort: sort,
1424      tag: tagValue,
1425    },
1426    // beforeSend: function () {
1427    //   $(".post-list").html("loading");
1428    // },
1429    success: function (response) {
1430      // console.log(response);
1431
1432      $(".post-list").empty();
1433      $(".post-list").append(response);
1434    },
1435  });
1436}
1437
1438// discussion board tag filter
1439$(".tag-list .tag-item").on("click", function () {
1440  let tagValue = $(this).attr("data-tag");
1441  $(".tag-item").removeClass("active-tag");
1442  $(this).addClass("active-tag");
1443
1444  let sortValue = $(".orderBy select").val();
1445  // console.log(sortValue);
1446
1447  postsSorting(sortValue, tagValue);
1448});
1449
1450// discussion board order by categories
1451$(".orderBy select").on("change", function () {
1452  let sortValue = $(this).val();
1453  let catValue = $("#category-header").attr("data-category");
1454  let sortby = "";
1455  let sort = "";
1456
1457  let tagValue = $(".tag-list .active-tag").attr("data-tag");
1458
1459  postsSorting(sortValue, tagValue);
1460});
1461
1462// discussion board search filter
1463$("#category-search input").keyup(function () {
1464  let filter = $(this).val().trim().toLowerCase();
1465  var filterItems = $(".post-item");
1466
1467  $(".post-item").filter(function () {
1468    $(this).toggle(
1469      $(this).find("h3").text().toLowerCase().indexOf(filter) > -1,
1470    );
1471  });
1472});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.