Creating Interactive Water Level Animation with Multiple Steps in HTML and JavaScript

I’m working on a project where I need to create an interactive water level animation with four steps. Each step represents a percentage, and the sum of all steps should be 100%. I want the water level to rise or fall by one step (from 0 to 3) each time the user scrolls the mouse wheel.

Additionally, I’d like the water levels from different steps to be displayed with different colors, and when the animation reaches step 3, it should fill the entire screen since the total is 100%.

I have a demo of my current progress here: https://codesandbox.io/s/simple-data-viz-2023-w7tv67?file=/src/index.html

While my code is almost working, I’m encountering some issues with making the water levels stack vertically and ensuring the correct color representation. Any help or guidance on how to achieve this functionality would be greatly appreciated!

we have 3 array and how pick 1 item from each array and push a new array using javascript

For example

const array1 = [Male, Female];

const array2 = [18-20];

const array3 = [Self Employed, Part Time, Full Time];

output will be

First Array:- [Male, 18-20, Self Employed];

Second Array:- [Male, 18-20, Part Time];

Third Array:- [Male, 18-20, Full Time];

Fourth Array:- [Female, 18-20, Self Employed];

Fifth Array:- [Female, 18-20, Part Time];

Sixeth Array:- [Female, 18-20, Full Time];

Cannot find module or its corresponding type declarations.ts(2307)

I created this custom npm package: https://www.npmjs.com/package/leon-theme?activeTab=code

Then I created a basic create-react-app https://github.com/leongaban/test-project and in the src/index.tsx file I tried to import my package.

However when add my import import { LeonTheme } from "leon-theme";

I get the following error when I hover over the above line:

Cannot find module ‘leon-theme’ or its corresponding type declarations.ts(2307)

node_modules/leon-theme folder structure in the new react app

enter image description here

Javascript sort callback dosen’t work for hash object [duplicate]

I am trying to sort the hash object, but it doesn’t work.

It is so simple sample, and try snippet, but in vain.

Where am I wrong?

function compareItem(a,b){
     console.log("a",a.class_id);
     console.log("b",b.class_id);
     console.log(a.class_id < b.class_id) 
     return a.class_id < b.class_id;
}
var arr = [{class_id:2},{class_id:1},{class_id:3}];
console.log(arr.sort(compareItem));
console.log(arr);

The custom “Buy Now” button in shopify is not working correctly

How to create a custom “Buy Now” button in Shopify so that it goes to the checkout page and not to cart. The problem is that when the user for the first time goes to the site clicks the button, he is redirected to the main page of the site and not to the checkout page. When the button is pressed again, everything works.

https://mistdream.org/products/rainserenity-by-mistdream

enter image description here

My code

    {% form 'product', product %}
                 <div class="item-bottom">

                        <div class="item-left">
                            <h4>quantity</h4>
                            <div class="item-count">
                                <div class="button-container">
                                    <button type="button" id="decrease">-</button>
                                </div>
                                <input type="text" name="quantity" min="1" value="1" id="quantity" aria-label="Quantity of goods">
                                <div class="button-container">
                                    <button type="button" id="increase">+</button>
                                </div>
                            </div>

                        </div>
                    </div>

                    <div class="item-price">
                        <h4>price</h4>
                        <p>{{ product.price | money }} <span>129.99$</span></p>
                    </div>
                <select name="id" style="display: none;">
                  <option value="{{ product.variants[0].id }}">
                    {{ product.variants[0].title }}
                  </option>
                </select> 

                <button class="button buynow-btn" title="Buy" onClick="instantBuy()">Buy now</button>
                    
              {% endform %}
 function instantBuy(){
     var $ = jQuery;

   var formParams = $('form').serialize();
     $.ajax({
      url: "/cart",
      type: "post",
      data: formParams,
      success: function(){ 
       window.location.href = "/checkout";
      },
      error: function(){
      }
     })
 }

React-PDF – expected expression, got ‘<'

Bit of a noob question, but I’ve been following React and React-pdf documentation/examples, but have been stuck at the titular error so far. Here’s my code:

// App.js

import './App.css';
import React from 'react';
import ReactDOM from 'react-dom';
import {Page, Document} from 'react-pdf';
import {StyleSheet} from "@react-pdf/renderer";
import samplePDF from "./pdfs/renal.pdf";


// Create styles
const styles = StyleSheet.create({
    page: {
        flexDirection: 'row', backgroundColor: '#E4E4E4'
    }, section: {
        margin: 10, padding: 10, flexGrow: 1
    }
});

function App() {
    return (
        <div>
            <Document file={samplePDF}>
                <Page pageNumber={1} />
            </Document>
        </div>
    )
}

export default App;
// index.js - unchanged from what's provided by create-react-app

import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: (removed because SO doesn't like shortened links)
reportWebVitals();

<!-- index.html - unchanged from create-react-app, except for the added Babel script which didn't fix the issue -->

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#000000" />
    <meta
      name="description"
      content="Web site created using create-react-app"
    />
    <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
    <!--
      manifest.json provides metadata used when your web app is installed on a
      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
    -->
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
    <!--
      Notice the use of %PUBLIC_URL% in the tags above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.

      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    -->
    <!-- babel script -->
    <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>

    <title>React App</title>
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
    <!--
      This HTML file is a template.
      If you open it directly in the browser, you will see an empty page.

      You can add webfonts, meta tags, or analytics to this file.
      The build step will place the bundled scripts into the <body> tag.

      To begin the development, run `npm start` or `yarn start`.
      To create a production bundle, use `npm run build` or `yarn build`.
    -->
  </body>
</html>

The error appears on the page after I open it – strangely, I can see ‘loading pdf’ and sometimes ‘failed to load PDF’ on the page shortly before the error appears. I’ve seen similar usages in online examples (for example, here) so I’m a bit confused as to what’s going wrong.

half day calculation js(java script) code [closed]

(my problem) …how to include a half day in leave system application using java script. if i select (Am ) radio button for from date that day calculate 0.5 day else one day. any one give me solution with code .am using PHP application

I try put radio button for half day calculation user choose a option for half day and full day using if condition. but no result what am expecting .if user select AM automatically calculate and display the value.

Trying to make a request to openai and return an image in base64

Uncaught Error: Could not load data:image/png;base64,undefined: undefined
    at index-dc6125bc.esm.js:1648:36
    at HTMLImageElement.onImageError (three.module.js:42367:19)
handleDecals(type, `data:image/png;base64,${data.photo}`)

I’ve researched and can’t find anything useful. My application runs great except for this one part. I try using express server to make a get request to openai and return an image that i can use as a logo to paste onto a tshirt, but as soon as i click the generate button, the errors show. I’m not sure what the problem is.

Thank you in advance for any help!

Read basePath in Next.js AppRouter

How can I read basePath in Next.js 13 when I use AppRouter?

We can get it by reading router.basePath from useRouter of PageRouter by importing `import { useRouter } from ‘next/router’

I cannot find any way to read it when I use AppRouter

import { useRouter } from 'next/navigation' has no basePath

Hidden Form Control wtih condition

I am confused about implementing the click function for the select form

I’ve tried using id, trigger if, else, but it doesn’t work
please help me,

<td scope="row">
                <select name="tpureq-detail-type[]" class="form-select" id="tpureq-detail-type">
                    <option value="barang stok" name="tpureq-detail-type-a">Barang Stok</option>
                    <option value="barang non stok" name="tpureq-detail-type-b">Barang Non-Stok</option>
                    <option value="jasa" name="tpureq-detail-type-c">Jasa</option>
                </select>
            </td>
            <td scope="row">
                <div class="input-group">
                    <input type="text" class="form-control" name="tpureq-detail-mat[]" placeholder="Code Material" aria-describedby="tpureq-detail-mat" readonly>
                    <button type="button" class="btn btn-success" id="tpureq-detail-mat" data-bs-toggle="modal" data-bs-target="#modalDialogScrollableMaterial" onclick="select_item(this)">
                        <i class="bi bi-search"></i>
                    </button>
                </div>
            </td>
            <td scope="row"><input type="text" class="form-control" name="tpureq-detail-desc[]" placeholder="Deskripsi" required readonly></td>

In Sveltkit, how do i import SCSS variables into my JS?

Im trying to access my color pallete within the script tag of my component:

import pallete from "$src/style/pallete.scss";

but it is returning the export as a string:

:export {
  mainColor: #e8d44d;
  mainColorHover: #c0aa1d;
  mainColorContrast: #1e1e1e;
  mainContrastDark: #000000;
}

I know i need to add these webpack configurations as said in some articles that i read in my searching, like this one.

module.exports = {
 // ...
 module: {
  rules: [
   {
    test: /.scss$/,
    use: ["style-loader", "css-loader", "sass-loader"]
   },
   // ...
  ]
 }
};

but im fallowing the Sveltekit docs so i have no webpack.config.js or rollup.config.js

Your webpack.config.js or rollup.config.js should be replaced with a svelte.config.js, as documented here.

What should i do?

customized marker for leaflet locate control plugin does’nt appear

I created a customized marker for leaflet locate control and inserted it with this code

      /*button to turn on GPS*/
      //function from leaflet locate control (plugin)
      L.Control.locategpsmarker = L.Control.Locate.extend({
          
          _drawMarker: function () {

              var icongpsMarker = {
                  iconUrl: 'img2/gps_marker.png',
                  iconAnchor: [18, 18]};

              var startMarker = L.marker(e.latlng, { icon: L.icon(icongpsMarker) });
              startMarker.addTo(mymap);
          }     

      });

      /*add geolocation button to map*/
      var lc = new L.Control.locategpsmarker({
          initialZoomLevel: 13,
          locateOptions: { enableHighAccuracy: true }, 
          position: 'topright',
          drawCircle: false,
          showPopup: false,
      });
      mymap.addControl(lc);
      /*END GEOLOCATION BUTTON*/

and got this error for the customized marker

Uncaught ReferenceError: e is not defined
    at i._drawMarker (main.html:119:44)
    at i._onLocationFound (L.Control.Locate.js:772:12)
    at i.fire (Events.js:190:11)
    at i._handleGeolocationResponse (Map.js:729:8)
_drawMarker @ main.html:119
_onLocationFound @ L.Control.Locate.js:772
fire @ Events.js:190
_handleGeolocationResponse @ Map.js:729

Has anybody already put a customized marker to this plugin?

Files missing from custom module npm package

I created a new npm package (leon-theme) here: https://www.npmjs.com/package/leon-theme

Github here: https://github.com/leongaban/leon-theme

Locally after running npm run build in the custom package, the dist folder builds correct, however when I publish it, all the files are missing except for the README and package.json.

Thus if I try to import my new package into a brand new react app, it cannot find the module.

https://www.npmjs.com/package/leon-theme?activeTab=code

tsconfig

{
  "compilerOptions": {
    "module": "ES6",
    "target": "es2016",
    "lib": ["ES2020", "DOM"],
    "jsx": "react",
    "declaration": true,
    "declarationDir": "types",
    "sourceMap": true,
    "allowSyntheticDefaultImports": true,
    "noEmit": false,
    "outDir": "./dist/lib/es6",
    "moduleResolution": "node"
  },
  "include": ["src/**/*"]
}

enter image description here

enter image description here