// Weighting is based on number of results you will have
// Each answer can be weighted to multiple results
// Intro background image
const intro_bgimage_desktop = ”
const intro_bgimage_mobile = ”
// Intro headline & dek
const intro_headline = “
This Is What Your Oral Care Routine Should Look Like, Based On Your Personality
“;
const intro_dek = “
The building blocks of a basic oral care routine are: floss, rinse, brush. But when you’ve been following the same steps — and using the same products — for as long as you can remember, then perhaps it’s time to rethink your whole approach with a Reality Checkup. What that means: upgrading your current products that may not be getting the job done, like swapping out your disappointingly ineffective toothpaste because it’s not giving you the whiter teeth you want, and figuring out a routine that’s best suited for your lifestyle and personality. Take the quiz to find your new and improved oral care regimen.
“;
// Intro sponsor banner
const sponsor_logo_intro = ”
const sponsor_alt_intro = “CREATED IN PARTNERSHIP WITH CREST”;
const sponsor_url_intro = “”;
// Personas sponsor banner
const sponsor_logo_persona = ”
const sponsor_alt_persona = “CREATED IN PARTNERSHIP WITH CREST”;
const sponsor_url_persona = “”;
// Content
const questions = [
[
‘What’s your idea of the perfect vacation?’,
[
[‘Lounging somewhere tranquil, basking in relentless sunshine, ideally on a beach.’,[1]],
[‘Exploring a major, culture-rich metropolitan, complete with a packed itinerary.’,[2]],
[‘Trekking hiking trails, which combines two loves: nature and athleticism.’,[3]]
],
[
‘
‘
],
‘#d6bdfe’
],
[
‘Your beauty routine in one word:’,
[
[‘Opulent’,[1]],
[‘Efficient’,[2]],
[‘Invigorating’,[3]]
],
[
‘
‘
],
‘#ffe1e1’
],
[
‘How do you like to wind down at the end of the day?’,
[
[‘Spending a few minutes to reflect and jot down your thoughts in your gratitude journal.’,[1]],
[‘Reviewing and rapid-planning your schedule for the next day.’,[2]],
[‘Stretching and meditating on your yoga mat before you head to bed.’,[3]]
],
[
‘
‘
],
‘#f1e748’
],
[
‘How would you describe your personal style?’,
[
[‘Fairly eclectic — you dress based on whatever fits your mood .’,[1]],
[‘Comfortingly uniform — you have a go-to, streamlined look that eliminates the “what do I wear?” dilemma.’,[2]],
[‘High-performing athleisure — you reach for technical, comfortable fabrics that can take you from your workout class to a hangout with friends.’,[3]]
],
[
‘
‘
],
‘#f1e748’
],
[
‘What scent do you gravitate toward?’,
[
[‘Lavender for its calming, relaxing properties.’,[1]],
[‘Clary sage for its ability to improve productivity and mental focus.’,[2]],
[‘Peppermint for its invigorating scent that can help increase performance.’,[3]]
],
[
‘
‘
],
‘#f1e748’
]
];
const personas = [
[
‘The Self-Care
Seeker’,
‘If you had boundless time, energy, and resources, you’d do an Everything Shower every single day. Actually, make that an Everything Routine — a gloriously indulgent, head-to-toe ritual in which no part of you isn’t cared for or tended to. You have zero qualms splurging on the latest gadget or trend — it’s all in the name of self-care. So obviously, you apply the same more-is-more approach to your teeth (Everything Oral Care, if you will), from using Crest 3DWhite Brilliance Vibrant Peppermint, a whitening toothpaste designed to remove 100% more stains than basic toothpastes (to give you a whiter, brighter smile in three days), to blissfully applying whitening strips.’,
‘#D7BEFA’,
‘
‘
‘#F9DCBF’,
[
[‘Crest 3DWhite Brilliance Vibrant Peppermint’,’brand’,’
[‘Crest 3DWhitestrips Professional Effects’,’brand’,’
[‘Oral-B iO Series 10 Rechargeable Electric Toothbrush’,’brand’,’
],
‘Products For The Self-Care Seeker’,
‘#AADCD0’
],
[
‘The Bustling
Overachiever’,
‘Even when you wake up as early as 5 a.m., you find there’s still not enough time in the day. Not only do you have a full-time job, but you also have a side hustle, a robust social life, and a rigorous workout routine. That means you tend to plan your day down to the second. That also means you have no time (literally) or patience for products that don’t perform. When it comes to your teeth, you want an efficient routine that maximizes results with minimal fuss, like the Crest 3DWhite Brilliance Vibrant Peppermint that’s formulated to achieve a noticeably whiter, brighter smile in just three days; or a whitening pen that allows you to erase stains while you’re on-the-go.’,
‘#6DE2DC’,
‘
‘
‘#F9DCBF’,
[
[‘Crest 3DWhite Brilliance Vibrant Peppermint’,’brand’,’
[‘Crest 3DWhite Teeth Whitening Pen’,’brand’,’
[‘Crest Pro-Health Advanced with Extra Whitening’,’brand’,’
],
‘Products For The Bustling Overachiever’,
‘#A3A6F7’
],
[
‘The Health &
Wellness Enthusiast’,
‘You have one great passion: your health. You treat your body like a temple, which means you’ve tried every wellness trend, every new-fangled workout class (from aerial yoga to underwater cycling), every nutritionist-recommended meal. You love green juice more than a milkshake, roasted potato wedges more than fries. So naturally, for your dental care routine, you reach for products that nourish and promote all aspects of your oral health, whether that’s Crest 3DWhite Brilliance Vibrant Peppermint, a toothpaste that removes 100% more stains than basic toothpastes and helps you achieve a noticeably whiter, brighter smile in just three days, or a health-focused mouthwash.’,
‘#F8DCBF’,
‘
‘
‘#6DE2DC’,
[
[‘Crest 3DWhite Brilliance Vibrant Peppermint’,’brand’,’
[‘Crest Pro-Health Advanced with Extra Deep Clean’,’brand’,’
[‘Oral-B iO Series 2 Electric Toothbrush’,’brand’,’
],
‘Products For The Health & Wellness Enthusiast’,
‘#F2DAD0’
]
];
// Store the user answers
let userAnswers = [];
// Variables
let SQ,SA;
let PrQ = “”;
let PrA = “”;
let bg = “”;
let slide = 0;
const alpha = new Array(‘A’,’B’,’C’,’D’,’E’,’F’); // Add more if needed
function showShare() {
let a = document.querySelectorAll(“.share-bottom-wrapper”)[0];
let b = document.getElementById(“tmp__share-button”);
a.style.display = “block”;
b.style.opacity = “0.0”;
b.style.transition = “opacity 0.75s ease-in-out”;
b.style.webkitTransition = “opacity 0.75s ease-in-out”;
const w1 = setTimeout(function () {
clearTimeout(w1);
b.style.display = “none”;
}, 800);
const w2 = setTimeout(function () {
clearTimeout(w2);
a.style.opacity = “1.0”;
a.style.transition = “opacity 0.75s ease-in-out”;
a.style.webkitTransition = “opacity 0.75s ease-in-out”;
}, 100);
}
function hideBGimage(n) {
let trg = n;
let a;
if (window.innerWidth > 1024) {
a = [“pbg” + n];
} else {
a = [“pbg” + n + “_mobile”];
}
let b = document.getElementById(a);
b.style.opacity = “0.0”;
b.style.transition = “opacity 0.75s ease-in-out”;
b.style.webkitTransition = “opacity 0.75s ease-in-out”;
const w = setTimeout(function () {
clearTimeout(w);
b.style.display = “block”;
}, 800);
}
function showBGimage(n) {
let trg = n;
let a;
if (window.innerWidth > 1024) {
a = [“pbg” + n];
} else {
a = [“pbg” + n + “_mobile”];
}
let b = document.getElementById(a);
b.style.opacity = “0.0”;
b.style.display = “block”;
const w = setTimeout(function () {
clearTimeout(w);
b.style.opacity = “1.0”;
b.style.transition = “opacity 0.75s ease-in-out”;
b.style.webkitTransition = “opacity 0.75s ease-in-out”;
}, 50);
}
function showDots(n) {
let a = document.getElementById(“dots”);
for (let i = 0; i < questions.length; i++) {
let b = ["dot" + i];
let c = document.getElementById(b);
if (i != n) {
c.style.backgroundColor = "var(–dot-bg)";
} else {
c.style.backgroundColor = "var(–dot-selected)";
}
}
if (n == 0) {
const w = setTimeout(function () {
clearTimeout(w);
a.style.opacity = "1.0";
a.style.transition = "opacity 0.5s ease-in-out";
a.style.webkitTransition = "opacity 0.3s ease-in-out";
}, 50);
}
}
function setupProducts(n) {
// Target container
const a = document.getElementById("products__set");
const b = document.getElementById("personas__bg-mobile");
const c = document.querySelectorAll(".tmp__nav")[0];
let products = "
for (let i = 0; i < personas[n][6].length; i++) {
products = products + "
“;
}
a.innerHTML = products + “
“;
a.style.display = “flex”;
a.style.backgroundColor = personas[n][5];
b.style.backgroundColor = personas[n][8];
c.style.background = “transparent”;
c.style.backgroundColor = “transparent”;
}
function switchPersonas(n) {
let a = document.getElementById(“personas__set”);
let b = document.getElementById(“personas__bg”);
a.style.opacity = “0.0”;
a.style.transition = “opacity 0.75s ease-in-out”;
a.style.webkitTransition = “opacity 0.75s ease-in-out”;
b.style.opacity = “0.0”;
b.style.transition = “opacity 0.75s ease-in-out”;
b.style.webkitTransition = “opacity 0.75s ease-in-out”;
// Target specific persona bg
hideBGimage(persona);
const w1 = setTimeout(function () {
clearTimeout(w1);
a.innerHTML = “”;
setupPersona(n);
}, 750);
const w2 = setTimeout(function () {
clearTimeout(w2);
a.style.opacity = “1.0”;
a.style.transition = “opacity 0.75s ease-in-out”;
a.style.webkitTransition = “opacity 0.75s ease-in-out”;
b.style.opacity = “1.0”;
b.style.transition = “opacity 0.75s ease-in-out”;
b.style.webkitTransition = “opacity 0.75s ease-in-out”;
showBGimage(n);
}, 751);
}
let mobile = false;
function restartQuiz() {
}
function viewPersonasDrop() {
const a = document.getElementById(“personas__set-dropdown”);
const b = document.getElementById(“dropdown__overlay”);
a.style.display = “flex”;
b.style.display = “block”;
const w = setTimeout(function () {
clearTimeout(w);
a.style.opacity = “1.0”;
a.style.transition = “opacity 0.3s ease-in-out”;
a.style.webkitTransition = “opacity 0.3s ease-in-out”;
b.style.opacity = “1.0”;
b.style.transition = “opacity 0.3s ease-in-out”;
b.style.webkitTransition = “opacity 0.3s ease-in-out”;
}, 50);
}
function hidePersonasDrop() {
const a = document.getElementById(“personas__set-dropdown”);
const b = document.getElementById(“dropdown__overlay”);
a.style.opacity = “0.0”;
a.style.transition = “opacity 0.3s ease-in-out”;
a.style.webkitTransition = “opacity 0.3s ease-in-out”;
b.style.opacity = “0.0”;
b.style.transition = “opacity 0.3s ease-in-out”;
b.style.webkitTransition = “opacity 0.3s ease-in-out”;
const w = setTimeout(function () {
clearTimeout(w);
a.style.display = “none”;
b.style.display = “none”;
}, 350);
}
const tempsiteurl = ”
function setupPersonasDrop(n) {
// Target container
let a = document.getElementById(“personas__set”);
// Create a new div for the question
let elem = document.createElement(‘div’);
// Add a class to the question
elem.setAttribute(“class”,”personas__set-buttons”);
// Add a class to the question
elem.setAttribute(“id”,”personas__set-buttons”);
// Setup element
let drp =”
for (let i = 0; i < personas.length; i++) {
if (n == i) {
drp = drp + "“;
} else {
drp = drp + ““;
}
}
elem.innerHTML = drp + “
“;
// Add new div to the target container
a.appendChild(elem);
}
function hideQuestions() {
const a = document.getElementById(“questions__set”);
const b = document.getElementById(“dots”);
const w = setTimeout(function () {
clearTimeout(w);
a.style.display = “none”;
b.style.display = “none”;
}, 750);
}
function hideQuiz() {
const a = document.getElementById(“questions__set”);
const b = document.getElementById(“questions__bg”);
const c = document.getElementById(“dots”);
const d = document.getElementById(“tmp”);
a.style.display = “none”;
b.style.display = “none”;
c.style.display = “none”;
d.style.backgroundImage = “unset”;
}
let persona;
function setupPersona(n) {
// Target container
const a = document.getElementById(“personas__set”);
const b = document.getElementById(“questions__set”);
// Prep for fade in
a.style.opacity = “0.0”;
// Add the text
a.innerHTML = “
YOU ARE…
” + personas[n][0] + “
” + personas[n][1] + “
“;
// Show personas set
if (window.innerWidth > 1024) {
a.style.display = “flex”;
} else {
a.style.display = “block”;
}
// BG
let pa = document.getElementById(“personas__bg”);
pa.style.opacity = “0.0”;
pa.style.backgroundColor = personas[n][2];
if (window.innerWidth {
counts[item] = (counts[item] || 0) + 1;
if (counts[item] > maxCount) {
mostCommon = item;
maxCount = counts[item];
}
});
return mostCommon;
}
function storeAnswers(e) {
for (let i = 0; i < e.length; i++) {
userAnswers.push(e[i]);
}
}
function showElem(n,e,d) {
let a = ["a" + n + "_" + e];
let b = document.getElementById(a);
b.style.display = "flex";
const w = setTimeout(function () {
clearTimeout(w);
b.style.opacity = "1.0";
b.style.transition = "opacity 0.75s ease-in-out";
b.style.webkitTransition = "opacity 0.75s ease-in-out";
b.style.transitionDelay = d;
b.style.webkitTransitionDelay = d;
}, 50);
}
function showAnswers(n) {
let delay;
for (let i = 0; i 1024) {
bga = [“bg” + slide];
} else {
bga = [“bg” + slide + “_mobile”];
}
let bgb = document.getElementById(bga);
const w1b = setTimeout(function () {
clearTimeout(w1b);
d.style.opacity = “0.0”;
d.style.display = “block”;
bgb.style.opacity = “0.0”;
bgb.style.display = “block”;
}, 450);
const w2 = setTimeout(function () {
clearTimeout(w2);
d.style.opacity = “1.0”;
d.style.transition = “opacity 0.4s ease-in-out”;
d.style.webkitTransition = “opacity 0.4s ease-in-out”;
bgb.style.opacity = “1.0”;
bgb.style.transition = “opacity 0.5s ease-in-out”;
bgb.style.webkitTransition = “opacity 0.5s ease-in-out”;
}, 500);
const w3 = setTimeout(function () {
clearTimeout(w3);
showAnswers(n);
}, 900);
}
function next(n) {
// Get the answer hinting
let a = questions[SQ][1][SA][1];
// Store the hints into the array
storeAnswers(a);
// Show the next question
animQuestions(n);
// Stagger animate the answers
showAnswers(n+1);
// Dots
showDots(n+1);
// Remove before pulishing
let s = document.getElementById(“temp__arr”);
s.innerHTML = userAnswers;
}
function select(n,e) {
// Store the selected options until next is clicked
SQ = n;
SA = e;
// Hide previous answer
if (PrQ == n) {
for (let i = 0; i < questions[n][1].length; i++) {
// Unselect answers first
let pa = ["a" + n + "_" + i];
let pb = document.getElementById(pa);
pb.style.backgroundColor = "transparent";
}
}
// Select answer
let a = ["a" + n + "_" + e];
let b = document.getElementById(a);
b.style.backgroundColor = "var(–answer-select-color)";
b.style.transition = "backgroundColor 0.2s ease-in-out";
b.style.webkitTransition = "backgroundColor 0.2s ease-in-out";
b.style.transitionDelay = "0s";
b.style.webkitTransitionDelay = "0s";
// Set new one to
PrQ = n;
PrA = e;
// Go next after clicking
const w = setTimeout(function () {
clearTimeout(w);
if (n == questions.length-1) {
finish();
} else {
next(n);
}
}, 500);
}
function createAnswer(n,e) {
// Which div
let a = ["q" + n];
// Target the specific question div
let b = document.getElementById(a);
// Create a new div for the question
let elem = document.createElement('button');
// Add the text
elem.innerHTML = "
“;
// Add an id to the question
elem.setAttribute(“id”,”a” + n + “_” + e);
// Add an id to the question
elem.setAttribute(“class”,”answer__item”);
// Add an id to the question
elem.setAttribute(“onclick”,”select(” + n + “,” + e + “)”);
// Add new div to the target container
b.appendChild(elem);
}
function initAnswers(n) {
for (let i = 0; i < questions[n][1].length; i++) {
createAnswer(n,i);
}
}
function createPersonaBGdesktop(n) {
let a = document.getElementById("personas__bg-desktop");
let b = a.innerHTML;
let c = "
“;
a.innerHTML = b + c;
}
function createPersonaBGmobile(n) {
let a = document.getElementById(“personas__bg-mobile”);
let b = a.innerHTML;
let c = “
“;
a.innerHTML = b + c;
}
function createBGdesktop(n) {
let a = document.getElementById(“questions__bg-desktop”);
let b = a.innerHTML;
let c = “
“;
a.innerHTML = b + c;
}
function createBGmobile(n) {
let a = document.getElementById(“questions__bg-mobile”);
let b = a.innerHTML;
let c = “
“;
a.innerHTML = b + c;
}
function createDots() {
// Target container
let a = document.getElementById(“dots”);
let b = “”;
for (let i = 0; i < questions.length; i++) {
b += "
“;
}
// Add the text
a.innerHTML = b;
}
function createQuestion(n) {
// Target container
let a = document.getElementById(“questions__set”);
// Create a new div for the question
let elem = document.createElement(‘div’);
// Add the text
elem.innerHTML = “
” + questions[n][0] + “
“;
// Add an id to the question
elem.setAttribute(“id”,”q” + n);
// Add a class to the question
elem.setAttribute(“class”,”question__item”);
// Add new div to the target container
a.appendChild(elem);
}
function hideQuestions() {
let a = document.getElementById(“questions__set”);
let b = document.getElementById(“questions__bg”);
a.style.opacity = “0.0”;
a.style.transition = “opacity 0.75s ease-in-out”;
a.style.webkitTransition = “opacity 0.75s ease-in-out”;
b.style.opacity = “0.0”;
b.style.transition = “opacity 0.75s ease-in-out”;
b.style.webkitTransition = “opacity 0.75s ease-in-out”;
b.style.transitionDelay = “0.25s”;
b.style.webkitTransitionDelay = “0.25s”;
const w1 = setTimeout(function () {
clearTimeout(w1);
a.style.display = “none”;
}, 750);
const w2 = setTimeout(function () {
clearTimeout(w2);
b.style.display = “none”;
}, 1000);
}
function processResults() {
let s = document.getElementById(“temp__arr”);
s.innerHTML = userAnswers;
// Get the most common number
let a = calculateMostCommonAnswer(userAnswers);
// Hide last question
hideQuestions();
// Show result
setupPersona(a-1);
}
function finish() {
// Get the answer hinting
let a = questions[SQ][1][SA][1];
// Store the hints into the array
storeAnswers(a);
// Process results
processResults()
}
function initQuestions() {
// Init questions
for (let i = 0; i < questions.length; i++) {
createQuestion(i);
initAnswers(i);
createBGdesktop(i);
createBGmobile(i);
}
// Init personas
for (let pr = 0; pr < personas.length; pr++) {
createPersonaBGdesktop(pr);
createPersonaBGmobile(pr);
}
// Init dots
createDots();
}
function setupSharing() {
const a = document.querySelectorAll(".share-bottom-wrapper .fa-facebook")[0];
const b = document.querySelectorAll(".share-bottom-wrapper .fa-twitter")[0];
const c = document.querySelectorAll(".share-bottom-wrapper .fa-envelope-o")[0];
a.innerHTML = "”;
b.innerHTML = “”;
c.innerHTML = “”;
}
function startQuiz() {
let t = document.getElementById(“intro__set”);
(t.style.opacity = “0.0”),
(t.style.transition = “opacity 0.6s ease-in-out”),
(t.style.webkitTransition = “opacity 0.6s ease-in-out”);
let b = document.getElementById(“intro__sponsor”);
(b.style.opacity = “0.0”),
(b.style.transition = “opacity 0.6s ease-in-out”),
(b.style.webkitTransition = “opacity 0.6s ease-in-out”);
let e = document.getElementById(“q0”);
let i;
if (window.innerWidth > 1024) {
i = document.getElementById(“bg0”);
} else {
i = document.getElementById(“bg0_mobile”);
}
(e.style.opacity = “0.0”),
(e.style.display = “block”),
(i.style.opacity = “0.0”),
(i.style.display = “block”);
let s = setTimeout(function () {
clearTimeout(s),
(e.style.opacity = “1.0”),
(e.style.transition = “opacity 0.4s ease-in-out”),
(e.style.webkitTransition = “opacity 0.4s ease-in-out”),
(i.style.opacity = “1.0”),
(i.style.transition = “opacity 0.4s ease-in-out”),
(i.style.webkitTransition = “opacity 0.4s ease-in-out”),
(t.style.display = “none”),
(b.style.display = “none”),
showAnswers(0),
showDots(0);
}, 400);
}
function showSite() {
let n = “all 0.5s ease-in-out”,
e = document.getElementById(“tmp-loading”),
i = document.getElementById(“tmp”),
s = setTimeout(function () {
clearTimeout(s),
(e.style.opacity = “0.0”),
(e.style.transition = n),
(e.style.WebkitTransition = n),
(i.style.display = “block”);
}, 1500),
l = setTimeout(function () {
clearTimeout(l),
(e.style.display = “none”),
(i.style.opacity = “1.0”),
(i.style.transition = n),
(i.style.WebkitTransition = n);
}, 2000);
}
function initIntro() {
const a = document.getElementById(“tmp”);
let b;
if (window.innerWidth > 1024) {
b = intro_bgimage_desktop;
} else {
b = intro_bgimage_mobile;
}
a.style.backgroundImage = “url(” + b + “)”;
const c = document.getElementById(“intro__headline”);
c.innerHTML = intro_headline;
const d = document.getElementById(“intro__dek”);
d.innerHTML = intro_dek;
const e = document.getElementById(“intro__sponsor”);
e.innerHTML = ““;
}
const t = setTimeout(function () {
clearTimeout(t),
initQuestions(),
setupSharing(),
initIntro(),
showSite();
}, 100);
<!– –>
Like what you see? How about some more R29 goodness, right here?