In the CSS .style.transform function im trying to add the degrees to be 90 + MenuRotate which is a variable

The code

function OpenMenu(){
 var MenuRotate = getCurrentRotation(document.getElementById("Menu-Icon"));
document.getElementById("menu").style.margin = "450px";
document.getElementById("Menu-Icon").style.transform ="rotate(90deg)";
var Menu1 = 1;
//alert(MenuRotate);

I would like to be able to add MenuRotate to the 90 degrees, not sure how i could do this so im looking for some answers

Can you tell Javascript to run without it being open? [duplicate]

I’m into finace and wanted and to create a function where at certain at a specific time of day (when US markets close) this function tweets out financial data using the Twitter API. I wrote all the functions needed to gather the information for this already in Javascript but now I’m wondering if the whole timing process is even possible? How could I make these functions run without me having to tell them to do so and not having it open?

How to trigger an HTML element inside a PHP file from an external JS file

I would like to trigger an HTML element within a PHP file from a JS file with an event listener. This is my PHP file:

<?php echo password : is <div style='visibility:visible' id='password'> ".$pass."</div>  
          <button id='togglePassword'>See</button>";  ?> 

and this is my JS file. Obviously I’m using an event listener which pointing on my password and toggle! Here is my JS file:

const toggle = document.getElementById('togglePassword');
const password = document.getElementById('password');

toggle.addEventListener("click", function () {
    console.log("test")
    if(password.style.visibility==="visible"){
        password.style.visibility=  "hidden"
    }else {
        password.style.visibility = "visible"
    }   
});

Import JSDOC documentation from another file

How can I import the documentation for class foo in File B?

// FileA.js
/** This is a class */
class foo { }

export default objectThatContainsFoo // foo isn't directly exported
// FileB.js
/** @typdef {--IMPORT DOCUMENTATION FOR foo--} foo */

/**
 * @param {foo} foo - This is a foo
 */
function bar(foo) { return true }

Lexical Environment and bind()

When creating a function with bind() is a lexical environment also created?
My code works as expected, I am making a Partially applied function with an object and I want to confirm if the reference is never lost when we use currying

    let literal = {
    
        nombre: 'Daniel'
    };
    function parcial(unObjeto, numero) {
    
        console.log(unObjeto);
    }
    let vinculada = parcial.bind(null, literal);
    vinculada(); // {nombre: 'Daniel'}
    
    literal.nuevapropiedad = 'nuevo valor';
    vinculada(); // {nombre: 'Daniel', nuevapropiedad: 'nuevo valor'}

I see that if I modify the “literal” object later in the code the linked function reads that “updated” object.

To the best of my knowledge this has logic because bind() creates a lexical environment that closes in this case on “literal” as if it did with the first argument (in this case I don’t want to use the first argument) and it will never lose the reference

Can I change the class of a link from one class to another using javascript?

I’ve been attempting to use the js .toggle feature to change the class of a link to turn it from one colour to another onclick.

<html>

<style>

.the-button-inactive {
    display: inline-block;
    height: 20px;
    width: 20px;
    border-radius: 10px;
    background-color: black;
}
.the-button-active {
    display: inline-block;
    height: 20px;
    width: 20px;
    border-radius: 10px;
    background-color: blue;
}

</style>

<body>

   <div class="the-button-container">

                <a href="#the-image-1" id="the-image-1-id" onclick="myFunction()" class="the-button-inactive"></a>

  </div>
  
  <script>
    function myFunction() {
   var element = document.getElementByID("the-image-1-id");
   element.classList.toggle("the-button-active");
}
</script>
  

</body>

</html>

The link already has the “the-button-inactive” class and I’m trying to switch it to “the-button-active” class on click using the above script though I’m not sure why it’s not working. The ultimate goal would be to get the link to change colour from black to blue when clicked and then from blue to black again when another link is clicked.

So far, nothing happens when the link is clicked.

I was able to achieve this previously using buttons instead of links, but have decided to try to tackle this issue using links now.

Here is the jsfiddle I’m using to test this script: https://jsfiddle.net/tqr2h4pb/

Handle API request Rate Limit – Axios 429 Error

I am using getting live actions from API and I’m getting a lots of requests. I’m trying to check all of the responses. Rate limit is 4 requests per second and API key is required.
I have 10 API keys and every time I’m making requests with different keys, so I can make 40 requests per second, which is way more than what I get from Api per second. Although I still get a lot of Axios 429 error and I can not handle it.

I try to run them separate on different terminals and files. It’s working better but if one of the servers get error, other ones will start throwing same error AXIOS 429. Also would like to know if I can fix that issue, so separate server don’t get affected by an other server’s error.
Any advice/help is much appreciated! Thank you.

keys = [1,2,3,4,5,6,7,8,9,10]
streamApi.onEvents('*', event =>{
   i < keys.length-1 ? i++ : i = 0
    axios.get(api, {"Accept":'application/json', "x-api-key": keys[i]}})
  })

enter code here

Javascript keydown event not working when three keys that form a triangle are pressed

I am currently trying to detect which keys are currently pressed at any given time. Like others have said, I used the keydown and keyup events and log the keyCodes to an object. I also added console.log statements in my keydown and keyup listeners. Currently, everything works well except when three keys are pressed simultaneously in a triangular shape (on a QWERTY keyboard: ["T", "G", "Y"], ["4", "5", "R"], etc.), the keys don’t log as expected: either one or two logs, or none of them logs. I wonder if there’s a way to get around whatever limitation is causing this?

.net Core 3.1 Signalr Javascript, Can’t make a connection between my javascript web app to my .net core backend

I’m getting this error when trying to connect to my signalR .net core 3.1 api:

Access to fetch at 'https://localhost:44318/livelisting/negotiate?negotiateVersion=1' from origin 
'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't 
pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response 
must not be the wildcard '*' when the request's credentials mode is 'include'.

I do have everything setup as the documentation says from Microsoft

Backend code current config:
backend code current config

Frontend code current config:

frontend code current config

use Genero Shortcut By Html

I have a question now because IE was not maintained after 2022/6/15 also as the ActiveX
We have the ERP system only can use ActiveX By GDC(Genero Desktop Client), But now it can’t use.
I google for it and found that I can create a shortcut By GDC, than export the shortcut on my desktop, that I can double click the shortcut to run my ERP system not using any browser(IE、chrome、EDGE…etc)
Now I want to create a webpage include this shortcut, let my co-worker can click the button on the webpage to run ERP system
If I use href to call the chortcut, it always show 404, but on the server I can double click shortcut to run the ERP system.
Can anyone tell me the problem or how can I do for it?
(ps. the shortcut like xxxx.gdc)

Thank you for your Reading, if anything I missed Please tell me

cannot get cookies that is set from backend

My frontend is running on localhost:3000 while backend which is on nestjs is running on localhost:3006. When user signs up or logs in then I have set cookie in the following way

const setCookie = context.res.cookie('cookie-data', {
      accessToken: token.accessToken,
      refreshToken: token.refreshToken,
      user: user,
    });

Now, I need this cookie to authenticate each route. I mean if I go to particular page which is a private page then I need to check if those token exist and is valid or not from cookie by calling api for that particular user through the token I get from cookie. If it’s valid then allow user to navigate to that page otherwise redirect user to login.

This is how I am trying to get the cookie that’s set from backend while user logs in

_app.tsx

function MyApp({ router, pageProps, Component, cookies }) {
  return (
    <>
      <Header />
      {
        Component.auth ?
          <Auth cookies={cookies}>
            <Component key={router.route} {...pageProps} />
          </Auth> :
          <Component key={router.route} {...pageProps} />
      }
    </>
  )
}

MyApp.getInitialProps = async (appContext) => {
  const appProps = await App.getInitialProps(appContext);
  let cookies = {};
  if (process.browser === false) {
    cookies = appContext.ctx.req?.cookies;
  } else {
    cookies = Cookies.get();
  }

  return { ...appProps, cookies }
}

export default MyApp

The problem is appContext.ctx.req?.cookies; returns an empty object. How can I receive cookie that is set from backend(nestjs) ?

How to Filter object and get certain field in Javascript

I’m struggle with using filter.

Initial object
This is my object.

[{
  isOpen : true,
  items : [
    {itemId : '', name : 'some name'},
    {itemId : 'new', name : 'new name'}
  ]
},]

Expected Result

I just want to show that the itemId is not an empty string and also isOpen field.

[{
  isOpen : true,
  items : [
    {itemId : 'new', name : 'new name'}
  ]
},]

What I try

  const removeEmptyStringInItems = (item) => item.items?.filter((v) => v.itemId);
  const finalItems = myItems.map(removeEmptyStringInItems);

output.

{itemId : 'new', name : 'new name'}

Any ideas for this problem? I really need help!

How to whitelist only a few URLs to make API calls at client site?

So, we recently launched our website, and things are going great so far. But since last night we have seen that some end-users browsers are making calls to strange URLs. We don’t know how or why the browser makes those calls. Our guess is that the user’s browser was compromised and they might have unknowingly installed some browser extension that makes those calls.

Now the question is whether we could make the browser to stop making those cross-domain calls and only whitelist our domain and a few additional domains like GTM and other tracking apps? Of course, we need to handle this at the front-end level, but I’m not sure how to set a whitelist URLs list for fetch. Is there a way to do it??

Javascript conditional method chaining

How can I simplify this code to use conditional method chaining for useBuffer() method. Please suggest.

  const getApi = async (headers, userContext, httpRequest, url, isBlob) => {
  if (isBlob) {
    const result = await httpRequest
      .get(url)
      .withCredentials()
      .set(headers)
      .send({ userContext })
      .useBuffer()
      .then((res) => [res.body, res.headers]);
    return result;
  }
  else {
    const result = await httpRequest
      .get(url)
      .withCredentials()
      .set(headers)
      .send({ userContext })
      .then((res) => res);
    return result;
  }
};

to something like this:

const getApi = async (headers, userContext, httpRequest, url, isBlob) => {
    const result = await httpRequest
      .get(url)
      .withCredentials()
      .set(headers)
      .send({ userContext })
      .isBlob && useBuffer()
      .then((res) => isBlob ? [res.body, res.headers] : res);
    return result;
};