close different browser tabs from one application

I have 2 applications where App2 is accessible when we click on a link in App1.
Each time this link is clicked, a new browser tab is opened containing App2.

Now I have a requirement where upon logout of App1, all the instances (tabs) opened for App2 should be closed.

I tried capturing window objects of App2. And thought of using winObj.close() to close each one of them with a loop. But the problem is that how and where can I capture window Objects ? (I need to get those objects when user clicks on logout).

I tried in cookie and localStorage by using
localStorage.setItem('app2Window', JSON.stringify(window))
but JSON.stringify(window) gives me following error:

Uncaught TypeError: Converting circular structure to JSON
–> starting at object with constructor ‘Window’
— property ‘window’ closes the circle
at JSON.stringify ()
at :1:41

Any help/pointers towards this problem will be appreciated.

How do I correctly handle this table with multiple embedded form rows in vue?

I have this table where I loop through data from the backend. One of the rows contain a form with hidden input fields.

The table displays properly but the input fields are not bound to the form.

This is the SFC for the page:

<template>
    <jet-action-section>
        <template #title>
            Pending Bills
        </template>

        <template #description>
            A list of all pending payments.
        </template>

        <template #content>
            <h3 class="text-sm font-medium text-gray-900 dark:text-gray-200" v-if="pendingBills.length > 0">
                Pending Payments.
            </h3>

            <div class="mt-3 max-w-xl text-sm text-gray-600 dark:text-gray-300" v-if="pendingBills.length > 0">
                <div class="p-6 overflow-x-auto">
                    <table class="w-full whitespace-nowrap">
                        <tr class="text-left font-bold text-white">
                            <th class="bg-blue-500 border-4 p-2 rounded">Payment Description</th>
                            <th class="bg-blue-500 border-4 p-2 rounded">Amount</th>
                            <th class="bg-blue-500 border-4 p-2 rounded">Action</th>
                        </tr>
                        <tr v-for="(bill, index) in pendingBills" :key="bill.id" class="text-gray-700 dark:text-gray-200 hover:bg-blue-200 dark:hover:bg-blue-300 focus-within:bg-blue-100">
                            <td class="border-2 p-2">{{ bill.message }}</td>
                            <td class="border-2 p-2">₦{{ bill.amount }}</td>
                            <td class="border-2 p-2" :id="bill.id">
                                <form @submit.prevent="payPerformanceFee(index)">
                                    <input id="amount" type="hidden" v-model="form.amount" />
                                    <input id="goal_id" type="hidden" v-model="form.goal_id" />
                                    <div class="flex items-center justify-end mt-4">
                                        <jet-button class="ml-4" :class="{ 'opacity-25': form.processing }" :disabled="form.processing">
                                            Pay Performance Fee
                                        </jet-button>
                                    </div>
                                </form>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            <h3 class="text-sm font-medium text-gray-900 dark:text-gray-200" v-else>
                Payments you're yet to pay will show up here.
            </h3>
        </template>
    </jet-action-section>
</template>

<script setup>
import { computed } from 'vue'
import JetActionSection from '@/Jetstream/ActionSection.vue'
import Pagination from '@/Jetstream/Pagination.vue'
import JetButton from '@/Jetstream/Button.vue'
import { useForm , usePage} from '@inertiajs/inertia-vue3'


defineProps({pendingBills: Object})

const bills = computed(() => usePage().props.value.pendingBills)
console.log(bills.value) //this returns all the data from the backend

bills.value.forEach((value, index) => {
    const amount = value.amount
    const goal_id = value.goal_id
    console.log(goal_id) //this gives the expected values
    console.log(amount) //this gives the expected values
})

const form = useForm({
    amount: bills.value.amount, //this show up as undefined in vue dev tools
    goal_id: bills.value.goal_id //this show up as undefined in vue dev tools
    
})

function payPerformanceFee(index) {
    form.post(route('pending.bill'))
}
</script>

The page displays like this: Page screenshot

When I click on the button, it hits the backend with no data.

What I’m trying to achieve is to map amount and goal_id values to the corresponding inertia form so that the data is sent to the backend when the button is clicked. Obviously only one button can be clicked at a time.

I got stuck at the foreach loop. I don’t know how to pass each loop cycle data to the inertia form or if I’m going about this the correct way.

React components displays on each other

I’m making my portfolio website with Reactjs + tailwind and i have a problem in components in the page

the footer always displays on the other elements in responsive

for example :

enter image description here

Here is the Footer Component

import React from "react";
import { FaLinkedin } from "react-icons/fa";
import { SiGmail } from "react-icons/si";
import { VscGithub } from "react-icons/vsc";

export default function Footer() {
  return (
    <footer className="pt-9">
        <div className="flex flex-col m-auto justify-between w-[192px] h-[102px]">
          <div className="flex justify-between">
            <a target="_blank" href="https://github.com/Ali-Eldeba">
              <VscGithub className="cursor-pointer text-[2rem] text-[#333] transition ease-in-out hover:scale-125 hover:rotate-[10deg] dark:text-white" />
            </a>
            <a target="_blank" href="https://www.linkedin.com/in/alieldeba/">
              <FaLinkedin className="cursor-pointer text-[2rem] text-[#0077b5] transition ease-in-out hover:scale-125 hover:rotate-[5deg]" />
            </a>
            <a target="_blank" href="mailto:[email protected]">
              <SiGmail className="cursor-pointer text-[2rem] text-red-500 transition ease-in-out hover:scale-125 hover:rotate-[5deg]" />
            </a>
          </div>
        </div>
        <p className="text-center dark:text-white mt-[-3rem]">
          Made with <span className="text-red-500">❤</span> by alieldeba &copy;
          {new Date().getFullYear()}
        </p>
    </footer>
  );
}

How to i do an age calculator in JS

im making a js app that ask for your age an integer and tells you what generation you are i Think i need to take each generation and but each generation age in an array then use if else to print the right generation name, am I on the right track as far as thinking

i want the input taken to be the age i have the arrays but now idk what to do with them

const Alpha = [1,2,3,4,5,6,7,8,9,]
const Genz = [10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]
const Mill = [26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,]
const boom = [42]

I am trying to get a setTimeout on my Preloader so it shows for more than just a split second

Can anyone tell me what I’m doing wrong in my code below? The timeout isn’t working – my page is just showing in a split second. Thanks in advance

<body onload=myFunction()>
  <div id="loading"></div>
</body>
var preloader = document.getElementById("loading");

window.addEventListener('load', function() {
  preloader.style.display = 'none';
})

function myFunction() {
  setTimeout(function() {
    preloader.style.display = 'none';
  }, 5000)
};

I am trying to get my Javascript to cooperate and open my hamburger icon with my links inside

Here is the code I am trying to get to cooperate with one another. I just need my Javascript to help in opening my hamburger icon menu. Currently, my hamburger icon works. It will create an “x” when clicked on, but it’s just that my menu does not display when I click on the hamburger icon as it should.


* JAVASCRIPT *

export const navAnimation = function () {
    const hamburgerDiv = document.querySelector(".nav--hamburger");
    const hamburgerIcon = document.querySelector(".hamburger");
    const nav = document.querySelector(".nav--ul");
    const blur = document.querySelector(".blur");

    hamburgerDiv.addEventListener("click", () => {
        // nav.classList.toggle("hidden");
        hamburgerIcon.classList.toggle("hidden");
        cross.classList.toggle("hidden");
        nav.classList.toggle("move-in");
        nav.classList.toggle("move-out");
        // blur.classList.toggle("hidden");
        blur.classList.toggle("move-in");
        blur.classList.toggle("move-out");
    });
};

navAnimation();

// Hamburger Icon //
$(document).ready(function(){
    $('#nav-icon1,#nav-icon2,#nav-icon3,#nav-icon4').click(function(){
        $(this).toggleClass('open');
    });
});


* HTML *

 <header class="header">
            <div class="blur move-out"></div>
            <div class="header--logo">
                <img src="images/Logo-2.png" alt="Site logo" class="logo"/>
            </div>
            <nav class="nav">
                <div class="nav--hamburger">
                    <div id="nav-icon1" class = "hamburger">
                        <span></span>
                        <span></span>
                        <span></span>
                      </div>
                </div>
                <ul class="nav--ul move-out">
                    <li class="nav--li--item">
                        <a class="nav--li--anchor" href="#home">
                            <span class="order"></span>HOME
                        </a>
                    </li>
                    <li class="nav--li--item">
                        <a class="nav--li--anchor" href="#about">
                            <span class="order"></span>ABOUT
                        </a>
                    </li>
                    <li class="nav--li--item">
                        <a class="nav--li--anchor" href="#services"
                            ><span class="order"></span>SERVICES
                        </a>
                    </li>
                    <li class="nav--li--item">
                        <a class="nav--li--anchor" href="booking">
                            <span class="order"></span>BOOKING
                        </a>
                    </li>
                    <li class="nav--li--item">
                        <a class="nav--li--anchor" href="#footer">
                            <span class="order"></span>CONTACT US
                        </a>
                    </li>
                </ul>
            </nav>
        </header>

Exporting object keys individually

I want to mock fs in vitest using memfs. And for that I created a mock file ./__mocks__/fs.ts and set up the mocked volume and fs.

However, I cannot get the mocked export to work properly. I always get TypeError: readdirSync is not a function.

What is the correct way to export this?

__mocks_/fs.ts:

// fs.ts
import { createFsFromVolume, Volume } from "memfs"

const musicFolder = "./musicFolder"
const files = {
  "./1.mp3": "1",
  "./2.mp3": "2",
}

const volume = Volume.fromJSON(files, musicFolder)

const fs = createFsFromVolume(volume)

export { fs } // This does not work

Test file:

// test.spec.ts
import { describe, expect, it, vi } from "vitest"
import * as fs from "fs"

vi.mock("fs")

it("testing fs", async () => {
  const files = fs.readdirSync("./musicFolder") //! TypeError: readdirSync is not a function

  expect(files).toBeTruthy()
})

Why does querySelectorAll() return NodeList instead of HTMLCollection?

I was recently learning about the querySelectorAll() method in JavaScript and the fact that it returns back a NodeList object containing all the elements that match a particular CSS selector.

Now the confusion I have is that if querySelectorAll() is meant to only match element nodes, why doesn’t it return back an HTMLCollection instead, like getElementsByClassName() and getElementsByTagName() do?

What’s the point of querySelectorAll() returning back a NodeList instance?

Is it the case that querySelectorAll() can be used to select non-element nodes as well?

VS Code: cspell checker stopped working, getting ‘command resulted in as an error, command not found’

I used Code Spell Checker in VS Code for many months, and it’s stopped working. I’m using ‘Code Spell Checker’ and ‘Polish – Code Spell Checker’. I tried uninstall , reload extensions, tried with only the default english one (Code Spell Checker) and also restart vscode. Nothings helps. When I try using Command Panel with any commands from ‘CSpell Checker’ this is what I get:

Command ‘…’ resulted in an error

examples of the used commands:

  • Spell: Enable Spell Checking by Default => Command ‘Spell: Enable Spell Checking by Default’ resulted in an error (command ‘cSpell.enableForGlobal’ not found)

  • Spell: Create a CSpell Configuration File => Command ‘Spell: Create a CSpell Configuration File.’ resulted in an error (command ‘cSpell.createCSpellConfig’ not found)

  • Spell: Show Spell Checker Configuration Info => (Command ‘Spell: Show Spell Checker Configuration Info’ resulted in an error (command ‘cSpell.displayCSpellInfo’ not found)

Trying to deply a discord bot and getting error code 403

When I try to deploy my bot with Railway, I get the following output:

DiscordAPIError[50001]: Missing Access
at SequentialHandler.runRequest (/workspace/node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.js:198:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.queueRequest (/workspace/node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.js:99:20)
at async /workspace/src/functions/handleCommands.js:30:17 {
rawError: { message: 'Missing Access', code: 50001 },
code: 50001,
status: 403,
method: 'put',
url: 'https://discord.com/api/v9/applications/992512310834905258/guilds/919140223135416350/commands';
}

Repository:

AkatsuRepo
_node_modules
_ressources
_src
___commands
___events
___functions
___Handlers
___config.json
___index.js
___loadcommands.js

_.gitignore
_package.json
_README.md

My bot is working on local file but not with Railway. Any idea of how can I fix that?

Should add an Onchange Event to each input box by maintaining an array. Update it to true at each box index

Add same onchange event to each input box and maintain one array… Update it to true at each box index (When 3 input boxes are there) and at-least 1 is filled save should get enabled
One of the value in array is true then make save button enable
The number of input boxes should be equal to values in array..
First all indexes false..
If user change some thing in one box update array at its index..

Deleting a line in a txt file with Node.js

I recently made a script in which I want to delete an EXACT match from a txt file with node. It print’s out true but doesn’t actually remove the line from the txt file. I am using discord to get the argument.
I’m not sure what I’m doing wrong but here is my script:

        const fs = require('fs')
        fs.readFile('notredeemed.txt', function (err, data) {
            if (err) throw err;
                if (data.toString().match(new RegExp(`^${args[0]}$`, "m"))) {
                    fs.readFile('notredeemed.txt', 'utf8', function (err,data) {
                      if (err) {
                        return console.log(err);
                      }
                      var result = data.replace(/${args[0]/g, '');
                    
                      fs.writeFile('notredeemed.txt', result, 'utf8', function (err) {
                         if (err) return console.log(err);
                      });
                    });
                      console.log("true")

If someone could help me I would appreciate it 🙂