Apex Charts on Mudblazor .Net6

This is ApexChart Razor Page which is not showing any chart displays blank page. I want to implement ApexChart on MudBlazor .Net6

@page "/apexChart"
@using MudBlazor
@using MudBlazor.Charts

<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
<div id="chart"></div>
<script>
    var options = {
        chart: {
            type: 'line'
        },
        series: [{
            name: 'sales',
            data: [30, 40, 35, 50, 49, 60, 70, 91, 125]
        }],
        xaxis: {
            categories: [1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999]
        }
    }

    var chart = new ApexCharts(document.querySelector("#chart"), options);

    chart.render();
</script>
@code {
   
}

I was expecting to display apex chart in Mudblazor as it display in html code. The code below is html code for apex chart

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
    <title>Hello, world!</title>
  </head>
  <body>
    <h1>Hello, world!</h1>
    <div id="chart"></div>
<script>
var options = {
  chart: {
    type: 'line'
  },
  series: [{
    name: 'sales',
    data: [30,40,35,50,49,60,70,91,125]
  }],
  xaxis: {
    categories: [1991,1992,1993,1994,1995,1996,1997, 1998,1999]
  }
}

var chart = new ApexCharts(document.querySelector("#chart"), options);

chart.render();
</script>
  </body>
</html>

Get microphone access for entire browser using chrome extension

i have a chrome extension with manifest v3 and in that i want that when user clicks on a button in popup then user should see a prompt to allow microphone access across entire browser and this should give my extension the access to user’s microphone over entire chrome browser but i am not able to achieve this have tried

function getLocalStream() {
  navigator.mediaDevices
    .getUserMedia({ video: false, audio: true })
    .then((stream) => {
      window.localStream = stream;
      window.localAudio.srcObject = stream;
      window.localAudio.autoplay = true;
    })
    .catch((err) => {
      console.error(`you got an error: ${err}`);
    });
}

getLocalStream();

but it gives me permission denied error and it doesn’t even show me the prompt to allow or deny access. Anyone any idea about how to handle this functionality??

Understanding immediately-invoked function expressions

I am confused as to why this html doesn’t display the cards when ran. I have tried moving the IIFE to the functions.js instead and also tried completely rewrote my prototype thinking that was the issue. I am stumped.
I am supposed to Replace the markup for the book cards with an immediately-invoked function expression that loops through my array of Book objects and calls the object’s outputCard() function.

Here is the code I currently have with the issue:

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
    <title>Project 3</title>

    <link rel="stylesheet"
        href="https://fonts.googleapis.com/css?family=Roboto:regular,bold,italic,thin,light,bolditalic,black,medium&amp;lang=en">
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
    <link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.blue_grey-deep_orange.min.css" />
    <script defer src="https://code.getmdl.io/1.1.3/material.min.js"></script>

    <link rel="stylesheet" href="css/styles.css">
    <script src="js/data.js"></script>
</head>
<body>
    <div class="mdl-layout mdl-layout--fixed-header mdl-js-layout mdl-color--blue-grey-50">
        <header class="mdl-layout__header mdl-layout__header--scroll mdl-color--blue-grey-800 mdl-color-text--white">
            <div class="mdl-layout__header-row">
                <span class="mdl-layout-title"><strong>CRM</strong> Admin</span>
                <div class="mdl-layout-spacer"></div>
                <div class="material-icons mdl-badge mdl-badge--overlap mdl-color-text--blue-grey-300" data-badge="6">
                    notifications</div>
                <div class="secondary material-icons mdl-badge mdl-badge--overlap mdl-color-text--blue-grey-300"
                    data-badge="2">email</div>
                <div class="secondary material-icons mdl-badge mdl-badge--overlap mdl-color-text--blue-grey-300"
                    data-badge="3">sms</div>
            </div>
        </header>
        <main class="mdl-layout__content">
            <aside class="mdl-grid mdl-color--blue-grey-500 mdl-shadow--2dp">
                <div class="mdl-cell mdl-cell--10-col mdl-color-text--blue-grey-50">
                    <h4>User's Products</h4>
                    <em>These are the products assigned to the current user</em>
                </div>
                <div class="mdl-cell mdl-cell--2-col ">
                    <button class="mdl-button mdl-button--icon mdl-button--colored mdl-color-text--blue-grey-200">
                        <i class="material-icons">info_outline</i>
                    </button>
                    <button class="mdl-button mdl-button--icon mdl-button--colored mdl-color-text--blue-grey-200">
                        <i class="material-icons">mode_edit</i>
                    </button>
                    <button class="mdl-button mdl-button--icon mdl-button--colored mdl-color-text--blue-grey-200">
                        <i class="material-icons">build</i>
                    </button>
                    <button class="mdl-button mdl-button--icon mdl-button--colored mdl-color-text--blue-grey-200">
                        <i class="material-icons">file_download</i>
                    </button>
                    <button class="mdl-button mdl-button--icon mdl-button--colored mdl-color-text--blue-grey-200">
                        <i class="material-icons">delete</i>
                    </button>
                </div>
            </aside>
            <section class="mdl-grid">
                <script src="js/functions.js" type="text/javascript">
(function() {
    for (var i = 0; i < books.length; i++) {
        books[i].outputCard();
    }
})();</script>
            </section>
        </main>
    </div> <!-- end layout -->
</body>
</html>

functions.js file

function Book(isbn, title, description, universities) {
    "use strict";
    this.isbn = isbn;
    this.title = title;
    this.description = description;
    this.universities = universities;
}

Book.prototype.outputCard = function() {
    document.write('<div class="mdl-cell mdl-card mdl-shadow--2dp">');
    document.write('<div class="mdl-card__media">');
    document.write('<img src="images/' + this.isbn +  'title="' + this.title + '">');
    document.write('</div>');
    document.write('<div class="mdl-card__supporting-text">');
    document.write('<p>'+this.description+'</p>');
    document.write('<h6>Adopters</h6>');
    document.write('<ul>');
    document.write('<li>'+this.universities+'</li>');
    document.write('</ul>');
    document.write('</div>');
    document.write('<div class="mdl-card__actions mdl-card--border">');
    document.write('<a class="mdl-button">READ MORE</a>');
    document.write('</div>');
    document.write('</div>');
}

There is also a file data.js with an array of 5 book objects.

How do I prioritize the visibility between input checkbox and input text?

I am having a display problem between data from input checkbox and input text

I am trying to merge 2 arrays into 1 to display in the order I choose from input checkbox or input text but it is not as I expected because the value I enter from input text is always displayed after input checkbox.

const arr1 = [...source.fields]
  const arr2 = [...source.calculates]
  const abc = arr1.concat(arr2).map((field, i) => {
      return (
        <td key={i} className={getClassNameBasedOnRole(field)}>
          {field.DISPLAY_NAME || field.field_name || field.display_name}
        </td>
      );
    })

here is my input checkbox

here is my input checkbox

here is my input text

here is my input text

here is my display table but my input text always behind

here is my display tale

How do I display letters in the correct order when I select checkbox or text first?

Error: The certificate for this server is invalid

I am creating an Outlook add-in locally. The react application for the UI makes an api call to a locally deployed flask app for some data. But the react app is never able to get the data from the flask app due to some security issue which I initially thought was because of the CORS error.

Not allowed to request resource

XMLHttpRequest cannot load https://localhost:5000/api/generate-email due to access control check

Even with CORS enabled on the flask server, the error didnt change. I also tried adding a self signed certificate in my flask app but then it shows the below errors in the console of Outlook

The certificate for this server is invalid. You might be connecting to a server that is pretending to be “localhost”, which could put your confidential information at risk

XMLHttpRequest cannot load https://localhost:5000/api/generate-email due to access control check

Failed to load resource: The certificate for this server is invalid. You might be connecting to a server that is pretending to be “localhost”, which could put your confidential information at risk

There is very limited documentation on the official website. Am I doing something wrong here or is there any other way to achieve this? Any help will be appreciated.

html-to-image returns a darker image compare to front-end component

Using Next.js 14 and html-to-image library.
The item icon, which is implemented with img tag seems to be okay.
But others get darker.

html component
enter image description here

Image downloaded from using html-to-image
enter image description here

  const handleSaveAsImage = async () => {
    const image = await toPng(boxRef.current);

    const link = document.createElement("a");
    link.href = image;
    link.download = `${itemName}`;
    link.target = "_blank"; // Open in a new tab
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
  };
      <Box
        ref={boxRef}
        sx={{
          position: "relative",
          padding: 0,
          paddingTop: 1.5,
          paddingBottom: 2,
          minWidth: "261px",
          maxWidth: "271px",
          height: "auto",
          minHeight: 180,
          backgroundColor: "background.quaternary",
          borderRadius: 2,
          display: "flex",
          flexDirection: "column",
          border: "1px solid rgba(155,155,155,0.16)",
          justifyContent: "start",
        }}
      >
      ...
      </Box>

Update SVG Quadratic Bezier curve or Cubic curve to dragging the point on the path

Im tying to achieve dragging the point should always stay on the path should update the command Q or C or S to update the curve through the point, this draggable point should not be a control point, it should pull the curve with it.

Here image shows (15,5) pointer act as control pointer. but I want this draggable circle to stay on the path and when user drags it should pull the curve with it.

currently I am using x and y position of the draggable pointer with Q command.

const d = `M10,0 Q ${draggable.x} ${draggable.y} 400 390`;

this is default behavior

Expected behavior is like this below in image, Draggable pointer should stick on top the path always and it should update the Q command or any Bezier command with its x and y.
enter image description here

React/JSX : variable is returning an empty array even after setting its value

might be best explain with an example:

I have a cascading dropdown list (where there options on the 2nd list depends on the selected option in the first)

some info

  • primary is an array of object which was populated inside a useEffect.

  • The object consists fields with primitive data types like string but other fields are array of objects

  • I’m trying to extract this array of objects into a variable that’s been defined using useState and when I tried console.log on its contents, it displays an empty array

      import { useEffect, useState } from 'react'
      import { fetchData } from '../services/Fetch'
    
      const [primary, setPrimary] = useState([])
      const [secondary, setSecondary] = useState([])
    
      useEffect(() => {
      //fetchData is just a basic fetch (built-in) function to retrieve a  JSON from a URL
      fetchData().then((response) => {
          if (Object.entries(response)) {
              setPrimary(response.primary)
          } else {
              console.log('The API has response is empty. Please check the API.')
          }
      })
      }, [])
    
      //this is my onChange event for the 1st dropdown list
      const handlePrimaryChange = (event) => {
      if (event.target.value) {
          const selectedPrimary = primary.filter((x) => x.id == event.target.value)[0]
    
          console.log('--------------------')
          if (Object.entries(selectedPrimary).length) {
              //THIS console.log DISPLAYS AN ARRAY OF OBJECTS IN THE CONSOLE
              setSecondary(selectedPrimary.secondary)
              console.log('selectedPrimary.secondaryTopics')
              console.log(selectedPrimary.secondaryTopics)
              console.log('--------------------')
    
              //THIS console.log DISPLAYS AN EMPTY ARRAY IN THE CONSOLE
              console.log('secondaryTopics')
              console.log(secondaryTopics)
              console.log('--------------------')
          }
      }
    

    }

Why fix Cannot find module?

enter image description here
I put the parcel, but as if the installed dateFns module still does not see

The operability of parcel and dateFns

index.html modules
<script src="./scripts/create-elements.mjs" type="module"></script> <script src="./scripts/storage.mjs" type="module"></script> <script src="./scripts/utils.mjs" type="module"></script> <script src="./scripts/errors-handling.mjs" type="module"></script> <script src="./scripts/favorites.mjs" type="module"></script> <script src="./scripts/ui.mjs" type="module"></script> <script src="./scripts/requests.mjs" type="module"></script> <script src="./scripts/main.mjs" type="module"></script>

utils.mjs
`import { format } from “date-fns”;

export const getTimeByTimestamp = (timestamp) => {
const time = new Date(timestamp);
const dateFormat = 'HH:mm';

return format(time, dateFormat);

}`

Is it possible to get the tab/favicon position with Javascript?

Is there a way to get the position, or the coordinates of the favicon, or the tab that the current page is at?

The context/goal

I wanted to add a little favicon game to a page (those games that run on the favicon) but I was wondering if I could add an arrow pointing to the favicon of the page so that I could grab the attention of the user. Something like this:

enter image description here

I could make a rough estimate and point near it with a burned padding, but this would only work if the page is the first tab opened, which most likely is not the case. Ideally I could calculate the position of the arrow to point to the tab, wherever is in the browser’s window. Like this:

enter image description here

Is there a way to do that? is there a way to access the coordinates of the tab/favicon of the current page?

What I’ve tried/found so far

I know I can locate the coordinates of an element inside the document by using the Element.getBoundingClientRect which returns a DOMRect object with the x, y, width, height and so on. But it doesn’t seem to work for the favicon, as the DOMRect returns always {x: 0, y: 0, width: 0, height: 0,...}. In the specification I couldn’t find anything that stated that this could only be used on the elements inside the body, but maybe it does not work because the favicon is not considered to be inside the viewport.

I found that I can get the position of the browser’s window itself relative to the users screen using window.screenX as explained here, but it does not change when the tab order change; it points to the upper left corner of the window.

So is there a way to get the relative tab position/coordinates using javascript? Something like window.tabX or if not, could there be a way to aproximate it maybe using the tab index or something if available? I posted all I found, I did not find anything else

Thanks so much in advance

IF statement reading the last in the series

Strange one here, I’ve got a variable racks_value which has it’s value altered on the page, depending on various calculations (yes it’s an integer and not a string). I’ve got a series of IF statements that updates the value of another variable, depending on the value of racks_value.

Now here’s the strange part – even though I’ve manually declared here in the example below that racks_value = 2 and had a console log verify this, after the IF statements have been run, the second console log shows racks_value to be 20, when it should still be 2. You can copy/paste the code below into your console of any page and it will behave the same way.

There must be something simple and obvious that I’ve missed here, but I really can’t see it, as the code looks so straightforward and simple.

var racks_value = 2;
console.log('racks value is ' + racks_value);

if (racks_value = 1){ var upfront_racks = 1000; }
if (racks_value = 2){ var upfront_racks = 2000; }
if (racks_value = 3){ var upfront_racks = 3000; }
if (racks_value = 4){ var upfront_racks = 4000; }
if (racks_value = 5){ var upfront_racks = 5000; }
if (racks_value = 6){ var upfront_racks = 6000; }
if (racks_value = 7){ var upfront_racks = 7000; }
if (racks_value = 8){ var upfront_racks = 8000; }
if (racks_value = 9){ var upfront_racks = 9000; }
if (racks_value = 10){ var upfront_racks = 10000; }
if (racks_value = 11){ var upfront_racks = 11000; }
if (racks_value = 12){ var upfront_racks = 12000; }
if (racks_value = 13){ var upfront_racks = 13000; }
if (racks_value = 14){ var upfront_racks = 14000; }
if (racks_value = 15){ var upfront_racks = 15000; }
if (racks_value = 16){ var upfront_racks = 16000; }
if (racks_value = 17){ var upfront_racks = 17000; }
if (racks_value = 18){ var upfront_racks = 18000; }
if (racks_value = 19){ var upfront_racks = 19000; }
if (racks_value = 20){ var upfront_racks = 20000; }
    
console.log('racks value is ' + racks_value);

I’ve tried changing the = to ===, but it doesn’t appear to help. If another new line for the IF statement series is added, the lower console log message will then return the new one.

How to correctly use the forEach method to modify an array in JavaScript?

I’m new to JavaScript and trying to understand how to use the forEach method to modify the elements of an array. I attempted the following code to append “!” to each string in an array, but it doesn’t work as expected:
code

The output remains unchanged as [“Hi”, “Hello”, “Hey”]. I expected it to be [“Hi!”, “Hello!”, “Hey!”]. Could someone explain why the changes aren’t reflected in the array and how I can modify the array elements using forEach?

Read data from subcategories on Realtime Database (Firebase)

I am trying to read the message inputs from ALL users. I can do it for a specific user but I would like to do it for all of them by specifying in my code, however, each UID is unique…

My Realtime Database is setup as:

-Realtime Database Tree-

--- chats ---
             |
            UID (unique) ---
                            |
                            email: [email protected]
                            message: Hello World.
                            date: Tues Apr 16 2024

I tried the current code below:

const dbRef = ref(getDatabase());
            get(child(dbRef, 'chats/')).then((snapshot) => {
              if (snapshot.exists()) {

                const snaps = snapshot.val();
                console.log(snaps);


              } else {
                console.log("No data available");
              }
            }).catch((error) => {
              console.error(error);


            });

I want to retrieve the email, message, and date to display it into the console.log. I can do it with specific UID’s like

            get(child(dbRef, 'chats/specific_UID')).then((snapshot) => {
              if (snapshot.exists()) {

                const snaps = snapshot.val().message;
                console.log(snaps);

However, I want to get the data inside each UID from the email, message, and date.

How can I do this?

SwaggerUI not render with Angular 13, when the build optimizer is AOT

I have an angular app when it is published to PROD the CI/CD runs the below command

node --max_old_space_size=16384 node_modules/@angular/cli/bin/ng build --aot --build-optimizer=true --optimization=true  --vendorChunk=true  --sourceMap=false --configuration=production --output-hashing=all

With this command when the swagger UI is rendered I can see it is broken with below error message at the console

ReferenceError: Must call super constructor in derived class before accessing 'this' or returning from derived constructor
    at new FM (70973.b4120c6a853870c0.js:1:868538)
    at wh (70973.b4120c6a853870c0.js:1:1404179)
    at cy (70973.b4120c6a853870c0.js:1:1425258)
    at Iy (70973.b4120c6a853870c0.js:1:1471991)
    at My (70973.b4120c6a853870c0.js:1:1459909)
    at Py (70973.b4120c6a853870c0.js:1:1459837)
    at dp (70973.b4120c6a853870c0.js:1:1459700)
    at Kh (70973.b4120c6a853870c0.js:1:1456440)
    at Ey (70973.b4120c6a853870c0.js:1:1456827)
    at xl (70973.b4120c6a853870c0.js:1:1396387)

enter image description here

However, when I do the below command, setting to FALSE

<Exec Command="node --max_old_space_size=16384 node_modules/@angular/cli/bin/ng build --aot=false --build-optimizer=false --optimization=false --vendorChunk=false --sourceMap=false --configuration=production --output-hashing=all" />

It does work and I can see the UI is working, But I can’t change the optimization. Is there anything I need to do in configuration to make it work.

"swagger-ui": "^5.15.2"


  setupSwagger() {
    SwaggerUI({
      url: `${this._baseUrl}/swagger/v1/swagger.json`,
      domNode: this.swaggerContainer?.nativeElement,
      deepLinking: false,
      presets: [
        SwaggerUI['presets']['apis']
      ],
    });
  }

<mat-card>
    <mat-card-content>
        <div #swaggerContainer></div>
    </mat-card-content>
</mat-card>

Posted the similar issue on GitHub https://github.com/swagger-api/swagger-ui/issues/9830, but no response

Browser allways pull old static files

I have a Reactjs app. When build production, i deleted wwwroot folder, then create again and copy all built file into that folder (css and js file name always diffirent). When i reload website, browser always pull old js, css files, except Ctrl + F5.

Build, deploy and reload website