alloneword! #176451
Replies: 7 comments
-
|
hey scotty, had a look, man this stuff can be a headache for sure. your code actually looks fine, that regex i think whats happening is your script is doing its job perfectly, it's taking the text, cleaning it all up, and putting it in that so the script runs, the you need to grab an element on your page and stuff your new text into it. so in your html you could have something like
that tells the browser "hey find the thing with the id 'result-text' and put my new clean hope that helps mate, pretty sure thats your issue. |
Beta Was this translation helpful? Give feedback.
-
|
Try this instead of your start() `function start(){ } |
Beta Was this translation helpful? Give feedback.
-
|
Hello, I appreciate your help, yep, I will be on to it tomorrow for sure
now, gave up on today, kindest regards. Scotty.
https://theoriginalalloneword.com.au
…On Fri, 10 Oct 2025, 5:20 pm Victor Johnson, ***@***.***> wrote:
Try this instead of your start()
`function start(){
setUpButtons();
// Keep the original text for reference
var rawText = gameText;
var cleanText = gameText
.toLowerCase()
.replace(/[^a-z0-9]/g, ''); // build the "alloneword" version
var realLoc = 0;
for (var i = 0; i < rawText.length; i++) {
var ch = rawText[i];
if (ch === " ") {
loc.push({ type:"Space", ch:" ", help:"You needed a space here", loc:realLoc });
} else if (ch === ".") {
loc.push({ type:"FullStop", ch:".", help:"You need a full stop", loc:realLoc });
} else if (ch === ",") {
loc.push({ type:"Comma", ch:",", help:"You need a comma", loc:realLoc });
} else if (ch === "'") {
loc.push({ type:"Quote", ch:"'", help:"You need to add a quote", loc:realLoc });
} else if (ch === "?") {
loc.push({ type:"QuestionMark", ch:"?", help:"You need a question mark", loc:realLoc });
} else if (ch === "!") {
loc.push({ type:"ExclamationMark", ch:"!", help:"You need an exclamation mark", loc:realLoc });
} else if (ch.toUpperCase() === ch && ch.match(/[A-Z]/)) {
loc.push({ type:"Capital", ch:ch, help:"You need to capitalise", loc:realLoc });
newText += ch.toLowerCase();
realLoc += 1;
} else if (ch.match(/[a-z0-9]/i)) {
newText += ch.toLowerCase();
realLoc += 1;
}
}
// Display the clean text (no punctuation)
theText.textContent = cleanText;
setTimeout(displayFlash, 1000);
help.innerHTML = "Fix this alloneword text using the buttons below.";
}
`
—
Reply to this email directly, view it on GitHub
<#176451 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQ5KIVJT5GRN3JKNW7QUACT3W524NAVCNFSM6AAAAACI2CO5TSVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTINRUGU2TENI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
I really appreciate it, I will definitely be on to it tomorrow, gave up on
today. Kindest regards Scotty
https://theoriginalalloneword.com.au
…On Fri, 10 Oct 2025, 5:20 pm Victor Johnson, ***@***.***> wrote:
Try this instead of your start()
`function start(){
setUpButtons();
// Keep the original text for reference
var rawText = gameText;
var cleanText = gameText
.toLowerCase()
.replace(/[^a-z0-9]/g, ''); // build the "alloneword" version
var realLoc = 0;
for (var i = 0; i < rawText.length; i++) {
var ch = rawText[i];
if (ch === " ") {
loc.push({ type:"Space", ch:" ", help:"You needed a space here", loc:realLoc });
} else if (ch === ".") {
loc.push({ type:"FullStop", ch:".", help:"You need a full stop", loc:realLoc });
} else if (ch === ",") {
loc.push({ type:"Comma", ch:",", help:"You need a comma", loc:realLoc });
} else if (ch === "'") {
loc.push({ type:"Quote", ch:"'", help:"You need to add a quote", loc:realLoc });
} else if (ch === "?") {
loc.push({ type:"QuestionMark", ch:"?", help:"You need a question mark", loc:realLoc });
} else if (ch === "!") {
loc.push({ type:"ExclamationMark", ch:"!", help:"You need an exclamation mark", loc:realLoc });
} else if (ch.toUpperCase() === ch && ch.match(/[A-Z]/)) {
loc.push({ type:"Capital", ch:ch, help:"You need to capitalise", loc:realLoc });
newText += ch.toLowerCase();
realLoc += 1;
} else if (ch.match(/[a-z0-9]/i)) {
newText += ch.toLowerCase();
realLoc += 1;
}
}
// Display the clean text (no punctuation)
theText.textContent = cleanText;
setTimeout(displayFlash, 1000);
help.innerHTML = "Fix this alloneword text using the buttons below.";
}
`
—
Reply to this email directly, view it on GitHub
<#176451 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQ5KIVJT5GRN3JKNW7QUACT3W524NAVCNFSM6AAAAACI2CO5TSVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTINRUGU2TENI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
|
G'day Victor, I hope you are well, I think I've confused myself. The script
files are https://theoriginalalloneword/scriptvic.js /scriptcqa.js &
scriptcqae.js
I got about 4 replies and you are the only person that sent a wee-bit of
code to try. I may have confused myself with the rawText gameText and
cleanText and what day is it again?
I say, there's 37 different punctuation and keyboard characters that can be
added to text, I'm better to have 1 script with buttons, Capitalise Next
character Space & Full stop being used for almost every if not every text,
and a second script for the other four buttons. That would make it 9-10
scripts? When remembering which script I'm using c for Comma, q for
Question, a for Apostrophe, e for Exclamation, if the text I add has a
punctuation in another script, can i now have three scripts?
I think 8 buttons is the right amount.
I'm in Perth WA, it's Sunday afternoon and I'm going to spend time trying
things out.
Scotty.
https://theoriginalalloneword.com.au
…On Fri, Oct 10, 2025 at 5:20 PM Victor Johnson ***@***.***> wrote:
Try this instead of your start()
`function start(){
setUpButtons();
// Keep the original text for reference
var rawText = gameText;
var cleanText = gameText
.toLowerCase()
.replace(/[^a-z0-9]/g, ''); // build the "alloneword" version
var realLoc = 0;
for (var i = 0; i < rawText.length; i++) {
var ch = rawText[i];
if (ch === " ") {
loc.push({ type:"Space", ch:" ", help:"You needed a space here", loc:realLoc });
} else if (ch === ".") {
loc.push({ type:"FullStop", ch:".", help:"You need a full stop", loc:realLoc });
} else if (ch === ",") {
loc.push({ type:"Comma", ch:",", help:"You need a comma", loc:realLoc });
} else if (ch === "'") {
loc.push({ type:"Quote", ch:"'", help:"You need to add a quote", loc:realLoc });
} else if (ch === "?") {
loc.push({ type:"QuestionMark", ch:"?", help:"You need a question mark", loc:realLoc });
} else if (ch === "!") {
loc.push({ type:"ExclamationMark", ch:"!", help:"You need an exclamation mark", loc:realLoc });
} else if (ch.toUpperCase() === ch && ch.match(/[A-Z]/)) {
loc.push({ type:"Capital", ch:ch, help:"You need to capitalise", loc:realLoc });
newText += ch.toLowerCase();
realLoc += 1;
} else if (ch.match(/[a-z0-9]/i)) {
newText += ch.toLowerCase();
realLoc += 1;
}
}
// Display the clean text (no punctuation)
theText.textContent = cleanText;
setTimeout(displayFlash, 1000);
help.innerHTML = "Fix this alloneword text using the buttons below.";
}
`
—
Reply to this email directly, view it on GitHub
<#176451 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQ5KIVJT5GRN3JKNW7QUACT3W524NAVCNFSM6AAAAACI2CO5TSVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTINRUGU2TENI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
Hi @ocpscotty 👋 This part:
means “replace anything that is not a lowercase letter or number with nothing,” so it should remove exclamation marks. If ! is still appearing, that usually means one of two things: The code that displays the text (gameText or another function) is re-adding punctuation afterward, or The .replace() isn’t being applied to the same text that’s shown on the page. To be sure, try logging it right after replacement: If the console output has no !, then your regex works, and the issue is later in how text is rendered. Optional: You can also simplify the regex a little:
\W removes everything that’s not a letter, number, or underscore. Hope that helps — your idea is fun! 👍 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Body
Hello, this is my first time asking for help, it's taken me three days to get here, I've added material to a repository, essentially a Javascript, that takes any passage of text, removes capitals, spaces and punctuation presenting an alloneword piece of text: https://theoriginalalloneword.com.au/scriptcqae.js
function start(){
setUpButtons();
var text = gameText.toLowerCase()
.replace(/[^a-z0-9]/g, '');
and a html page asking for users to fix the alloneword text as per the original text. https://theoriginalalloneword.com.au/A1WXTESTTEMPCQAE.html
You can see there's an exclamation mark; but there shouldn't be.
Any advice would be helpful. Scotty.
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions