Using CSS3Renderer and WebGLRenderer to render one HTML page

I have seen a lot of comments and tutorials on how to work with CSS3DRenderer and WebGLRenderer. I could implement the CSS3DRenderer, although it seems that I can’t find the right way to make orbitControls work.
My project idea is to make a HTML page and insert it on a plane to “simulate” a screen on my scene.
Right now the div seems to be overlaping the WebGL Canvas.
enter image description here

If I insert a zIndez of -1 for the css3drenderer, everything works fine again, although it doesn’t show the content from css3dRenderer.

The code for the renderer:

import * as THREE from 'three';
import Experience from "./Experience";
import { CSS3DRenderer } from 'three/examples/jsm/renderers/CSS3DRenderer.js';

export default class Renderer {
    constructor() {
        // Instancializing a singletong
        this.experience = new Experience();

        // Setup
        this.canvas = this.experience.canvas;
        this.sizes = this.experience.sizes;
        this.scene = this.experience.scene;
        this.sceneCSS3D = this.experience.sceneCSS3D;
        this.camera = this.experience.camera;

        // Methods
        this.setInstance();     
    }

    setInstance() {     
        this.instance = new THREE.WebGLRenderer({
            canvas: this.canvas,
            antialias: true,
            alpha: true
        });
        this.instance.physicallyCorrectLights = true;
        this.instance.outputEncoding = THREE.sRGBEncoding;
        this.instance.toneMapping = THREE.CineonToneMapping;
        this.instance.toneMappingExposure = 1.75;
        this.instance.shadowMap.enabled = true;
        this.instance.shadowMap.type = THREE.PCFSoftShadowMap;
        this.instance.setClearColor(0xFF00FF, 1);
        this.instance.setSize(this.sizes.width, this.sizes.height);
        this.instance.setPixelRatio(Math.min(window.devicePixelRatio, 2));
        document.body.appendChild(this.instance.domElement);

        // CSS3d
        this.css3drenderer = new CSS3DRenderer();
        this.css3drenderer.setSize(this.sizes.width, this.sizes.height);
        this.css3drenderer.domElement.style.position = 'absolute';
        this.css3drenderer.domElement.style.top = 0;        
        document.body.appendChild(this.css3drenderer.domElement);   
    }

    resize() {
        this.instance.setSize(this.sizes.width, this.sizes.height);
        this.instance.setPixelRatio(Math.min(window.devicePixelRatio, 2));
    }

    update() {
        this.instance.render(this.scene, this.camera.instance);
        this.css3drenderer.render(this.sceneCSS3D, this.camera.instance);
    }
}

How I tried setting up the object:

import * as THREE from 'three';
import Experience from "../Experience";
import { CSS3DObject } from 'three/examples/jsm/renderers/CSS3DRenderer.js';

export default class Object {
    constructor() {
        this.experience = new Experience();
        this.scene = this.experience.scene;
        this.sceneCSS3D = this.experience.sceneCSS3D;
        this.resources = this.experience.resources;
        this.time = this.experience.time;
        this.debug = this.experience.debug;

        // Setup
        this.resources = this.resources.items;

        // Methods
        this.setModel();
    }

    setModel() {
        this.model = {};

        // CSS3D
        this.model.element = document.createElement('div');     
        this.model.element.innerHTML = `Tutorix is the best e-learning platform Tutorix is the best e-learning platform Tutorix is the best e-learning platform`;
        this.model.element.style.width = '5px';     
        this.model.element.style.height = '5px';
        this.model.element.style.overflowY = 'auto';
        this.model.element.style.backgroud = new THREE.Color(0xFFFFFF).getStyle();      

        this.model.meshCss3d = new CSS3DObject(this.model.element);
        this.model.meshCss3d.scale.x = 1;
        this.model.meshCss3d.scale.y = 1;
        this.sceneCSS3D.add(this.model.meshCss3d);

        // Plane
        this.model.material = new THREE.MeshBasicMaterial({
            color: 0x000000,
            wireframe: true,
            wireframeLinewidth: 1,
            side: THREE.DoubleSide
        });
        this.model.mesh = new THREE.Mesh(new THREE.PlaneGeometry(10, 10), this.model.material);

        this.scene.add(this.model.mesh);        
    }

    update() {      
    }
}

My HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Nilton SF</title>        
        <link rel="stylesheet" href="../tailwind/tailwind.css">
</head>
<body>
  <canvas class="webgl"></canvas>
</body>
</html>

Function called twice with one call

import logo from './logo.svg';
import './App.css';

function getRandomInt(max) {
  return Math.floor(Math.random() * max);
}

function App() {

//ReactDOM.render(<Welcome />, feedDisplay);
fetch('http://localhost:8000/results',{ mode: 'cors' })
    .then(response => {return response.json();})
    .then(data => {
        var businesses = [];
        for (const business of data) {  
            businesses.push(business);
        }
        const result = businesses[getRandomInt(businesses.length)].name;
        this.setState({fetchedData: result});
    })
.catch(err => console.log(err))

  return (
    <div className="App">
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <p>
          Choice:
          {this}
        </p>
        <a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer"
        >
          Learn React
        </a>
      </header>
    </div>
  );
}

export default App;

Why is fetchIt called twice? My state always gets updated twice even though there’s only one call.

I thought maybe it was the definition, and I tried commenting out the call and not the definition but it doesnt get results anymore.

Console logs running twice and state is updated twice.

Daemon setTimeout in js

I am writing a node.js library that requires setup in order to run. I have used setTimeout to show a warning if the setup function isn’t run within 5 seconds.

However, this makes the program wait for 5 seconds before exiting, even if all the other code is finished.

I want to show a warning message iff the setup function hasn’t been called and the program is still running after 5 seconds. Is there a way to do this with vanilla JS?

const done = new Event(); // Event is a simple class I made for a one-time event multicast

function setup() {
  done.emit();
}

const timeoutHandle = setTimeout(() => showWarning(), 5000);
done.subscribe(() => {
  clearTimeout(timeoutHandle);
});

console.log("The program should end here");

// The program keeps going for 5 seconds even after the last statement

Expected type X but passed X | undefined | null even with check

I have this piece of code:

if (!context) {
  alertStore.SET_GLOBAL_ALERT({
    color: "red",
    text: "Cannot get context of chart",
    show: true,
    loading: false,
  });
  return;
}
let sets = usersDatapoints.map(({ data }) => {
  return getDatasets(data, context, gradientHeight, borderWidth).consumption
})

My problem is at getDatasets. It complains about context.

My function getDatasets expects an CanvasRenderingContext2D but receives an CanvasRenderingContext2D | undefined | null

I even did an check before if(!context) { ... return } but it still complains about.

Why is typescript not able to get the right type here?

Hide certain search results using JQuery

I have a basic search bar with about 25 options to be searched, what I need to do is hide 2 of those options from the user. Initially, the modal with the options loads like this:

Init

But if i write and delete something in the input this is what happens:

Example

I need to hide the repeated option CÓDIGO and the blank one from the user, (just like the first image) but I’m having trouble doing so…

Here is the JQuery code used to perform the search:

 $('#searchColumns').on('keyup', function () {
    var search = $(this).val().toLowerCase();

    $('#selectColumnsTable tr').filter(function() {
       $(this).toggle($(this).text().toLowerCase().indexOf(search) > -1);
    });
 });

And just in case, the code for the modal: (using Alpine.js v2.8.2 and laravel-livewire)

<div x-data="{
        data:columns,
        selectedColumns: ['sap_id'],
    }" 
    wire:ignore class="modal fade" id="selectColumnsModal" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">Selecionar Colunas</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <i aria-hidden="true" class="ki ki-close"></i>
                    </button>
                </div>
                <p class="mx-10 mt-4">Selecione até 9 colunas para exibir...</p>
                <div class="text-center mx-10">
                    <div class="input-icon">
                        <input type="text" class="form-control" placeholder="Nome da coluna..." id="searchColumns">
                        <span>
                            <i class="flaticon2-search-1 text-muted"></i>
                        </span>
                    </div>
                </div>
                <div class="modal-body">
                    <div class="mt-6 text-center">
                        <table id="selectColumnsTable" class="table table-hover gy-5">
                            <thead>
                                <th class="text-left">
                                    Coluna
                                </th>
                                <th class="text-left">
                                    <i class="la la-eye"></i>
                                </th>
                            <thead>
                            <tbody>
                                <tr>
                                    <td class="text-left ml-4"> 
                                        <span x-html="columns[1].title"></span> 
                                    </td>
                                    <td class="text-left">
                                        <input 
                                            x-model="selectedColumns"
                                            class="sapId" 
                                            id="sapId"
                                            type="checkbox"
                                            value="sap_id" 
                                            disabled 
                                            checked
                                        >
                                    </td>
                                </tr> 
                                <template x-for="(column, index) in data" :key="index">                          
                                    <tr x-show="column.field != 'id' && column.field != 'sap_id' &&column.title != '' && column.title != 'CÓDIGO'">
                                        <td class="text-left ml-4"> 
                                            <span x-html="column.title"></span> 
                                        </td>
                                        <td class="text-left">
                                            <input 
                                                x-model="selectedColumns" 
                                                id="selectColumns" 
                                                class="selectColumns" 
                                                type="checkbox" 
                                                :value=column.field
                                            >
                                        </td>
                                    </tr>
                                </template>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="modal-footer d-flex justify-content-around">
                    <button @click="displaySelected(selectedColumns)" type="button" class="btn btn-primary col-5" data-target="click">Exibir selecionadas</button>
                    <button type="button" class="btn btn-danger col-5" data-dismiss="modal">Cancelar</button>
                </div>
            </div>
        </div>
    </div>

How to group inside a JS map function

I have some data coming from the DB:

{InteractionDate: '2022-07-07', Time: 10, ID: 'eac61b7e-8e25-4445-ad1d-f1ee8c6ac86c'}
{InteractionDate: '2022-07-07', Time: 20, ID: 'c3a78dbe-553d-4ecc-b4ef-8d8d3039c521'}
{InteractionDate: '2022-07-07', Time: 33, ID: 'c3a78dbe-553d-4ecc-b4ef-8d8d3039c521'}
{InteractionDate: '2022-07-07', Time: 30, ID: '229530ed-ca44-4015-b1d7-b528be5b6071'}

and I need to show it in the UI like so:

Month   Time    # of Unique ID's
=====   ====    ================
07/22   93      3

The ID’s is a new addition that I need some help with. Right now, I’m using this to group all the dates and sum the times.

        const groupedArray = _(allInteractions)
        .groupBy(v => moment(v.InteractionDate).format('MM/YYYY'))
        .map((item, date) => ({
            interactionDate: date,
            totalSec: _.sumBy(item, 'Time')
            //uniqueIDs:    ?
        }))
        .value();

The question is – How do I know how many DIFFERENT id’s were seen in 07/22?

how to change the zoom JQPlot

I was interested in how the chart is drawn in steam using jqPlot and tried to do it myself. However I ran into a problem that the pop-up window is not displayed when changing the zoom.

The function responsible for this is pricehistory_zoomMonthOrLifetime(). Please tell me how to fix this. Thanks in advance.

let itemInfoDiv = document.getElementById("largeiteminfo");
let itemDiagramHistory = `<div id="diagram_history"></div>`;
itemInfoDiv.insertAdjacentHTML('afterend', itemDiagramHistory);
var lineHistory = [
  ["Jan 21 2022 01: +0", 10.675, "76680"],
  ["Jan 22 2022 01: +0", 6.173, "70330"],
  ["Jan 23 2022 01: +0", 4.914, "62767"],
  ["Jan 24 2022 01: +0", 4.328, "52950"],
  ["Jan 25 2022 01: +0", 3.996, "51942"],
  ["Jan 26 2022 01: +0", 3.329, "52060"],
  ["Jan 27 2022 01: +0", 3.007, "53145"],
  ["Jan 28 2022 01: +0", 2.833, "58964"],
  ["Jan 29 2022 01: +0", 2.639, "62989"],
  ["Jan 30 2022 01: +0", 2.32, "62221"],
  ["Jan 31 2022 01: +0", 2.149, "57524"],
  ["Feb 01 2022 01: +0", 2.253, "52495"],
  ["Feb 02 2022 01: +0", 2.249, "53070"],
  ["Feb 03 2022 01: +0", 2.177, "52633"],
  ["Feb 04 2022 01: +0", 2.091, "56569"],
  ["Feb 05 2022 01: +0", 2.028, "59364"],
  ["Feb 06 2022 01: +0", 1.827, "59430"],
  ["Feb 07 2022 01: +0", 1.677, "57285"],
  ["Feb 08 2022 01: +0", 1.595, "53459"],
  ["Feb 09 2022 01: +0", 1.458, "54600"],
  ["Feb 10 2022 01: +0", 1.478, "53461"],
  ["Feb 11 2022 01: +0", 1.53, "57660"],
  ["Feb 12 2022 01: +0", 1.537, "61756"],
  ["Feb 13 2022 01: +0", 1.478, "58925"],
  ["Feb 14 2022 01: +0", 1.371, "49140"],
  ["Feb 15 2022 01: +0", 1.348, "51438"],
  ["Feb 16 2022 01: +0", 1.382, "52438"],
  ["Feb 17 2022 01: +0", 1.376, "50224"],
  ["Feb 18 2022 01: +0", 1.37, "57686"],
  ["Feb 19 2022 01: +0", 1.347, "61149"],
  ["Feb 20 2022 01: +0", 1.248, "59893"],
  ["Feb 21 2022 01: +0", 1.2, "56376"],
  ["Feb 22 2022 01: +0", 1.207, "58730"],
  ["Feb 23 2022 01: +0", 1.187, "58204"]
]

m_timePriceHistoryEarliest = new Date();
if (lineHistory != false) {
  m_timePriceHistoryEarliest = new Date(lineHistory[0][0]);
  m_timePriceHistoryLatest = new Date(lineHistory[lineHistory.length - 1][0]);
}



m_plotPriceHistory = CreateMyPriceHistoryGraph(lineHistory, 5, "$", "");

pricehistory_zoomMonthOrLifetime(m_plotPriceHistory, m_timePriceHistoryEarliest, m_timePriceHistoryLatest);

function CreateMyPriceHistoryGraph(lineHistory, numYAxisTicks, strFormatPrefix, strFormatSuffix) {
  var plot = $.jqplot('diagram_history', [lineHistory], {
    title: {
      text: 'Price',
      textAlign: 'left'
    },
    gridPadding: {
      left: 45,
      right: 45,
      top: 25
    },
    axesDefaults: {
      showTickMarks: false
    },
    axes: {
      xaxis: {
        renderer: $.jqplot.DateAxisRenderer,
        tickOptions: {
          formatString: '%b %#d<span class="priceHistoryTime"> %#I%p<span>'
        },
        pad: 1
      },
      yaxis: {
        pad: 1.1,
        tickOptions: {
          formatString: strFormatPrefix + '%0.2f' + strFormatSuffix,
          labelPosition: 'start',
          showMark: false
        },
        numberTicks: numYAxisTicks
      }
    },
    grid: {
      gridLineColor: '#1b2939',
      borderColor: '#1b2939',
      background: '#101822'
    },
    cursor: {
      show: true,
      zoom: true,
      showTooltip: false
    },
    highlighter: {
      show: true,
      lineWidthAdjust: 2.5,
      sizeAdjust: 5,
      showTooltip: true,
      tooltipLocation: 'n',
      tooltipOffset: 20,
      fadeTooltip: true,
      yvalues: 2,
      formatString: '<strong>%s</strong><br>%s<br>Продано: %d'
    },
    series: [{
      lineWidth: 3,
      markerOptions: {
        show: false,
        style: 'circle'
      }
    }],
    seriesColors: ["#688F3E"]
  });

  plot.defaultNumberTicks = numYAxisTicks;
  return plot;
}

function MyGetYAXisForPriceHistoryGraph(plotPriceHistory, timeMin, timeMax) {
  var min = -1;
  var max = 0.06;
  for (var index in plotPriceHistory.series[0].data) {
    var rgData = plotPriceHistory.series[0].data[index];
    if (rgData[0] >= timeMin.getTime() && rgData[0] <= timeMax.getTime()) {
      if (rgData[1] > max) {
        max = rgData[1];
      }

      if (rgData[1] < min || min == -1) {
        min = rgData[1];
      }
    }
  }

  return $.jqplot.LinearTickGenerator(min, max, null, plotPriceHistory.defaultNumberTicks, false, false);
}



function pricehistory_zoomMonthOrLifetime(plotPriceHistory, timePriceHistoryEarliest, timePriceHistoryLatest) {
  var timeMonthAgo = new Date(timePriceHistoryLatest.getTime() - (30 * 24 * 60 * 60 * 1000));
  plotPriceHistory.resetZoom();

  var days = (timePriceHistoryLatest.getTime() - timePriceHistoryEarliest.getTime()) / (24 * 60 * 60 * 1000);
  if (days / 7 < 1) {
    var difference = timePriceHistoryLatest.getTime() - timePriceHistoryEarliest.getTime();
    plotPriceHistory.axes.xaxis.ticks = [timePriceHistoryEarliest, new Date(timePriceHistoryEarliest.getTime() + difference * 0.25), new Date(timePriceHistoryEarliest.getTime() + difference * 0.5), new Date(timePriceHistoryEarliest.getTime() + difference * 0.75), timePriceHistoryLatest];
  } else {
    plotPriceHistory.axes.xaxis.tickInterval = (days / 7) + " days";
  }
  if (timePriceHistoryEarliest > timeMonthAgo)
    plotPriceHistory.axes.xaxis.min = timePriceHistoryEarliest;
  else
    plotPriceHistory.axes.xaxis.min = timeMonthAgo;
  plotPriceHistory.axes.xaxis.max = timePriceHistoryLatest;

  var rgYAxis = MyGetYAXisForPriceHistoryGraph(plotPriceHistory, plotPriceHistory.axes.xaxis.min, timePriceHistoryLatest);
  plotPriceHistory.axes.yaxis.min = rgYAxis[0];
  plotPriceHistory.axes.yaxis.max = rgYAxis[1];
  plotPriceHistory.axes.yaxis.numberTicks = rgYAxis[2];
  plotPriceHistory.axes.yaxis.tickInterval = rgYAxis[4];

  plotPriceHistory.replot();

  $('#diagram_history').children().first().remove();
  $('#diagram_history').children().last().remove();

  return false;
}
<link href="https://community.cloudflare.steamstatic.com/public/css/skin_1/economy.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://community.cloudflare.steamstatic.com/public/javascript/jqplot/jquery.jqplot.js"></script>
<script src="https://community.cloudflare.steamstatic.com/public/javascript/jqplot/plugins/jqplot.cursor.min.js"></script>
<script src="https://community.cloudflare.steamstatic.com/public/javascript/jqplot/plugins/jqplot.dateAxisRenderer.min.js"></script>
<script src="https://community.cloudflare.steamstatic.com/public/javascript/jqplot/plugins/jqplot.highlighter.min.js"></script>

<div id="largeiteminfo"></div>

Javascript to calculate the control point for svg path corresponding to custom cubic-bezier

To draw a bezier-curve as svg path one needs to use the following where x0,y0 are start anchor point x1,y1 and x2,y2 are control points and x3,y3 are end point- Ref

 M x0,y0 C x1 y1, x2 y2, x3 y3

A complete example is below

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script type="text/javascript" src="https://d3js.org/d3.v7.min.js"></script>


<body>

    <!--<link rel="stylesheet" href="style.css"></link>-->
    <!-- <style type="text/css">
        @import url("cssVar.css");
    </style>-->
    <style>
        @import url('https://fonts.googleapis.com/css2?family=DM+Sans&display=swap');
        @import url('https://fonts.googleapis.com/css2?family=Oswald:wght@200&display=swap');
    </style>

    <!--<link rel="stylesheet" href="style.css"></link>
    -->
    <div id="container" class="svg-container"></div>
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1280 720">
        <g class="test">
        <path d="M0,0 C100,100 400,100 1280,720" stroke="red" fill="none"></path>
    </g>
    <!--d3 script-->
    <script src="prod.js"></script>
</body>

</html>

However, I have custom bezier values such as "0.42,0,1,1." coming from CSS custom-bezier easing and I can draw the path that corresponds to the value. Such as,

const width = 1280;
height = 720;

svg = d3.select('svg')
    .attr('xmlns', 'http://www.w3.org/2000/svg')
    .attr('viewBox', `0 0 ${width} ${height}`)

rect = svg.append('rect')
    .attr('x', '0')
    .attr('y', '0')
    .attr('width', `${width}`)
    .attr('height', `${height}`)
    .attr('fill', `transparent`)

pathVal = (data) => d3.line()
    .x(d => d.x)
    .y(d => d.y)
    (data);

//testing curve = #ease-in = cubic-bezier(0.42,0,1,1)    
var cubicBezCurvVal = "0.42,0,1,1."

//split bezier curve value
var cleanVal = cubicBezCurvVal.split(',');
//clean space with map -retunrns new array with the function, original array unchnaged
var cleanVal = cleanVal.map((x) => parseFloat(x.replace(/ /g, '')));


//p0 - startPoint/start anchor point
const p0 = { x: 0, y: 0 };
//p3 - endPoint /end achor point
const p3 = { x: 1, y: 1 };
//p1 - controlPoint1 /start control point
const p1 = { x: cleanVal[0], y: cleanVal[1] };
//p2 - controlPoint2 / end control point
const p2 = { x: cleanVal[2], y: cleanVal[3] };

const x0 = p0.x;
const y0 = p0.y;

const x1 = p1.x;
const y1 = p1.y;

const x2 = p2.x;
const y2 = p2.y;

const x3 = p3.x;
const y3 = p3.y;

const pct = [];

for (let i = 0; i <= 1; i += 0.1) {
    pct.push(i)
}

const dataPoints = [];

//credit - https://blog.maximeheckel.com/posts/cubic-bezier-from-math-to-motion/
//get x coordinate for t
const getX = (t) => {
    return Math.pow(1 - t, 3) * x0 +
        3 * Math.pow(1 - t, 2) * t * x1 +
        3 * (1 - t) * Math.pow(t, 2) * x2 +
        Math.pow(t, 3) * x3;
}

//get y coordinate for t
const getY = (t) => {
    return Math.pow(1 - t, 3) * y0 +
        3 * Math.pow(1 - t, 2) * t * y1 +
        3 * (1 - t) * Math.pow(t, 2) * y2 +
        Math.pow(t, 3) * y3;
}

pct.forEach(
    (a) => dataPoints.push({ x: getX(a) * width, y: getY(a) * height })
)

svg.append('g')
    .attr('class', 'index1')
    .append('path')
    .attr('class', 'BezierLine')
    .attr('d', pathVal(dataPoints))
    .attr('stroke', 'green')    
    .attr('fill', 'none')
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script type="text/javascript" src="https://d3js.org/d3.v7.min.js"></script>


<body>

    <!--<link rel="stylesheet" href="style.css"></link>-->
    <!-- <style type="text/css">
        @import url("cssVar.css");
    </style>-->
    <style>
        @import url('https://fonts.googleapis.com/css2?family=DM+Sans&display=swap');
        @import url('https://fonts.googleapis.com/css2?family=Oswald:wght@200&display=swap');
    </style>

    <!--<link rel="stylesheet" href="style.css"></link>
    -->
    <div id="container" class="svg-container"></div>
    <svg>
        <g class="test">
        <path d="M0,0 C100,100 400,100 1280,720" stroke="red" fill="none"/>
    </g>
    </svg>
    <!--d3 script-->
    <script src="prod.js"></script>
</body>

</html>

But instead of calculating it this way,
if I want to create the red path using M x0,y0 C x1 y1, x2 y2, x3 y3 that would exactly correspond to the green path, how do I calculate the control points, that would go in the following path string M 0,0 C x1 y1, x2 y2, 1280,720

Flask how to save render_template(html_file) as a string variable?

Hi all I’m trying to save a html render_template file as a string variable. For example

render_variable = str(render_template(email.html,house_prices=prices)

I’m trying to get the string version of this render html file because I’ll be sending the html file as an email. In order to send an outlook email with this html file, the body of the email (html file) needs to be a string.

Thanks in advance.

function is not running completly instead moving to other function

In my route
router.get("/", verifyAdmin, getUsers);

It should first verify admin then move to the getUsers function.

but instead ,In my function verify admin:

export const verifyAdmin = (req, res,next) => {
    verifyToken(req,res,next,() => {     // this annonymous function is not running
       
      if (req.user.isAdmin) {
        next();
      } else {
        return res.status(403).json("you are not admin");
      }
    });
  };

export const verifyToken = (req,res,next) => { 
    const token = req.cookies.access_token;
    if(!token) return res.status(404).json("You are not authenticated");

    jwt.verify(token,JWT_KEY,(err,user)=>{
        if(err) return res.status(403).json("Token is invalid");

        req.user =user;
        
        next();    // after this it is supposed to move to the annonymous function but it is moving to getUser function instead.
    })
   

};

how can I remove gray outline that insists on appearing on my logo when refreshing pages?

I guess it’s easier to understand my problem with images:

This is the homepage (image 1). When I refresh it or if I go to the other pages, an annoying gray outline contours the logo (image2), like a glance, and then disappears. Do you guys know how to remove this thing?

image1
image2

I added an additional CSS code on elementor pro so it started happening….This is the code:

selector.elementor-sticky--effects{
background-color: rgba(0,0,0,0.7)!important
}

selector{
transition: background-color 1s ease !important;
}

selector.elementor-sticky--effects >.elementor-container{
min-height: 70px;
}

selector > .elementor-container{
transition: min-height 1s ease !important;
}

.logo img {
max-width: 110px;
height: auto;
transition: all 1s ease;
}

}

.elementor-sticky--effects .logo img {
max-width: 90px;
height: auto;
}

How to get a list of warnings from next.js terminal?

When i run my project with VScode, i see a lot of warnings in my terminal. The example of such warning:

 The `bg-variant` mixin has been deprecated as of v4.4.0. It will be removed entirely in v5.
         on line 8 of node_modules/bootstrap/scss/mixins/_deprecate.scss, in mixin `deprecate`
         from line 15 of node_modules/bootstrap/scss/mixins/_background-variant.scss, in mixin `bg-variant`
         from line 256 of src/styles/_utils.scss
         from line 23 of stdin

How can i get these warnings from the VSCode terminal into my JS code and handle them? (in example, log them in browser console or store in an array)

Shape disappears in fullscreen

var id = document.getElementById('canvas');
var ctx = id.getContext('2d');
console.log(ctx);

var arrow = {

  triangle: function() {
    ctx.beginPath();
    ctx.moveTo(75, 50);
    ctx.lineTo(100, 75);
    ctx.lineTo(100, 50);
    ctx.fill();
  }
};

arrow.triangle();

when I run this it shows the shape however when I enter fullscreen it disappears. How can I make it so on fullscreen it doesn’t disappear?

How to move entire PopupSubMenuMenuItem higher on aggregate menu

I’m curently working on some extension to the gnome-shell. I added a new Popup menu into aggregate menu in status area, but can’t move it to the desired position. Tried menu.moveMenuItem(item, position), but it moves only the “main” item, not the entire dropdown (How it looks – my PopupSubMenuMenuItem is named ThermalManagement, and submenu menu items starts from Optimized). What I need to do to move an entire submenu into specific position?

Code sample:

enable() {
    this._item = new PopupMenu.PopupSubMenuMenuItem('Thermal Management', true);
    this._item.icon.icon_name = 'applications-system-symbolic';
    let position = this._findMenuItemPosition(Main.panel.statusArea.aggregateMenu._power.menu) + 1;

    this._optimizedOption = this._createOptimizedOption();
    this._item.menu.addMenuItem(this._optimizedOption);

    this._quietOption = this._createQuietOption();
    this._item.menu.addMenuItem(this._quietOption);

    this._coolOption = this._createCoolOption();
    this._item.menu.addMenuItem(this._coolOption);

    this._ultraPerformanceOption = this._createUltraPerformanceOption();
    this._item.menu.addMenuItem(this._ultraPerformanceOption);

    Main.panel.statusArea.aggregateMenu.menu.addMenuItem(this._item);
    Main.panel.statusArea.aggregateMenu.menu.moveMenuItem(this._item, position);
}