What is the NEL line terminator?

I know CR, LF, and CRLF, but I have never encountered NEL. I encountered this line terminator for the first time today. No particularly detailed descriptive documents were found. Will it cause some request resources to be garbled? The JavaScript file I obtained from the Android client is garbled.

Manually change it to LF.

How to access a variable between JavaScript Files?

I need to use a variable that I have in one JavaScript file in another file.

I have a variable in my angular TypeScript file:

   public data1: Array<string> =["One"];

then I save it to FormData:

   const imageForm = new FormData();
    imageForm.append('image', this.imageObj);
    imageForm.append('data', this.data1[0]);
    this.imageUploadService.imageUpload(imageForm).subscribe((res:any) => {
      this.imageUrl = res['image'];
    });

Finally I am sending the data to the API:

  imageUpload(imageForm: FormData) {
  console.log('image uploading');
  return this.http.post('http://localhost:3000/api/v1/upload/', 
  imageForm);
 }

in my first.js file I have:

app.post('/api/v1/upload', upload.array('image', 1), (req, res) => {
   myVar= JSON.parse(JSON.stringify(req.body));
   theVar = myVar["data"];
   module.exports.token = theVar;

in my second.js file I have:

    const importedVar = require('../server');
    let newVar = importedVar.token;

trying to print the value:

console.log(JSON.stringify(newVar))

now I am getting undefined, why is that?

viết ngôn ngữ java [closed]

Viết chương trình thực hiện các yêu cầu sau:

  1. Khai báo lớp nhân viên với các thuộc tính: mã nhân viên, họ tên, hệ số lương.
  2. Tạo Các contrustor (có đối số, không đối số), getter, setter
  3. Xây dựng các phương thức: nhập, xuất,tính tiền lương một đối tượng nhân viên, biết lương = hệ số lương * 2.000.000;
  4. Nhập vào n nhân viên. In ra màn hình thông tin của nhân viên có lương cao nhất
  5. Sắp xếp danh sách nhân viên tăng dần theo lương

có được bài làm tốt

Prevent webpage scrolling with keyboard only if an element is displayed

On a webpage, certain keyboard keys will control the scrolling of the webpage such like spacebar, arrowup, arrowdown.

I intend to prevent the user from scrolling with these keys when an overlay element is displayed. This overlay element has a default of display: none;.

I understand the sentiment of “do not alter browser’s behavior,” but scrolling will still be allowed by scroll wheel and/or touchpad (and of course, the scrollbar).
When the overlay is displayed, these keys are only intended for controlling the overlay contents, and not the page scrolling.
Respectively, when the overlay is not displayed, the keys should resume their default behavior of scrolling the page.

Due to this, I’m thinking of using an EventListener, and I found one here:

window.addEventListener("keydown", function(e) {
    if([" ","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].indexOf(e.code) > -1) {
        e.preventDefault();
    }
}, false);

Snippets of example code:

function launchOverlay() {
    overlay.style.display = "flex";

    window.addEventListener("keydown", function(e) {
        if([" ","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].indexOf(e.code) > -1) {
            e.preventDefault();
        }
    }, false);
}

function closeOverlay() {
    overlay.style.display = "none";

    window.removeEventListener("keydown", function(e) {
        if([" ","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].indexOf(e.code) > -1) {
            e.preventDefault();
        }
    }, false);
}

document.addEventListener('keydown', function(event) {
    if (overlay.style.display == "flex") {
        if (event.code === "Space") {
            space();
        } else if (event.code === "ArrowUp") {
            aUp();
        } else if (event.code === "ArrowDown") {
            aDown();
        } else if (event.code === "ArrowLeft") {
            aLeft();
        } else if (event.code === "ArrowRight") {
            aRight();
        } else if (event.code === "Escape") {
            closeOverlay();
        }
    }
});

I’m wondering how I can assign the EventListener only if the overlay element is showing. At the current, my arrow keys remain “hijacked” and will not function, after the overlay is closed. If I open the overlay again, it functions as I have assigned it.

css animation using keyframe not working as expected

I have come accross this problem and don’t understand the behaviour.

Here we have a simple rectangle that should animate in and out on the press of the toggle button.

When the button is clicked, the rectangle class name will be toggled between ‘animation-in’ and ‘animation-out’.

The keyframe object for ‘scale-easeInOutBounce’ and ‘scale-easeInOutBounce-out’ is identical, only the name reference is different between the two.

Everything works perfectly.

When the property ‘animation-name:’ within the css rule’.animation-out’ is changed from ‘scale-easeInOutBounce-out’ to ‘scale-easeInOutBounce’ the animation breaks.

The question here is, why does this occur? Is there a logic error in the code, or an incorrect implementation of animation?

Would love to understand this behaviour.

This behaviour was replicated using ‘Chrome’ on Windows 11


<!DOCTYPE html>
<html>
<head>
    <title>Rectangle Animation</title>
    <style>
        #myRectangle {
            width: 100px;
            height: 150px;
            background-color: green;
            margin: 20px;
            transform: scale(0);
            
        }

        .animation-out {
            animation-duration: 4s;
            animation-timing-function: ease; /*linear*/
            animation-delay: 0s;
            animation-iteration-count: 1;
            animation-direction: normal;
            animation-fill-mode: forwards;
            animation-play-state: running;
            animation-name: scale-easeInOutBounce;
            animation-timeline: auto;
            animation-range-start: normal;
            animation-range-end: normal;
        }

        .animation-in {
            animation-duration: 4s;
            animation-timing-function: ease;
            animation-delay: 0s;
            animation-iteration-count: 1;
            animation-direction: reverse;
            animation-fill-mode: forwards;
            animation-play-state: running;
            animation-name: scale-easeInOutBounce;
            animation-timeline: auto;
            animation-range-start: normal;
            animation-range-end: normal;
        }

        @keyframes scale-easeInOutBounce {
            0% { transform: scale(1); }
            2% { transform: scale(0.99); }
            4% { transform: scale(1); }
            10% { transform: scale(0.97); }
            14% { transform: scale(0.99); }
            22% { transform: scale(0.88); }
            32% { transform: scale(0.99); }
            42% { transform: scale(0.6); }
            50% { transform: scale(0.5); }
            58% { transform: scale(0.4); }
            68% { transform: scale(0.01); }
            78% { transform: scale(0.12); }
            86% { transform: scale(0.01); }
            90% { transform: scale(0.03); }
            96% { transform: scale(0); }
            98% { transform: scale(0.01); }
            100% { transform: scale(0); }
        }

        @keyframes scale-easeInOutBounce-out {
            0% { transform: scale(1); }
            2% { transform: scale(0.99); }
            4% { transform: scale(1); }
            10% { transform: scale(0.97); }
            14% { transform: scale(0.99); }
            22% { transform: scale(0.88); }
            32% { transform: scale(0.99); }
            42% { transform: scale(0.6); }
            50% { transform: scale(0.5); }
            58% { transform: scale(0.4); }
            68% { transform: scale(0.01); }
            78% { transform: scale(0.12); }
            86% { transform: scale(0.01); }
            90% { transform: scale(0.03); }
            96% { transform: scale(0); }
            98% { transform: scale(0.01); }
            100% { transform: scale(0); }
        }
    </style>
</head>
<body>

<div id="myRectangle"></div>
<button id="toggleButton">Toggle Animation</button>

<script>
    document.getElementById('toggleButton').addEventListener('click', function() {
        var rectangle = document.getElementById('myRectangle');
        if (rectangle.classList.contains('animation-in')) {
            rectangle.classList.remove('animation-in');
            rectangle.classList.add('animation-out');
        } else {
            rectangle.classList.remove('animation-out');
            rectangle.classList.add('animation-in');
        }
    });
</script>

</body>
</html>

https://jsfiddle.net/midnightstudios/vajqdcLo/2/

how to have a scrool scroll animation on a script

what i mean by that is i am makeing a website and it has scroll animation and a phaser.js game what i want is to that scroll animation to be able to the same afect on the phaser game
i have 2 class name are hidden and show they do the scroll animation

it trd to put script into a div class dut it did not work this is also on https://github.com/CrystalX775/probable-telegrama
js code

const observer = new IntersectionObserver((entries) =>{
  entries.forEach((entry) => {
  console.log(entry)
  if(entry.isIntersecting){
      entry.target.classList.add('show');
  } else{
      entry.target.classList.remove('show');
  }

  });
});
const hiddenElements = document.querySelectorAll(".hidden");
hiddenElements.forEach((el)=> observer.observe(el));

function myfunction() {
document.getElementById("Hacker1").style.color = "blue";
};
function myFunction1() {
document.getElementById("Hacker1").style.color = "red";
}
let pepole = prompt("Please enter your name");
if(pepole != null){
  document.getElementById("demo").innerHTML = "Hello " + pepole + "! How are you today?";
}

phaser.js code

function preload() {
    this.load.image('codey', 'https://content.codecademy.com/courses/learn-phaser/codey.png');
  }
  
  function create() {
    this.add.sprite(50, 50, 'codey');
  }
  
  const config = {
      type: Phaser.AUTO,
      width: 1300,
      height: 300,
      backgroundColor: "#5f2a55",
      scene: {
      create,
      preload
      }
  }
  
  const game = new Phaser.Game(config)
  

html code

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<div class="scripts">
<script defer src="app.js"></script>
<link rel="stylesheet" href="style.css">
</div>
<body>
<section>
  <h1 onmouseout="myFunction1()"onmouseover="myfunction()" style="font-size: 60px;"id="Hacker1"class="hidden">HackerXGames</h1>
  <p class="hidden">this is my way to play</p>
</section>
<section>
  <h1 style="font-size: 30px;" class="hidden" id="demo"></h1>
</section>
<section class="hidden">
  <div class="hidden">
  <script  src="https://cdn.jsdelivr.net/npm/[email protected]/dist/phaser.js"></script>
  <script src="game.js"></script>
</div>
</section>
</body>
</html>

css code

@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@200;400;700&display=swap");
body{
    background-color: #131316;
    color: #ffffff;
    font-family: Poppins, sans-serif;
    padding: 0;
    margin: 0;
}
section {
    display: grid;
    place-items: center;
    align-content: center;
    min-height: 100vh;
}
.hidden{
    opacity: 0;
    filter: blur(5px);
    transform: translateX(-100%);
    transition: all 1s;
}

.show {
    opacity: 1;
    filter: blur(0);
    transform: translateX(0);
}
.media{
    display: flex;
}
.media:nth-child(2){
    transition-delay: 200ms;
}
.media:nth-child(3){
    transition-delay: 7s;
}

Trouble Rendering Checkboxes in JSReport

I followed instructions to open developer tab > create textbox > create checkbox > edit properties & title.
My scenario: I have a survey, I am generating a docx report template with handlebars. This is a multiple choice question that has 2 options 1) general and 2)cultural.

doxc template:

{{docxCheckbox value=general}} General Monitoring
{{docxCheckbox value=cultural}} Cultural Resource Monitoring

json:

{
"general": "true",
"cultural": "false"
}

Does anyone have ideas or solutions?

Error_Screenshot

Running JavaScript (Turf.js) in Controller – Asp Net Core 7

I am working on an app where I serve a map (Mapbox) to users and a part of this is calculating lines and polygons intersecting on the map. Currently, I am using Turf.js to do this calculation in JavaScript that is a part of the view. This means that every time the page loads, the calculation is redone. I would like to be able to do the calculation once on the server side and store it in a database. Then I would be able to send the precomputed data to the frontend to be rendered using Mapbox. Additionally, I would like to be able to recompute the data based on webhook events.

I have tried to look around, but I haven’t been able to find much on how to do this. Is it really even possible?

Some alternatives I am thinking of:

  1. Is there some C# library that has similar capabilities of Turf.js?
  2. I guess I could send a variable to the view telling it whether or not to do the calculation, and then after, it could send the data back to an endpoint in my controller for inserting into the database. Think this would work but seems very clunky.

I have tried to use jsRuntime in the controller, but I was getting an error since I had not returned a view, so that was a bit of a dead end.

EDIT: Just though of this and I think it may be my solution. I assume I could host a javascript API (on Azure) that I call whenever I want to do the calculations. This would also work well with the webhooks since there is no client in that situation. I think I will go this route unless someone has something better. Leaving open to see if there are any other suggestions.

hHow to use css mask? [closed]

Excuse me, how to achieve the movement effect on the right side of this website? Thanks

I will use masks, but I don’t know how to move,
It is also useful on RWD.
I found a lot of information and solved only the cover of the mask, but the animation part was not similar. There are some Japanese websites.

Is there a way to create a blur effect without using backdrop-filter: blur that causes flickering?

I’m working on a complex design that involves multiple blur effects, a div that has a blur effect applied, and another div behind it that needs to be blurred. I’ve been searching online, but I can’t find an answer

The current filter backdrop-filter: blur(); is causing flickering/glitching on non-flagship phones, and I believe nobody truly wants to create a poor user experience through their work.

Has any frontend developer found a solution or encountered such an experience? Any guidance would mean a lot!

I have a timed quiz that I need to save username input to local storage

I created a timed quiz that saves the score into the local storage but not the user’s entered username. I’ll include the last html doc of the application, the score is saved from the game script file. I figure that I wouldn’t need to edit my game script file as the score does get saved into local storage.

//html code below

!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="assets/style.css">
    <title>Congratulations</title>
</head>
<body>
    <div class="container">
        <div id="end" class="flex-center flex-column">
            <h1 id="finalScore">0</h1>
            <form>
                <input 
                type="text name" 
                name="username" 
                id="username" 
                placeholder="username"/>
                <button 
                type="submit" 
                class="btn" 
                id="submitBtn" 
                onclick>
                Save
                </button>
                <a class="btn" href="game.html">Play Again</a>
                <a class="btn" href="start.html">Go Home</a>
            </form>
        </div>
    </div>
    <script src="assets/end.js"></script>
</body>
</html>

javascript code below-I have comments for what I was planning in my code.

//links username from end html doc

const usernameInput = document.getElementById('username');

//links save socre button from html doc

const submitBtn = document.getElementById('submit');

//links the final score

const finalScore = document.getElementById('finalScore');

//retrieves the end score from local storage

const mostRecentScore = localStorage.getItem('mostRecentScore');


//pulls most recent score from game script and saves it to end screen

finalScore.innerText = mostRecentScore;

submitBtn.addEventListener('click', function(event)  {
    //keeps entry form being entered into the url
    event.preventDefault();

    var username = document.querySelector("#username").value;
    //turn array entry into a string
    localStorage.setItem('username', username);

});

I get an error for the application i am trying to create. A player’s username does not get saved into local storage.

ObservableHQ faceted plot remove x-axes ticks

I am trying to get rid of x-axis ticks for individual bar plots in this faceted plot. This plot is generated using ObservableHQ’s Plot object.

Plot.plot({
  marginLeft: 10,
  marginRight: 10,
  label: null,
  y: { padding: 0, label: "Channels (Log_2)" },
  color: {
    legend: true,
  },
  marks: [
    Plot.barY(processed_data, {
      fx: "layer",
      x: "concept",
      y: "channel",
      fill: "concept",
      inset: 0.5,
    }),
    Plot.ruleX([0])
  ],
});

I want the ticks to be removed from the bottom, because it is redundant as the class is encoded as colors.

Axios returns string instead of object [closed]

I have updated my axios version from 0.18.2 to 0.21.2. My app fails because the response, is not parsed. Instead of objects, like

{ 
   data: { 
     foo: 'bar'
   }
}

when I console.log, I get "{data:{foo:"bar"}}" as a string. What may be the issue?

My config:

const axios = axios.create({
   responseType: 'json',
   baseURL: '...',
   headers: {
     'Content-Type': 'application/vnd.api+json',
     'Accept': 'application/vnd.api+json',
   }
})

How to excute file-reading processing every time in `app.messages()` function in Slack with Javascript

Recently, I’ve been creating Slack Bot.

And then, I have a question today, about how do I execute file-reading processing every time when send the messages, to return the result.

'use strict';
import bolt from '@slack/bolt';
import dotenv from 'dotenv';
import chalk from 'chalk';
dotenv.config();

import fs from 'node:fs';
import readline from 'readline';
const rs = fs.createReadStream('./meaning-data.csv');
const rl = readline.createInterface({ input: rs});
const app = new bolt.App(
  { token: process.env.SLACK_BOT_TOKEN, 
    appToken: process.env.SLACK_APP_TOKEN, 
    socketMode: true, 
    logLevel: 'debug' 
  });     
   
  const meaningObject = {};//Object

    //display-meaning function
     app.message(/mea (.+)/i, async({message, say}) => {
      const userInput = await message.text.match(/mea (.+)/i)[1];
        fs.readFile('./meaning-data.csv', 'utf-8', async(err, lineString) => {
           // values = [index, meaning, synonyms, URL];
          const values = lineString.split(',');
          const index = values[0];
          const meaning = values[1];
          const synonyms = values[2];
          const  URL = values[3];
          // meaningObject[index] = {index: index, meaning: meaning, synonyms: synonyms, URL: URL};
          meaningObject[index] = {index, meaning, synonyms, URL};
        });  
          await say(`Certainly <@${message.user}>, Here's meaning of *${meaningObject[userInput].index}*.`);  
          await say(`*Meaning:* ${meaningObject[userInput].meaning}`);
          await say(`*Synonyms:* ${meaningObject[userInput].synonyms}`);
          await say(`*URL:* ${meaningObject[userInput].URL}`);
        });

I’ve tried to include fees.readFile() function in the app.message() function.

Though, fs.readFile() function executed just at once for some reason, even if I included fs.readFile() function in the app.message().

How to modify a local (client side) JSON file with React?

I am trying to modify a JSON file as follows:

fetch("../../public/ordered_json_file.json")
  .then((response) => {
    return response.json();
  })
  .then((data) => {
    for (let i = 0; i < data.length; i++) {
      if (data[i].name === name) {
        data[i].name = "TEST";

        fs.writeFile("../../public/ordered_json_file.json", data, null, 4);
        break;
      }
    }
  })
  .catch((error) => console.error("Error fetching the JSON file:", error));

And getting this error:

Error: Module “fs” has been externalized for browser compatibility. Cannot access “fs.writeFile” in client code

Cannot seem to get a straight answer whether fs does’t work well for that purpose or this kind of operation is prohibited for security reasons.

Tried other modules but found nothing that solved the issue.

Any help is appreciated.