added win display
- Fixed nbs chars to only render in char component
This commit is contained in:
parent
c87ab6e07c
commit
289ca7b7f6
@ -12,5 +12,8 @@
|
|||||||
></app-letter>
|
></app-letter>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" placeholder="Type here" class="input w-full mt-10 text-center" (input)="onChangeInput($event)" (keydown.enter)="nextSentence()" #textInput />
|
<input type="text" placeholder="Type here" class="input w-full mt-10 text-center" (input)="onChangeInput($event)" (keydown.enter)="nextSentence()" #textInput />
|
||||||
|
<div class="mt-5" *ngIf="enteredText === text"> <!-- This check doesn't work because of the character code difference of space(160) and space(32) -->
|
||||||
|
<p class="text-center text-lg">You Won!</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
import {Component} from '@angular/core';
|
import {Component} from '@angular/core';
|
||||||
import {LetterComponent} from "../letter/letter.component";
|
import {LetterComponent} from "../letter/letter.component";
|
||||||
import {NgForOf} from "@angular/common";
|
import {NgForOf, NgIf} from "@angular/common";
|
||||||
import sentences from "./sentenceProvider";
|
import sentences from "./sentenceProvider";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-challenge',
|
selector: 'app-challenge',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
LetterComponent,
|
LetterComponent,
|
||||||
NgForOf
|
NgForOf,
|
||||||
],
|
NgIf
|
||||||
|
],
|
||||||
templateUrl: './challenge.component.html',
|
templateUrl: './challenge.component.html',
|
||||||
styleUrl: './challenge.component.scss'
|
styleUrl: './challenge.component.scss'
|
||||||
})
|
})
|
||||||
@ -18,19 +19,27 @@ export class ChallengeComponent {
|
|||||||
enteredText = "";
|
enteredText = "";
|
||||||
|
|
||||||
getSentence() {
|
getSentence() {
|
||||||
const sentenceArray = sentences.split('\n');
|
const sentenceArray = sentences.split('\n');
|
||||||
return sentenceArray[Math.floor(Math.random() * sentenceArray.length)];
|
return sentenceArray[Math.floor(Math.random() * sentenceArray.length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getText() {
|
getText() {
|
||||||
this.text = this.text.replace(/ /g, '\u00A0');
|
return this.text.split('');
|
||||||
return this.text.split('')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onChangeInput($event: Event) {
|
onChangeInput($event: Event) {
|
||||||
const target = $event.target as HTMLInputElement;
|
const target = $event.target as HTMLInputElement;
|
||||||
this.enteredText = target.value;
|
this.enteredText = target.value;
|
||||||
console.log()
|
|
||||||
|
const trimmedText = this.text.trim();
|
||||||
|
const trimmedEnteredText = this.enteredText.trim();
|
||||||
|
for (let i = 0; i < trimmedText.length; i++) {
|
||||||
|
if (trimmedText.charCodeAt(i) !== trimmedEnteredText.charCodeAt(i)) {
|
||||||
|
console.log(`Difference at position ${i}: '${trimmedText[i]}' (${trimmedText.charCodeAt(i)}) vs '${trimmedEnteredText[i]}' (${trimmedEnteredText.charCodeAt(i)})`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nextSentence() {
|
nextSentence() {
|
||||||
|
@ -1,62 +1,52 @@
|
|||||||
let sentences = `It isn't true that my mattress is made of cotton candy.
|
let sentences = `The dog sniffed curiously around the new litter box, confused by the cat's presence.
|
||||||
Had he known what was going to happen, he would have never stepped into the shower.
|
"Why does the furnace always seem to break on the coldest day?" she wondered, shivering.
|
||||||
You're good at English when you know the difference between a man eating chicken and a man-eating chicken.
|
The unmistakable aroma of wet dog filled the room after the rainstorm.
|
||||||
The tart lemonade quenched her thirst, but not her longing.
|
"Remember to hydrate," the coach yelled, as the players ran laps under the hot sun.
|
||||||
People keep telling me "orange" but I still prefer "pink".
|
The cat's fur glistened in the sunlight, showcasing its healthy skin.
|
||||||
Her hair was windswept as she rode in the black convertible.
|
A plumber's day is never dull, especially when the next call involves a clogged toilet.
|
||||||
The water flowing down the river didn’t look that powerful from the car
|
He wrinkled his nose at the bad smell emanating from the forgotten gym bag.
|
||||||
Mom didn’t understand why no one else wanted a hot tub full of jello.
|
The water in the lake was so clear, you could see the fish swimming below.
|
||||||
Everybody should read Chaucer to improve their everyday vocabulary.
|
"Training a puppy requires patience, especially when it comes to housebreaking," she advised.
|
||||||
It must be five o'clock somewhere.
|
The crackling sound from the furnace was a comforting reminder of warmth in winter.
|
||||||
He was 100% into fasting with her until he understood that meant he couldn't eat.
|
She applied sunscreen diligently, knowing the importance of protecting her skin.
|
||||||
The sunblock was handed to the girl before practice, but the burned skin was proof she did not apply it.
|
The cat proudly presented its latest catch, much to its owner's dismay.
|
||||||
The estate agent quickly marked out his territory on the dance floor.
|
A walk in the park often turned into a poop-scooping adventure with his new puppy.
|
||||||
If you like tuna and tomato sauce, try combining the two, it’s really not as bad as it sounds.
|
The stench from the garbage can was a clear reminder to take out the trash.
|
||||||
He said he was not there yesterday; however, many people saw him there.
|
"This toilet has seen better days," he thought, reaching for the plunger.
|
||||||
Normal activities took extraordinary amounts of concentration at the high altitude.
|
Water droplets glistened on the leaves after the morning dew.
|
||||||
The snow-covered path was no help in finding his way out of the back-country.
|
He couldn't help but laugh at the dog's silly antics in the bath.
|
||||||
Instead of a bachelorette party
|
A sudden whiff of sulfur indicated that the furnace needed servicing.
|
||||||
She opened up her third bottle of wine of the night.
|
The cat's indifference to the new dog was both amusing and frustrating.
|
||||||
I’m a living furnace.
|
"Hydration is key," she reminded herself, filling her water bottle.
|
||||||
The spa attendant applied the deep cleaning mask to the gentleman’s back.
|
The toilet overflowed, leading to a chaotic and wet mess in the bathroom.
|
||||||
She couldn't understand why nobody else could see that the sky is full of cotton candy.
|
He marveled at how the skin heals itself after a minor cut.
|
||||||
Beach-combing replaced wine tasting as his new obsession.
|
The litter box duty was the least favorite of all the pet-related chores.
|
||||||
The teenage boy was accused of breaking his arm simply to get out of the test.
|
As the furnace kicked on, a warm and cozy feeling enveloped the room.
|
||||||
Thirty years later, she still thought it was okay to put the toilet paper roll under rather than over.
|
The dog's excitement for its daily walk was infectious and uplifting.
|
||||||
As the asteroid hurtled toward earth, Becky was upset her dentist appointment had been canceled.
|
He noticed a strange smell coming from the basement, hinting at a possible furnace issue.
|
||||||
The old apple revels in its authority.
|
Applying moisturizer became a daily ritual to combat dry skin.
|
||||||
Too many prisons have become early coffins.
|
The cat curled up in the sunbeam, purring contentedly.
|
||||||
Despite what your teacher may have told you, there is a wrong way to wield a lasso.
|
Walking the dog was more about sniffing every tree than actual exercise.
|
||||||
Situps are a terrible way to end your day.
|
The bathroom air freshener worked overtime to combat the lingering bad smells.
|
||||||
The lyrics of the song sounded like fingernails on a chalkboard.
|
He was fascinated by the water's ability to shape the landscape over time.
|
||||||
Don't put peanut butter on the dog's nose.
|
The skin clinic offered new treatments for rejuvenation and care.
|
||||||
Today we gathered moss for my uncle's wedding.
|
The playful kitten knocked over the water bowl again.
|
||||||
She wrote him a long letter, but he didn't read it.
|
A routine checkup of the furnace ensured it would run smoothly all winter.
|
||||||
He didn’t want to go to the dentist, yet he went anyway.
|
The dog's muddy paws were a clear sign of an adventurous day.
|
||||||
It was obvious she was hot, sweaty, and tired.
|
"There's nothing like a hot shower to relax," she thought, turning on the water.
|
||||||
Smoky the Bear secretly started the fires.
|
The cat's agility and grace were always a marvel to watch.
|
||||||
If you don't like toenails, you probably shouldn't look at your feet.
|
He dreaded the toilet cleaning, but it was a necessary evil.
|
||||||
His mind was blown that there was nothing in space except space itself.
|
Hydrating face masks became her go-to for maintaining healthy skin.
|
||||||
The urgent care center was flooded with patients after the news of a new deadly virus was made public.
|
The dog trainer emphasized the importance of consistency in training.
|
||||||
The fact that there's a stairway to heaven and a highway to hell explains life well.
|
A faint burning smell suggested it was time to service the furnace.
|
||||||
Watching the geriatric men’s softball team brought back memories of 3 yr olds playing t-ball.
|
The cat's disdain for the new puppy was evident in its hissing.
|
||||||
Chocolate covered crickets were his favorite snack.
|
After a long run, he appreciated the importance of replenishing his body with water.
|
||||||
Henry couldn't decide if he was an auto mechanic or a priest.
|
The smell of rain on hot pavement was both refreshing and nostalgic.
|
||||||
Various sea birds are elegant, but nothing is as elegant as a gliding pelican.
|
"This new toilet cleaner works wonders," she noted with satisfaction.
|
||||||
The thick foliage and intertwined vines made the hike nearly impossible.
|
He carefully applied aloe vera to soothe his sunburned skin.
|
||||||
The bird had a belief that it was really a groundhog.
|
The kitten's playful antics with a water bottle cap were endlessly entertaining.
|
||||||
She had some amazing news to share but nobody to share it with.
|
Regular maintenance of the furnace was key to avoiding unexpected breakdowns.
|
||||||
The light in his life was actually a fire burning all around him.
|
The dog's loyalty and companionship were unmatched.
|
||||||
Two seats were vacant.
|
She marveled at the way water droplets formed patterns on the window during a storm.`;
|
||||||
The toilet paper floated in the air, but she was thankful it wasn't a spider.
|
sentences = sentences.replace(/\u00A0/g, ' ');
|
||||||
I flushed the spider down the toilet.
|
|
||||||
The hummingbird's wings blurred while it eagerly sipped the sugar water from the feeder.
|
|
||||||
Getting up at dawn is for the birds.
|
|
||||||
Sucking on the ice cube made the toothache less painful.
|
|
||||||
Shitting rainbows is a disgusting way to describe something amazing.
|
|
||||||
The fish dreamed of escaping the fishbowl and into the toilet where he saw his friend go.
|
|
||||||
The fish listened intently to what the frogs had to say.
|
|
||||||
Buying deodorant is a rite of passage for young teens.
|
|
||||||
A floating human heart is a creepy thing to see in the middle of the ocean.`;
|
|
||||||
|
|
||||||
export default sentences;
|
export default sentences;
|
||||||
|
@ -1 +1 @@
|
|||||||
<p [class]="[getColor(), getSize()]">{{letter}}</p>
|
<p [class]="[getColor(), getSize()]">{{ getEncodedLetter() }}</p>
|
||||||
|
@ -31,4 +31,8 @@ export class LetterComponent {
|
|||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getEncodedLetter() {
|
||||||
|
return this.letter.replace(' ', '\u00A0');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
It isn't true that my mattress is made of cotton candy.
|
|
||||||
Had he known what was going to happen, he would have never stepped into the shower.
|
|
||||||
You're good at English when you know the difference between a man eating chicken and a man-eating chicken.
|
|
||||||
The tart lemonade quenched her thirst, but not her longing.
|
|
||||||
People keep telling me "orange" but I still prefer "pink".
|
|
||||||
Her hair was windswept as she rode in the black convertible.
|
|
||||||
The water flowing down the river didn’t look that powerful from the car
|
|
||||||
Mom didn’t understand why no one else wanted a hot tub full of jello.
|
|
||||||
Everybody should read Chaucer to improve their everyday vocabulary.
|
|
||||||
It must be five o'clock somewhere.
|
|
||||||
He was 100% into fasting with her until he understood that meant he couldn't eat.
|
|
||||||
The sunblock was handed to the girl before practice, but the burned skin was proof she did not apply it.
|
|
||||||
The estate agent quickly marked out his territory on the dance floor.
|
|
||||||
If you like tuna and tomato sauce, try combining the two, it’s really not as bad as it sounds.
|
|
||||||
He said he was not there yesterday; however, many people saw him there.
|
|
||||||
Normal activities took extraordinary amounts of concentration at the high altitude.
|
|
||||||
The snow-covered path was no help in finding his way out of the back-country.
|
|
||||||
Instead of a bachelorette party
|
|
||||||
She opened up her third bottle of wine of the night.
|
|
||||||
I’m a living furnace.
|
|
||||||
The spa attendant applied the deep cleaning mask to the gentleman’s back.
|
|
||||||
She couldn't understand why nobody else could see that the sky is full of cotton candy.
|
|
||||||
Beach-combing replaced wine tasting as his new obsession.
|
|
||||||
The teenage boy was accused of breaking his arm simply to get out of the test.
|
|
||||||
Thirty years later, she still thought it was okay to put the toilet paper roll under rather than over.
|
|
||||||
As the asteroid hurtled toward earth, Becky was upset her dentist appointment had been canceled.
|
|
||||||
The old apple revels in its authority.
|
|
||||||
Too many prisons have become early coffins.
|
|
||||||
Despite what your teacher may have told you, there is a wrong way to wield a lasso.
|
|
||||||
Situps are a terrible way to end your day.
|
|
||||||
The lyrics of the song sounded like fingernails on a chalkboard.
|
|
||||||
Don't put peanut butter on the dog's nose.
|
|
||||||
Today we gathered moss for my uncle's wedding.
|
|
||||||
She wrote him a long letter, but he didn't read it.
|
|
||||||
He didn’t want to go to the dentist, yet he went anyway.
|
|
||||||
It was obvious she was hot, sweaty, and tired.
|
|
||||||
Smoky the Bear secretly started the fires.
|
|
||||||
If you don't like toenails, you probably shouldn't look at your feet.
|
|
||||||
His mind was blown that there was nothing in space except space itself.
|
|
||||||
The urgent care center was flooded with patients after the news of a new deadly virus was made public.
|
|
||||||
The fact that there's a stairway to heaven and a highway to hell explains life well.
|
|
||||||
Watching the geriatric men’s softball team brought back memories of 3 yr olds playing t-ball.
|
|
||||||
Chocolate covered crickets were his favorite snack.
|
|
||||||
Henry couldn't decide if he was an auto mechanic or a priest.
|
|
||||||
Various sea birds are elegant, but nothing is as elegant as a gliding pelican.
|
|
||||||
The thick foliage and intertwined vines made the hike nearly impossible.
|
|
||||||
The bird had a belief that it was really a groundhog.
|
|
||||||
She had some amazing news to share but nobody to share it with.
|
|
||||||
The light in his life was actually a fire burning all around him.
|
|
||||||
Two seats were vacant.
|
|
Loading…
x
Reference in New Issue
Block a user