Firestore Security Rules: Getting all docs with field specific where query

As mentioned in the positive example of the Firestore Documentation I tried the query with the where condition, but it didn’t work (premission error):

getDocs(query(collection(db, 'users'), where('shareWith', 'array-contains', email)))
  .then(q => q.forEach(doc => console.log(doc.id, " => ", doc.data())))
;

Why does it not work with the following rule?

match /users/{userId}/{documents=**} {  
  allow read: if request.auth.token.email in get(/databases/$(database)/documents/users/$(userId)).data.shareWith;
  allow read, write: if request.auth.uid == userId;
}

PS: What works with the rule above, is accessing a specific user document though (for example users/123).

How to get element from injected html (page)

How to get specific element from injected html?

I want to get element ELEM[ATTE="VAL"] under div = document.querrySelector('DIV#elemWithHtml') but (div/document).querrySelectorAll('ELEM[ATTR="VAL"]') returns null.

Also it does not recognize HTML as child element.

I am using Firefox if it makes any difference.

Example:

<div id="elemWithHtml">
 ---
 <!-- injectet html -->
 <html>
     <head></head>
     <body>
         ----
         <elem attr="val"> <!-- wanted element -->
         ----
     </body>
 </html>
 ---
 </div>

var div = document.querrySelector('DIV#elemWithHtml');
var findElem = function (el) {
    for (let c of el.children) {
    if(/elem/gi.test(c.nodeName)) {
        if(/val/gi.test(c.getAttribute('attr')))
            return c;
    }
    let r = findCB(c);
    if (!!r)
        return r;
    }
    return null;
}

var f = findElem(div);

or

var f = div.querrySelector('ELEM[ATTR="VAL"]');

I want “f” to contain wanted element;

Sorry I do not know how to properly format it

when I run “npm run watch:js”,it change app.js file code

I have a Node.js project, and after the Parcel update, I’m running into an issue.

In my ./public/js/ folder I have 2 files: bundle.js and bundle.js.map. Previously, Parcel was compiling/bundling the code in these 2 files. However, after the update, it’s now changing my app.js file. And I can’t figure out how to adjust the parcel to the before-mentioned 2 files.

This is my package.json file

{
  "name": "Project",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "start": "nodemon server.js",
    "watch:js": "parcel watch ./public/js/index.js --dist-dir ./public/js/bundle.js",
    "build:js": "parcel watch ./public/js/index.js --dist-dir ./public/js/bundle.js"
    }
 "dependencies": {
    "@babel/polyfill": "^7.12.1",
    "axios": "^1.10.0"
  },
  "devDependencies": {
    "parcel": "^2.15.4".
}

Using Pascal-bundle, I want to run this code from the index.js file

Login.js file

import axios from 'axios'
export const login=async(email,password)=>{ 
    try{
        const res=await axios({
            method:'POST',
            url:'http://127.0.0.1:7000/api/v1/user/login',
            data:{
                email,
                password
            }
        })
        if(res.data.status==='success'){
            alert('Logged in Successfully!')
            window.setTimeout(()=>{
                location.assign('/')
            },1500)
        }
        
    }catch(err){
        alert(err.response.data.message)
    }
}
console.log('the document is: ',document.querySelector('.form'))

index.js file

import '@babel/polyfill'
import {login} from './login'
document.querySelector('.form').addEventListener('submit',e=>{
    e.preventDefault()
    const email=document.getElementById('email').value;
    const password=document.getElementById('password').value;
    login(email,password)
})

When I run the ‘npx parcel build ./public/js/js/index.js –dist-dir ./public/js –no-cache’ command or the ‘npm run watch’ command. This command changes my app.js file.

Before executing the command, my app.js file

app.use('/',viewRoute)
app.use('/api/v1/tours',tourRoute)
app.use('/api/v1/user',userRoute)
app.use('/api/v1/review',reviewRoute)
app.all('*',(req,res,next)=>{
  next(new AppError(`Can't find ${req.originalUrl} on this server!`,404))})

After running the command on my app.js file, it automatically generates this code

require("@babel/polyfill");
var $knI9B$axios = require("axios");
const $70af9284e599e604$export$596d806903d1f59e = async (email, password)=>{
    try {
        const res = await (0, ($parcel$interopDefault($knI9B$axios)))({
            method: 'POST',
            url: 'http://127.0.0.1:7000/api/v1/user/login',
            data: {
                email: email,
                password: password
            }
        });
        if (res.data.status === 'success') {
            alert('Logged in Successfully!');
            window.setTimeout(()=>{
                location.assign('/');
            }, 1500);
        }
    } catch (err) {
        alert(err.response.data.message);
    }
};
console.log('the document is: ', document.querySelector('.form'));
document.querySelector('.form').addEventListener('submit', (e)=>{
    e.preventDefault();
    const email = document.getElementById('email').value;
    const password = document.getElementById('password').value;
    (0, $70af9284e599e604$export$596d806903d1f59e)(email, password);
});


//# sourceMappingURL=app.js.map

I want to try to executed this code into bundle.js and bundle.js.map . Not executed in app.js and does not make app.js.map file

require("@babel/polyfill");
var $knI9B$axios = require("axios");
const $70af9284e599e604$export$596d806903d1f59e = async (email, password)=>{
    try {
        const res = await (0, ($parcel$interopDefault($knI9B$axios)))({
            method: 'POST',
            url: 'http://127.0.0.1:7000/api/v1/user/login',
            data: {
                email: email,
                password: password
            }
        });
        if (res.data.status === 'success') {
            alert('Logged in Successfully!');
            window.setTimeout(()=>{
                location.assign('/');
            }, 1500);
        }
    } catch (err) {
        alert(err.response.data.message);
    }
};
console.log('the document is: ', document.querySelector('.form'));
document.querySelector('.form').addEventListener('submit', (e)=>{
    e.preventDefault();
    const email = document.getElementById('email').value;
    const password = document.getElementById('password').value;
    (0, $70af9284e599e604$export$596d806903d1f59e)(email, password);
});

I’ve tried a number of things to fix it, and continually get this same output.

Thank you advance

Azure function not recognizing handlers on deployment when importing @azure/cosmos

Summary

When deploying a Node.js Azure Functions v4 application, the function handlers are not detected by the Azure runtime if the @azure/cosmos package is imported and used. The deployment appears to succeed, but the functions list in the Azure portal is empty, and any attempt to call the endpoints results in a 404 Not Found error.

If the import { CosmosClient } from "@azure/cosmos"; line and any usage of CosmosClient are commented out, the code builds, deploys, and runs correctly, with the function handlers being detected as expected.

Environment Details:

  • Azure Functions Runtime: v4
  • Node.js Version: v22.x
  • TypeScript Version: latest
  • Bundler: tsup v8.5.0
  • @azure/functions: v4.7.3
  • @azure/cosmos: v4.4.1

deployment command im using func azure functionapp publish <app-name>

Expected Behavior

The deployed function app should recognize the get-user-details HTTP trigger, and the endpoint …/api/user/{userId} should be active and callable.

Actual Behavior

The deployment completes without error, but the Azure Functions runtime does not detect any functions. The “Functions” tab in the Azure Portal is empty, and all API calls return a 404 Not Found error.

Deployed Code (dist/index.js)

import { app } from "@azure/functions";
import { CosmosClient } from "@azure/cosmos";

var COSMOS_DB_ENDPOINT = process.env.COSMOS_DB_ENDPOINT;
var COSMOS_DB_KEY = process.env.COSMOS_DB_KEY;
var COSMOS_DB_NAME = process.env.COSMOS_DB_DATABASE_ID;
var cosmosConfig = {
  endpoint: COSMOS_DB_ENDPOINT,
  key: COSMOS_DB_KEY,
  databaseId: COSMOS_DB_NAME,
  containers: {
    users: "Users",
  }
};

// src/functions/user/userDetails.get.ts
var container = new CosmosClient({
  endpoint: cosmosConfig.endpoint,
  key: cosmosConfig.key,
  connectionPolicy: {
    enableEndpointDiscovery: true
  }
}).database(cosmosConfig.databaseId).container("Items");
async function getUserDetails(request) {
  try {
    console.log(container);
    return {
      status: 200,
      jsonBody: {
        data: "validatedUserItem"
      }
    };
  } catch (error) {
    console.log("error: ", error);
    return {
      status: 500,
      jsonBody: {
        data: "error"
      }
    };
  }
}
app.http("get-user-details", {
  methods: ["GET"],
  authLevel: "anonymous",
  route: "user/{userId}",
  handler: getUserDetails
});
export {
  getUserDetails,
};

this is my package.json

{
  "name": "my-app",
  "version": "1.0.0",
  "type": "module",
  "main": "dist/index.js",
  "scripts": {
    "build": "tsup",
    "dev": "npm run build -- --watch",
    "clean": "rm -rf package-lock.json node_modules",
    "start": "npm run build && func start --typescript",
    "func:deploy": "npm run build && func azure functionapp publish waqfwakalah-dev-func"
  },
  "imports": {
    "#common/*": "../common/src/*"
  },
  "dependencies": {
    "@azure/cosmos": "^4.4.1",
    "@azure/functions": "^4.7.3",
    "zod": "^4.0.5"
  },
  "devDependencies": {
    "@types/node": "^24.0.13",
    "esbuild-plugin-alias": "^0.2.1",
    "tsup": "^8.5.0"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "description": ""
}

this is my tsup config:

import { defineConfig } from 'tsup'
import alias from 'esbuild-plugin-alias'
import path from 'path'

export default defineConfig({
  entry: ['src/index.ts'],
  outDir: 'dist',
  format: 'esm',
  target: 'node22',
  splitting: false,
  sourcemap: false,
  dts: false,
  external: ['@azure/functions', '@azure/cosmos'],
  clean: true,
  esbuildPlugins: [
    alias({
      '#common': path.resolve(__dirname, '../common/src'),
    }),
  ],
})
``

The issue seems to be directly related to how the @azure/cosmos package is handled during the bundling process.

there is no errors when deploying so im not sure how to go about solving this, the only thing i can see is 0 functions found

Getting read access for specific document in case a field matches

I have the following rules in Cloud Firestore:

match /users/{userId}/{documents=**} {  
  allow read: if request.auth.token.email in resource.data.shareWith;
  allow read, write: if request.auth.uid == userId;
}

However, I still get a permission error when trying to access a document from a different user, even though that document does have the email address from the requesting user in the shareWith field array.


My code for accessing the document looks like this:

  const
    docRef = doc(db, 'users', uid)
  ;

  return getDoc(docRef).then(d => d.exists() ? d.data() : this.create(docRef));

And this is the db:
enter image description here


Additional info:


What am I missing?

Why isnt the file download is working? Error: ‘file is unable to be downloaded’ [closed]

When I download the file it says the file wasn’t available on the site. When I download the file based on my Javascript code it doesn’t download the file properly, it says file is unable to be downloaded

function addDownload() {
  const filename = document.getElementById("myfile").files[0].name;
  console.log(filename)

  let newelecment = document.createElement('a');
  newelecment.setAttribute('href', 'filename')
  newelecment.setAttribute('download', filename);
  alert(newelecment.value)
  newelecment.textContent = `${filename}`
  let par = document.createElement('p');
  par.appendChild(newelecment);
  console.log(par.value)

  document.getElementById('link').appendChild(par);
}

document.getElementById("myfile").addEventListener("input", addDownload);
<label for="myfile">Select a file:</label>
<input type="file" id="myfile" name="myfile">
<div id="link"></div>

Why isnt the file download is not working?

When I download file says file wasn’t available on site, when I download the file based on my javascript code it doesn’t download the file properly, it says file is unable to be downloaded

<html>
<head>
    <title>How to Download File in HTML</title>
</head>
<body>

        <label for="myfile">Select a file:</label>
        <input type="file" id="myfile" name="myfile">



    <div id="link"></div>
    <script>

        function addDownload(){
            
            const filename = document.getElementById("myfile").files[0].name;
            alert(filename)

            let newelecment = document.createElement('a');
            newelecment.setAttribute('href','filename')
            newelecment.setAttribute('download', filename);
            alert(newelecment.value)
            newelecment.textContent = `${filename}`
            let par = document.createElement('p');
            par.appendChild(newelecment);
            alert(par.value)

            document.getElementById('link').appendChild(par);
        }


        document.getElementById("myfile").addEventListener("input", addDownload);

        
    </script>
</body>
</html>```

Real-Time Discord Messaging via Chrome Extension using RGOK Node Integration(watch out! let’s build server) [closed]

I recently built a system that lets you send and receive Discord messages directly inside a Chrome Extension — without needing to switch to the Discord app. It uses Node.js + Discord.js for backend handling, and Ngrok for exposing local servers. The frontend handles real-time updates, read/unread message logic, and scroll-triggered UI behavior.

Currently, I run a local Node server to handle Discord bot events and webhooks.

My next goal:

  • Move the backend logic fully into the Chrome Extension,
    or
  • Connect to a cloud-hosted server (e.g., Firebase Functions, AWS Lambda, etc.)
    to eliminate the need to run node server.js every time.

My goal is to make this feel fully integrated and lightweight — no terminal needed.


Project Overview

  • UI built with popup.html, popup.js, and styles.css
  • Server logic isolated in /server/server.js and exposed via Ngrok
  • Uses webhook + bot combo for 2-way messaging

My Question

Is there a best-practice way to embed backend-like logic into a Chrome Extension (e.g., using Service Workers or background scripts)?
Or, what are efficient cloud deployment strategies (serverless, free-tier friendly) you recommend for low-latency Discord integrations?


Project Screenshots

  1. Introduction UI
  2. File Logic Architecture
  3. System Overview UI
  4. Conclusion: Idea for Global Cloud Server

Decreasing load times on blog post site

So, I’ve been working on an ExpressJS blog site which allows for image uploading for covers to a post. But, after using Artillery to see how an initial build fares under multiple concurrent users, I’ve found that the site’s performance degrades pretty quickly… I was wondering how I could fix/improve this? This is my first time doing any development of this sort and I could really use some pointers :).

Some details

  • Everytime a post is to be viewed in some way, the server fetches the post document from a MongoDB database, this includes a coverImageID.

  • This coverImageID is then used to find the image source at …/posts/image/<%= item.coverImageID %> using EJS

  • The server in turn handles this GET request using the following code:

     router.get('/image/:id', async (req, res) => {
     try {
     const bucket = getGridFSBucket();
     const fileId = new mongoose.Types.ObjectId(req.params.id);
    
     const files = await bucket.find({ _id: fileId }).toArray();
     if (!files || files.length === 0) {
         return res.status(404).send('Image not found');
     }
    
     res.set('Content-Type', files[0].contentType);
     const downloadStream = bucket.openDownloadStream(fileId);
     downloadStream.pipe(res);
     } catch (err) {
         res.status(500).send('Error retrieving image');
     }
     });
    

Retrieving the image from the database.

During load testing, it didn’t take long at all to overload the server and responses took up to ten seconds to respons (not ideal)
So, any tips/really dumb mistakes I’ve made, would be appreciated 🙂
Thanks.

Create a Canvas inside a Worker [closed]

I know about OffscreenCanvas, this works well.

But i need several Canvases for compositing operations.

Is it possible to create canvas inside a worker without pointing document ?

something like this :

const myOtherCanvas = new Canvas();

Blazor Server collocated JavaScript causing crash on Blazor connection timeout due to auth CORS policy

We have a Blazor Server app that requires authorization on all its components (internal business app):

// ...

app.UseHttpsRedirection();
app.MapStaticAssets();  // <-- Static files middleware before auth.
app.UseAuthentication();
app.UseAuthorization();

// ...

app.MapRazorComponents<App>()
    .AddInteractiveServerRenderMode()
    .RequireAuthorization(); // <-- All pages require auth.

We also have a component in a Razor Class Library (RCL) that requires JavaScript to work. We’ve put it inside a .razor.js collocated file.

We are using a mix of Azure AD and Azure B2C in our auth flow (handled via OIDC), and our Routes.razor uses the <AuthorizeRouteView> component to render our pages/layouts.

Everything seemed to work fine, but we’ve hit an issue when the user’s Blazor Server connection times out (i.e. they leave the app running in the background for 15-30 minutes).

We get this in the browser’s logs (sensitive information redacted):

Access to script at ‘https://login.microsoftonline.com/{OIDC URL parameters redacted}’ (redirected from ‘https://{site URL}/_content/{RCL}/Components/MyComponent.razor.js‘) from origin ‘https://{site URL}’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

Failed to load resource: net::ERR_FAILED

Error: Microsoft.JSInterop.Exception: Failed to fetch dynamically imported module: ‘https://{site URL}/_content/{RCL}/Components/MyComponent.razor.js

{Stack trace that shows it tried and failed to import module}

Information: Connection disconnected.

My understanding is that Blazor tries to reconnect, but it tries to access the collocated JavaScript file (which is apparently a protected resources despite our static assets middleware being configured before the authentication/authorization middleware) before actually renewing the auth.

This crashes (unhandled exception, Blazor’s error ui pops-up) because it causes a redirect to our Azure AD/B2C setup, but that doesn’t know how to handle our static assets, because they’re not supposed to be protected resources (and we don’t want to have to configure every single static asset in Azure).

This leads me to believe that maybe collocated JavaScript files are considered “a part of” their component as far as .RequireAuthorization() is concerned?

Am I missing something? I can’t find anything in the documentation about collocated JavaScript files behaving differently with the authentication. In fact, the docs state this (Emphasis: mine):

[…] Blazor takes care of placing the JS file in published static assets for you.

Once the user refreshes the page, everything works as expected. So maybe it’s something to do with how renewing a Blazor connection works? I’m honestly not sure why this is happening. Any help would be appreciated.

How do I make my dialog-modal open a different modal for every link with the “data-open-modal” code?

I taught myself HTML, CSS, PHP, and MySQL many years ago, but I never got around to learning JavaScript. I’ve just picked up where I left off, but there are so many new things to learn since I last did any web coding. Can anyone help me with my JavaScript code as it currently is? I’ve only learned the basics of JS so far, and I can’t proceed with my project until I’ve learned a lot more.

Basically, my problem is, I want every edit button to open a unique dialog-modal, so far only the first one works.

const openButton = document.querySelector("[data-open-modal]")
const closeButton = document.querySelector("[data-close-modal]")
const modal = document.querySelector("[data-modal]")

openButton.addEventListener("click", () => {
  modal.showModal()
})
closeButton.addEventListener("click", () => {
  modal.close()
})

modal.addEventListener("click", e => {
  const dialogDimensions = modal.getBoundingClientRect()
  if (
    e.clientX < dialogDimensions.left ||
    e.clientX > dialogDimensions.right ||
    e.clientY < dialogDimensions.top ||
    e.clientY > dialogDimensions.bottom
  ) {
    modal.close()
  }
})
.rota-container {
  display: flex;
  flex-wrap: wrap;
  margin: 10px 0px 50px 0px;
}

.rota-item {
  flex: 1 0 13%;
  background-color: #dcdcdc;
  border: 1px solid #c0c0c0;
  height: auto;
  padding: 5px 0px 7px 0px;
}

.rota-item-day {
  height: auto;
  padding: 5px 0px 5px 0px;
  text-align: center;
  font-size: clamp(7px, 1.5vw, 50px);
  font-weight: bold;
  color: #000000;
}

.rota-date {
  text-align: right;
  margin: 0px 5px 0px 0px;
  font-size: clamp(7px, 1.5vw, 15px);
  color: #000000;
  font-family: Verdana, sans-serif;
}

.rota-edit {
  float: left;
  padding-left: 5px;
}

.rota-user {
  width: 90%;
  margin: 2px auto 0px auto;
  padding: 3px 0px 3px 3px;
  border-radius: clamp(0px, 0.4vw, 15px);
  color: white;
  font-size: clamp(7px, 1.5vw, 15px);
  font-family: Verdana, sans-serif;
}

.rota-user-1 {
  background-color: #008000;
  /*green*/
  border: 1px solid #008000;
}

.rota-user-2 {
  background-color: #cc006d;
  /*pink*/
  border: 1px solid #cc006d;
}

.rota-user-3 {
  background-color: #4b0082;
  /*blue*/
  border: 1px solid #4b0082;
}

.rota-user-4 {
  background-color: #707070;
  /*dark grey*/
  border: 1px solid #707070;
}

.rota-user-none {
  background-color: transparent;
  border: 1px solid transparent;
  color: transparent;
}

.modal {
  background-color: #f2f2f2;
  border: 1px solid #000000;
  border-radius: 10px;
  z-index: 10;
  padding: 20px;
}

.modal-container {
  display: grid;
  grid-template-columns: 1fr repeat(2, 1.5fr) 1fr;
  grid-template-rows: repeat(7, 1fr);
  grid-column-gap: 0px;
  grid-row-gap: 10px;
}

.modal-area-1 {
  grid-area: 2 / 2 / 3 / 3;
}

.modal-area-2 {
  grid-area: 3 / 2 / 4 / 3;
}

.modal-area-3 {
  grid-area: 4 / 2 / 5 / 3;
}

.modal-area-4 {
  grid-area: 5 / 2 / 6 / 3;
}

.modal-area-5 {
  grid-area: 6 / 2 / 7 / 3;
}

.modal-area-6 {
  grid-area: 2 / 3 / 3 / 4;
}

.modal-area-7 {
  grid-area: 3 / 3 / 4 / 4;
}

.modal-area-8 {
  grid-area: 4 / 3 / 5 / 4;
}

.modal-area-9 {
  grid-area: 5 / 3 / 6 / 4;
}

.modal-area-10 {
  grid-area: 6 / 3 / 7 / 4;
}

.modal-area-11 {
  grid-area: 2 / 4 / 3 / 5;
}

.modal-area-12 {
  grid-area: 3 / 4 / 4 / 5;
}

.modal-area-13 {
  grid-area: 4 / 4 / 5 / 5;
}

.modal-area-14 {
  grid-area: 5 / 4 / 6 / 5;
}

.modal-area-15 {
  grid-area: 6 / 4 / 7 / 5;
}

.modal-area-16 {
  grid-area: 1 / 2 / 2 / 3;
}

.modal-area-17 {
  grid-area: 1 / 3 / 2 / 4;
}

.modal-area-18 {
  grid-area: 2 / 1 / 3 / 2;
}

.modal-area-19 {
  grid-area: 3 / 1 / 4 / 2;
}

.modal-area-20 {
  grid-area: 4 / 1 / 5 / 2;
}

.modal-area-21 {
  grid-area: 5 / 1 / 6 / 2;
}

.modal-area-22 {
  grid-area: 6 / 1 / 7 / 2;
}

.modal-area-23 {
  grid-area: 7 / 4 / 8 / 5;
}
<div class="rota-container">
  <div class="rota-item rota-item-day">Monday</div>
  <div class="rota-item rota-item-day">Tuesday</div>
  <div class="rota-item rota-item-day">Wednesday</div>
  <div class="rota-item rota-item-day">Thursday</div>
  <div class="rota-item rota-item-day">Friday</div>
  <div class="rota-item rota-item-day">Saturday</div>
  <div class="rota-item rota-item-day">Sunday</div>
  <div class="rota-item">
    <div class="rota-date"><a class="rota-edit" data-open-modal>Edit</a>21</div>
    <div class="rota-user rota-user-1">8am-1pm</div>
    <div class="rota-user rota-user-none">1pm-4pm</div>
    <div class="rota-user rota-user-4">4pm-5pm</div>
    <div class="rota-user rota-user-none">5pm-9pm</div>
    <div class="rota-user rota-user-1">9pm-8am</div>
  </div>
  <div class="rota-item">
    <div class="rota-date"><a class="rota-edit" data-open-modal>Edit</a>22</div>
    <div class="rota-user rota-user-1">8am-1pm</div>
    <div class="rota-user rota-user-none">1pm-4pm</div>
    <div class="rota-user rota-user-2">4pm-5pm</div>
    <div class="rota-user rota-user-2">5pm-9pm</div>
    <div class="rota-user rota-user-2">9pm-8am</div>
  </div>
  <div class="rota-item">
    <div class="rota-date"><a class="rota-edit" data-open-modal>Edit</a>23</div>
    <div class="rota-user rota-user-2">8am-1pm</div>
    <div class="rota-user rota-user-none">1pm-4pm</div>
    <div class="rota-user rota-user-4">4pm-5pm</div>
    <div class="rota-user rota-user-none">5pm-9pm</div>
    <div class="rota-user rota-user-2">9pm-8am</div>
  </div>
  <div class="rota-item">
    <div class="rota-date"><a class="rota-edit" data-open-modal>Edit</a>24</div>
    <div class="rota-user rota-user-2">8am-1pm</div>
    <div class="rota-user rota-user-none">1pm-4pm</div>
    <div class="rota-user rota-user-3">4pm-5pm</div>
    <div class="rota-user rota-user-3">5pm-9pm</div>
    <div class="rota-user rota-user-3">9pm-8am</div>
  </div>
  <div class="rota-item">
    <div class="rota-date"><a class="rota-edit" data-open-modal>Edit</a>25</div>
    <div class="rota-user rota-user-3">8am-1pm</div>
    <div class="rota-user rota-user-none">1pm-4pm</div>
    <div class="rota-user rota-user-4">4pm-5pm</div>
    <div class="rota-user rota-user-none">5pm-9pm</div>
    <div class="rota-user rota-user-3">9pm-8am</div>
  </div>
  <div class="rota-item">
    <div class="rota-date"><a class="rota-edit" data-open-modal>Edit</a>26</div>
    <div class="rota-user rota-user-3">8am-1pm</div>
    <div class="rota-user rota-user-none">1pm-4pm</div>
    <div class="rota-user rota-user-4">4pm-5pm</div>
    <div class="rota-user rota-user-none">5pm-9pm</div>
    <div class="rota-user rota-user-3">9pm-8am</div>
  </div>
  <div class="rota-item">
    <div class="rota-date"><a class="rota-edit" data-open-modal>Edit</a>27</div>
    <div class="rota-user rota-user-3">8am-1pm</div>
    <div class="rota-user rota-user-none">1pm-4pm</div>
    <div class="rota-user rota-user-4">4pm-5pm</div>
    <div class="rota-user rota-user-none">5pm-9pm</div>
    <div class="rota-user rota-user-1">9pm-8am</div>
  </div>
</div>

<dialog class="modal" data-modal>
  <form method="post" action="" class="modal-container">

    <div class="modal-area-1"><input type="text" name="time-start-1" value="" /></div>
    <div class="modal-area-2"><input type="text" name="time-start-1" value="" /></div>
    <div class="modal-area-3"><input type="text" name="time-start-1" value="" /></div>
    <div class="modal-area-4"><input type="text" name="time-start-1" value="" /></div>
    <div class="modal-area-5"><input type="text" name="time-start-1" value="" /></div>
    <div class="modal-area-6"><input type="text" name="time-start-1" value="" /></div>
    <div class="modal-area-7"><input type="text" name="time-start-1" value="" /></div>
    <div class="modal-area-8"><input type="text" name="time-start-1" value="" /></div>
    <div class="modal-area-9"><input type="text" name="time-start-1" value="" /></div>
    <div class="modal-area-10"><input type="text" name="time-start-1" value="" /></div>
    <div class="modal-area-11">
      <select id="time-employee-1" name="time-employee-1">
        <option value="Helping Hands">None</option>
        <option value="Helping Hands">Helping Hands</option>
        <option value="Emma Cooper">Emma Cooper</option>
        <option value="Savannah Gregoire">Savannah Gregoire</option>
        <option value="Tracy Walker">Tracy Walker</option>
      </select>
    </div>
    <div class="modal-area-12">
      <select id="time-employee-1" name="time-employee-1">
        <option value="Helping Hands">None</option>
        <option value="Helping Hands">Helping Hands</option>
        <option value="Emma Cooper">Emma Cooper</option>
        <option value="Savannah Gregoire">Savannah Gregoire</option>
        <option value="Tracy Walker">Tracy Walker</option>
      </select>
    </div>
    <div class="modal-area-13">
      <select id="time-employee-1" name="time-employee-1">
        <option value="Helping Hands">None</option>
        <option value="Helping Hands">Helping Hands</option>
        <option value="Emma Cooper">Emma Cooper</option>
        <option value="Savannah Gregoire">Savannah Gregoire</option>
        <option value="Tracy Walker">Tracy Walker</option>
      </select>
    </div>
    <div class="modal-area-14">
      <select id="time-employee-1" name="time-employee-1">
        <option value="Helping Hands">None</option>
        <option value="Helping Hands">Helping Hands</option>
        <option value="Emma Cooper">Emma Cooper</option>
        <option value="Savannah Gregoire">Savannah Gregoire</option>
        <option value="Tracy Walker">Tracy Walker</option>
      </select>
    </div>
    <div class="modal-area-15">
      <select id="time-employee-1" name="time-employee-1">
        <option value="Helping Hands">None</option>
        <option value="Helping Hands">Helping Hands</option>
        <option value="Emma Cooper">Emma Cooper</option>
        <option value="Savannah Gregoire">Savannah Gregoire</option>
        <option value="Tracy Walker">Tracy Walker</option>
      </select>
    </div>
    <div class="modal-area-16">Start</div>
    <div class="modal-area-17">Finish</div>
    <div class="modal-area-18">Morning</div>
    <div class="modal-area-19">Afternoon</div>
    <div class="modal-area-20">Teatime</div>
    <div class="modal-area-21">Evening</div>
    <div class="modal-area-22">Night time</div>
    <div class="modal-area-23"><button data-close-modal>Close</button></div>

  </form>
</dialog>

I face a problem of email validaion in vue js [closed]

So How to solve this problem and how to set this email validtation by using vue js and html . Please solve My problem by using this method of validation or suggest some else

<input id="email"  type="email" class="form-control"
          :class="{ 'error-input': !$v.user.email.required || !$v.user.email }" placeholder="Email"  v-model.trim="$v.user.email.$model">
        <p class="error" v-if="!$v.user.email.required">Email required</p>
        <p class="error" v-if="!$v.user.email">Enter valid Email</p>

  email: {
        required,
        email
      },

Beforeunload Preventdefault workarounds?

So I have a website that is creating a file in the backend to store data. Once the user leaves or refreshes the page, that data is deleted.

window.addEventListener('beforeunload', function () {
    delete_file();
});

This works locally, but in some browsers / builds, if you refresh the page, beforeunload doesn’t trigger. So this is the workaround:

window.addEventListener('beforeunload', function (event) {
    event.preventDefault();
    delete_file();
});

Now, however, it gives a popup to the browser on whether or not they want to leave, even with unsaved changes. That’s fine, but if I press cancel and stay on the page, this still runs and deletes the file.

Here’s what I’ve tried:

  • Somehow get the canceled event from preventdefault
  • Create a fake “you may lose changes!” popup that calls preventdefault if user wants to leave

Compare dates of format dd/mm/yyyy hh:mm:ss and return the latest one in Zulu format [closed]

If I’ve an array like the following:

var "estd": [
        "30/05/2025 14:06:37",
        "30/05/2025 15:14:28",
        "01/06/2025 08:00:01",
        "26/05/2025 12:43:42"
    ]

What would be the way of returning the latest timestamp in yyyy-mm-ddTHH:MM:ssZ format?

Expected result:

2025-06-01T08:00:01Z

The way (longer or procedural way that I can think of is the following)

  • Loop through the array
  • On each iteration use split(" ") to get the date part and then split("/") on the date part to get the day, month and year, then join them via [2]-[1]-[0] index and finally concat it with the “time” part to get each date in
    yyyy-mm-ddThh:mm:ssZ format
  • Push this value into a new array
  • Once all dates in the original array are looped, as the last step use the .sort() method on the new array

But I’m sure there would be a more optimum/better way of doing the same.