Dynamically added content is not resizing container correctly

I have stripped down my code to the minimum that does what I want and still shows the problem.

I have a dialog that has three parts: header, content and footer. The dialog content is further broken down into an inner content and inner footer.

The inner content will get it’s data from an ajax call. The data is a collapsable tree. The problem occurs when I click on a node to expand it the inner footer and dialog footer get pushed off the visible portion of the dialog.

The dialog is resizable and the moment I resize it even by as little as a pixel the layout corrects itself immediately. I have been at this for a couple of days now with no luck. I am open to any suggestions.

JSFiddle Demo

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Testing Collapsable Trees</title>
        <style>
        ul.tree
        {
            margin-block-start: 0;
        }
        
        ul.tree li:hover
        {
            background-color: yellow;
        }

        ul.tree li 
        {
            padding-top : 0.25em;
            list-style-type: none;
            position: relative;
        }

        ul.tree ul 
        {
            display: none;
        }

        ul.tree ul.open
        {
            display: block;
        }

        ul.tree li::before 
        {
            height: 1em;
            padding: 0.1em;
            font-size: 0.8em;
            display: block;
            position: absolute;
            left: -1.3em;
            top: 0.35em;
        }
        
        ul.tree li:has(+ul)
        {
            text-decoration : underline black double 1px;
        }

        ul.tree li:has(+ul)::before 
        {
            content: '+';
        }

        ul.tree li:has(+ul.open)::before 
        {
            content: '-';
        }
        
        .selectedNode
        {
            color : green;
        }
        
        dialog
        {
            overflow: hidden;
            resize: both;
            padding : 0;
            margin: auto;
            max-height: 25%;
        }
        
        dialog h3
        {
            margin : 0.25em 0;
        }

        dialog button
        {
            margin: 0.33em;
            padding: 0.33em 0.5em;
        }
        
        .dlgbody
        {
            height: 100%;
            display: grid;
            grid-template-columns: 1fr;
            grid-template-rows: auto 1fr auto;
            grid-template-areas: 'header' 'main' 'footer';
        }
        
        .dlgheader 
        {
            background-color: lightgreen;
            display: flex;
            justify-content: center;
            border-bottom: 2px double black;
            grid-area: header;
        }

        .dlgcontent 
        {
            overflow: hidden;
            background-color: white;
            grid-area: main;
            padding: 5px;
        }

        .dlgfooter 
        {
            background-color: lightblue;
            padding-right: 0.5em;
            display: flex;
            justify-content: flex-end;
            border-top: 2px double black;
            grid-area: footer;
        }

        .fmbody
        {
            height: 100%;
            display: grid;
            grid-template-columns: 1fr;
            grid-template-rows: 1fr auto;
            grid-template-areas: 'fmmain' 'fmfooter';
        }

        .fmcontent 
        {
            background-color: white;
            grid-area: fmmain;
            overflow: auto;
            padding: 0px 5px 0px 5px;
        }

        .fmfooter 
        {
            background-color: white;
            border-top: 1px solid black;
            grid-area: fmfooter;
        }
        </style>
        <script>
        class Tree
        {
            constructor(root)
            {
                this.root = document.createElement("ul");
                this.root.classList.add("tree");
                this.root.tabIndex = "-1";
                
                this.root.addEventListener("click", evt => this.mouseHandler(evt));
            }
            
            toggleCollapse(evt)
            {
                let node = evt.target.nextElementSibling;
                
                if(node == null || node.nodeName != "UL")
                    return;
    
                if(node.classList.contains("open")) 
                {
                    node.classList.remove('open');
       
                    let opensubs = node.querySelectorAll(':scope .open');
       
                    for(let i = 0; i < opensubs.length; i++) 
                        opensubs[i].classList.remove('open'); 
                } 
                else 
                    node.classList.add('open'); 
            }
            
            mouseHandler(evt)
            {
                this.toggleCollapse(evt);
            
                let node = this.getSelected();
                
                if(node != null)
                    node.classList.remove("selectedNode");
                    
                evt.target.classList.add("selectedNode");
                
                this.root.dispatchEvent(new Event("selected"));
            }
            
            getRoot()
            {
                return this.root;
            }
            
            getSelected()
            {
                return this.root.querySelector(":scope .selectedNode");
            }
        }
        
        class Dialog
        {
            constructor()
            {
                this.dialogDiv = document.createElement("dialog");
                this.dlgHeader = document.createElement("div");
                this.dlgContent = document.createElement("div");
                this.dlgFooter = document.createElement("div");
            }
            
            init(opts)
            {
                let body = document.createElement("div");
                body.classList.add("dlgbody");
                
                // Build header
                let title = document.createElement("h3");
                title.innerHTML = opts.title;
                this.dlgHeader.appendChild(title);
                this.dlgHeader.classList.add("dlgheader");
                body.appendChild(this.dlgHeader);
                
                // build div for dialog content
                this.dlgContent.classList.add("dlgcontent");
                body.appendChild(this.dlgContent);
        
                // build footer
                let okbutton = document.createElement("button");
                okbutton.textContent = "OK";
                okbutton.onclick = (evt) => { this.dialogDiv.close("OK"); }
                this.dlgFooter.appendChild(okbutton);
        
                this.dlgFooter.classList.add("dlgfooter");
                body.appendChild(this.dlgFooter);
                
                this.dialogDiv.appendChild(body);
                document.body.appendChild(this.dialogDiv);
            }
            
            show()
            {
                this.dialogDiv.returnValue = "";
                this.dialogDiv.showModal();
            }
            
            getContentDiv()
            {
                return this.dlgContent;
            }
            
            getDialogRoot()
            {
                return this.dialogDiv;
            }
        }   
        
        class FileManager
        {
            constructor(opts)
            {
                this.uiList = document.createElement("div");
                this.files = new Tree();
                this.dialog = new Dialog();
        
                this.dialog.init({title : opts.title});
        
                this.uiList.classList.add("fmcontent");
                this.uiList.appendChild(this.files.getRoot());
                
                let uiFooter = document.createElement("div");
                uiFooter.classList.add("fmfooter");
        
                let label = document.createElement("h3");
                label.textContent = "Content Footer";   
                uiFooter.appendChild(label);
        
                let ui = document.createElement("div");
                ui.classList.add("fmbody");
                ui.appendChild(this.uiList);
                ui.appendChild(uiFooter);
        
                this.dialog.getContentDiv().appendChild(ui);
            }
            
            loadData()
            {
                let tree = this.files.getRoot();
                let data = JSON.parse(testData);
                
                this.build(tree, data);
            }
            
            showDialog()
            {
                this.dialog.show();
                this.files.getRoot().focus();
                
                if(this.files.getRoot().children.length == 0)
                    this.loadData();
            }
            
            build(tree, data)
            {
                for(let i = 0; i < data.length; i++)
                {
                    if(i == 0)
                    {
                        if(data[i] == "")
                            continue;
                    
                        let li = document.createElement("li");
                        li.textContent = data[i];
                        tree.appendChild(li);
                        
                        let ul = document.createElement("ul");
                        tree.appendChild(ul);
                        tree = ul;
                    }
                    
                    if(Array.isArray(data[i]))
                        this.build(tree, data[i]);
                    else if(i > 0)
                    {
                        let li = document.createElement("li");
                        li.textContent = data[i];
                        tree.appendChild(li);
                    }
                }
            }
        }

        var testData = '["", ["files", "subfile1", "subfile2", "subfile3", "subfile4", "subfile5", "subfile6"], ["images", "image 1"]]';
        var fm = null;

        function init()
        {
            fm = new FileManager({title : "Dialog Header"});
        }
        </script>
    </head>
    <body onload="init();">
        <button onclick="javascript:fm.showDialog();">Dialog</button>
    </body>
</html>

Initial

Broken

After manual resizing

How to open new page with certain radio inputs checked

To simplify, here is an example.
I want to have a link from my index page to my Inputs.html with one of the inputs selected.

For example, on first link i want to open the Inputs page with “red” radio input to be checked, on second- green and etc.

So far only html, js and css are used on site, with some php on server

Inputs.html

...
<input type="radio" name="color" id="red" value="red" />
<label...>
<input type="radio" name="color" id="green" value="green" />
<label...>
<input type="radio" name="color" id="blue" value="blue" />
<label...>
...

Why is my D3 map showing a blank/dead area for one county but correctly showing all other 3,140 counties?

I updated a D3 map of all US counties by SNAP participation to use newer data (2021 ACS) and an updated topojson file (counties-alters-10m.json, from US Atlas, on Github here: https://github.com/topojson/us-atlas). It worked great for all but one county: Mohave County, Arizona.

I checked the FIPS code for Mohave County (04015), which is correct in both the SNAP data and in the topojson file–leading 0 showing and everything.

Here’s some of the JavaScript code, which layers the set of all counties with sets of counties divided into those in Metropolitan areas, those in micropolitan areas, and those in neither, so I can add buttons to turn on/off each set of counties:

// Queue up datasets using d3 Queue
d3.queue()
    .defer(d3.json, "./data/counties-albers-10m.json")
    .defer(d3.tsv,  "./data/snap_acs_2021_5yr.tsv")
    .await(ready);

function ready(error, us, snap) {
  if (error) throw error;
<variable initiation here>

             snap.forEach(function(d) {
<variable value setting here>
             });
    
g.selectAll("path")
      .data(topojson.feature(us, us.objects.counties).features)
    .enter().append("path")
      .attr("d", path)
      .attr("class", "counties")
      .on("click", clicked)
        .style("fill", function(d) {
             return color(rateById[d.id]);
        }).on("mousemove", function(d) {          
<HTML code ommitted here for length>  
                      
                          $("#tooltip-container").html(html);
                          $("#tooltip-container").show();
                          
                              var coordinates = d3.mouse(this);
            d3.select("#tooltip-container")
              //Show the tooltip above where the mouse triggers the event
              .style("top", (d3.event.pageY - 250) + "px")
              .style("left", (d3.event.pageX - 250) + "px");
        })
                      .on("mouseout", function() {
                        $console.log(d);
                              $("#tooltip-container").hide();
                      });

    d3.select("#metro-county").on("click", function() {
        // Determine if current line is visible
        var active   = g.active ? false : true ,
          newOpacity = active ? 0.1 : 1;
        var newFill = active ? "#333" : "#ccc";
       d3.selectAll("path")
       .filter(function(d) { return metroById[d.id] == "metro" })
       .style("opacity", newOpacity); // New Position
       d3.select("#metro-county")
         .style("background-color", newFill);
       g.active = active;
    });

    d3.select("#rural-county").on("click", function() {
        // Determine if current line is visible
        var active   = g.active ? false : true ,
          newOpacity = active ? 0.1 : 1;
        var newFill = active ? "#333" : "#ccc";
       d3.selectAll("path")
       .filter(function(d) { return metroById[d.id] == "rural" })
       .style("opacity", newOpacity); // New Position
       d3.select("#rural-county")
         .style("background-color", newFill);
       g.active = active;
    });

    d3.select("#micro-county").on("click", function() {
        // Determine if current line is visible
        var active   = g.active ? false : true ,
          newOpacity = active ? 0.1 : 1;
        var newFill = active ? "#333" : "#ccc";
       d3.selectAll("path")
       .filter(function(d) { return metroById[d.id] == "micro" })
       .style("opacity", newOpacity); // New Position
       d3.select("#micro-county")
         .style("background-color", newFill);
       g.active = active;
    });

This is what I get:
screenshot of map with Mohave County, Arizona blank

A similar question was asked here in 2015: County choropleth skipping counties
But it got no responses.

How to keep persist data between background and popup script?

As everybody knows, we can’t persist data in popup window.

I have to recover the data when the popup window is opened again.
But this data is not static data. It’s a count value which is incremented by one per second.

So, for instance, if we close the popup window when the count value is 5 and reopen the popup window after 5 seconds, the count value should be 10.
But now I get the initial value 0.

To handle this, I tried to use Sync storage.

Interval is running on the background script. And in the popup script, we just get the storage value and render.

But I think it’s very bad practice to set storage value in every interval.

So Any solution to solve this problem?

I am currently thinking how to detect the popup window is closed.

If we detect the popup window is closed, then we can run the interval on the background script and get the count value from background script when popup window is opened again.

chrome.runtime.onConnect.addListener(function (externalPort) {
  externalPort.onDisconnect.addListener(function () {
    console.log("Disconnect");
  });
  console.log("Connect")
})

I try like above. But it didn’t work.

Please help me how to detect the popup window is destroyed.

Also it would be great for me to let me know any other solution.

Thanks in advance.

antd design select filtering not worked

First of all i take select. Inside the select tag I have mapped category showSearch using input field but data is not found when searching.

My code is here..

<Select
            bordered={false}
            placeholder="Search to Select"
            size="large"
            showSearch
            className="form-select m-3 w-96 border"
            onChange={(value) => {
              setCategory(value);
            }}
          >
            {categories?.map((c) => (
              <Option key={c._id} value={c._id}>
                {c.name}
              </Option>
            ))}
          </Select>

Mongoose Library fetching results tooo slow

I am is ng mongoose Libray to fetch data using $in query.
It is taking too much time to return the results.

I am using documentDB as my database.. there are 2.5 lakh+ documents in my collection and one of the field is indexed.
Whenever i use explain to get the query execution time its giving me around 250 milliseconds. but when i use normal execution its taking around 15 seconds to return the results.(I am doing this using npm’s mongoose package).
I have tried everything from lean to parallel processing of $in query in batches..
but its taking the same time always..
(there are around 800+ parameters in the $in query)

Please share your views and give any solutions

Regarding how to limit the number of characters entered in sumernote

I am using summernote in my app.
I want to limit the number of characters that can be entered in the text input area. Therefore, I have included processing to limit the number of characters in the onPaste, onKeydown, and onKeyup events, as shown in this source code.
With this processing, I am able to limit the number of characters that can be entered as expected for normal keyboard input.
However, there is a problem when inserting links.
In the Insert Link modal, the “Text to display” allows the user to enter an arbitrary string of characters, but does not limit the number of characters for each individual text entry.

<!DOCTYPE html>
<html>
<head>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.20/summernote-lite.min.css" integrity="sha512-ZbehZMIlGA8CTIOtdE+M81uj3mrcgyrh6ZFeG33A4FHECakGrOsTPlPQ8ijjLkxgImrdmSVUHn1j+ApjodYZow==" crossorigin="anonymous" referrerpolicy="no-referrer" />
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
    <script src="https://code.jquery.com/jquery-3.7.0.min.js" integrity="sha256-2Pmvv0kuTBOenSvLm6bvfBSSHrUJ+3A7x6P5Ebd07/g=" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.20/summernote-lite.min.js" integrity="sha512-lVkQNgKabKsM1DA/qbhJRFQU8TuwkLF2vSN3iU/c7+iayKs08Y8GXqfFxxTZr1IcpMovXnf2N/ZZoMgmZep1YQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.20/lang/summernote-ja-JP.min.js" integrity="sha512-hpUqToD3dE5r5L85PTHtgEJCOjWhYUoFoih5BQLcwU9yfqb4K8cFTgj7Prd28oRGAGmFR/FqJoePYM/vnKz/0Q==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
</head>
<body>
    <div id="summernote-input">
        <p></p>
    </div>
    <span id= "char-count"> 0 </span><span>/10</span>
</body>
<script type="text/javascript" language="javascript">

    function summernoteSettings(inputArea, charCountOutput, charCountLimit) {
        this.toolbar = [ ['insert', ['link']],];
        this.callbacks = {
            onPaste: function (e) {
                var bufferText = ((e.originalEvent || e).clipboardData || window.clipboardData).getData('Text');
                e.preventDefault();

                var t = e.currentTarget.innerText;
                if( t.trim().length + bufferText.length >= charCountLimit){
                    var pasteLength = charCountLimit - t.trim().length;
                    document.execCommand('insertText', false, bufferText.substring(0, pasteLength));
                }else{
                    document.execCommand('insertText', false, bufferText);
                }

                var tafter = e.currentTarget.innerText;
                charCountOutput.text(tafter.trim().length);
            },
            onKeydown: function (e) {
                var t = e.currentTarget.innerText;
                charCountOutput.text(t.trim().length);

                if (t.trim().length >= charCountLimit) {
                    if (e.keyCode != 8 &&                           // 8:BackSpace    
                        !(e.keyCode >= 37 && e.keyCode <= 40) &&    // 37:←,38:↑,39:→,40:↓
                        e.keyCode != 46 &&                          // 46:Delete,
                        !(e.keyCode == 88 && e.ctrlKey) &&          // 88:X
                        !(e.keyCode == 67 && e.ctrlKey)){           // 67:C
                        e.preventDefault();
                    }
                }
            },
            onKeyup: function (e) {
                var t = e.currentTarget.innerText;
                charCountOutput.text(t.trim().length);
            },
        };

        this.inputArea = inputArea;
        this.charCountOutput = charCountOutput;
        this.charCountLimit = charCountLimit;
    };

    $('#summernote-input')
        .summernote(new summernoteSettings(
            $('#summernote-input'),
            $('#char-count'),
            10 ));

</script>
</html>

enter image description here

I am considering the following two countermeasures, but do not know how to implement them.

  1. disable text input to “Text to display” in the link insertion modal.
  2. Receive the text entered into “Text to display” in an event when the link insertion modal is closed, and limit the number of characters.

How can these measures be implemented?
Or is there any other way to limit the number of characters?

Updating a specific object data in my rtk asyncthunk

I am new to rtk and immer. I have a problem regarding updating my state with my redux. Lets say when I logging in my user, I will store my user’s data in redux with these kind of structure:

data = {
    "user_profile" : {
    "name": "John Doe",
    "Token": "12345678"
  },
  "basic_information": {
    "primary_information": {
        "sex": "MALE",
        "age": 30,
        "photo": "test.png"
    }
  }
}

now when i will call my update api, then my api returns something like these updated values:

updated_data = {
    "user_profile" : {
    "name": "John Test",   
  },
  "basic_information": {
    "primary_information": {
        "sex": "FEMALE",
        "age": 27,
    }
  }
}

I want to update my current state based on my api update state values, but i want the token will remain and other data that i didnt update.

Here is what i did/tried with the asyncthunk rtk.
I have a slice:

export const updatePrimaryInformation = createAsyncThunk(
  "profile/primary_info",
  async (arg, { rejectWithValue }) => {
    const { body, headers } = arg;
    try {
      const updateRequest = await commonPutRequest({
        body,
        headers,
        url: "http://localhost:8000/api/accounts_app/primary_information",
      });
      if (updateRequest) {
        return updateRequest;
      } else {
        throw new Error(updateRequest.message);
      }
    } catch (err) {
      return rejectWithValue(err.message);
    }
  }
);

// loading: 'idle' | 'pending' | 'succeeded' | 'failed'
    const initialState = {
      data: {},
      loading: "idle",
      message: "",
    };


const authenticateSlice = createSlice({
  name: "auth",
  initialState,
  reducers: {},
  extraReducers: (builder) => {
    builder
      //login
      .addCase(fetchUserLogin.pending, (state) => {
        state.loading = "pending";
      })
      .addCase(fetchUserLogin.fulfilled, (state, action) => {
        state.loading = "succeeded";
        state.data = action.payload;
      })
      .addCase(fetchUserLogin.rejected, (state, action) => {
        state.loading = "failed";
        state.message = action.payload;
      })
      //logout
      .addCase(logoutUser.pending, (state) => {
        state.loading = "pending";
      })
      .addCase(logoutUser.fulfilled, (state, action) => {
        return initialState;
      })
      .addCase(logoutUser.rejected, (state, action) => {
        state.loading = "failed";
        state.message = action.payload;
      })
      //updatePrimaryInfo
      .addCase(updatePrimaryInformation.pending, (state) => {
        state.loading = "pending";
      })
      .addCase(updatePrimaryInformation.fulfilled, (state, action) => {
        state.loading = "succeeded";        
        state.data.basic_information.primary_information = action.payload.basic_information.primary_information;        
      })
      .addCase(updatePrimaryInformation.rejected, (state, action) => {
        state.loading = "failed";
        // state.message = action.payload;
      });
    // .addCase(userLogout, (state) => {
    //   return initialState;
    // });
  },
});

Attempting to deliver an hls stream using express, works in browser but wont play in HLS player

I am trying to make an express server that takes rtsp(am using ffmpeg) converted to hls/m3u8 and streams it upon request(so it can later be viewed on a client).I am still learning and am not too familiar, so any and all help is appreciated – if you have any resources that could help me in this endeavor or if you have a better way of doing this I would appreciate it.

When going to localhost:PORT in a browser it shows the ts file information as I believe it should, but when using an hls.js demo player it gives the error – “Error while loading fragment A network error occurred: fragLoadError”. Checking in the dev tools for the browser it shows GET requests to url localhost:PORT/cameras/cam1 as expected and the status comes back okay 200, but when it requests a ts file the url changes to localhost:PORT/cameras/123.ts and the status comes back Not Found 404.

HLS PLAYER OUTPUT:

Loading http://localhost:PORT/cameras/cam1

Loading manifest and attaching video element…

1 quality levels found

Manifest successfully loaded

Media element attached

Error while loading fragment http://localhost:4000/cameras/index133.ts

Error while loading fragment http://localhost:4000/cameras/index134.ts

Error while loading fragment http://localhost:4000/cameras/index135.ts

Here is my code, should start an express server on process.env.PORT, the /cameras routes are handles by cameras.js which should get an incoming request set the headers and read the index.m3u8 file which points to the location of ts files to stream video.

index.js

`
const express = require("express");
const exec = require("child_process").exec;
const fs = require("fs");
const app = express();
const cors = require("cors")
const cameras = require("./routes/cameras")
require("dotenv").config();

app.use(cors());
app.use("/cameras", cameras);

app.get("/", (req,res) => {
console.log("New Request Incoming...", new Date());
})

app.listen(process.env.PORT, ()=> {
console.log("server online at port: ", process.env.PORT);
});
`

cameras.js

``
const express = require("express");
const router = express.Router();
const fs = require("fs");

const camOneStream = "./cameras/cam1/index.m3u8"

//Camera One Routes
router.get("/cam1", (req,res) => {

    console.log('Request Incoming for CAM1 from...', new Date());
    res.set('Access-Control-Allow-Origin', '*');
    res.set('Access-Control-Allow-Headers', 'Range');
    res.set('Access-Control-Expose-Headers', 'Content-Length, Content-Range');
    fs.readFile(camOneStream, (err, cont) => {
        if (err) {
            console.log(err);
            res.writeHead(500);
            res.end('Sorry, check with the site admin for error: ' + err.code + ' ..n');
            res.end();
            
        }
        else {
            res.writeHead(200);
            res.end(cont, 'utf-8');
        }
    });
});
module.exports = router;
`

I was expecting the hls stream to be played on the hls player but the files could not be found resulting in fragment loading errors.

I have verified the hls files work. I have verified all the file paths. I included CORS headers manually. I removed firewall. I am not getting any errors on the server console. Sort of stuck.

The div element following my cursor (JS) disappears when I hover over a CSS keyframe animation – how can I fix this?

I’m using a mousemove event in JS to get a small ball image (encased in a div) to follow my cursor. I also have an image in a separate div which uses keyframes animation in CSS to shake when the mouse cursor hovers over it.

My problem is that when I hover over the keyframe image and it shakes, the ball image disappears from the cursor.

Is there anyway to keep it visible over the top of the shaking image, while the shaking image is actively being animated?

body {
  background-color: white;
}

h1 {
  color: teal;
  font-family: Arial, Helvetica, sans-serif;
  text-align: center;
}

div {
  background-color: teal;
  padding: 5%;
  text-align: center;
}

#circle {
  max-width: 10%;
  background-color: transparent;
  position: absolute;
}

#circle:hover {
  cursor: url('***********'), auto;
}

#shakingimage {
  max-width: 45%;
  position: relative;
}

#shakingimage:hover {
  /* Start the shake animation and make the animation last for 0.5 seconds */
  animation: shake 0.5s;

  /* When the animation is finished, start again */
  animation-iteration-count: infinite;

  cursor: url('************'), auto;
}

@keyframes shake {
  0% {
    transform: translate(1px, 1px) rotate(0deg);
  }
  10% {
    transform: translate(-1px, -2px) rotate(-1deg);
  }
  20% {
    transform: translate(-3px, 0px) rotate(1deg);
  }
  30% {
    transform: translate(3px, 2px) rotate(0deg);
  }
  40% {
    transform: translate(1px, -1px) rotate(1deg);
  }
  50% {
    transform: translate(-1px, 2px) rotate(-1deg);
  }
  60% {
    transform: translate(-3px, 1px) rotate(0deg);
  }
  70% {
    transform: translate(3px, 1px) rotate(-1deg);
  }
  80% {
    transform: translate(-1px, -1px) rotate(1deg);
  }
  90% {
    transform: translate(1px, 2px) rotate(0deg);
  }
  100% {
    transform: translate(1px, -2px) rotate(-1deg);
  }
}

.buttonbox {
  display: inline-flex;
  justify-content: center;
  flex-direction: row;
}

button {
  padding: 15px 25px;
  margin: 5px;
  font-size: 24px;
  text-align: center;
  cursor: pointer;
  outline: solid 2px white;
  color: #ffffff;
  background-color: #008080;
  border: none;
  border-radius: 15px;
  box-shadow: 0 9px #999;
}

button:hover {
  background-color: rgb(0, 172, 172);
}

button:active {
  background-color: #008080;
  box-shadow: 0 5px #666;
  transform: translateY(4px);
}

let circle = document.getElementById('circle')
const onMouseMove = (e) => {
  circle.style.left = e.pageX + 'px'
  circle.style.top = e.pageY + 'px'
}
document.addEventListener('mousemove', onMouseMove)

Using Ajax / custome JS to dynamically update states_list(), based on choice from countries_list() in same question?

I have two questions earlier in my interview, that work great together.

Essentially, the first question presents a list of countries, using the very amazing and highly useful countries_list() function. The second question then presents a combobox of potential states using the (also) very amazing and highly useful states_list() function, but modified to only show the states that might apply to the user, and modifies the label “State” as appropriate (and I have some other code that skips this question if there is only one state in the country (eg. Singapore) ).

---
question: |
  What country do you live in?
fields:
 - Country: jurisdiction.country
   input type: combobox
   code: countries_list()
---
question: |
  What state do you live in?
fields:
 - ${ subdivision_type(jurisdiction.country) }: jurisdiction.state
   input type: combobox
   code: states_list(jurisdiction.country)
---

What I’m wondering, is if there’s a known way to accomplish this same effect “live” on a page using input type: ajax (as here), custom JS, or some other method?

Ideally, I could “live reload” the question prompt with subdivision_type() as well.

Matrix issue in PixiJS Texture sini Cocos2D-JS

I’m trying to animate a creature I use in a Pixi JS in Cocos2D-js. No matter how many similarities there are, I am experiencing shifts in the frame and I am encountering a visual like the one below. I don’t know what kind of scaling conversion I need to do, but I’m pretty close.

PixiJS: PixiJS

cocos2D: cocos2D

Cocos2D-Js TypeScript my Code:

import { _decorator, Asset, assetManager, Component, ImageAsset, JsonAsset, Node, Rect, resources, Sprite, SpriteFrame, UITransform, Animation, Texture2D, Vec2, Vec3, Mat4, Vec4, mat4, Size, misc, instantiate, Color, AnimationClip, AnimationComponent, size } from 'cc';

const { radiansToDegrees } = misc;

const { ccclass, property } = _decorator;


@ccclass('MainControler')
export class MainControler extends Component {

    @property(Node)
    main: Node

    @property(Node)
    botCanvas: Node

    @property(JsonAsset)
    textJson: JsonAsset


    @property(ImageAsset)
    texture: ImageAsset


    @property(Sprite)
    pic: Sprite

    @property(SpriteFrame)
    pic2: SpriteFrame
 

    deleteNode = [];
    matrixFrame = [];
    frameIndex = 0;

    botID = 1059;
    start() {
        this.atlasLoad();
    }
    spriteFrames = [];
    resolution = 1;

    frameEkle(name, dizi, img) {
        let parca = new Node;
        parca.addComponent(Sprite)
        var sprite1 = new SpriteFrame();
        var textture = new Texture2D();
        parca.name = name.toString();
        textture.image = new ImageAsset(img);
        sprite1.texture = textture;
        let source = dizi['sourceSize'];
        let a = dizi['frame'];
        if (dizi['rotated']) {
            sprite1.rect = (new Rect(a['x'] * 1, a['y'] * 1, a['w'] * 1, a['h'] * 1));
            sprite1.rotated = true;
        } else {
            sprite1.rect = (new Rect(a['x'] * 1, a['y'] * 1, a['w'] * 1, a['h'] * 1));
        }
        if (dizi['trimmed']) {
            sprite1.offset.set(source.x, source.y)
            sprite1.originalSize.set(a['w'], a['h'])
        }
        parca.getComponent(Sprite).spriteFrame = sprite1;
        parca.active = false;
        this.deleteNode.push(parca)
        return parca;
    }


    async framePlay() {
        this.frameIndex++;
        this.buttonClick();

    }
    async atlasLoad() {

        let child = this.main.getChildByUuid('aa5N8chohMuIwRKYhdm159');
        let images, sheetJson;
        resources.loadDir("bots/img" + this.botID, (err, spriteFrame) => {
            spriteFrame.forEach(element => {
                if (element._native == ".png") {
                    images = element.toString();
                } else if (element['json']) {
                    sheetJson = element['json'];
                }
            });
            var img = new Image();
            img.src = images;
            let obj = sheetJson;
            img.onload = (res) => {
                (Object.keys(obj['frames']) as (keyof typeof obj['frames'])[]).forEach((key, index) => {
                    let dizi = obj['frames'][key]
                    if (dizi) {
                        child.addChild(this.frameEkle(key, dizi, img));
                    }
                });
            };
        });
    }
    async buttonClick() {

        let child = this.main.getChildByUuid('aa5N8chohMuIwRKYhdm159');
        let images, sheetJson, mci;
        resources.loadDir("bots/img" + this.botID, (err, spriteFrame) => {
            spriteFrame.forEach(element => {
                if (element._native == ".png") {
                    images = element.toString();
                } else if (element['json']) {
                    sheetJson = element['json'];
                } else if (element._native == ".mci") {
                    mci = JSON.parse(element._nativeAsset)
                }

            });
            var img = new Image();
            img.src = images;

            let obj = sheetJson;
            img.onload = (res) => {
                var ideCh = mci['frames'][this.frameIndex]['ch']
                let i = 5;
                ideCh.forEach(element => {
                    i++;
                    let frameler = child.getChildByName(element.name + '.png');
                    if (frameler) {
                        let dizi = obj['frames'][element.name + '.png']
                        let meta = obj['meta']
                        if (element['ct']) {
                            if (!child.getChildByName(element.name + '.png' + i)) {
                                let frameler_new = instantiate(frameler);
                                frameler_new.name = frameler_new.name + i
                                frameler_new.getComponent(Sprite).color.set(element['ct']['0'] * 255, element['ct']['1'] * 255, element['ct']['2'] * 255, element['ct']['3'] * 255);
                                child.addChild(frameler_new);
                                child.insertChild(frameler_new, 1);
                                frameler = frameler_new;
                                this.deleteNode.push(frameler);
                            } else {
                                frameler = child.getChildByName(element.name + '.png' + i)
                            }

                        } else {
                            child.insertChild(frameler, i);
                        }
                        frameler.active = true;
                        let a = element['mx']['a'] ? element['mx']['a'] : 1
                        let b = element['mx']['b'] ? element['mx']['b'] : 0
                        let c = element['mx']['c'] ? element['mx']['c'] : 0
                        let d = element['mx']['d'] ? element['mx']['d'] : 1
                        let tx = element['mx']['tx'] ? element['mx']['tx'] : 0
                        let ty = element['mx']['ty'] ? element['mx']['ty'] : 0

                        let cocosMatrix = Mat4.IDENTITY.clone();
                        cocosMatrix.m00 = (a);
                        cocosMatrix.m01 = -(b);
                        cocosMatrix.m04 = -(c);
                        cocosMatrix.m05 = (d);
                        cocosMatrix.m12 = (tx)
                        cocosMatrix.m13 = -(ty);

                        frameler.matrix = cocosMatrix;

                        const uiTransform = frameler.getComponent(UITransform);

                        let anchorX = (dizi['pivot']['x'] / 250);
                        let anchorY = (dizi['pivot']['y'] / 250);
                        uiTransform.setAnchorPoint(anchorX, 1 - anchorY);
                    }

                });
            }
        });
    }
    sleep(seconds: number) {
        return new Promise((resole) => setTimeout(resole, seconds * 1000));
    }

    deleteAllNode() {
        this.deleteNode.forEach(element => {
            element.active = false;
        });
    }

    startStatus = false;
    async startFrame() {
        this.startStatus = true;
        // this.deleteAllNode();
        // this.frameIndex++;
        this.buttonClick();
        // await this.sleep(0.1);
        this.startStatus = false;
    }
    update(deltaTime: number) {
        if (this.startStatus == false) {
            this.startFrame();
        }
    }
}

PixiJs texturepack atlas:

enter image description here

Frame PixiJS Matrix data

{"frames":[{"lb":{"frame":1,"name":"idle"},"ch":[{"name":"im_0001","mx":{"tx":-55.5,"a":1.684,"ty":264.1,"d":1.415}},{"ct":[0.5,0.5,0.5,1,0,0,0,0],"name":"im_0002","mx":{"tx":79.2,"a":0.938,"ty":172,"b":0.344,"c":-0.344,"d":0.938}},{"ct":[0.5,0.5,0.5,1,0,0,0,0],"name":"im_0003","mx":{"tx":70.3,"ty":276.6}},{"ct":[0.5,0.5,0.5,1,0,0,0,0],"name":"im_0004","mx":{"tx":78.8,"a":0.968,"ty":224,"b":0.235,"c":-0.235,"d":0.968}},{"name":"im_0005","mx":{"tx":139.4,"a":0.891,"ty":157.5,"b":0.451,"c":-0.451,"d":0.891}},{"name":"im_0006","mx":{"tx":40,"a":0.927,"ty":127.7,"b":0.371,"c":-0.371,"d":0.927}},{"name":"im_0003","mx":{"tx":124.1,"a":0.995,"ty":288.3,"b":-0.101,"c":0.101,"d":0.995}},{"name":"im_0004","mx":{"tx":89.1,"a":0.766,"ty":265.6,"b":-0.637,"c":0.637,"d":0.766}},{"name":"im_0002","mx":{"tx":67.1,"a":0.985,"ty":209,"b":-0.156,"c":0.156,"d":0.985}},{"name":"im_0007","mx":{"tx":171.4,"a":0.981,"ty":201.3,"b":0.186,"c":-0.186,"d":0.981}},{"name":"im_0008","mx":{"tx":135,"a":0.999,"ty":194.2,"b":-0.04,"c":0.04,"d":0.999}},{"ct":[0.5,0.5,0.5,1,0,0,0,0],"name":"im_0009","mx":{"tx":-4.7,"ty":274.6}},{"ct":[0.5,0.5,0.5,1,0,0,0,0],"name":"im_0010","mx":{"tx":24.3,"a":0.98,"ty":197,"b":-0.195,"c":0.195,"d":0.98}},{"ct":[0.5,0.5,0.5,1,0,0,0,0],"name":"im_0011","mx":{"tx":37.5,"a":0.63,"ty":236.1,"b":0.775,"c":-0.775,"d":0.63}},{"name":"im_0012","mx":{"tx":-22.9,"a":0.997,"ty":165.7,"b":0.001,"c":-0.001,"d":0.997}},{"name":"im_0009","mx":{"tx":-34.7,"ty":285.6}},{"name":"im_0010","mx":{"tx":16.4,"a":0.983,"ty":193.8,"b":0.177,"c":-0.177,"d":0.983}},{"name":"im_0011","mx":{"tx":-4.1,"a":0.839,"ty":242.3,"b":0.54,"c":-0.54,"d":0.839}}]}]}

Pixijs Frame Sheet

{"frames": {

"im_0001.png":
{
    "frame": {"x":1,"y":1,"w":150,"h":35},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":0,"y":0,"w":150,"h":35},
    "sourceSize": {"w":160,"h":40},
    "pivot": {"x":0.5,"y":0.5}
},
"im_0002.png":
{
    "frame": {"x":70,"y":101,"w":51,"h":59},
    "rotated": true,
    "trimmed": true,
    "spriteSourceSize": {"x":9,"y":13,"w":51,"h":59},
    "sourceSize": {"w":60,"h":80},
    "pivot": {"x":0.5,"y":0.5}
},
"im_0003.png":
{
    "frame": {"x":52,"y":154,"w":57,"h":23},
    "rotated": true,
    "trimmed": true,
    "spriteSourceSize": {"x":5,"y":3,"w":57,"h":23},
    "sourceSize": {"w":80,"h":40},
    "pivot": {"x":0.5,"y":0.5}
},
"im_0004.png":
{
    "frame": {"x":117,"y":210,"w":23,"h":47},
    "rotated": true,
    "trimmed": true,
    "spriteSourceSize": {"x":3,"y":11,"w":23,"h":47},
    "sourceSize": {"w":40,"h":60},
    "pivot": {"x":0.5,"y":0.5}
},
"im_0005.png":
{
    "frame": {"x":1,"y":38,"w":49,"h":47},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":8,"y":15,"w":49,"h":47},
    "sourceSize": {"w":60,"h":80},
    "pivot": {"x":0.5,"y":0.5}
},
"im_0006.png":
{
    "frame": {"x":153,"y":1,"w":130,"h":90},
    "rotated": true,
    "trimmed": true,
    "spriteSourceSize": {"x":10,"y":6,"w":130,"h":90},
    "sourceSize": {"w":140,"h":100},
    "pivot": {"x":0.5,"y":0.5}
},
"im_0007.png":
{
    "frame": {"x":77,"y":154,"w":54,"h":47},
    "rotated": true,
    "trimmed": true,
    "spriteSourceSize": {"x":2,"y":15,"w":54,"h":47},
    "sourceSize": {"w":60,"h":80},
    "pivot": {"x":0.5,"y":0.5}
},
"im_0008.png":
{
    "frame": {"x":1,"y":133,"w":87,"h":49},
    "rotated": true,
    "trimmed": true,
    "spriteSourceSize": {"x":8,"y":10,"w":87,"h":49},
    "sourceSize": {"w":100,"h":60},
    "pivot": {"x":0.5,"y":0.5}
},
"im_0009.png":
{
    "frame": {"x":1,"y":87,"w":64,"h":20},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":3,"y":2,"w":64,"h":20},
    "sourceSize": {"w":80,"h":40},
    "pivot": {"x":0.5,"y":0.5}
},
"im_0010.png":
{
    "frame": {"x":1,"y":222,"w":27,"h":67},
    "rotated": true,
    "trimmed": true,
    "spriteSourceSize": {"x":0,"y":10,"w":27,"h":67},
    "sourceSize": {"w":40,"h":80},
    "pivot": {"x":0.5,"y":0.5}
},
"im_0011.png":
{
    "frame": {"x":70,"y":213,"w":39,"h":45},
    "rotated": true,
    "trimmed": true,
    "spriteSourceSize": {"x":9,"y":6,"w":39,"h":45},
    "sourceSize": {"w":60,"h":60},
    "pivot": {"x":0.5,"y":0.5}
},
"im_0012.png":
{
    "frame": {"x":70,"y":38,"w":61,"h":71},
    "rotated": true,
    "trimmed": true,
    "spriteSourceSize": {"x":16,"y":6,"w":61,"h":71},
    "sourceSize": {"w":80,"h":80},
    "pivot": {"x":0.5,"y":0.5}
},
"im_0013.png":
{
    "frame": {"x":52,"y":38,"w":14,"h":13},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":13,"y":14,"w":14,"h":13},
    "sourceSize": {"w":40,"h":40},
    "pivot": {"x":0.5,"y":0.5}
}},
"meta": {
    "app": "http://www.codeandweb.com/texturepacker",
    "version": "1.0",
    "image": "img1059.png",
    "format": "RGBA8888",
    "size": {"w":256,"h":256},
    "scale": "1",
    "smartupdate": "$TexturePacker:SmartUpdate:92ef2ab6841c7c88aaca359262215b5c:36594444f39e1a8a84f8bc0637488d48:2b7b47a504bdec855a69d7066d4599fe$"
}
}

Resolving “net::ERR_SSL_PROTOCOL_ERROR” and “Mixed Content: … the content must be served over HTTPS.” errors after converting site to HTTPS?

I first implemented my site on a remote VPS without SSL, but then recently got certs from letsencrypt.org.

The site is now accessible at https://www.example.com but some of my GET requests began throwing “Mixed Content … the content must be served over HTTPS.” errors in the inspection console, so I tried changing the base reference in my JS code from:

http://www.example.com:3000

to

https://www.example.com:3000

and now I’m getting this error: “net::ERR_SSL_PROTOCOL_ERROR”

Is there more that I need to do to make port 3000 or mongo serve correctly across https?

I’m pretty new to all of this, so any help or insights would be greatly appreciated! Thanks!

An example of a language which compiles to both C and JavaScript and how they handle the concept of pointers in both compilation targets?

I learned today that react native doesn’t compile to Swift/Java, it uses a “bridge” to communicate with native components, so it is executing your JavaScript directly, rather than transpiling it to Swift or Kotlin or Java or something. And Dart only compiles to JS (it is not a cross-platform higher level language).

I am wondering if it is just not possible to write a higher-level language and compile to both JS and to Rust/C.

Are there any examples of languages which compile to these two target types of languages:

  1. Languages with pointers (like C or Rust, or even to Assembly perhaps).
  2. Languages without pointers (like JavaScript).

I have been tinkering with making a custom language which could theoretically compile to JavaScript and Rust (or C), and am stuck trying to imaging how I would build an abstraction around the pointer and non-pointer case!

Some ideas I am playing with are, make the transpiled JavaScript code (coming from the custom language) simulate pointers. So a number would maybe be defined and used in a wrapper pseudo-number class like this in JavaScript:

class PointerNumber {
  constructor(x) {
    this.value = x
  }

  valueOf() {
    return this.value
  }
}

const x = new PointerNumber(10)
const y = x + 5 // => 15
x.value = 25 // *x = 25

But, this will come with all sorts of other problems now, such as probably a performance decrease, as well as you still can’t wrap all numbers, such as those coming through third-party libraries or JSON or something. So then it’s like, in JS you would have the idea of “pointer numbers” and “basic numbers”, and with basic numbers you can’t do the equivalent of *x = 10 or y = &x, but with pointer numbers you could. But even that feels clunky and hard to deal with / conceptualize / manage.

On the other hand, the idea of leaving pointers completely absent from the custom language seems like a no-no, because that would mean if the transpilation target is Rust (or C), then you can’t use pointers or dereferencing or access addresses at all. I don’t know if it’s possible to optimally use C or Rust without accessing those features, do you?

The main question is if there are any higher-level languages which compile down into both a pointerless language (JS) and a pointerful language (Rust/C), and if so, perhaps a brief explanation of how they handle the pointer conundrum. If there aren’t any, maybe a brief explanation of why it can’t be done effectively would be good to know, or if it can be done but just hasn’t yet, maybe a note on that perhaps.