How do I reference a dictionary in a word game? [duplicate]

I’m working on a JavaScript word game for my APCSP class, and I need to know how I can check to see if an inputted word is “real” or not. The game’s based off of BombParty (jklm.fun), which gives the user 2-3 letters and asks for a word containing those two letters.

Basically, I need two things: A way to upload an entire dictionary to my program, and a way to parse through that dictionary and see if it matches the word inputted. The first one is the most important right now, but I wouldn’t refuse any ideas on the second one, either.

Important note, I’m coding this all in CodeHS, so I’m not sure it’ll accept super in-depth JS functions, however it should take most things.

If anyone could offer some solutions or ideas, it would be appreciated. Thanks!

In Javascript, why is [somevar] considered an array?

In Javascript, the following declaration is from a text input:

numberInput = document.getElementById('number-input');

In HTML, “number-input” is this:

<input type="number" id="number-input" />

The numberInput variable is passed to a function like this:

function processInputs(list) 
  let total = 0;
  // add the items in list to a total
  for (const item of list) {
    total += item;
  }

Why does the statement processInputs([numberInput]) treat numberInput as an Array/NodeLIst ?

RegExp.test call influences subsequent string.matchAll [duplicate]

I found a strange behavior with javascript regular expressions in my vuejs project.

It seems like RegExp.test() somehow influences subsequent calls of string.matchAll.

Whenever I call test() before matching, some matches are missing in the result. What’s even stranger is, not ALL matches are missing, only some.

Here is a reproducible example on play.vuejs.org

Can somebody explain to me what’s going on here and how to circumvent this?

const DurationUnits = ['w', 'week', 'weeks', 'd', 'day', 'days', 'h', 'hour', 'hours', 'm', 'minute', 'minutes', 's', 'second', 'seconds', 'ms', 'millisecond', 'milliseconds', 'μs', 'microsecond', 'microseconds', 'ns', 'nanosecond', 'nanoseconds', 'ps', 'picosecond', 'picoseconds', 'fs', 'femtosecond', 'femtoseconds', 'as', 'attosecond', 'attoseconds', 'zs', 'zeptosecond', 'zeptoseconds', 'ys', 'yoctosecond', 'yoctoseconds', 'rs', 'rontosecond', 'rontoseconds', 'qs', 'quectosecond', 'quectoseconds']

// sort units longest first in order to correctly match 500ms as milliseconds (ms), not minutes (m)
const DurationUnitsSorted = [...DurationUnits].sort((a,b) => b.length-a.length)

const DurationRegexp = new RegExp(`(?<value>\d+(\.\d+)?)(?<unit>${DurationUnitsSorted.join('|')})`, 'g')

function parseDurationWithoutTest(duration) {
  if (typeof duration !== 'string') {
    console.warn('[parseDuration]', 'Invalid duration argument:', duration)
    return []
  }

  return duration.matchAll(DurationRegexp).toArray()
}

function parseDurationWithTest(duration) {
  if (typeof duration !== 'string' || !DurationRegexp.test(duration)) {
    console.warn('[parseDuration]', 'Invalid duration argument:', duration)
    return []
  }

  return duration.matchAll(DurationRegexp).toArray()
}

// works
const matchWithoutTest1 = parseDurationWithoutTest('123ns')
console.log('without test', matchWithoutTest1.map(o => o[0]))
const matchWithoutTest2 = parseDurationWithoutTest('1d 23h 30m 59s 500ms 123ns')
console.log('without test', matchWithoutTest2.map(o => o[0]))

// does not work
const matchWithTest1 = parseDurationWithTest('123ns')
console.log('with test', matchWithTest1.map(o => o[0]))
const matchWithTest2 = parseDurationWithTest('1d 23h 30m 59s 500ms 123ns')
console.log('with test', matchWithTest2.map(o => o[0]))

get how many backspaces with on single input event of type deleteContentBackward

We are making a complex text editor using a contentEditable DIV. On mobile, when virtual keyboard give a suggestion or autocorrects a word, a single input event is first called of type deleteContentBackward before inserting text. This single input event often erase more than one character in that context. How can we get the number of backward deletion of a single input event of type deleteContentBackward using javascript?

Here is the code we use to debug at the moment:

document.getElementById('INPUT').addEventListener('input', (event) => { console.log(event);   

document.getElementById('inputDebugDIV').innerHTML+="event.inputType:"+event.inputType; });

Run a bat-file from php js

I’ve tried to implement this code but unfortunately Nothing Happens when I click the button: Play example.

Here’s my code:

<script language="Javascript" type="text/javascript"> 
var wshShell = new ActiveXObject('WScript.Shell');
</script>

My PHP code includes:

echo "<input id='btnExplore' type='button' value='Play example' 
onclick='wshShell.Run('C:\tools\Play Example.bat');";

The Clipboard holds the correct adress to the source to play, like C:toolsexample.avi

I really would appreciate a comment from any of you.

Cheers, Torbjorn

TailwinddCSS issues [closed]

frontend/
│── dist/
│── node_modules/
│── public/
│   ├── favicon.ico
│   ├── index.html
│   ├── logo192.png
│   ├── logo512.png
│   ├── manifest.json
│   ├── output.css
│   ├── robots.txt
│── src/
│   ├── assets/
│   ├── components/
│   │   ├── FAQ.js
│   │   ├── Hero.js
│   │   ├── MajorSelect.js
│   │   ├── Navbar.js
│   │   ├── UploadButton.js
│   ├── pages/
│   │   ├── Pages.js
│   │   ├── Results.js
│   ├── App.js
│   ├── index.css
│   ├── index.js
│── .gitignore
│── .postcssrc.json
│── package-lock.json
│── package.json
│── README.md
│── tailwind.config.js

this is how my current directory is. I have been trying to resolve the issues, it has not been working. I have installed and reinstalled tailwindcss postcss config etc a lot of times it does not work. my node version is up to date. I want to build this webpage however. I think the issue lies with the new version of the tailwind. fix this issue please. search the web think deeply. do this. also basically I created my own tailwindconfig file and added this

module.exports = {
content: ["./src/**/*.{js,jsx,ts,tsx,html}"],
theme: {
extend: {},
},
plugins: [],
};

created my own .postcssrc.json file earlier postcssconfig file which i deleted

{
"plugins": {
"@tailwindcss/postcss": {}
}
}

have index.html and index.css

<link href="/output.css" rel="stylesheet" />
@tailwind base;
@tailwind components;
@tailwind utilities;

index.js

import "./index.css";
import React from "react";
import ReactDOM from "react-dom";
import App from "./assets/App";

ReactDOM.render(<App />, document.getElementById("root"));

‘render’ here is strikethrough also . none of this has worked. search the web think deeply and please help. u have my directory, tell me what to do.

always endups in this error:

ERROR in ./src/index.css (./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[5].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[5].use[2]!./node_modules/source-map-loader/dist/cjs.js!./src/index.css)

Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):

Error: It looks like you’re trying to use tailwindcss directly as a PostCSS plugin. The PostCSS plugin has moved to a separate package, so to continue using Tailwind CSS with PostCSS you’ll need to install @tailwindcss/postcss and update your PostCSS configuration.

at Oe (/Users/priyanshusinghal/Documents/WatCourse/watcourse/frontend/node_modules/tailwindcss/dist/lib.js:33:1925)

at LazyResult.runOnRoot (/Users/priyanshusinghal/Documents/WatCourse/watcourse/frontend/node_modules/postcss/lib/lazy-result.js:361:16)

at LazyResult.runAsync (/Users/priyanshusinghal/Documents/WatCourse/watcourse/frontend/node_modules/postcss/lib/lazy-result.js:290:26)

at LazyResult.async (/Users/priyanshusinghal/Documents/WatCourse/watcourse/frontend/node_modules/postcss/lib/lazy-result.js:192:30)

at LazyResult.then (/Users/priyanshusinghal/Documents/WatCourse/watcourse/frontend/node_modules/postcss/lib/lazy-result.js:436:17)

Here is an overview.

Project Overview:

You’re building a web application called WatCourse, which helps students check which major requirements they have met by uploading their unofficial transcript (PDF) and selecting their major.

The backend is built using FastAPI (Python), which parses the transcript and checks the major requirements.

The frontend is built using React with Tailwind CSS for styling and Framer Motion for animations.

You want a dark-themed, sleek UI with a navbar, a hero section with a tagline, an upload button, a major selection dropdown, a video/banner section explaining features, an FAQ section, and a results page displaying completed and pending requirements.

Current Issues:

Tailwind CSS Setup Issues:

You’re getting a postcss-loader error indicating that Tailwind’s PostCSS plugin has moved to a separate package (@tailwindcss/postcss).

You’ve tried reinstalling Tailwind, PostCSS, and related dependencies multiple times, but the error persists.

Your postcss.config.js file may not be correctly set up.

Project Structure & Dependencies:

Your frontend has a proper directory structure (src/components, src/pages, public/index.html, tailwind.config.js), but Tailwind isn’t working.

You installed dependencies using npm install -D tailwindcss postcss autoprefixer, but it’s still not working.

Running npx tailwindcss init did not work because Tailwind v4 changed the CLI commands.

React & Tailwind Integration Issues:

Your index.css correctly imports Tailwind (@tailwind base;, @tailwind components;, @tailwind utilities;), but Tailwind is not being processed.

index.js is using ReactDOM.render(), but it’s deprecated in newer React versions.

I have done everything except the frontend. tell me what I can do, anything else you need

Object is returning empty has some properties on expand it shows

I’m getting response as empty by checking Object.keys(response) it returns empty array but on expanding the response it looks like what shown below. Can someone help me to understand this?

This is the response:
Response {type: 'basic', url: 'https://us-west-2/fd…d=4ed89588-409a-4b5a-9d32-b04665818797&v=2.332.19', redirected: false, status: 400, ok: false, …}body: (...)bodyUsed: falseheaders: Headers {}ok: falseredirected: falsestatus: 400statusText: ""type: "basic"url: "https://us-west-2.e2e./fdx/v2/accounts/2a8eb2ce-cf2f-4301-b730-c09f7dd57fa4?authType=ofx2&consentAgreed=false&consentForReauth=false&country_code=US&flowId=c0be9de2-1034-4826-9f83-4b2d9e69b181&flow_name=EditConnection&intuit_apikey=preprdakyresw7JPdK9pAVi7FwnK41H8sw1W47M2&intuit_offeringid=&=fde0bdf6-6a94-4af9-834e-d17509db1aa9&isRealmContext=false&isTestReCaptcha=true&locale=en_US&providerId=4ed89588-409a-4b5a-9d32-b04665818797&v=2.332.19"[[Prototype]]: Response

Issue with jQuery library scanner detection

hope you are doing fine

I’m using jQuery Scanner detection Version: 1.2 library in my web application but I’m having some issues, I made 2 barcodes, one with the word “SENSOR” and works without any issue and the other one with the word “PEEK” and that one is not being detected by the library as correct, I’m getting the onError code

$("#txt_partNo").scannerDetection({
    timeBeforeScanTest: 200, // Tiempo para distinguir entre tecleo y escaneo
    avgTimeByChar: 30,      // Tiempo promedio por carácter de un escáner
    onComplete: function (barcode, qty) {
        getPartData(barcode);
    },
    onError: function () {
        alert("Error: Por favor, usa un escáner válido.");
        $('#txt_partNo').val('');
    }
});

I’ve already tried give super high parameters on timeBeforeScanTest and avgTimeByChar but still don’t works when I scan “PEEK”

Have you face the same issue?
Hope you can help me

Regards!

Reducing the Docker image size of Next.js in a Turborepo

I have set up a Turborepo with a Next.js application (admin-frontend) and three packages:

  • eslint-config
  • typescript-config
  • ui

All three packages are used within the Next.js application.

After building my Docker image, it has a size of around 850MB, which seems quite large to me. Am I unintentionally copying unnecessary files, or am I not following the correct Turborepo workflow, which might be inflating the image size?

This is the Dockerfile of the next.js application

FROM node:20-alpine AS base

# Prune project
FROM base AS prune
WORKDIR /app
RUN npm install -g turbo
COPY . .
RUN turbo prune @project/admin-frontend --docker

# Install dependencies
FROM base AS installer
WORKDIR /app
COPY --from=prune /app/out/json/ .
RUN npm install

# Install production dependencies
FROM base AS installer-production
WORKDIR /app
COPY --from=prune /app/out/json .
RUN npm install --only=production

# Build the project
FROM base AS builder
WORKDIR /app
COPY --from=installer /app/node_modules /app/node_modules
COPY --from=prune /app/out/full/ .
RUN npx turbo build --filter=@project/admin-frontend 

# Final image
FROM base AS runner
WORKDIR /app
COPY --from=installer-production /app/node_modules /app/node_modules
COPY --from=builder  /app/apps/admin-frontend/package.json /app/apps/admin-frontend/
COPY --from=builder  /app/apps/admin-frontend/.next /app/apps/admin-frontend/.next

WORKDIR /app/apps/admin-frontend

CMD ["npm", "run", "start"]

This is the package.json of the next.js application:

{
  "name": "@project/admin-frontend",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "dotenv -e .env -- next dev --turbopack",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@project/ui": "*",
    "next": "15.2.3",
    "react": "^19.0.0",
    "react-dom": "^19.0.0"
  },
  "devDependencies": {
    "@eslint/eslintrc": "^3",
    "@project/eslint-config": "*",
    "@project/typescript-config": "*",
    "@tailwindcss/postcss": "^4",
    "@types/node": "^20",
    "@types/react": "^19",
    "@types/react-dom": "^19",
    "dotenv-cli": "^8.0.0",
    "eslint": "^9",
    "eslint-config-next": "15.2.3",
    "tailwindcss": "^4",
    "typescript": "^5"
  }
}

If I run du in /app/apps/admin-frontend inside the container, I get the following output.

12  ./.next/diagnostics
12  ./.next/static/css
96  ./.next/static/media
8   ./.next/static/chunks/app/_not-found
20  ./.next/static/chunks/app
12  ./.next/static/chunks/pages
796 ./.next/static/chunks
12  ./.next/static/_eCz52W9GGEyf7Z-bojwC
920 ./.next/static
12  ./.next/types/app
28  ./.next/types
8   ./.next/cache/eslint
4   ./.next/cache/swc/plugins/v7_linux_aarch64_8.0.0
8   ./.next/cache/swc/plugins
12  ./.next/cache/swc
12  ./.next/cache/webpack/edge-server-production
22208   ./.next/cache/webpack/client-production
15416   ./.next/cache/webpack/server-production
37640   ./.next/cache/webpack
37668   ./.next/cache
348 ./.next/server/chunks
20  ./.next/server/app/_not-found
72  ./.next/server/app/favicon.ico
212 ./.next/server/app
48  ./.next/server/pages
660 ./.next/server
39536   ./.next
39544   .

Something Wrong With The Calculator

i’m coding a calculator by using html, css and javascript. majority of my buttons work except when i push a number, then push add, divide, minus or times, then try and push a number, the numbers do not want to work. im not to sure where i am going wrong. here is my javascript code

it has something to do with my input code i believe as the codes was working before the bit of the code was change around

function equivalentCheck() { //This allows the last value to remain in view until other buttons are pressed
    if(parseInt(document.getElementById('equivalent').value)){
        document.getElementById('equivalent') = 0;
        document.getElementById('result').value = 0;
    }
}

function input(x) {
    equivalentCheck();

    let y = parseFloat(document.getElementById('result').value);
    if(document.getElementById('decimalVar').value == 0) {
        x += y * 10; //Multiply the text input and add the value of x.

        document.getElementById('result').value = x; //Return x to the text output
    } 
    else {//If decimal is true
        let decimalCount = parseInt(document.getElementById('decimalVar').value);

        if(decimalCount == 1) {
            x *= 1/10; //We are using math to place the decimal point.
            y += x;
            document.getElementById('result').value = y;
        }
        else {
            document.getElementById('result').value += x;
        }

        decimalCount++;

        document.getElementById('decimalVar').value = decimalCount;

    }
}

function decimalPoint() {
    if(document.getElementById('decimalVar').value == 0){//This Prevents Multiple Decimal
        document.getElementById('decimalVar').value = 1;
    }
    if (parseInt(document.getElementById('operation').value)) {//If This Is An Empty String,It Wil Return False  
        document.getElementById('result').value = 0;
    }
}

function operandCheck() {
    if(document.getElementById('operand').value == ""){
        
        document.getElementById('operand').value = document.getElementById('result').value;
        document.getElementById('equivalent').value = 1;
    } else {
        operatorCheck();
    }
}

    function operatorCheck() {
        let a = parseFloat(document.getElementById('operand').value);
        let b = parseFloat(document.getElementById('result').value);

        switch (parseInt(document.getElementById('operation').value)) {
            case 1: //addition
                a += b;
                break;

            case 2: //subraction
                a -= b;
                break;

            case 3: //multiplcation
                a *= b;
                break;

            case 4: //division
                a /= b;
        }


        document.getElementById('operand').value = a;
        document.getElementById('result').value = a;
        document.getElementById('equivalent').value = 1;

    }

function operators(x) {
    switch(x) {
        case 1:
            document.getElementById('operation').value = 1;//Addition
            break;
        case 2:
            document.getElementById('operation').value = 2;//Subtraction
            break;
        case 3:
            document.getElementById('operation').value = 3; //Multiplcation
            break;
        case 4:
            document.getElementById('operation').value = 4; //Division
            break;
        default:
    }

    operandCheck();
}

function equals() {
    operators(parseInt(document.getElementById('operation').value));
    document.getElementById('result').value = document.getElementById('operand').value;
    document.getElementById('operand').value ="";
    document.getElementById('equivalent').value = 1;
}

function allClear(){
    document.getElementById('result').value = 0;
    document.getElementById('operand').value = "";
    document.getElementById('operation').value = 0;
    document.getElementById('equivalent').value = 0;
}

function plusminus(){
    let x = parseFloat(document.getElementById('result').value);
    x *= -1;
    document.getElementById('result').value = x;
}

function percent() {
    let x = parseFloat(document.getElementById('result').value);
    x *= 0.01;
    document.getElementById('result').value = x;
}

function square() {
    let x = parseFloat(document.getElementById('result').value);
    x *= x;
    document.getElementById('result').value = x;
}

How to keep fullscreen mode active on a TV dashboard that updates every 5 seconds in JavaScript?

I have a dashboard that updates every 5 seconds, and it’s displayed on a TV. I implemented a fullscreen toggle button using JavaScript, but every time the page refreshes or the content updates (using location.reload() or fetch()), the page exits fullscreen mode. This is problematic because I need the fullscreen mode to stay active during these automatic updates, without the need for manual intervention.

The main issue is that when the content is updated or the page is refreshed, the fullscreen state is lost, even though the content is updated dynamically.

I tried using localStorage to store the fullscreen state and also used fetch() to update the content dynamically without reloading the page. Here’s the code I’m using to toggle fullscreen:

   <script>
        document.getElementById("botao").addEventListener("click", function() {
            if (!document.fullscreenElement) {
                document.documentElement.requestFullscreen();
                localStorage.setItem("fullscreen", "true");
            } else {
                document.exitFullscreen();
                localStorage.setItem("fullscreen", "false");
            }
        });

        // Atualiza a página a cada 5 segundos sem sair do fullscreen
        setTimeout(function() {
            if (localStorage.getItem("fullscreen") === "true") {
                location.reload();
                setTimeout(() => {
                    document.documentElement.requestFullscreen();
                }, 500);
            } else {
                location.reload();
            }
        }, 5000);
    </script>

I expected that after the content was updated or the page refreshed, the fullscreen mode would remain active, preserving the state even during content changes. However, the fullscreen mode is lost after each update or refresh.

Can you add a header to an html page using javascript?

I have a static html page that incorporates a <frame>.

If I start things up locally with an npm run start, the static html page displays fine.

The front end of this app needs to run against Spring Boot, though.

And when I start the front end up in Spring Boot, I get the following error when I try to display the html page:

Refused to display 'http://localhost:4200/' in a frame because it set 'X-Frame-Options' to 'deny'.

I know that I’m not explicitly setting X-Frame-Options to deny anywhere – but I thought maybe I could explicitly set it to sameorigin by doing something like this:

<script type="text/javascript" language="javascript">

    add_header "X-Frame-Options" "SAMEORIGIN";
    var strHTML = "<frameset rows="32,*"> <frame src="whskin_tbars.htm"></frame></frameset>";   
    document.write(strHTML);

</script>

Any suggestions?

Thanks much.

Why is my server not logging a login session?

For some context: I’m trying to make a basic login system. At the moment, signing up works with no problems. Logging in also seems to be okay, it makes a connection with the database properly – however, the big problem is that the login itself is not saved/recognized. I see no cookie or anything else that would indicate that the server is recognizing the login. I’m working in NodeJS, and the backend is hosted on my VPS (running Ubuntu). Trying to get some advice from ChatGPT didn’t really help out unfortunately.
I have two endpoints mainly used for logging in. One is called api/login and the other is api/auth-check. api/login returns a 200 OK, with the response of {"success":true}. api/auth-check on the other hand returns a 304 not modified, and returns a {"loggedIn":false}. I made sure to check in my frontend code that any fetch being done towards api/auth-check and api/login includes credentials: 'include'.

The reason why I need a session/cookie and for the server to remember the login is because I want to make the login & signup buttons disappear when a user logs in, and instead display “logout” and some other text. It also has to do with some other logic that I’m doing on the site which requires the user to be logged in to perform certain functions/tasks.