Dropdowns stop working using Livewire and wire:navigate

I’m using Livewire components integrated with the botstrap 5.3 navbar.
Everything works fine but, when I add wire:navigate to the links in the navbar, all interactive elements stop working. There are no errors in the console. navbar toggle, dropdowns, everything stops working.

here’s the navlink example

<li><a class="dropdown-item" href="{{ route('home') }}" wire:navigate>Home</a></li>

Anyone to help me please

How to create a react app with typescript template on windows machine

I want to create a react application with typescript template.

npm version: 10.2.4

node version: 20.1.1

I tried the following commands but got errors:

First command npx create-react-app my-app --template typescript

Got error:

npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path D:usr
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, lstat 'D:usr'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

Second command npm create-react-app my-app --template typescript

Got error:

Unknown command: "create-react-app"

To see a list of supported npm commands, run:
  npm help```

How to add onClick event to PopupMenuBarItem in Dojo?

I can’t figure out how to add an onclick event to a menu item, please help me solve this problem.

<script>
    require([
        "dijit/MenuBar",
        "dijit/PopupMenuBarItem",
        "dijit/Menu",
        "dijit/MenuItem",
        "dijit/DropDownMenu",
        "dojo/domReady!"
    ], function(MenuBar, PopupMenuBarItem, Menu, MenuItem, DropDownMenu){
        var pMenuBar = new MenuBar({});

        var pSubMenu = new DropDownMenu({});
        pMenuBar.addChild(new PopupMenuBarItem({
            label: "ItemMenu1",
            popup: pSubMenu
        }));

        var pSubMenu2 = new DropDownMenu({});
        pMenuBar.addChild(new PopupMenuBarItem({
            label: "ItemMenu2",
            popup: pSubMenu2,
        }));

        pMenuBar.placeAt("navigation");
        pMenuBar.startup();
    });
</script>

I added onClick to the code using this method, but it doesn’t work.

var pSubMenu = new DropDownMenu({});
pMenuBar.addChild(new PopupMenuBarItem({
    label: "ItemMenu1",
    popup: pSubMenu,
    onClick: function () {alert('ItemMenu1');}
}));

require is not defined in js file that compiled from typescript file

Hello,

I am currently working on a Firebase project, and it was working fine until I converted the JavaScript code to TypeScript. Since then, I’ve encountered many problems. I resolved most of the issues in the code, but there are still a couple of challenging ones that I can’t solve.

in this two lines of code:

// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.13.0/firebase-app.js";
import {  getDatabase, ref, set,  onChildAdded , onValue } from "https://www.gstatic.com/firebasejs/10.13.0/firebase-database.js";

The first error was “exports is not defined at main.js:38:23”, which I fixed with this code: <script>var exports = {};</script> in HTML file.

The second error is “main.js:40: require is not defined”, and I don’t know how to fix it.

If anyone can help, it would be greatly appreciated.

I tried to install firebase locally to my project and try to download webpack.config.js but the problem remains unsolved.

vue-cesium – how reduce the height of the 3d tiles layer relative to the ground?

vue-cesium – how reduce the height of the 3d tiles layer relative to the ground?
here is my vue 3 component:

<template>
  <vc-viewer>
    <vc-layer-imagery>

      <!--      this is a ground layer-->

      <vc-imagery-provider-bing
        ref="provider"
        bm-key="AmGu3cvB_g1HbkQErEyvmLc9j0YIGWS7IdOqR7-hQbO8J92Fzrzkhy_bYKSsyoEx"
        :map-style="'AerialWithLabels'"
      ></vc-imagery-provider-bing>

      <!--      this is a 3d tiles layer, i need to reduce its height-->

      <vc-primitive-tileset
        :url="'https://lol/3d/new_form/tileset.json'"
        :maximum-memory-usage="4096"
        :maximumScreenSpaceError="4"
      ></vc-primitive-tileset>
    </vc-layer-imagery>
  </vc-viewer>
</template>

this is what my problem looks like – the layer is “flying in the air”:
screenshot

I would like the 3d layer to be at ground level or below

I’m trying to make a Select with Tailwind in React but I have an Infinite Loop error when I select an option

Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.

Component Principal:

const optionsTipoEvento = [
  { id: 1, name: t("posts-master.views.event_types.birthday") },
  { id: 2, name: t("posts-master.views.event_types.assisteds") },
  { id: 3, name: t("posts-master.views.event_types.lessons") },
  { id: 4, name: t("posts-master.views.event_types.days_assist") },
  { id: 5, name: t("posts-master.views.event_types.days_renewal") },
];

const [selectTipoEvento, setSelectTipoEvento] = useState(optionsTipoEvento[0]);

<Select
selected={selectTipoEvento}
setSelected={(option) =>
setSelectTipoEvento(option)
}
options={optionsTipoEvento}
tittle={t("posts-master.views.event_type")}
/>

Component Select:

import { Label, Listbox } from "@headlessui/react";
import { FC, Fragment } from "react";
import { OptionsSelect } from "../molecules/OptionsSelect";
import { ButtonSelect } from "../molecules/ButtonSelect";

type option = { id: number; name: string };
export type Selectprops = {
  selected: option;
  setSelected: (option: option) => void;
  options: option[];
  tittle: string;
  textDescribe?: string;
};

export const Select: FC<Selectprops> = ({
  selected,
  setSelected,
  options,
  tittle,
  textDescribe,
}) => {
  return (
    <Fragment>
      <Listbox value={selected} onChange={(option) => setSelected(option)}>
        <div>
          <div>
            <Label className="block text-sm font-medium leading-6 text-gray-600">
              {tittle}
            </Label>
          </div>

          <div className="relative">
            <ButtonSelect nameSelected={selected.name} />
            <OptionsSelect options={options} />
          </div>

          {/* Descripción en gris */}
          <p className="mt-1 text-sm text-gray-400">{textDescribe}</p>
        </div>
      </Listbox>
    </Fragment>
  );
};

Component OptionSelect:

import { ListboxOptions, ListboxOption } from "@headlessui/react";
import { FC, Fragment } from "react";
import { SpanIconCheckSelect } from "../atoms/SpanIconCheckSelect";

type option = { id: number; name: string };

export type OptionsSelectprops = {
  options: option[];
};

export const OptionsSelect: FC<OptionsSelectprops> = ({ options }) => {
  return (
    <Fragment>
      <ListboxOptions
        transition
        className="absolute z-50 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none data-[closed]:data-[leave]:opacity-0 data-[leave]:transition data-[leave]:duration-100 data-[leave]:ease-in sm:text-sm"
      >
        {options.map((person) => (
          <ListboxOption
            key={person.id}
            value={person}
            className="group relative cursor-default select-none py-2 pl-8 pr-4 text-gray-300 data-[focus]:bg-indigo-600 data-[focus]:text-white"
          >
            <span className="block truncate font-normal group-data-[selected]:font-semibold text-gray-900">
              {person.name}
            </span>
            <SpanIconCheckSelect />
          </ListboxOption>
        ))}
      </ListboxOptions>
    </Fragment>
  );
};

I have tried useEffect and usememo but I didn’t have any solution

Gitlab Pipeline fails finding secure file in container

I currently have a Gitlab pipeline that is running the following node.JS code

const options = {
  hostname: 'test.test.test.com',
  port,
  key: fs.readFileSync(path.join(process.env.CERT_PATH, '/'+process.env.CERT_NAME+'.key')),
  cert: fs.readFileSync(path.join(process.env.CERT_PATH, '/'+process.env.CERT_NAME+'.crt')),
};

It is failing while trying to access a secure file I uploaded, call it TEST.key and TEST.crt to the project saying it does not exist. I assume the problem is my code is not seeing the right directory for the file(s) but I can’t seem to understand where this code is looking.

My .gitlab-ci.yml file is failing on this section

test_job:
  stage: test
  only:
    - dev
    - test
    - main
  # Allow the use of Node Package Manager: Grabs the latest version of Node
  image: node:16.15.1
  variables:
    SECURE_FILES_DOWNLOAD_PATH: '/etc/ssl/certs/'
  script:
    - echo "Downloading necessary files..."
    - curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash
    - echo "Testing Application..."
    - npm test
    - echo "Done!"

Here is the log from the pipeline

$ echo "Downloading necessary files..."
Downloading necessary files...
$ curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash
Downloading download-secure-files from https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/releases/permalink/latest/downloads/download-secure-files-linux-amd64
Installing download-secure-files at /usr/bin/download-secure-files
Downloading Secure Files (v0.1.12) to /builds/axxxx/myApp/etc/ssl/certs
TEST.crt downloaded to /etc/ssl/certs/TEST.crt
TEST.key downloaded to /etc/ssl/certs/TEST.key
$ ls -alrth /etc/ssl/certs/TEST.key
ls: cannot access '/etc/ssl/certs/TEST.key': No such file or directory

Angular custom controller context not working with slow internet

So I’m trying to create a custom service (called ControllerContext) for my application that makes a call to the backend to get some data that is used in multiple parts of the application. The advantage of doing it this way is that the service will run on its own and I can just make a call to it in every component that needs the data instead of having to rewrite the code to call the backend every time I need the data.

What I have so far works fine EXCEPT for if the internet connection speed is very slow. If I’m just running on my normal 5G+ speed, everything works, but if I use the network settings in edge or chrome to purposely throttle my connection down to 4G or 3G or even lower, the ControllerContext starts getting blank data. The actual call to the backend is still made and succeeds and has the right data, but when the component calls the context, it gets the wrong data.

ControllerContext:

import { Injectable } from '@angular/core';
import { Observable, Subject } from 'rxjs';
import { getDataFromServer } from './api.service';

export interface iData {
  name: string,
  age: number,
  job: string
}

export interface iControllerContextValue {
  data: iData;
  getData: () => void;
}

@Injectable({
  providedIn: 'root',
})
export class ControllerContext {
  private contextValue: iControllerContextValue;
  private subject: Subject<iControllerContextValue> =
    new Subject<iControllerContextValue>();
  private contextObs: Observable<iControllerContextValue>;

  constructor() {
    this.contextObs = this.subject.asObservable();

    this.contextValue = {
      data: {
        name: '',
        age: 0,
        job: ''
      },
      getData: () => {
        void this.getData();
      },
    };
    
    this.subject.next(this.contextValue);
    void this.getData();
  }

  setControllerContext({
    data,
  }: {
    data: iData;
  }) {

    this.contextValue = {
      ...this.contextValue,
      data: data,
    };
    this.subject.next(this.contextValue);
  }

  getControllerContext() {
    return this.contextValue;
  }

  getObservedControllerContext() {
    return this.contextObs;
  }

  private async getData() {
    try {
      const data = await getDataFromServer();
      this.setControllerContext({
        data: data,
      });
    } catch (error) {
      console.error(error);
    }
  }

  public updateControllerContext() {
    void this.getData();
  }
}

The component trying to use it:

import {
  ControllerContext,
  iControllerContextValue,
} from 'src/app/controller-context.service';

@Component({
  selector: 'user',
  templateUrl: './user.component.html',
  styleUrls: ['./user.component.scss'],
})
export class UserComponent implements OnInit {
    controllerContext: { context: ControllerContext; sub?: Subscription };
    data: any;
    
    constructor( controllerContext: ControllerContext) {
        this.controllerContext = { context: controllerContext };
        this.data = this.controllerContext.context.getControllerContext().data;
    }
    
    ngOnInit(): void { 
        this.controllerContext = {
          ...this.controllerContext,
          sub: this.controllerContext.context
            .getObservedControllerContext()
            .subscribe((controllerContextData: iControllerContextValue) => {
              this.data = controllerContextData.data;
            }),
        };
        
        this.data = this.controllerContext.context.getControllerContext().data;
        console.log(this.data);
    }
}

When I run the code without throttling myself, the console outputs:

{
    name: "testName",
    age: 25,
    job: "testJob"
}

But if I throttle my connection to be slow, the console outputs the default data:

{
    name: "",
    age: 0,
    job: "",
}

This means that in slow internet connection environments, my application does not work. How do I fix this? I need my application to work in both slow and fast internet connection speeds. I would like to fix the service and not have to go back to manually calling the backend everywhere if possible. Note that ControllerContext is registered in my NgModule, I’m just trying to avoid putting the entire application here.

Vite .js files not loading from public/build folder! But loading directly from resources folder

Laravel 10,
laravel-vite-plugin – ^1.0.5,
vite – ^5.4.5

Below is my vite config.js

import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
import path from "path";

export default defineConfig({
    build: {
        outDir: "public/build",
        emptyOutDir: false,
        assetsDir: "static",
        sourcemap: true,
        rollupOptions: {
            input: {
                "js/app": path.resolve(__dirname, "resources/js/app.js"),
                "js/bootstrap": path.resolve(
                    __dirname,
                    "resources/js/bootstrap.js"
                ),
                "js/vendor": path.resolve(__dirname, "resources/js/vendor.js"),
                "js/sockets/bootstrap": path.resolve(
                    __dirname,
                    "resources/js/sockets/bootstrap.js"
                ),
                "js/layouts/smart": path.resolve(
                    __dirname,
                    "resources/js/layouts/smart.js"
                ),
                "js/libraries/cs": path.resolve(
                    __dirname,
                    "resources/js/libraries/cs.js"
                ),
                "js/libraries/skin": path.resolve(
                    __dirname,
                    "resources/js/libraries/skin.js"
                ),
                "js/libraries/vertex": path.resolve(
                    __dirname,
                    "resources/js/libraries/vertex.js"
                ),
                "js/libraries/widget": path.resolve(
                    __dirname,
                    "resources/js/libraries/widget.js"
                ),
                "js/app/layouts/bxslider": path.resolve(
                    __dirname,
                    "resources/js/app/layouts/bxslider.js"
                ),
                "js/app/layouts/page": path.resolve(
                    __dirname,
                    "resources/js/app/layouts/page.js"
                ),
                "js/app/layouts/portal": path.resolve(
                    __dirname,
                    "resources/js/app/layouts/portal.js"
                ),
                "js/app/modules/admin/managing/listing/index": path.resolve(
                    __dirname,
                    "resources/js/app/modules/admin/managing/listing/index.js"
                ),
                "js/app/modules/admin/member/member/index": path.resolve(
                    __dirname,
                    "resources/js/app/modules/admin/member/index.js"
                ),
                "js/app/modules/admin/member/member/form": path.resolve(
                    __dirname,
                    "resources/js/app/modules/admin/member/form.js"
                ),
                "js/config/core/dev/app": path.resolve(
                    __dirname,
                    "resources/js/config/core/dev/app.js"
                ),
                "css/app": path.resolve(__dirname, "resources/css/app.css"),
                "css/vendor": path.resolve(
                    __dirname,
                    "resources/css/vendor.css"
                ),
                "css/app/layouts/cms": path.resolve(
                    __dirname,
                    "resources/css/app/layouts/cms.css"
                ),
                "css/app/layouts/auth": path.resolve(
                    __dirname,
                    "resources/css/app/layouts/auth.css"
                ),
                "css/app/layouts/page": path.resolve(
                    __dirname,
                    "resources/css/app/layouts/page.css"
                ),
                "css/app/layouts/admin": path.resolve(
                    __dirname,
                    "resources/css/app/layouts/admin.css"
                ),
                "css/app/layouts/portal": path.resolve(
                    __dirname,
                    "resources/css/app/layouts/portal.css"
                ),
            },
            output: {
                entryFileNames: (chunkInfo) => {
                    if (chunkInfo.name.startsWith("js/")) {
                        return `${chunkInfo.name}.[hash].js`;
                    }
                    if (chunkInfo.name.startsWith("css/")) {
                        return `${chunkInfo.name}.css`;
                    }
                    //return `${chunkInfo.name}.[hash].js`;
                },
                chunkFileNames: (chunkInfo) => {
                    if (chunkInfo.name.startsWith("js/")) {
                        return `${chunkInfo.name}.[hash].js`;
                    }
                    if (chunkInfo.name.startsWith("css/")) {
                        return `${chunkInfo.name}.css`;
                    }
                    //return `${chunkInfo.name}.[hash].js`;
                },
                assetFileNames: (assetInfo) => {
                    if (assetInfo.name?.endsWith(".css")) {
                        return `[name].[hash][extname]`;
                    }

                    if (assetInfo.name?.endsWith(".js")) {
                        return `js/[name].[hash][extname]`;
                    }

                    if (
                        assetInfo.name.startsWith("fonts/") ||
                        assetInfo.name.startsWith("vendor/")
                    ) {
                        return `[name][extname]`;
                    }

                    return `[name].[hash][extname]`;
                },
            },
        },
    },
    plugins: [
        laravel({
            input: [
                "resources/css/app.css",
                "resources/css/vendor.css",
                "resources/css/app/layouts/cms.css",
                "resources/css/app/layouts/auth.css",
                "resources/css/app/layouts/page.css",
                "resources/css/app/layouts/admin.css",
                "resources/css/app/layouts/portal.css",
                "resources/js/app.js",
                "resources/js/bootstrap.js",
                "resources/js/vendor.js",
                "resources/js/sockets/bootstrap.js",
                "resources/js/layouts/smart.js",
                "resources/js/libraries/cs.js",
                "resources/js/libraries/skin.js",
                "resources/js/libraries/vertex.js",
                "resources/js/libraries/widget.js",
                "resources/js/app/layouts/bxslider.js",
                "resources/js/app/layouts/page.js",
                "resources/js/app/layouts/portal.js",
                "resources/js/app/modules/admin/managing/listing/index.js",
                "resources/js/app/modules/admin/member/member/index.js",
                "resources/js/app/modules/admin/member/member/form.js",
                "resources/js/config/core/dev/app.js",
            ],
            refresh: true,
            esm: true,
        }),
    ],
});

This is my manifest.json file build after runnung npm prod build.

{
  "resources/css/app.css": {
    "file": "css/app.CNk80R6N.css",
    "src": "resources/css/app.css",
    "isEntry": true
  },
  "resources/css/app/layouts/admin.css": {
    "file": "css/app/layouts/admin.qSM2Dncf.css",
    "src": "resources/css/app/layouts/admin.css",
    "isEntry": true
  },
  "resources/css/app/layouts/auth.css": {
    "file": "css/app/layouts/auth.CgXVspRn.css",
    "src": "resources/css/app/layouts/auth.css",
    "isEntry": true
  },
  "resources/css/app/layouts/cms.css": {
    "file": "css/app/layouts/cms.DqOcUH1V.css",
    "src": "resources/css/app/layouts/cms.css",
    "isEntry": true
  },
  "resources/css/app/layouts/page.css": {
    "file": "css/app/layouts/page.EEtcLhQm.css",
    "src": "resources/css/app/layouts/page.css",
    "isEntry": true
  },
  "resources/css/app/layouts/portal.css": {
    "file": "css/app/layouts/portal.Dc-ro14i.css",
    "src": "resources/css/app/layouts/portal.css",
    "isEntry": true
  },
  "resources/css/vendor.css": {
    "file": "css/vendor.C5ruzaah.css",
    "src": "resources/css/vendor.css",
    "isEntry": true
  },
  "resources/js/app.js": {
    "file": "js/app.CnL08CsG.js",
    "name": "js/app",
    "src": "resources/js/app.js",
    "isEntry": true
  },
  "resources/js/app/layouts/bxslider.js": {
    "file": "js/app/layouts/bxslider.DzL8e1Hr.js",
    "name": "js/app/layouts/bxslider",
    "src": "resources/js/app/layouts/bxslider.js",
    "isEntry": true
  },
  "resources/js/app/layouts/page.js": {
    "file": "js/app/layouts/page.DrJWWN61.js",
    "name": "js/app/layouts/page",
    "src": "resources/js/app/layouts/page.js",
    "isEntry": true
  },
  "resources/js/app/layouts/portal.js": {
    "file": "js/app/layouts/portal.CW5bVUqY.js",
    "name": "js/app/layouts/portal",
    "src": "resources/js/app/layouts/portal.js",
    "isEntry": true
  },
  "resources/js/app/modules/admin/managing/listing/index.js": {
    "file": "js/app/modules/admin/managing/listing/index.BcXq96BO.js",
    "name": "js/app/modules/admin/managing/listing/index",
    "src": "resources/js/app/modules/admin/managing/listing/index.js",
    "isEntry": true
  },
  "resources/js/app/modules/admin/member/form.js": {
    "file": "js/app/modules/admin/member/member/form.CwcMkPk1.js",
    "name": "js/app/modules/admin/member/member/form",
    "src": "resources/js/app/modules/admin/member/form.js",
    "isEntry": true
  },
  "resources/js/app/modules/admin/member/index.js": {
    "file": "js/app/modules/admin/member/member/index.mt8nT3RK.js",
    "name": "js/app/modules/admin/member/member/index",
    "src": "resources/js/app/modules/admin/member/index.js",
    "isEntry": true
  },
  "resources/js/bootstrap.js": {
    "file": "js/bootstrap.CEsE5a7F.js",
    "name": "js/bootstrap",
    "src": "resources/js/bootstrap.js",
    "isEntry": true
  },
  "resources/js/config/core/dev/app.js": {
    "file": "js/config/core/dev/app.l0sNRNKZ.js",
    "name": "js/config/core/dev/app",
    "src": "resources/js/config/core/dev/app.js",
    "isEntry": true
  },
  "resources/js/layouts/smart.js": {
    "file": "js/layouts/smart.BtPzgjTD.js",
    "name": "js/layouts/smart",
    "src": "resources/js/layouts/smart.js",
    "isEntry": true
  },
  "resources/js/libraries/cs.js": {
    "file": "js/libraries/cs.l0sNRNKZ.js",
    "name": "js/libraries/cs",
    "src": "resources/js/libraries/cs.js",
    "isEntry": true
  },
  "resources/js/libraries/skin.js": {
    "file": "js/libraries/skin.l0sNRNKZ.js",
    "name": "js/libraries/skin",
    "src": "resources/js/libraries/skin.js",
    "isEntry": true
  },
  "resources/js/libraries/vertex.js": {
    "file": "js/libraries/vertex.l0sNRNKZ.js",
    "name": "js/libraries/vertex",
    "src": "resources/js/libraries/vertex.js",
    "isEntry": true
  },
  "resources/js/libraries/widget.js": {
    "file": "js/libraries/widget.BzK2CPaz.js",
    "name": "js/libraries/widget",
    "src": "resources/js/libraries/widget.js",
    "isEntry": true
  },
  "resources/js/sockets/bootstrap.js": {
    "file": "js/sockets/bootstrap.ZJELHheL.js",
    "name": "js/sockets/bootstrap",
    "src": "resources/js/sockets/bootstrap.js",
    "isEntry": true
  },
  "resources/js/vendor.js": {
    "file": "js/vendor.COF9nXa8.js",
    "name": "js/vendor",
    "src": "resources/js/vendor.js",
    "isEntry": true
  }
}

I load my CSS and js files like the below,

@section('scripts')
    @parent
    @vite('resources/js/app/modules/admin/managing/listing/index.js')
@endsection

@section('styles')
            @include('templates.layouts.style')
            @vite('resources/css/app.css')
            @vite('resources/css/app/layouts/portal.css')
            @vite('resources/css/app/layouts/admin.css')
        @show

Currently CSS files load properly from the public/build folder but JS files directly load from the resources folder. How can I fix this? I’m first time using vite in laravel, so don’t have much idea about this issue.

JavaScript reduce returning different values

I have an array as follows:

"Totales": [
    {
        "Id": "1",
        "Medio": "Datafono",
        "diferenciaGr": 0.00,
        "diferenciaML": 6000.00
    },
    {
        "Id": "2",
        "Medio": "Efectivo",
        "diferenciaGr": 0.00,
        "diferenciaML": 165000.00
    },
    {
        "Id": "3",
        "Medio": "Credito",
        "diferenciaGr": 0.00,
        "diferenciaML": 0.00
    },
    {
        "Id": "4",
        "Medio": "Transferencias",
        "diferenciaGr": 0.00,
        "diferenciaML": 0.00
    }

I need to sum the last two fields: diferencaML and diferenciaGr.
For this, I am using reduce()

 determinarBalance: function (balance) {
        var cobranzasModel = this.getView().getModel("CobranzasSet"),
            data = this.getView().getModel("CobranzasSet").getData();

        let difML = data.Totales.reduce(function (dif, c) {
            return dif + c.diferenciaML
        })
        let difGr = data.Totales.reduce(function (dif, c) {
            return dif + c.diferenciaGr
        })

        console.log(difML);
        console.log(difGr);

        return (balance);
    },

But for some reason both reduce functions are returning the following results:

[object Object]16500000
[object Object]000

Given the data above, the results should be 171000.00 and 0.00.
So, reduce it is not paying any attention to decimal point, plus adding [object Object] at the beginning. Any clues about this odd behaviour?

javascript: How to create a autocomplete tool (pricing strategy tool)

Are there any plugins where you can do this?
i need a vanilla javascript tool or react plugin I can add.
I need a way to create a pricing stargey tool with autocomplete then allow the user to enter a table name for example like the video shows, the description box isnt necessary.
I havent found any tool that has this autocomplete to tag functionality and do it well!
enter image description here
https://youtu.be/GrNEX1u-exY?si=MsgyRe9i0-D96G85&t=126

I tried loads tool but most of them dont allow tags/autocomplete in the format I need.
Auto complete would only work for single words and tags added “x” next to them and was not as smooth as the youtube video i have sent.
Im struggling to find anything close and its hard to explain my issue so I need some suggestions please!

How do I fix this code to consolidate my google sheet notes?

I’m using Google Apps Script and I am trying to write a program that consolidates my monthly notes. I have hidden columns i-t which are labeled “January 2024” – “December 2024” chronologically. I have a dropdown configured in column H that shows “January 2024” – “December 2024” to select from.

The idea is to hide the 12 months of notes (which looks terrible on the sheet), and let me unhide a singular column of my choosing. “January 2024” from the dropdown, should unhide column i named “January 2024”.

For some reason it’s not doing anything. Not sure what to do.

Here’s the code:

function onEdit(e) {
  // Ensure the function only runs during actual edits
  if (!e) return;  // If no event object (e), stop the execution to avoid errors

  var sheet = e.source.getActiveSheet();
  
  // Ensure the edit was made in column H (8th column) and after the header row
  if (e.range.getColumn() == 8 && e.range.getRow() > 1) {
    var selectedMonth = e.range.getValue(); // Get the value of the selected month

    // Define the mapping of months to columns
    var monthMapping = {
      "January 2024": 9,   // Column I
      "February 2024": 10, // Column J
      "March 2024": 11,    // Column K
      "April 2024": 12,    // Column L
      "May 2024": 13,      // Column M
      "June 2024": 14,     // Column N
      "July 2024": 15,     // Column O
      "August 2024": 16,   // Column P
      "September 2024": 17,// Column Q
      "October 2024": 18,  // Column R
      "November 2024": 19, // Column S
      "December 2024": 20  // Column T
    };

    // Notes columns from I to T (9 to 20)
    var notesColumnStart = 9;
    var notesEndColumn = 20;

    // Unhide all columns from I to T
    sheet.showColumns(notesColumnStart, notesEndColumn - notesColumnStart + 1);
    
    // Check if the selected month exists in the mapping
    if (selectedMonth in monthMapping) {
      var selectedColumn = monthMapping[selectedMonth]; // Get the corresponding column number
      
      // Check if the selected column is already visible
      var isColumnVisible = !sheet.isColumnHiddenByUser(selectedColumn);
      
      if (isColumnVisible) {
        // If the column is visible, re-hide it (toggle behavior)
        sheet.hideColumns(selectedColumn);
        Logger.log("Hiding column: " + selectedColumn);
      } else {
        // If the column is hidden, show it and hide all others
        Logger.log("Showing column: " + selectedColumn);
        for (var col = notesColumnStart; col <= notesEndColumn; col++) {
          if (col !== selectedColumn) {
            sheet.hideColumns(col);  // Hide the column if it is not the selected month
          }
        }
        sheet.showColumns(selectedColumn); // Make sure the selected column is shown
      }
    } else {
      // If the selected month isn't in the mapping, log the issue
      Logger.log("Month not found in the mapping: " + selectedMonth);
    }
  }
}

Auto-scroll to next video when less than 30% of the current video is visible

Problem Description:
I’m trying to implement a feature where videos automatically play when they enter the viewport and scroll to the next video when less than 30% of the current video is visible. Currently, I have videos playing and pausing based on their visibility in the viewport, but I’m struggling to implement the scrolling functionality.

What I have tried:
I used the IntersectionObserver to detect when the videos are in view and play or pause them. However, I also want the page to scroll to the next video when the user has scrolled more than 30% past the current video.

Here’s the code I’m working with:

document.addEventListener('DOMContentLoaded', function() {
    const videos = document.querySelectorAll('.video-player');

    // Create an intersection observer
    const observer = new IntersectionObserver((entries) => {
        entries.forEach(entry => {
            const video = entry.target;

            // If the video is in view
            if (entry.isIntersecting) {
                video.play(); // Play the video when it enters the viewport
            } else {
                video.pause(); // Pause the video when it leaves the viewport
            }
        });
    }, {
        threshold: 0.7  // Play the video when 70% is visible
    });

    // Observe each video element
    videos.forEach(video => {
        observer.observe(video);
    });
});

What I need:

  1. I want to automatically scroll to the next video when less than 30% of the current video is visible.
  2. The current implementation doesn’t seem to work as expected. The videos don’t always scroll to the next one, and sometimes the videos pause or behave inconsistently.
    Any suggestions on how I can improve the code to achieve the desired functionality would be greatly appreciated!

google.visualization.DataTable() – Adding columns Dynamically to the Data Table

I am trying to create Dynamic DataTable for drawing line chart.

This is my Data Structure for Line chart, In my scenario columns will not be same for all users. For example

User - ABC will have
array_json =
[["date","CA","SF"],
["May-2024",100,200],
["Jun-2024",200,300]]
User - XYZ will have
array_json=
[["date","CA","SF","IL"],
["May-2024",100,200,400],
["Jun-2024",200,300,500]]

I tried creating Data Table like below

dynamic_col_names = array_json.shift(1);
dtbl = new google.visualization.DataTable();
for(var i in dynamic_col_names){
        //console.log(dynamic_col_names[i]);
        if(i==0){
          dtbl.addColumn({label:dynamic_col_names[i],id:dynamic_col_names[i],type:'string'});                
        }
        else{          
          dtbl.addColumn({label:dynamic_col_names[i],id:dynamic_col_names[i],type:'number'});          
        }
      }

I have probelm in adding my column to rows, my code for adding values to data Table

combined[0] = dynamic_col_names;
      for (var i = 1; i < array_json.length; i++){
        var dt_ = convertdate(array_json[i][0]);  // convertdate is function I created to format the date  
// In this Line dt_ column is always fixed, but other number of columns will change based on user
        combined[i + 1] = [dt_,Number(array_json[i][i]),Number(array_json[i][i]),Number(array_json[i][i])];                       
      }  

In this line of code , I want to add this particular column “Number(array_json[i][i])” specific number of times for example user ABC has 2 number data type columns “CA”,”SF”

combined[i + 1] = [dt_,Number(array_json[i][i]),Number(array_json[i][i])]; 

User XYZ has 3 data type number columns “CA”,”SF”,”IL”, my code should be loke this

combined[i + 1] = [dt_,Number(array_json[i][i]),Number(array_json[i][i]),Number(array_json[i][i])]; 

How can I do this in an efficient way. Thanks in advance!!

how can i tell gsap and js to do something ONLY IF width is above 1200px?

i’m in trouble with a project. I’m trying to create a horizontal scroll with Javascript and GSAP, but only if width is > 1200px. i did a thing and it kinda works, but if i resize the web page to a smaller width it still does the horizontal scroll. srry for my english and please help me!!!

const aboutContainer = document.querySelector(".about__container");
const aboutContent = gsap.utils.toArray(".about__container .about__content");
const aboutMask = document.querySelector(".about__mask");
if (document.body.clientWidth > 1200) {
  let scrollTween = () => {
    gsap.to(aboutContent, {
      xPercent: -100 * (aboutContent.length - 1),
      ease: "none",
      scrollTrigger: {
        trigger: ".about__container",
        pin: true,
        scrub: 1,
        end: "+=3000",
      },
    });

    gsap.to(aboutMask, {
      width: "100%",
      scrollTrigger: {
        trigger: ".about__section",
        start: "top left",
        scrub: 1,
      },
    });

    let tl = gsap.timeline({
      scrollTrigger: {
        trigger: ".about__container",
        start: "center bottom",
      },
    });

    tl.from(aboutContent, { x: 300, opacity: 0, duration: 1 });
  };
  scrollTween();
};