Limit pasted words in multiple text area fields? - javascript

I'm a complete novice in JavaScript, so please forgive my ignorance. I've worked on this for several days, but it's beyond my skill level.
Please, could someone help me implement into this specific script: https://stackoverflow.com/a/11228092, something that limits words in each text area when pasted, too?
The script limits correctly when typing, but pasting sneaks past the word limit. To emphasize for clarity, I do mean counting words rather than characters.
I've tried looking at other methods, but they either limit characters rather than words, don't seem to apply to multiple, differing teaxtarea fields, or I just don't understand enough to implement them properly.
Thanks for any help anyone can give!

Related

Discord.js chinese characters appearing as boxes?

I have been working on a bot, it displays information, which includes names. Often these names are entirely/include Chinese characters. Whenever they do, they are converted into boxes or random characters. This sorta break the bot completely as it means you cant tell what box box symbol box means. I assume this is not only Chinese characters, I just haven't come across any others so far.
Looked it up on google, different phrases but found nothing even related to it on discord.js.
Any help would be greatly appreciated :D
Low quality and small ik..

how to match continuous string input to passage in javascript, while showing mistakes?

Hey guys I am working on an application and so far its going well but while working on a recent features i am a little stuck.
Here is my problem:
using java script I am getting continuous user speech input and transcribing it. While I am getting this speech input i want to be able to identify and highlight the text on the screen that is being read. I want to highlight mistakes (words spoken that don't match) and I want to highlight all the content that is going correct.
I am not asking for someone to code this for me, i just want to be pointed in the right direction.
A similar implementation you have probably seen is in online typing games. where you try to type parts of a passage as fast as possible and it highlights the ones you are getting right and the ones that you are getting wrong.
Any help is appreciates, libraries, algorithms, methods, or terms I should search. Thank you !
Are you indexing the text at all? Do you know the text in advance? If you created an in memory graph database using each word in the text, you could search edges to find 'weighted' hits. It's ambitious, but there's an article here:
https://graphaware.com/neo4j/2016/07/07/mining-and-searching-text-with-graph-databases.html
If you want to go dirt simple and follow your typing game analogy:
In the typing game an event is fired each input (keypress).
The key pressed is compared to the expected one.
If it is not correct it is flagged as wrong.
There is usually no way to go back and correct the mistakes.
The user has to type the next expected letter correctly to
get things rolling correctly again.
You could do the same thing.
Underline the next expected word.
Each word (whitespace) is an event.
Match the text to speech word to the expected word.
If it is not right, flag it as wrong, strike it out.
The user has to say the next underlined word correctly to start things going smoothly again.
You could allow the user to back space the expected word so he/she could start over where they wanted to.
This will have some hiccups, as all things speech to text do, but it will work like your typing game and be simple to implement.

Javascript read time word count textarea

This question is based on Trouble getting real time word count from html textbox.
I am also fairly new to Javascript, and would please like some help in understanding the examples presented on this page. There are multiple lines in the code, in the different examples that have a "text area" tag, yet there is only one text area on the screen. Is this correct?
What I am looking to do is to have multiple text areas on the page, all of which will feed into another page via a form (this part I understand). But, I only want one of the boxes to have the real time word count.
Can someone please assist? Thanks.

text string / word cloud ignore line break symbol

I have an implementation of the popular d3 word cloud. It has been working great for documents that are very lengthy, but I have been having an issue when I tried to re-purpose the word cloud to visualize a very simple txt file of the following format:
interesting. interesting. interesting.
boring. boring.
amazing. amazing. amazing.
stupid. stupid. stupid.
average. average.
disappointing.
(ect...)
It's basically just a txt file that has around 20 words. Each word repeats anywhere from 1 to 5 times. I would like this information to govern the sizing of the font (repeated 5 times = big font, 1 time = small font). When I put all the words on the same line, the resulting word cloud strangely makes all words the same font size. So I started to play around with it and tried a few different things. The closest I got to the desired effect was with the above txt format, having a line break after each new word.
This did result in the correct font sizing, but it also created a new problem. When I passed word_count object to the console log, I got something like this:
"⏎boring":1,
"boring":1,
"⏎stupid":1,
"stupid":2,
This means that the word cloud has repeated words in the visual (for example, the word "stupid" in large font size and also "stupid" in small font size). To make things more confusing, this behavior was isolated to a few words. Some words did not have the line break sign in front of them (even though I still hit enter in notepad when I made the txt in the same exact was as the ones that did wind up with the ⏎ sign.)
My next stab at fixing this was to add the "⏎" sign to the list of ignored words, hoping that would make the word cloud library treat them as if they were the same. Unfortunately for me, the problem persisted.
That sums it up pretty well; it's also really easy to reproduce, just need notepad and copy and paste my above words to see what I'm talking about.
Let me know if anyone has ideas for troubleshooting further.
Minimalist Block:
https://bl.ocks.org/diggetybo/cd644316f52465495f39c8fc27f04de8
(refreshing page will randomize the layout)

Syntax Highlighter Numbering off and Closing List<Object> "tags"

This is kind of weird. I'm trying to get my code up on my website using Syntax Highlighter. I've come up against two weird problems.
1 - Code lines are off, in some cases worse than others
2 - Syntax Highlighter wants to close what it thinks are xml / html tags. If you go to the following link and look at the numbers and the bottom of the screen, you'll know what I mean.
http://kentcdodds.com/projectsamples/BankGUI/GUI.html
I'm not sure what's wrong. But I also just noticed it changed my capital S on String to a lower case s. I'm developing a program in Java to add all the html necessary before and after each of my .java files for my school projects this last year so I can put the code up for the world to see and hopefully help. So if I could get some help from someone with this Syntax Highlighter problem, that would be great.
It seems as though there is no real solution using this technology. So the best I can do is say hard-code changes for when String goes to lowercase and don't use line numbers. I'm sorry if this isn't helpful for people in the future. You might try one of these alternatives.

Categories

Resources