SSRS, Chrome Javascript

I am having and issure with Java scrrpt working in Chrome. It Worked in the morning and stopped in the afternoon. I am working on a P21 epicor softtware and the code has worked before. when reviewing the code at the bottom of the screen with I press a button it looks correct.

Code os as Follows
=”javascript:void(window.open(‘https://p21.castertech.com/Prophet21/index.html#/window/m_purchaseorderentry?po_no=” & parameters!PONumber.value & “‘,’_blank’))”

I have uninstalled Chrome, Removed or disabled extenstions, check to make sure Jave is on and still it just sits there when I press the buttom. This works in Firefox but not edge.

Can someone maybe give a an idea as to what to go to get this to work again?

Javascript event listerens in classes, bind vs arrow functions

Is there a proper way to handle setting up event listeners in a class such that it preserves this?

This is similar to Binding vs Arrow-function (in JavaScript, or for react onClick) but for vanilla event handlers instead of react, and the methods they use don’t work for private methods

  1. Use bind
 this.#myelem.addEventListener("click",this.#onclick1.bind(this));`
  1. Use arrow functions
this.#myelem.addEventListener("click",(event)=>this.#onclick2(event));
  1. Pre-binding the function in the constructor, however this only works with public
    methods and not private ones
class MyClass {
    #elem;
    constructor() {
        this.#elem = /*...*/;
        this.onclick4 = this.onclick.bind(this);

        //doesn't work with private vars
        //Error: cannot assign to private method
        //this.#onclick = this.#onclick.bind(this);
        this.#elem.addEventListener("click",this.onclick);
    }

    onclick(event) {/*...*/}
}
  1. Creating a class level arrow function
class MyClass{ 
    constructor() {
        this.#elem = /*...*/;
        this.#elem.addEventListener("click",this.#onclick);
    }

    this.#onclick = (event) => {/*...*/}
}

The above answer compares 3 and 4 mentioning that 4 has higher memory usage that 3,
however 3 doesn’t work with private methods. Is there one of these options, or
an option I don’t have here that is better? Are they all close enough that the choice
should be based on style and not on performance?

class MyClass {

    constructor()
    {
        this.onclick4 = this.onclick4.bind(this);
        //Error: cannot assign to private method
        //this.#onclick5 = this.#onclick5.bind(this);

        document.getElementById("elem1").addEventListener("click",this.#onclick1.bind(this));
        document.getElementById("elem2").addEventListener("click",(event)=>this.#onclick2(event));
        document.getElementById("elem3").addEventListener("click",this.#onclick3);
        document.getElementById("elem4").addEventListener("click",this.onclick4);
        //document.getElementById("elem5").addEventListener("click",this.#onclick5);
    }

    #onclick1(event) { this.#print("1 was clicked"); }
    #onclick2(event) { this.#print("2 was clicked"); }
    #onclick3 = (event) => { this.#print("3 was clicked"); }
    onclick4(event) { this.#print("4 was clicked"); }
    #onclick5(event) { this.#print("5 was click"); }

    #print(str)
    {
        console.log(str);
    }
}

let mc = new MyClass();
<button id="elem1">btn1</button>
<button id="elem2">btn2</button>
<button id="elem3">btn3</button>
<button id="elem4">btn4</button>
<button id="elem4">btn5</button>

Chrome Extension – listen to status “canceled” or “unknown” in network requests

My extension listens to certain network requests and responses, then logs them into the console using the chrome.webRequest api from the documentation. Here’s my background script that does all the listening.

The extension then console logs the requests. It’s a debugging tool. You can see that on response, I pass the status code along to be logged. That status code is for me to be able to indicate for the user that their request has failed or succeeded in the console log.

Now, I want to be able to do the same for the requests that were cancelled or the status of which is unknown to the browser.

Here are the examples of how they look like (sorry for the quality, got it from the user):
enter image description here

I looked for the callback, but I couldn’t easily find it. Not sure if Chromium is nice enough to provide those.

Now I think of two options if there’s indeed no convenient callbacks:

  1. Try using the performance.getEntriesByType(“resource”) but I believe the performance API doesn’t provide the statuses of the requests sent.

  2. I could implement some weird awkward logic… I’m already storing the requests sent in a map onBeforeRequest. So I could just add the timestamp to each of them, then poll them and if I see a request there that is like N seconds old (probably 1 second, or I’ll make a config for it), I would just log it with an error saying something like: “received no server response” and remove it from the map. I don’t like the idea of manual polling though. Always feels like a hack.

How do I make an html button change my java functions [closed]

My code (below) is supposed to chronicle if the button is clicked, and register the said click as a certain selection depending on the button pressed. Unfortunately when I check both the item function and itemselector function after clicking one of the buttons, I currently am just getting an undefined value

if (document.querySelector("button name="item1").click) {
  let itemselector = 1; 
}

if (document.querySelector("button name="item2").click) {
  let itemselector=2;   
}

if (document.querySelector("button name="item3").click) {
  let itemselector=3;   
}

function itemselector{
if (itemselector===1) { 
then let item==="item1"
}
if (weaponselector===2) {
then let item==="item2"
}

if (weaponselector===3) {
then let item==="item3"
}

create multiple div in a row, dynamically using a loop

I want to create some div dynamically, like in the image shown below. There could be 30+ div aligned like that, so hardcoding that will be painful. I want to do it with a loop. I tried many weird things that didn’t work. And the loop right now does not make sense, since I’m hardcoding everything in the loop.

How can I make it so that it is created in the loop, without repeating the code? So like a row having 4 or 5 cols. And also, if I change the dbRes to be 20 or some other number, it should create the rows accordingly?

I have this code

const SearchRes = () => {
    const dbRes = 10;
    let res = null;

    const user = {            
        uname: 'Piggy',
        lang: 'English',
        country: 'England',
        level: 'Noob'
    }

    const divInfo = 
        <div style={{border: '2px solid red', width: '200px'}}>
            <p>Name:&nbsp;{user.uname}</p>
            <p>Language:&nbsp;{user.lang}</p>
            <p>Count:&nbsp;{user.country}</p>
            <p>Level:&nbsp;{user.level}</p>
        </div>
    
    for (let i = 0; i < dbRes; ++i) {
       res =  
            <>
            <Row>
                <Col>
                    {divInfo}
                </Col>

                <Col>
                    {divInfo}
                </Col>

                <Col>
                    {divInfo}
                </Col>

                <Col>
                    {divInfo}
                </Col>

                <Col>
                    {divInfo}
                </Col>                
            </Row>                
            </>                          
    }    
    
    return (
        <Container>
            {res}
        </Container>
        
    )
}

I searched for some similar problems, and the closest I found was this: is there a way to create multiple divs using a loop in React

But it didn’t help me

Thanks in advance

enter image description here

React Firebase authentication keeps the user logged in all the time even after refreshing

Console keeps showing that uthContext user: _UserImpl. I’m trying to make a different component to show up after clicking a button depending on if the user is logged in or not. (SignUp component if not logged in, Jobs component if logged in) All the time even if the I refresh, the user stays logged in and the same component (‘/rejestracja) show ups whether I’m logged in or not.

Boxes.jsx: (Starting component, so I want the (‘/oferty-pracy’) to open if the user is logged in and (‘/rejestracja’) if not logged in.)

import { useContext, useEffect } from "react";
import { useNavigate } from "react-router-dom";
import { AuthContext } from "../AuthContext";

export default function Boxes() {
    const { user } = useContext(AuthContext);
    const navigate = useNavigate();

    useEffect(() => {
        console.log('User state changed:', user);
    }, [user]);

    const handleClick = () => {
        console.log('Handle Click - User:', user);
        if (user) {
            navigate('/oferty-pracy');
        } else {
            navigate('/rejestracja');
        }
    };

    return (

AuthContext.jsx:

import React, { createContext, useState, useEffect } from 'react';
import { getAuth, onAuthStateChanged } from 'firebase/auth';

export const AuthContext = createContext();

export const AuthProvider = ({ children }) => {
    const [user, setUser] = useState(null);
    const auth = getAuth();

    useEffect(() => {
        const unsubscribe = onAuthStateChanged(auth, (user) => {
            console.log('AuthContext user:', user);
            setUser(user);
        });
        return () => unsubscribe();
    }, [auth]);

    return (
        <AuthContext.Provider value={{ user }}>
            {children}
        </AuthContext.Provider>
    );
};

App.jsx:

import React from 'react';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import { AuthProvider } from './config/AuthContext';
import Navbar from './config/Components/Navbar';
import Boxes from './config/Components/Boxes';
import LogIn from './config/Components/LogIn';
import SignUp from './config/Components/SignUp';
import Jobs from './config/Components/Jobs';

export default function App() {
    return (
        <div className="App">
            <AuthProvider>
                <Router>
                    <Navbar />
                    <Routes>
                        <Route path="/" element={<Boxes />} />
                        <Route path="/zaloguj" element={<LogIn />} />
                        <Route path="/rejestracja" element={<SignUp />} />
                        <Route path="/onas" element={<div>O nas</div>} />
                        <Route path="/oferty-pracy" element={<Jobs />} />
                    </Routes>
                </Router>
            </AuthProvider>
        </div>
    );
}

Validating invalid JSON [closed]

I am trying to validate JSON but i keep getting this error:

Error: Parse error on line 1:
{“id”:1,”Lst_Envir
-^
Expecting ‘STRING’, ‘}’, got ‘undefined’

Here is the code:

{"id":3"Lst_Environmental":[{"id":0,"EnvironmentalItemID":"f-4cb4-9b77-27d5489e2442","EnvironmentalItem_GUID":"f1a-43e4-8885-5e96eee6bf0f","EmergencyPlanReviewed":true,"DMECheckComplete":true,"EmergencyEquipmentCheckComplete":true,"RespToGoBagCheckComplete":false,"GIToGoBagCheckComplete":false,"Other":false,"OtherDetailsText":null,"EnvironmentalItemTime":"05/2/2023 12:05:24","EnvironmentalItemTimeDT":"2024-05-30 12:05:24","LastChangedTimeUTC":"5/5/2024 4:05:27 PM"}],"VisitId":5981,"Environmental_GUID":"0d552e7a-0f1a-43e4-8885-5e96eee6bf0f","Environmental":"1111","InitialEnvironmentalTime":"06/30/2024 11:48:00"}

I tried removing all the (“) but didn’t work

How to add display:none to parent element of a slot with no content

I’m using web component(s) and I have created a Panel class. By default if no content has been provided for a named slot then the parent should not be visible

<div class="panel-header">
    <slot name="header">
        Header
    </slot>
</div>
<div class="panel-body">
    <slot name="body">
        Body
    </slot>
</div>
<div class="panel-footer"> <!-- display:none -->
    <slot name="footer"></slot> <!-- if there's no content -->
</div>

Here’s my parent component’s render method:

render() {
    this.innerHTML = `
        <panel-component>
            <span slot="header">Member Info</span>
            <span slot="body">${this.search ? this.search : 'Please select a member'}</span>
            <!-- no footer slot -->
        </panel-component>
    `;
}

I’d prefer to apply this style via CSS but I’m open to suggestions with JavaScript

::slotted(div:empty) {
    display: none;
}

.panel-footer:empty,
.panel-footer:has(:empty) {
    display: none;
}

:scope > :empty {
    display: none;
}

::slotted(div[slot="footer"]:empty) {
    display: none;
}

Cannot read properties of undefined in azure-maps-animations

I tried to redo this Azure Maps Animations sample with TypeScript: https://samples.azuremaps.com/animations/animate-marker-along-path

I have several issues and would need some help.
I’ll explain and provide my code below.

When running in Chrome, the console shows two errors:

Ucaught TypeError: Cannot read properties of undefined (reading 'EventEmitter')
    at azure-maps-animations.js:1101:23
    at azure-maps-animations.js:3424:2

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'moveAlongRoute')
    at main.ts:96:41

I wanted to use VSCode and RequireJs, I used these options in tsconfig.json:

  "compilerOptions": {
    "module": "AMD",
    "target": "ES6",
    "moduleResolution": "node",
    "esModuleInterop": true,

    "strict": true,
    "jsx": "preserve",
    "sourceMap": true,
    "declaration": false,
    "lib": ["ES6", "DOM"],
    "resolveJsonModule": true,
    "downlevelIteration": true,

    "outDir": "./js",
    "rootDir": "./ts",
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "typeRoots": [
      "./node_modules/@types",
      "./types"
    ],
    "baseUrl": "./",
    "paths": {
      "azure-maps-control": ["node_modules/azure-maps-control/dist/atlas.min"]
    },
  }

I used this config.js file to setup RequireJS:

require.config({
  baseUrl: './js',
  paths: {
    'azure-maps-control': 'https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas'
    ,'azure-maps-animations': '../lib/azure-maps/azure-maps-animations'
  }
});

require(['main'], function(main) {
});

My html page only has:

<head>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js" defer></script>
    <script src="./node_modules/requirejs/require.js" defer></script>
    <script src="./config.js" defer></script>
    <link href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.css" rel="stylesheet" />
</head>
<body>
    <div id="myMap"></div>
</body>

Here is the main.ts file:

import * as azmaps from 'azure-maps-control'
import * as atlas from 'azure-maps-animations'

var anim: atlas.RoutePathAnimation;
var map: azmaps.Map;

function main() {

    try {
        map = new azmaps.Map("myMap", {
            center: [-122.345, 47.615],
            zoom: 14,
            view: 'Auto',
            authOptions: {...}
        });

        map.events.add('click', function () {
            //anim.play();
        });

        map.events.add('ready', function () {

            map.imageSprite.createFromTemplate('arrow-icon', 'marker-arrow', 'teal', '#fff').then(function () {

                //Create data sources and add them to the map.
                var lineSource = new azmaps.source.DataSource();
                var pinSource = new azmaps.source.DataSource();
                map.sources.add([lineSource, pinSource]);

                //Create a layer to render the path.
                map.layers.add(new azmaps.layer.LineLayer(lineSource, undefined, {
                    strokeColor: 'DodgerBlue',
                    strokeWidth: 3
                }));

                //Extract the positions to highlight the full route on the map as a line.
                var path: azmaps.data.Position[] = [];

                var routePoints = [
                    new azmaps.data.Feature(new azmaps.data.Point([-122.34758, 47.62155]), { _timestamp: new Date('Tue, 18 Aug 2020 00:53:53 GMT').getTime() }),
                    new azmaps.data.Feature(new azmaps.data.Point([-122.34764, 47.61859]), { _timestamp: new Date('Tue, 18 Aug 2020 00:54:53 GMT').getTime() }),
                    new azmaps.data.Feature(new azmaps.data.Point([-122.33787, 47.61295]), { _timestamp: new Date('Tue, 18 Aug 2020 00:56:53 GMT').getTime() }),
                    new azmaps.data.Feature(new azmaps.data.Point([-122.34217, 47.60964]), { _timestamp: new Date('Tue, 18 Aug 2020 00:59:53 GMT').getTime() })
                ];

                routePoints.forEach(f => {
                    path.push(f.geometry.coordinates);
                });

                lineSource.add(new azmaps.data.LineString(path));

                //Create a layer to render a symbol which we will animate.
                map.layers.add(new azmaps.layer.SymbolLayer(pinSource, undefined, {
                    iconOptions: {
                        //Pass in the id of the custom icon that was loaded into the map resources.
                        image: 'arrow-icon',

                        //Anchor the icon to the center of the image.
                        anchor: 'center',

                        //Rotate the icon based on the rotation property on the point data.
                        //The arrow icon being used in this case points down, so we have to rotate it 180 degrees.
                        rotation: ['+', 180, ['get', 'heading']],

                        //Have the rotation align with the map.
                        rotationAlignment: 'map',

                        //For smoother animation, ignore the placement of the icon. This skips the label collision calculations and allows the icon to overlap map labels. 
                        ignorePlacement: true,

                        //For smoother animation, allow symbol to overlap all other symbols on the map.
                        allowOverlap: true
                    },
                    textOptions: {
                        //For smoother animation, ignore the placement of the text. This skips the label collision calculations and allows the text to overlap map labels.
                        ignorePlacement: true,

                        //For smoother animation, allow text to overlap all other symbols on the map.
                        allowOverlap: true
                    }
                }));

                //Create a pin and wrap with the shape class and add to data source.
                var pin = new azmaps.Shape(routePoints[0]);
                pinSource.add(pin);

                //Create the animation.
                anim = atlas.animations.moveAlongRoute(routePoints, pin, { 
                    //Specify the property that contains the timestamp.
                    //timestampProperty: 'timestamp',

                    captureMetadata: true,
                    loop: false,
                    reverse: false,
                    rotationOffset: 0,
                    
                    speedMultiplier: 60,
                    map: undefined,
                    zoom: 15,
                    pitch: 45,
                    rotate: true
                });
            });
        });
    } catch (error) {
        console.error('Error initializing game:', error);
    }
}

function ready(fn: () => void) {
    if (document.readyState !== 'loading') {
        fn();
    } else {
        document.addEventListener('DOMContentLoaded', fn);
    }
}

ready(() => {
    console.log("addEventListener");
    main();
});

If I uncomment //anim.play(); I get: Property ‘play’ does not exist on type ‘RoutePathAnimation’.

If I uncomment //timestampProperty: ‘timestamp’, I get: ‘timestampProperty’ does not exist in type ‘RoutePathAnimationOptions’

I noticed that the sample uses atlas namespace for both control and animations imports, I don’t know how to do this, could it be the issue ?

The file ../lib/azure-maps/azure-maps-animations.js comes from https://github.com/Azure-Samples/azure-maps-animations/blob/main/dist/azure-maps-animations.js

The file /types/azure-maps-animations.d.ts comes from https://github.com/Azure-Samples/azure-maps-animations/blob/main/typings/index.d.ts

I really love the idea of “timestampProperty” and wish to use it, could you please help me understand the issues ?

Thanks.

How to group the Y and X axis labels at the very bottom left corner in Chart.js?

I’m using Chart.js v4.4.3.

My goal is to group the Y and X axis label to achieve something like this:

chart-axes-design-goal

I wasn’t able to find what options to use to group this two axes labels together in https://www.chartjs.org/docs/latest/axes/labelling.html.

Would this be possible to achieve with the Chart.js options? Am I missing something?

This is what I have so far in my options, but it’s not quite what I’m trying to achieve.

{
  scales: {
    x: {
      title: {
        display: true,
        text: 'Day',
        align: 'start',
      },
    },
    y: {
      title: {
        display: true,
        text: 'Min',
        align: 'start',
      },
    },
  }
}

Any help would be greatly appreciated! Thank you!

‘ERR_REQUIRE_ESM’ error code when running js file using Slack API

I’m a bit new to this, but I followed the this Youtube tutorial on how to build a Slack Bot but I can’t seem to make it work.

Here is my code,

For index.js

require = require("esm")(module/*, options*/)
module.exports = require("./app.js")

For app.js

import { RTMClient } from "@slack/rtm-api";
import { SLACK_0AUTH_TOKEN } from './constants.js';

const rtm = new RTMClient(SLACK_0AUTH_TOKEN); 

rtm.start().catch(console.error);

rtm.on('ready', async () => {
    console.log('Bot is now online');

});

For package.json

{
  "name": "slackapi",
  "version": "1.0.0",
  "description": "Slack Bot Testing",
  "main": "src",
  "scripts": {
    "test": "echo "Error: no test specified" && exit 1",
    "start": "node ."
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@slack/rtm-api": "^7.0.0",
    "@slack/web-api": "^7.3.1",
    "esm": "^3.2.25"
  }
}

I’ve found similar articles on using ES6 modules in Node12 but I am currently using Node Version18, and using import modules basically messes up some of my referencing.

traccar post session cookie disapper

Hello am doing a react project on localhost:3000 and am using traccar demo4.traccar.api api post session when I post data the respone status is 200 ok and data return perfect but the problem in cookie it appears with yellow background and disappears after reload when I use localhost apis cookie set perfectly but I need to use demo..

Here is the code let post = async () => { try { const data = qs.stringify({ email: "****", password: "***", }); const response = await axios.post( "https://demo4.traccar.org/api/session", data, { withXSRFToken: true, withCredentials: true, headers: { "Content-Type": "application/x-www-form-urlencoded", }, } ); console.log(response); return response.data; } catch (error) { console.error("Error posting session:", error); throw error; } };

Am trying to set my cookie to use it in another api for sockets

How to prevent HTMX from going back to /login page after sign in?

I have a Go + HTMX web app. On the Login page, there’s a form that sends a POST request to the /login route, which is guarded by a middleware, which checks if the user is already logged in, and if that’s the case, redirects them to the Dashboard page.

The post /login handler, adds an HX-Location header, set to /dashboard, so that on successful login, the user is taken straight to the Dashboard page.

The problem is that if after login, the browser’s back button is pressed, the user is taken back to the Login page. Normally that’s guarded by the middleware, but since HTMX saves the page into localStorage, the browser doesn’t make a new request to the server, and instead serves the page from the localStorage, and so the guard isn’t implemented.

What’s the best way to work around this?

Pass variable into FetchXML via Javascript for Dynamics 365

I’ll keep this concise as I find I ramble on too much if I don’t.

I’ve come up with the code below, but I continue to get an error stating that the addCustomView isn’t a function. I’ve found numerous guides online but they don’t seem to run into this issue, so I suspect I am calling the wrong control.

https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/controls/addcustomview

For context:

I have three tables in a model driven app that have connections to each other.

Account
Contact
Facility

The facility table has a form in which I want a subgrid that can only add contacts that are already associated with the “parent” account to the facility. So only contacts with parentcustomerid (from the contact) == associatedaccount (on the facility) can be seen when a user adds them via the subgrid. I think I am making a mistake with the gridContext portion and either looking at the wrong control which might explain the error?

function setFacilityContactView(executionContext) 

{
        var formContext = executionContext.getFormContext();
        var gridContext = formContext.getControl("xyz_accountlookup");
        var fetchXml = "<fetch><entity name='contact'><attribute name='fullname' /><attribute name='emailaddress1' /><attribute name='parentcustomerid' /><link-entity name='xyz_facilities' from='xyz_associatedaccount' to='parentcustomerid' alias='Facility'><attribute name='xyz_associatedaccount' /></link-entity><filter><condition attribute='parentcustomerid' operator='eq' valueof='Facility.xyz_associatedaccount' /></filter></entity></fetch>";
    
        var layoutXml = "<grid name='resultset' object='2' jump='fullname' select='1' icon='1' preview='1'><row name='result' id='contactid'><cell name='fullname' width='142' /><cell name='emailaddress1' width='131' /></row></grid>";

        var viewId = "{00000000-0000-0000-0000-000012112023}";
        var viewDisplayName = "Facility Contacts";

        gridContext.addCustomView(viewId, "contact", viewDisplayName, fetchXml, layoutXml, true);
    
}