CustomElementRegistry repeat registration error

I am using the googlemaps/extended-component-library to use two web components those being the APILoader and the PlacePicker components,

When i run my application it throws these errors:

'CustomElementRegistry' already has "gmpx-api-loader" defined. 
 ReferenceError: HTMLDivElement is not defined
    at __webpack_require__ (C:UsersuserDesktopDevelopmentProduct-Shop.nextserverwebpack-runtime.js:33:42) 

Steps to reproduce:

  1. create next app
  2. install googlemaps/extended-component-library
  3. import APILoader and PlacePicker components from googlemaps/extended-component-library and use them in your application
  4. provide APILoader with google api key
  5. run your application

From googling i have not found anyone with a similar problem or solution

Why this Post method returns a 405 error?

I am receiving a 405 Error when i try to use the post method from a booking engine for our small hotel website.
Here is the code that the booking engine provider asked us to integrate below and the temporary url of website with the booking engine in questions on home page.
https://nicolass-trendy-site-521bc7.webflow.io/
What are we doing wrong?
We used this HTML block for it.

<section id="hbe-bws-wrapper-widget-code"></section>
<link type="text/css" rel="stylesheet" href="//book.securebookings.net/css/search-wdg.css" />
<script type="text/javascript" src="//book.securebookings.net/js/widget.search.js"></script>
<script> 
jQuery(document).ready(function() {
             $widget("#hbe-bws-wrapper-widget-code").searchWidgetCode({
            id: "cdc12a82-35c5-1668031886-4530-b288-fdfc406a9e3e",
            lang: "en",
            Layout: 0,
            ShowPromoCode: 1,
            ShowFilterSearch: 1,
            ShowBestRate: 0,
            InsiteUrl: "https://nicolass-trendy-site-521bc7.webflow.io/reservation",
            ButtonName: "Check Availability",
            ButtonBackground: "#4391DA",
            ButtonText: "#FFFFFF",
            WidgetBackground: "#AA8453",
            urlS3Json:"new-hls"

            });
            });
</script>

href to another html file wont play media content

I am using the following code to open an html file on a new tab:

                <button class="interactive-transcript-button" title="Open Interactive Transcript in a new tab">
                
                <svg file>
                
                </button>
                </a>

The media element in the html file being opened is in:

  <section data-media-src="file:////Users/filepath.mp4" data-wm="$ilp.uphold.com/123section">

These html files work on their own, but when I try to hyperlink the second html file to open from the first one, the media file no longer works.

how to assign default value for arguments when using the new Function method

how to assign default value for arguments when using the new Function method?

let fileName = "fileone.js", args = [], options = {};
let ls = new Function('fileName', 'args', 'options', 'somefunctionorValue', `....some...code...body...here`)
ls(fileName, args, options)

I want to assign the default value for 'someFunctionOrValue' when the function I am creating is done: new Function(....).

cannot able to share an image with text using Navigator.share

I want to share an image with caption. here I have a code which generate an image dynamically with using html-to-image plugin. Everything works properly but the text get discarded while the image get share on Whatsapp, Facebook and etc.

And on the otherside if i pass two file as an image and try to share then text get included on both the image.

following is my code


getScoreImage() {
    this.dynamicImageEle = document.getElementById('quiz-share-image-wrap');

    const v_this = this;

        htmlToImage.toPng(this.dynamicImageEle)
        .then(function (dataUrl) {
        var img = new Image();
        img.src = dataUrl;
        v_this.dynamicImageBase64 = img.src;
        const file = v_this.dataURLtoFile(dataUrl, "ipl-quiz.png");

        setTimeout(()=> {
            v_this.shareFile(file);
        },100)
    })
    .catch(function (error) {
        console.error('oops, something went wrong!', error);
    });
}

dataURLtoFile(dataurl: any, filename:any) {
    var arr = dataurl.split(","),
        mimeType = arr[0].match(/:(.*?);/)[1],
        decodedData = atob(arr[1]),
        lengthOfDecodedData = decodedData.length,
        u8array = new Uint8Array(lengthOfDecodedData);
    while (lengthOfDecodedData--) {
        u8array[lengthOfDecodedData] = decodedData.charCodeAt(lengthOfDecodedData);
    }
    return new File([u8array], filename, { type: mimeType });
    
};

async shareFile(file:any) {
    if (navigator.canShare && navigator.canShare({ files: [file] })) {
        await navigator.share({
            "title": this.shareTitle,
            "text": this.shareText,
            "files": [file, file],
        })
        .then(() => console.log("Share was successful."))
        .catch((error) => console.log("Sharing failed", error));
    } else {
        console.log(`Your system doesn't support sharing files.`);
    }
};

Current Output with image and no text

If Pass two image then output is proper but 2 image is not expected

Expecting output I want to share is image with text.

How can I write this python function in javascript?

Im currently working on this code wars pisano period.
We need to return the length of the period by which you divide the fibonacci sequence.

The python code I searched for on youtube looks like this. Also its important to note that the python function returns the entire modulo version of the fibonacci sequence instead of the length
here is the youtube video from which I got this answer from Lets Python: Pisano

def pisanoPython(divisor):
  '''Returns a modulo version of the Fibonacci sequence'''
  fib = [0,1]
  while True:
     fib.append((fib[-1]+fib[-2]) % divisor)
     if fib[-1] == 1 and fib[-2] == 0:
        return fib[:-2]

>>>pisano(3)
[0,1,1,2,0,2,2,1]

Below is my code (which is giving me the wrong output)

function pisanoJavascript(n){
  let fib = [0,1];
  let isRepeated = true;
  while(isRepeated) {
    let lastVal = fib[fib.length-1]
    let secondLastVal = fib[fib.length-2]
    let remainder = (lastVal + secondLastVal) % n
    fib.push(remainder)
    if(lastVal === 1 && secondLastVal === 0) isRepeated = false
  }
  return fib.slice(0,-2).length
}

I followed the logic and the steps from the python function but can’t figure out which part I am missing.

I find that the line
if(lastVal === 1 && secondLastVal === 0) isRepeated = false. will always hit and break out of the while loop so maybe I need to initialize fib array in a different way. Why are these two functions not the same even though I followed the logic from pisanoPython and how can I make the javascript version work

how can I toggle items in a list in javascript?

I write the toggleSelectedItems function but it did not work correctly and I could not solve the problem.

when I click on add button, I want to send the items that are in candidateItems to selectedGroups and if I click on add all, the all items in groups are added to selectedGroups.if I click on remove, the items that are in candidateItems are removed from selectedGroups . I want when I send the items to the toggleSelectedItems function, if they exist, they will be removed from the selectedGroups state, and if they don’t exist, they will be added. the items should be add to the related group. the groupId of items are equal to id of each group in selectedGroups.how can I fix the toggleSelectedItems function?

for example

const groups =[
    {
        "title": "Clusters",
        "id": "clusters",
        "items": [
            {
                "id": 1,
                "label": "cluster1",
                "groupId": "selected-clusters"
            },
            {
                "id": 2,
                "label": "cluster2",
                "groupId": "selected-clusters"
            }
        ]
    },
    {
        "title": "Rigs",
        "id": "rigs",
        "items": [
            {
                "id": 1,
                "label": "rig1",
                "groupId": "selected-rigs"
            },
            {
                "id": 2,
                "label": "rig2",
                "groupId": "selected-rigs"
            },
            {
                "id": 3,
                "label": "rig3",
                "groupId": "selected-rigs"
            }, 
        ]
    }
]
const selectedGroups=[
    {
        "title": "Selected Clusters",
        "id": "selected-clusters",
        "items": []
    },
    {
        "title": "Selected Rigs",
        "id": "selected-rigs",
        "items": []
    }
]

const candidateItems=[
    {
        "id": 1,
        "label": "cluster1",
        "groupId": "selected-clusters"
    },
    {
        "id": 2,
        "label": "cluster2",
        "groupId": "selected-clusters"
    }
]

my code :

 type GroupType = {
  title: string
  id: string
  items: GroupItemType[]
}

 type GroupItemType = {
  id: string | number
  label: string
  groupId: string | number
}

const [groups, setGroups] = useState<GroupType[]>([])
const [selectedGroups, setSelectedGroups] = useState < GroupType[] > ([])
const [candidateItems, setCandidateItems] = useState < GroupItemType[] > ([])

 const toggleSelectedItems = useCallback(
    (toggleItems: GroupItemType[]) => {
      setSelectedGroups((prevGroups) =>
        prevGroups.map((group) => {
          const groupToggleItems = toggleItems.filter(
            (toggleItem) => toggleItem.groupId === group.id
          )

          if (groupToggleItems.length === 0) return group

          const itemExists = groupToggleItems.some((toggleItem) =>
            group.items.some((item) => item.id === toggleItem.id)
          )

          const updatedItems = itemExists
            ? group.items.filter(
                (item) =>
                  !groupToggleItems.some(
                    (toggleItem) => toggleItem.id === item.id
                  )
              )
            : [...group.items, ...groupToggleItems]

          return { ...group, items: updatedItems }
        })
      )
    },
    [selectedGroups]
  )
  
  const add = useCallback(() => {
    toggleSelectedItems(candidateItems)
    setCandidateItems([])
  }, [candidateItems])
  
  const addAll = useCallback(() => {
    const allItems = groups.flatMap((item) => item.items)
    toggleSelectedItems(allItems)
  }, [groups])
 
  const remove = useCallback(() => {
    toggleSelectedItems(candidateItems)
    setCandidateItems([])
  }, [candidateItems])
 
  const removeAll = useCallback(() => {
    const allItems = selectedGroups.flatMap((item) => item.items)
    toggleSelectedItems(allItems)
  }, [selectedGroups])

css – how to align the flex centre item?

I have a React Component.
enter image description here

If the lengths of the labels(Football etc) are different, the starting position of the progress bar is different. I want to make them always start at the same position. Is it possible to do so using flex?

MyComponent.tsx

import React from "react";

const INITIAL_CATEGORIES = [
  { id: 1, label: "Football" },
  { id: 2, label: "Basketball & Baseball" },
];

const CategoryItem = ({ label }) => {
  return (
    <div className="flex justify-between items-center">
      <span>{label}</span>
      <div className="w-6/12 bg-indigo-100 rounded-full h-2.5 dark:bg-gray-700">
        <div
          className="bg-blue-600 h-2.5 rounded-full"
          style={{ width: "65%" }}
        >
          123
        </div>
      </div>
      <span>$650.00 / $ 1,000.00</span>
    </div>
  );
};

export default function Dictator() {
  return (
    <div className="px-5 py-5 bg-white rounded">
      <div className="flex flex-col gap-3 mt-4">
        {INITIAL_CATEGORIES.map(({ id, label }) => (
          <CategoryItem key={id} label={label} />
        ))}
      </div>
    </div>
  );
}

Appwrite Login Auth: TypeError: account.createEmailSession is not a function

I follow this tutorial with Vue, Appwrite
https://appwrite.io/docs/tutorials/vue/step-1

src/appwrite/index.js

import { Client, Databases, Account } from "appwrite";

const client = new Client();
client
  .setEndpoint("https://cloud.appwrite.io/v1")
  .setProject("PROJECT-ID"); // Replace with your project ID

export const account = new Account(client);
export const databases = new Databases(client);

src/store/user.js

import { ID } from 'appwrite';
import { account } from "@/appwrite";
import { reactive } from "vue";

export const user = reactive({
  current: null,
  async init() {
    try {
      this.current = await account.get();
    } catch (e) {
      this.current = null;
    }
  },
  async register(email, password) {
    await account.create(ID.unique(), email, password);
    await this.login(email, password);
  },
  async login(email, password) {
    await account.createEmailSession(email, password);
    window.location.href = "/";
  },
  async logout() {
    await account.deleteSession("current");
    this.current = null;
  },
});

src/pages/auth/Login.vue

<script setup>
import { user } from "@/store/users";
import { ref } from "vue";

const email = ref("");
const password = ref("");
</script>

<template>
  <section>
    <h1>Login or register</h1>
    <form>
      <input type="email" placeholder="Email" v-model="email" />
      <input type="password" placeholder="Password" v-model="password" />
      <div>
        <button type="button" @click="user.login(email, password)">
          Login
        </button>
        <button type="button" @click="user.register(email, password)">
          Register
        </button>
      </div>
    </form>
  </section>
</template>

Register function is OK. New user is created in Appwrite Console/Auth.
But when clicking to Login button, it throws an error
Uncaught (in promise) TypeError: account.createEmailSession is not a function

I cannot find a proper answer anywhere.
Can someone explain it?

Messy code and code returning false not working

I’m making this function where i buy a specific weapon for a specific price and if the coins aren’t enough then it wouldn’t be executed. the else isn’t working and I’m repeating the code so is there any way to write more efficient code and fixing the else code block? buyW() is the function where i buy the weapon

let xp = 0
let hp = 100
let coins = 200

const button1 = document.querySelector("#button1")
const button2 = document.querySelector("#button2")
const button3 = document.querySelector("#button3")
const button4 = document.querySelector("#button4")
const button5 = document.querySelector("#button5")

const textbox = document.querySelector("#textbox")
const textbox2 = document.querySelector("#textbox2")

const xpNum = document.querySelector("#xpNum")
const hpNum = document.querySelector("#healthNum")
const coinsNum = document.querySelector("#coinsNum")

//intiallize button functions
button1.onclick = goToStore

xpNum.innerHTML = xp
hpNum.innerHTML = hp
coinsNum.innerHTML = coins

const villains = [
    {name: "Sandman", hp:25},
    {name: "Vulture",hp:50},
    {name: "Lizard",hp:75},
    {name: "Mysterio",hp:80},
    {name: "Green Goblin",hp:120},
]

let inv = [
    {name: "Spiderweb" , damage: 2}
]

let currentWeapon = ""

inv.forEach((item,index)=>{
    currentWeapon+=`${index + 1}. ${item.name}<br>`
})

const weapons = [
    {name: "Shield", damage: 5 , price: 50},
    {name: "Gun" , damage: 10, price: 100},
    {name: "Trident", damage: 20, price: 200}
]

let weaponsList = ""

weapons.forEach((item,index)=>{
    weaponsList+=`${index + 1}. ${item.name} - ${item.price} coins<br>`
})


const scenes = [
    //start screen
    {scene:"start",
    text: "Spiderman is near a mom-and-pop shop in Queens. What should he do?",
    btnT: ["Go to store","Go to city","Go to underground","Exit"],
    btnF: [goToStore,goToCity,goToUnder,exit]
    },
    //entering store
    {scene:"store",
    text: "Spiderman is inside the store. What should he do?",
    btnT: ["Buy Weapon","Sell Weapon","Buy Health - 15 coins","Leave Store"],
    btnF: [buyW,sellW,buyH,leave]
    },
    //buy weapon
    {scene: "buy",
    text: `Spiderman currently has :<br> ${currentWeapon} Which weapon should he buy?`,
    btnT: ["Shield - 50 coins","Gun - 100 coins","Trident - 200 coins","Exit Buy"],
    btnF: [weapon("Shield"),weapon("Gun"),weapon("Trident"),exitBuy],
    text2 : weaponsList 
    }
]

function update(scene){
    button1.onclick = scene.btnF[0];
    button2.onclick = scene.btnF[1];
    button3.onclick = scene.btnF[2];
    button4.onclick = scene.btnF[3];
    
    button1.innerHTML = scene.btnT[0];
    button2.innerHTML = scene.btnT[1];
    button3.innerHTML = scene.btnT[2];
    button4.innerHTML = scene.btnT[3];

    textbox.innerHTML = scene.text

    if(Object.prototype.hasOwnProperty(scene,"text2")){
        textbox2.innerHTML = scene.text2
    } else {
        textbox2.style.display = "none"
    }
}

function goToStore(){
    update(scenes[1])
}

function goToCity(){
    update(scenes[0])
}

function goToUnder(){
    update(scenes[0])
}

function exit(){
    update(scenes[0])
}
function buyW(){
    update(scenes[2])
    textbox2.style.display = "block"
    textbox2.innerHTML = scenes[2].text2
    if(coins >= 50){
        function shield(){
            alert("Shield bought!")
            coins-=50
            coinsNum.innerHTML = coins
            inv.push(weapons[0])
            currentWeapon = ""
            inv.forEach((item,index)=>{
                currentWeapon+=`${index + 1}. ${item.name}<br>`
            })
            textbox.innerHTML = `Spiderman currently has :<br> ${currentWeapon} Which weapon should he buy?`
            button1.removeEventListener("click",shield)
        }
    } else {
        alert("Not enough coins!")
        return false
    }

    if(coins >= 100){
        function gun(){
            alert("Gun bought!")
            coins-=100
            coinsNum.innerHTML = coins
            inv.push(weapons[1])
            currentWeapon = ""
            inv.forEach((item,index)=>{
                currentWeapon+=`${index + 1}. ${item.name}<br>`
            })
            textbox.innerHTML = `Spiderman currently has :<br> ${currentWeapon} Which weapon should he buy?`
            button2.removeEventListener("click",gun)
        }
    } else {
        alert("Not enough coins!")
        return false
    }
    
    if(coins >= 200){
        function trident(){
            alert("Trident bought!")
            coins-=200
            coinsNum.innerHTML = coins
            inv.push(weapons[2])
            currentWeapon = ""
            inv.forEach((item,index)=>{
                currentWeapon+=`${index + 1}. ${item.name}<br>`
            })
            textbox.innerHTML = `Spiderman currently has :<br> ${currentWeapon} Which weapon should he buy?`
            button3.removeEventListener("click",trident)
        }
    } else {
        alert("Not enough coins!")
        return false
    }
    button1.addEventListener("click",shield)
    button2.addEventListener("click",gun)
    button3.addEventListener("click",trident)
}

function sellW(){
    
}

function buyH(){
    
}

function leave(){
    update(scenes[1])
}

function weapon(weapon){

}

function exitBuy(){

}

update(scenes[0])```

node error. I have 2 js files and on console I typed “node index.js functions.js” . Please note: im trying to use firebase

please check the error below:
node:internal/process/esm_loader:40
internalBinding(‘errors’).triggerUncaughtException(
^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module ‘D:web devscrimbamobile appfunctions’ imported from D:web devscrimbamobile appindex.js
Did you mean to import ../functions.js?

Given below is the code I’m trying to run: (Index.html, index.js, functions.js)

    <!doctype html>
<html>
    <head>
        <title>Reel Time</title>
        <link rel="preconnect" href="https://fonts.googleapis.com">
        <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
        <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300&family=Ultra&display=swap" rel="stylesheet">
        <link rel="stylesheet" href="index.css">
    </head>
    <body>
        <div class="container">
            <h1>Reel Time</h1>
            <div class="field">
                <input type="text" id="input-field" placeholder="Pulp Fiction">
                <button id="add-button">+</button>
            </div>
        </div>
        <script src="index.js" type="module"></script>
        <script src="functions.js" type="module"></script>
    </body>
</html>

//const readlineSync = require (readlineSync)


import { add } from "./functions"
console.log(add(20,30))

const appSettings = {
    databaseURL: "https://playground-91206-default-rtdb.asia-southeast1.firebasedatabase.app/"

}
const inputFieldEl = document.getElementById("input-field")
const addButtonEl = document.getElementById("add-button")

addButtonEl.addEventListener("click", function() {
    let inputValue = inputFieldEl.value
    
    console.log(`${inputValue} added to database`)
})

 //const readlineSync = require (readlineSync)

export function add(a,b) {
       return a + b
}

PHP post to mysql with dynamic table inside while loop

With some help, I made a truck check form with buttons for pass, warning, and fail. As well as a comment button that adds a line for a comment. This is all being done in a while loop from mysqli_fetch_array.

How do I post the data from the filled out form to the mysql db? I dont have much experience posting to mysql using dynamic table loops.

Example of my form

Here is my code:

<div class="container-xxl flex-grow-1 container-p-y">
             
<h2 align="center"><?php echo $appname?></h2><br />
   <div class="form-group">
   <form name="add_name" id="add_name">
                    
   <div class="table-responsive">
      <table class="table table-bordered" id="dynamic_field">

   <?php while ($checks = mysqli_fetch_array($checksqry)) {
            echo '<tr>';
            echo '<td style="width: 20%">'.$checks['check_name'].' <br><br> 
            <input type="radio" class="btn-check" name="btn[' . $checks['id'] . ']" id="btnpass[' . $checks['id'] . ']" value="Pass">
            <label class="btn rounded-pill btn-outline-success" for="btnpass[' . $checks['id'] . ']">Pass</label>&Tab;&Tab;

           <input type="radio" class="btn-check" name="btn[' . $checks['id'] . ']" id="btnwarning[' . $checks['id'] . ']" value="Warning">
           <label class="btn rounded-pill btn-outline-warning" for="btnwarning[' . $checks['id'] . ']">Warning</label>&Tab;&Tab;

           <input type="radio" class="btn-check" name="btn[' . $checks['id'] . ']" id="btnfail[' . $checks['id'] . ']" value="Fail">
           <label class="btn rounded-pill btn-outline-danger" for="btnfail[' . $checks['id'] . ']">Fail</label>&Tab;&Tab;

           <button onclick="myFunction('. $checks['id'] . ')" type="button" name="comment[' . $checks['id'] . ']" id="comment[' . $checks['id'] . ']" class="btn btn-info" style="float: right">Click</button> 
<br><br>
           <div style="display:none;" id="commentlinediv[' . $checks['id'] . ']">
           <input type="text" class="text-line" placeholder="Type Comment Here" id="commentline[' . $checks['id'] . ']"/>
</div>
</td>';
echo '<tr>';}?>

 </table>
<input type="button" name="submit" id="submit" class="btn btn-info" value="Submit" />
</div>
</form>
</div>
</div>

<style>
input[type="text"] {
   border:none; /* Get rid of the browser's styling */
   border-bottom:1px solid black; /* Add your own border */
}

.text-line {
   background-color: transparent;
   color: black;
   outline: none;
   outline-style: none;
   border-top: none;
   border-left: none;
   border-right: none;
   border-bottom: solid #eeeeee 1px;
   padding: 3px 10px;
   width: 300px;
}
                


</style>


<script>
function myFunction(var1) {
  
document.getElementById("commentlinediv[" + var1 + "]").style.display = "inline";
}

</script>

Exporting an auxiliar function outside the scope of a Adonis JS Controller class

I have an AdminController with a lot of backend API endpoints and there is an auxiliar function that one of the API depends upon. I need to call this auxiliar function from a Task File that runs every day in the morning. I tried exporting an object using module.exports = { AdminController, createReportAux } but that did not seem to work. How can I achieve this? Am I doing the import or export wrong?

class AdminController {

// backend API endpoint methods

    async deleteProgram({ request, params, response }) {
}

    async addProgram({ auth, request, response }) {
}

//I could call this but cannot pass auth information from the task file as it is not available there
    async createReport({ auth, params, response }) {
                        createReportAux(requestInfo, auth.user.email)
}

}


//function that I need to call which is outside AdminController class
const createReportAux = async (requestInfo, email) => {
}

module.exports = AdminController


const AdminController = use("App/Controllers/Http/AdminController")

class GetScheduledEmailForTheDay extends Task {
  static get schedule() {

  }
 await AdminController.createReportAux(requestInfo, individualEmailToSend.receiver_email)

}

Please suggest a solution, I have been stuck at it for a while. Exporting as an object seems to work but the API methods are not accessible that way.

How do i store data for HTML for file://

so I wanted to store a cookie for light mode and dark mode inside a html file in file://, NOT a webpage. file:// path, not a webpage

but then I learnt that cookies don’t actually work on file:// (or at least on chrome).
so I googled and learnt about local storage, but that too does not work….

so I wanted to know is there any other way of storing data even on a file:// path?

thank you