Skip to content

Commit

Permalink
Merge pull request #48 from consensusnetworks/feature/bot-checking
Browse files Browse the repository at this point in the history
@shanejearley @DemogorGod - Thank you for the review and suggested changes. Changes have all been made and am merging them in now. Feel free to check them out.
  • Loading branch information
ccali11 authored Jul 5, 2022
2 parents 94b1a8f + a5342c4 commit 45e8b37
Showing 1 changed file with 76 additions and 76 deletions.
152 changes: 76 additions & 76 deletions apps/website/src/pages/index/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ const successMessage: Ref = ref<HTMLDivElement>()
const invalidMessage: Ref = ref<HTMLDivElement>()
const email = ref('')
const botTrapInput = ref('')
const timeArrived = ref(new Date().getTime())
async function onSubmit() {
const isLikelyABot = checkForBot()
if (isLikelyABot) return
const validEmail = validateEmail(email.value)
if (!validEmail) {
invalidMessage.value.style.display = 'block'
return
}
console.log('validEmail :>> ', validEmail)
try {
const newEmail = email.value
Expand All @@ -34,14 +39,36 @@ const hideMessages = () => {
}
/**
*
*
*
*
* @param email {string} email string from user input to validate
* @returns {boolean} true if email is valid, false if not
*/
function validateEmail(email: string) {
function validateEmail(email: string): boolean {
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
if (email.length < 5 || email.length > 100) {
return false
}
return re.test(String(email).toLowerCase())
}
/**
*
*
* @returns {boolean} true if bot, false if not
*/
function checkForBot(): boolean {
const botTrap = botTrapInput.value.length ? true : false
if (botTrap) return true
const timeNow = new Date().getTime()
const timeDiff = timeNow - timeArrived.value
if (timeDiff < 3000) {
invalidMessage.value.style.display = 'block'
return true
} else {
return false
}
}
</script>

<template>
Expand All @@ -57,38 +84,35 @@ function validateEmail(email: string) {
<ArrowRightIcon class="w-[15px] h-[20px] mx-2" />
</button>
<h1 class="header-text text-[#101828] mt-4 pb-0">
<span
class="text-[#F36F38]"
@click="$router.push('/')"
>
<span class="text-[#F36F38]" @click="$router.push('/')">
Your
</span>
digital assets
</h1>
<h1 class="header-text text-[#101828] mb-4">
<span
class=" text-[#c4c4c4]"
@click="$router.push('/')"
>
<span class=" text-[#c4c4c4]" @click="$router.push('/')">
All
</span>
in one place
</h1>
<h1 class="body-text text-[#667085] py-[40px]">
Non-custodial digital asset management and staking
</h1>
<form
novalidate
@submit.prevent="onSubmit"
>
<form novalidate @submit.prevent="onSubmit">
<div class="mt-10 grid grid-cols-5 gap-2 ">
<input
v-model="email"
type="text"
placeholder="Sign up for early access"
class="border border-[#D0D5DD] rounded-md px-4 py-2 col-span-3 input-text text-[#F36F38]"
@click="hideMessages"
>
/>
<input
v-model="botTrapInput"
class="bot-trap"
type="text"
placeholder="Bot Trap"
/>
<button
type="submit"
class="bg-[#F36F38] button-text text-white py-2 px-4 rounded-md w-[130px] hover:bg-[#F36F38]/[.75]"
Expand All @@ -111,64 +135,51 @@ function validateEmail(email: string) {
>
Please enter a valid email.
</div>
<span class="small-text text-[#667085] pl-[5px]">We won't spam you. We promise.</span>
<span class="small-text text-[#667085] pl-[5px]">
We won't spam you. We promise.
</span>
</form>
</div>
<div class="min-w-[370px] w-1/2 h-[500px] relative overflow-hidden">
<Puddles class="absolute right-[-300px] top-[-200px]" />
</div>
</div>

<div class="border w-full p-[50px] bg-[#c4c4c4]/[.5] mt-[100px] min-w-[395px]">
<div
v-if="currentSlide === 0"
class="flex flex-wrap slideshow"
>
<div
class="border w-full p-[50px] bg-[#c4c4c4]/[.5] mt-[100px] min-w-[395px]"
>
<div v-if="currentSlide === 0" class="flex flex-wrap slideshow">
<div class="min-w-[375px] w-1/2 pl-[50px] pt-[50px] slideshow">
<img
src="/Dashboard.png"
class="p-[5%] h-[90%] object-cover"
alt=""
>
/>
</div>
<div class="min-w-[375px] w-1/2 pt-[50px] pr-[50px]">
<h1 class="text-[42px] text-left ">
<span class="text-[#F36F38] font-extrabold">Manage</span> your
assets and earnings across chains. See all of your coins and NFTs
in one dashboard.
assets and earnings across chains. See all of your coins and NFTs in
one dashboard.
</h1>
</div>
</div>
<div
v-if="currentSlide === 1"
class="flex flex-wrap slideshow"
>
<div v-if="currentSlide === 1" class="flex flex-wrap slideshow">
<div class="min-w-[375px] w-1/2 pl-[50px] pt-[50px]">
<img
src="/earn.png"
class="p-[5%] h-[90%] object-cover"
alt=""
>
<img src="/earn.png" class="p-[5%] h-[90%] object-cover" alt="" />
</div>
<div class="min-w-[375px] w-1/2 pt-[50px] pr-[50px]">
<h1 class="text-[42px] text-left ">
<span class="text-[#F36F38] font-extrabold">Earn</span> by staking
your assets to high performing validators. Participate in
liquidity pools. Help keep staking decentralized with a strong set
of independent validators.
your assets to high performing validators. Participate in liquidity
pools. Help keep staking decentralized with a strong set of
independent validators.
</h1>
</div>
</div>
<div
v-if="currentSlide === 2"
class="flex flex-wrap slideshow"
>
<div v-if="currentSlide === 2" class="flex flex-wrap slideshow">
<div class="min-w-[375px] w-1/2 pl-[50px] pt-[50px]">
<img
src="/earn3.png"
class="p-[5%] h-[90%] object-cover"
alt=""
>
<img src="/earn3.png" class="p-[5%] h-[90%] object-cover" alt="" />
</div>
<div class="min-w-[375px] w-1/2 pt-[50px] pr-[50px]">
<h1 class="text-[42px] text-left ">
Expand All @@ -193,46 +204,29 @@ function validateEmail(email: string) {
target="_blank"
class="w-[25px]"
>
<img
src="/twitter.svg"
alt=""
class="border"
>
<img src="/twitter.svg" alt="" class="border" />
</a>
<a
href="https://discord.gg/hkJD9gnN"
target="_blank"
class="w-[25px]"
>
<img
src="/discord.svg"
alt=""
>
<a href="https://discord.gg/hkJD9gnN" target="_blank" class="w-[25px]">
<img src="/discord.svg" alt="" />
</a>

<a
href="https://github.com/consensusnetworks/casimir"
target="_blank"
class="w-[25px]"
>
<img
src="/github.svg"
alt=""
>
<img src="/github.svg" alt="" />
</a>
</div>
</div>
<div class="flex flex-wrap justify-center">
<img
src="/CopyrightIcon.svg"
alt=""
class="w-[20px]"
>
<img src="/CopyrightIcon.svg" alt="" class="w-[20px]" />
<a
href="https://consensusnetworks.com/"
target="_blank"
class="text-[#F36F38] mx-4"
>Consensus Networks</a>
>Consensus Networks</a
>
<span> | All Right Reserved</span>
</div>
</div>
Expand Down Expand Up @@ -285,11 +279,13 @@ function validateEmail(email: string) {
}
.linear-bg {
background: linear-gradient(307.15deg,
#f36f38 -3.58%,
#f36f38 -3.58%,
#f36f38 -3.57%,
rgba(243, 111, 56, 0.16) 137.28%);
background: linear-gradient(
307.15deg,
#f36f38 -3.58%,
#f36f38 -3.58%,
#f36f38 -3.57%,
rgba(243, 111, 56, 0.16) 137.28%
);
}
.slideshow {
Expand All @@ -303,4 +299,8 @@ function validateEmail(email: string) {
#invalid-message {
display: none;
}
.bot-trap {
display: none;
}
</style>

0 comments on commit 45e8b37

Please sign in to comment.