chartjs error Uncaught SyntaxError: expected expression, got ‘&’

I’m trying to integrate data from a database into Chart.js, but I’m encountering an error: Uncaught SyntaxError: expected expression, got ‘&’

Here is the code in the controller:

for (int i = 1; i <= days; i++)
{
     daysMonth.Add(string.Format(""Day {0}"", i));
}
ViewBag.XLabelCommission = string.Join(", ", daysMonth);

This is the returned result values of @ViewBag.XLabelCommission: "Day 1", "Day 2", "Day 3", "Day 4", "Day 5", "Day 6", "Day 7", "Day 8", "Day 9", "Day 10", "Day 11", "Day 12", "Day 13", "Day 14", "Day 15", "Day 16", "Day 17", "Day 18", "Day 19", "Day 20", "Day 21", "Day 22", "Day 23", "Day 24", "Day 25", "Day 26", "Day 27", "Day 28", "Day 29", "Day 30", "Day 31"

And when I put it into the chart as label.

var myChart1 = new Chart(ctx1, {
            type: 'line',
            data: {
                labels: [@ViewBag.XLabelCommission],
                datasets: [{

Just finding right element, For console to Auto scroll this container. (Archive internet’s book)

Archive’s book

Just want to know whats the root element of this? May you find quick and test code for console to auto scroll this? Here’s link to try https://archive.org/details/scottishsatirica0000unse/mode/1up?view=theater GPT can solve auto scroll, but the element will be based what will i gave to. Yoursly.

tried copy of js path of it document.querySelector(“#BookReader > div.BRcontainer > br-mode-1up”) and this can’t.

adding click event inside ngfor is not working

any idea guys why is that the click is not triggering inside the ngFor? I tried adding console log and it does not even fire. Thanks.

#html code

<ng-container *ngFor="let store of getLocationIds()">
  <a onclick="alert('clicked')" style="cursor: pointer;">Test Link</a>
  <a (click)="redirectToUrl(store.url)" class="location-link" style="cursor: pointer;">{{ store.locationId }}</a>
  <ng-container *ngIf="store !== getLocationIds()[getLocationIds().length - 1]">, </ng-container>
</ng-container>
  getLocationIds(): { locationId: string, url: string }[] {
    const stores = this.nonRetailProperty?.nonRetailAssociatedStores || [];
    return stores.map(store => ({
      locationId: store.locationId,
      url: store.url
    }));
  }

  redirectToUrl(url: string): void {
    console.log('1234', url)
    window.open(url, '_blank');
  }

I want to run specific line in a .js file, how to make it right?

source js file:
text

I just want to run this line:
var Jk = JN[‘V’](this[‘Y’][0xced + 0x83 * 0x4a + -0x32ca])
, Jk = Ja[Fh(bc.F)](Jw, Jk, JQ);

and I know “this[‘Y’][0xced + 0x83 * 0x4a + -0x32ca]” refer to string “/portal/main/flight/direct/query”

how to run it in python ? (selenium or whatever can make it right)

screenshot from chrome devtools

I tried selenium, use “execute_script” to run the whole file, then add “var Jk = JN[‘V’](this[‘Y’][0xced + 0x83 * 0x4a + -0x32ca])
, Jk = Ja[Fh(bc.F)](Jw, Jk, JQ);”, get an error, said “no JN blabla”

How do I rerun function without overlap instances in javascript?

So I want to rerun my function with updated values based on an event function.

Because i’m trying to use this javascript as a content-script, while statements don’t work as they just spam outputs and crash the page.

No if statements as it will just go through the code before the event and not repeat the if statement after I trigger the event. Here is basically what I’m trying to do.

function outer(value) {
  function inner() {
     outer(value); //rerun the function
     //then cancel this instance of the function
  
  }
  window.addEventListener('keydown', function(event) {
  //call function based off of evennt
  inner()
  }
}

I’ve tried all the ways to exit functions, but things like setInterval count as functions, so if I have a if statement be checked in intervals, it will only exit the setInterval.

Why does my react website page linking code not work?

navbar:

import React from 'react';
import './NavBar.css';

const NavBar = () => {
  return (
    <header className="navBar">
      <div className="logo">MEDIASURED</div>
      <nav>
        <ul>
          <li><a href="#about">About</a></li>
          <li><a href="#pricing">Pricing</a></li>
          <li><a href="#contact">Contact</a></li>
        </ul>
      </nav>
      <button className="quote-button">Get a Quote</button>
    </header>
  );
};

export default NavBar;

navbar css

.navBar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background-color: #333; /* Dark background for the header */
    color: white;
  }
  
  .navBar .logo {
    font-size: 24px;
    font-weight: bold;
  }
  
  .navBar nav ul {
    list-style: none;
    display: flex;
    gap: 20px;
    margin: 0;
    padding: 0;
  }
  
  .navBar nav ul li a {
    color: white;
    text-decoration: none;
    font-size: 18px;
  }
  
  .navBar nav ul li a:hover {
    text-decoration: underline;
  }
  
  .quote-button {
    padding: 10px 20px;
    background-color: #f44336; /* Red button */
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
  }
  
  .quote-button:hover {
    background-color: #d32f2f; /* Darker red on hover */
  }
  

footer

import React from 'react';
import './Footer.css';

const Footer = () => {
  return (
    <footer className="footer">
      <div className="footer-content">
        <p>&copy; 2024 Mediasured. All rights reserved.</p>
        <nav>
          <ul className="footer-links">
            <li><a href="#about">About</a></li>
            <li><a href="#privacy">Privacy Policy</a></li>
            <li><a href="#terms">Terms of Service</a></li>
          </ul>
        </nav>
      </div>
    </footer>
  );
};

export default Footer;

footer css

/* Footer.css */
.footer {
    background-color: #1c1c1c; /* Dark background matching the overall theme */
    color: white;
    padding: 20px 50px; /* Space around the footer */
    text-align: center; /* Center all text */
    font-family: 'Arial', sans-serif; /* Ensure consistent font */
  }
  
  .footer-content {
    max-width: 1200px; /* Keep footer content centered and contained */
    margin: 0 auto; /* Center the content horizontally */
  }
  
  .footer p {
    margin: 0;
    font-size: 14px;
    color: #bdc3c7; /* Light grey text color */
  }
  
  .footer nav {
    margin-top: 10px; /* Space between the text and the nav links */
  }
  
  .footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    gap: 30px; /* Space out the links evenly */
  }
  
  .footer-links li {
    display: inline;
  }
  
  .footer-links li a {
    color: white;
    text-decoration: none;
    font-size: 14px;
  }
  
  .footer-links li a:hover {
    text-decoration: underline;
  }

Hero CSS

/* Hero.css */
.hero {
    background-color: #2c3e50; /* Dark blue background */
    color: white;
    padding: 120px 20px; /* Padding for top/bottom and sides */
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh; /* Takes up most of the viewport height */
  }
  
  .hero-content {
    max-width: 800px; /* Limit the width of the content */
  }
  
  .hero h1 {
    font-size: 48px; /* Large font for the main headline */
    font-weight: 700; /* Bold */
    margin-bottom: 20px; /* Space below the headline */
    line-height: 1.2; /* Tighten the line height for a cleaner look */
  }
  
  .hero p {
    font-size: 24px; /* Medium font for the subheadline */
    margin-bottom: 40px; /* Space below the subheadline */
    line-height: 1.5; /* Slightly more relaxed line height */
    color: #bdc3c7; /* Light gray text for subheadline */
  }
  
  .cta-button {
    padding: 15px 30px; /* Size of the button */
    background-color: #e74c3c; /* Bright red button */
    color: white;
    border: none;
    border-radius: 5px; /* Slightly rounded corners */
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.3s ease; /* Smooth transition */
  }
  
  .cta-button:hover {
    background-color: #c0392b; /* Darker red on hover */
    transform: scale(1.05); /* Slight zoom effect on hover */
  }

HERO JS

import React from 'react';
import './Hero.css';
import { Link } from 'react-router-dom'; 

const Hero = () => {
  return (
    <section className="hero">
      <div className="hero-content">
        <h1>Securing your digital presence with us.</h1>
        <p>The most secure marketplace for buying and selling unique crypto assets.</p>
        <Link to="/Signup">
          <button className="cta-button">Get Your Quote</button>
        </Link>
      </div>
    </section>
  );
};

export default Hero;

index.js (home page)

import React from 'react';
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
import NavBar from '../../components/ui/NavBar';
import Footer from '../../components/ui/Footer';
import Hero from './Hero';  
import Signup from '../Signup';

function Home() {
  return (
    <Router>
      <div>
        <NavBar />
        <Routes>
          <Route path="/" element={<Hero />} />  
          <Route path="/signup" element={<Signup />} />
        </Routes>
        <Footer />
      </div>
    </Router>
  );
}

export default Home;

signup page (testing but this is were the error is happeneing

import React from 'react';

const Signup = () => {
  return (
    <div style={{ textAlign: 'center', marginTop: '50px' }}>
      <h1>Hello World</h1>
    </div>
  );
};

export default Signup;

app.js (official)

import React from 'react';
import Home from './pages/Home/index';

function App() {
  return (
    <div>
      <Home />
    </div>
  );
}

export default App;

index js official

import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './app';

const rootElement = document.getElementById('root');  // Make sure this isn't null
const root = ReactDOM.createRoot(rootElement);

root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);

index html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>MediaSured</title>
</head>
<body>
  <div id="root"></div> <!-- Ensure this exists -->
</body>
</html>

sorry for it being so long i need help

i thoughout it would display the website ive been coding (doesnt anymore i had it up)
i was trying to link sign up and home.
im sorry im new to react i need help thx alot

Path with Maximum Probability

I am trying to solve this problem:

Path with Maximum Probability leetcode 1514


You are given an undirected weighted graph of n nodes (0-indexed), represented by an edge list where edges[i] = [a, b] is an undirected edge connecting the nodes a and b with a probability of success of traversing that edge succProb[i].

Given two nodes start and end, find the path with the maximum probability of success to go from start to end and return its success probability.

If there is no path from start to end, return 0. Your answer will be accepted if it differs from the correct answer by at most 1e-5.


My code pass the test case but when I submit, for large data, it is giving wrong answer for one test case with very large node. I am doubting that problem lies in memo but can’t think of what might be the issue,

 var maxProbability = function (n, edges, succProb, start_node, end_node) {
       const graph = {}
       for (let i = 0; i < edges.length; i++) {
         const [a, b] = edges[i]
         if (!graph[a]) graph[a] = {}
         if (!graph[b]) graph[b] = {}
         graph[a][b] = succProb[i]
         graph[b][a] = succProb[i] 
      }

      const probability = (current_node, end_node, memo = {}, visited = {})=>{
          if(current_node == end_node) return 1
          visited[current_node] = true
          if(memo[current_node]) return memo[current_node]
          let result = 0;
          for(const node in graph[current_node]){
             if(!visited[node]){
                 result = Math.max(graph[current_node][node] * probability(node, end_node, memo, visited), result)
             }
         }
          delete visited[current_node]
          memo[current_node] = result
          return memo[current_node]
      }
      return probability(start_node, end_node)
  };

can anyone please help me understand what I am doing wrong.

Adjusting PlaneGeometry Dimensions and Camera Distance to Fill Screen width or height Without Exceeding Boundaries

I am trying to adjust a PlaneGeometry to match the screen dimensions and calculate the camera distance so that it fills the entire screen width or height without exceeding the screen boundaries. I have already added renderer.domElement to the page. However, I need to ensure that the PlaneGeometry dimensions match those of renderer.domElement and calculate the appropriate camera distance.

Requirements

  1. Get the width and height of renderer.domElement.

  2. Adjust the PlaneGeometry dimensions to match those of renderer.domElement.

  3. Calculate the camera distance so that the PlaneGeometry fills the entire screen without exceeding the screen boundaries.

Expected Result

  • The PlaneGeometry dimensions should match those of renderer.domElement.

  • The camera distance should be calculated appropriately so that the PlaneGeometry fills the entire screen without exceeding the screen boundaries.

Code Example

import * as THREE from 'three';

// Create scene, camera, and renderer
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

// Get the width and height of renderer.domElement
const screenWidth = renderer.domElement.clientWidth;
const screenHeight = renderer.domElement.clientHeight;

// Create PlaneGeometry
const planeGeometry = new THREE.PlaneGeometry(20, 30);// Width and height 
const planeMaterial = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
const planeMesh = new THREE.Mesh(planeGeometry, planeMaterial);
scene.add(planeMesh);

// `PlaneGeometry` 的宽度和高度
const planeWidth = planeGeometry.parameters.width;
const planeHeight = planeGeometry.parameters.height;

// Camera field of view (vertical)
const fovRadians = THREE.MathUtils.degToRad(camera.fov);

// Calculate camera distance
function calculateCameraDistance(screenWidth: number, screenHeight: number, planeWidth: number, planeHeight: number): number {
    const planeAspectRatio = planeWidth / planeHeight;
    const screenAspectRatio = screenWidth / screenHeight;

    if (planeAspectRatio > screenAspectRatio) {
        // Width fills screen width
        return (planeWidth / 2) / (Math.tan(fovRadians / 2) * (screenWidth / (2 * screenHeight)));
    } else {
        // Height fills screen height
        return planeHeight / (2 * Math.tan(fovRadians / 2));
    }
}

// Calculate camera distance
const cameraDistance = calculateCameraDistance(screenWidth, screenHeight, planeWidth , planeHeight );

// Set camera position
camera.position.z = cameraDistance;

console.log(`Camera Distance: ${cameraDistance}`);

// Render scene
function animate() {
    requestAnimationFrame(animate);
    renderer.render(scene, camera);
}
animate();

Question

How can I ensure that the PlaneGeometry dimensions match screen width or height and calculate the appropriate camera distance so that the PlaneGeometry fills the entire screen without exceeding the screen boundaries?

nodejs windows frame using third lib api e

I need help to “hello world” in windows screen, there are one lib in nodejs for use to windows notification overlay all screen?

[code]windows.frame.notification(“helloworld”,fixed);[code]

i want one simple for only one text in all screen and fixed

any name of one lib api ou framework ready to this. or in other language like java. or any other.

Vercel not sending the client’s IP address to Laravel backend on first SSR load (Nuxt 3)

I’m experiencing an issue with my setup where the client’s IP address isn’t forwarded correctly during the first SSR load of a page.

Backend: Laravel hosted on a VPS
Frontend: Nuxt 3 hosted on Vercel
Problem:
When a page is loaded for the first time with Server-Side Rendering (SSR), Vercel sends its own IP address instead of the client’s IP. This causes issues with my Laravel API, including:

429 errors due to rate limiting based on Vercel’s IP.
Incorrect geolocation since I use the client’s IP for location-based pricing and user experience.
However, this issue only happens on the first SSR load. For example, when a form request is made later, the correct client IP is sent.

What I’ve Tried:
I use the following plugin to make an initial request and load global values:ç

export default defineNuxtPlugin(async () => {
  const { products } = useProducts();
  const { limits } = useLimits();
  const route = useRoute();
  const sanctumClient = useSanctumClient();

  const { data, error } = await useAsyncData("globals", () =>
    sanctumClient("/globals"),
  );

  if (error.value) {
    if (error.value.statusCode === 503 && route.path !== "/maintenance") {
      await navigateTo("/maintenance");
    }

    if (route.path !== "/maintenance") {
      throw createError(error.value);
    }
  }

  if (data.value) {
    products.value = data.value.products;
    limits.value = data.value.limits;

    if (route.path === "/maintenance") {
      await navigateTo("/");
    }
  }
});

This issue also occurs in any other page that makes SSR calls, but only on the first load.

I enabled trustproxies in Laravel and set it to *, but it didn’t fix the problem.
In Nuxt, I tried forwarding the X-Forwarded-For header like this:

interceptors: {
  onRequest: (
    _app: NuxtApp,
    ctx: FetchContext,
    _logger: ConsolaInstance,
  ) => {
    const headers = useRequestHeaders();
    ctx.options.headers = {
      ...ctx.options.headers,
      "X-Forwarded-For": headers["x-forwarded-for"],
    };
  },
},

However, this triggers Cloudflare’s security mechanisms, flagging the request as potentially harmful.

Question:
Is there a better way to ensure the real client IP is sent to the backend during the first SSR load? Should I pass the IP in a different header, or is there a configuration I’m missing in Vercel to forward the client’s IP correctly?

Any suggestions are welcome!

Cargo2 preventing disabling vertical scroll

Im new to code, know a bit of HTML and CSS, and really none of js.
Im trying to do this website in cargo 2: www.empressao.com
what I want is that when im with the mouse inside my columns, the scroll for the body stop, and just work for the columns themselves. I did it work with JS in my .html file, in my computer, but when I past the scrips on the custom HTML box, it does not work.

What I really want is that when I have the mouse inside my “sticky” box, the box itself stops, and just the content inside scrolls. I just want to achieve that because, when im scroll to the top of each column, the container itself flies and is not very “user-friendly”.

         <script>
        document.querySelectorAll('.column').forEach(column => {
          column.addEventListener('mouseenter', () => {
            document.body.style.overflow = 'hidden'; // Disable body scroll
          });
          column.addEventListener('mouseleave', () => {
            document.body.style.overflow = ''; // Enable body scroll
          });
        });
       </script>

login, retrieve my account content with ajax

I’m looking to implement an ajax solution utilizing the [woocommerce_my_account] shortcode based on the code snippet posted here:

https://github.com/woocommerce/woocommerce/issues/43755

Is it possible to also complete the login or registration without reloading the page?

Or is it possible to pass a variable back to the browser on reload that could be used in javascript to display content based on the state of the page at the time the login or registration was submitted?

I’ve tested different WordPress ajax login plugins, and they all either redirect or reload on login and on registration.

Here’s the code posted to github on ajaxifying the wooCommerce my account page endpoints:

AJAX URL Script to support WooCommerce End Point loads:

function enqueue_ajax_url_script() {
    ?>
    <script>
        var ajaxurl = '<?php echo esc_url(admin_url('admin-ajax.php', 'https')); ?>';
    </script>
    <?php
}
add_action('wp_footer', 'enqueue_ajax_url_script');

JavaScript to enable woocommerce ajax endpoints:

// JavaScript

jQuery(document).ready(function($) {
    // Attach click event to tabs
    $('body').on('click', '.woocommerce-MyAccount-navigation-link', function(e) {
        e.preventDefault();

        // Get the endpoint and anchor from the tab link
        var endpointWithAnchor = $(this).attr('href').replace('#', '');

        // Extract the endpoint and anchor separately
        var endpoint = endpointWithAnchor.split('#')[0];
        var anchor = endpointWithAnchor.split('#')[1];

        // Trigger AJAX request
        $.ajax({
            url: ajaxurl,
            type: 'POST',
            data: {
                action: 'load_account_tab_content',
                endpoint: endpoint,
            },
            success: function(response) {
                // Update the tab content with the response
                $('#your-tab-content-container').html(response);

                // Scroll to the anchor if available
                if (anchor) {
                    $('html, body').animate({
                        scrollTop: $('#' + anchor).offset().top
                    }, 500);
                }
            },
        });
    });
});

Script to dynamically create a 3 columns per n rows from a list

I’m coding a MVC app with ASP .NET 8.0 framework and following code should retrieve a List from my controller to create a 3 columns per n rows table in my view. It run well till the last row:
tableau.appendChild(tbl);

Where I get the error:

Uncaught TypeError: Cannot read properties of null (reading ‘appendChild’)

I didn’t find a way to create my table using the foreach loop so I’m using the for loop with javascript.

@model List<ViewListTable>
<head>
  <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
  <script type="text/javascript">
    function f() {
      var myArray = [];
      @foreach(var d in Model) {
        @: myArray.push("@d.Name");
      }

      var cptData = myArray.length;
      var tableau = document.getElementById('tableau');
      var tbl     = document.createElement("table");
      var x       = 0;

      for (var i = 0; i < cptData / 3; i++) {
        var tr = document.createElement('tr');
        for (j = 0; j < 3; j++) {
          var td = document.createElement('td');
          if (x < cptData) {
            var a        = document.createElement('a');
            var el_span  = document.createElement('span');
            var linkText = document.createTextNode(myArray[x]);
            var tab      = myArray[x];

            //console.log(tab);
            el_span.setAttribute('style', 'color: #07C');
            a.setAttribute('href', "'" + tab + "'");
            a.setAttribute('class', 'button');
            a.title = "Éditer les données de la table:";
            a.appendChild(linkText);
            el_span.appendChild(a);
            td.appendChild(el_span);
          };
          x += 1;
          tr.appendChild(td)
        };
        tbl.appendChild(tr);
      }
      tableau.appendChild(tbl);
    }
    f();
  </script>
</head>
<body>
  <div id="tableau"></div> 
</body>

image

image

Dual datepicker jQuery selection

I am building a date picker from scratch as a learning exercise. My date picker has two months side by side, and my question is, what does the jQuery look like for picking a start date and end date, allowing for the user to change their mind and have both dates on the same month, or on opposite months?

My HTML

<div class="calendar left">
    <div class="calendar-days">
        <div class="calendar-day" day="1">1</div>
        <div class="calendar-day" day="2">2</div>   
        <div class="calendar-day" day="3">3</div>
        <div class="calendar-day" day="4">4</div>
        <div class="calendar-day" day="5">5</div>
        ...
        ...
    </div>
</div>
<div class="calendar right">
    <div class="calendar-days">
        <div class="calendar-day" day="1">1</div>
        <div class="calendar-day" day="2">2</div>   
        <div class="calendar-day" day="3">3</div>
        <div class="calendar-day" day="4">4</div>
        <div class="calendar-day" day="5">5</div>
        ...
        ...
    </div>
</div>

Say the left month is August and the right month is September… they can choose start date August 5th and end date August 17th, or start date August 5th and end date September 22nd, or start date September 8th and end date September 12th, etc… there’s three scenarios.

Selecting the start date is obvious with a click event, and adding a selected class to that day. But how do I only allow two days to be selected at any given time across both calendars?