Fix position of div when another div reached the top of page

For this I would rather use normal Javascript than jQuery.

I have 4 divs in the section of my page

<div id="div1">
  Content Here!
</div>

<div id="div2">
  Content Here!
</div>

<div id="div3">
  Content Here!
</div>

<div id="div4">
  Content Here!
</div>

<div id="footer">
  Content Here!
</div>

When scrolling I would like this behaviour:

  • When div1 and div2 reach the top of the page they stop scrolling and remain in a fixed position.

  • On continuing to scroll, div3 scrolls up until it reaches the top of div 2 and then remains in a fixed position, covering div2.

  • On continuing to scroll, div4 scrolls up until it reaches the top of div 3 and then remains in a fixed position, covering div3.

  • On continuing to scroll, the footer div scrolls over all divs above it and covers them

I have messed around a lot and not come anywhere close to achieving this and have no idea where to go

Thanks in advance

Is preload.ts leaking event listeners?

My Electron application opens, besides its main window, various secondary windows.

The preload.ts file is called every time one of the windows is created.

Preload define an event listener for "DOMContentLoaded".

Is this listener automatically removed when I close the corresponding window or should I remove it manually? In this case how? (I’m fighting leaks right now…)

Electron 35.0.0 on Windows 11 64 bits

Does shadcn SidebarProvider render all its children on the client on Next.js?

Out of curiosity, shadcn’s sidebar has ‘use client’ declaration on the top of its component file which includes the declaration of SidebarProvider.
From my understanding of nextjs, when a client component is rendered, all of its children are rendered on the client side too.
But the shadcn documentation encourages to wrap out entire application with the SidebarProvider.
Does this not render our entire app on the client side and kill ssr as a whole?

I am pretty sure this is not the case, but how does this SidebarProvider work under the hood?

Using Webpack to compile SCSS to CSS

Any webpack experts here? I’m trying to figure out how to get Webpack to compile my SCSS file to a CSS file

I’ve got a project with an index.html and a CSS file linked in the head, just the standard way. I’m using Webpack to bundle the React code in this project, but it also contains some Backbone code and other things i will replace over time, so the CSS needs to stay linked in the head at the moment. I’m not importing this CSS file vis JS in my React components.

When I edit say, example.scss I want webpack to compile it down and generate me a new example.css Can Webpack do something like this? I’ve done a ton of digging, and can’t seem to find a solution. Everything seems to involve CSS imported into JS components.

The previous setup for this project used Grunt, which accomplished this easily. I wonder if maybe I need two processes. One to compile React code and another just to compile SCSS and generate a new CSS file.

Thanks in advance!

how to force the import yjs module using mjs

My project using mjs style, I import the yjs("yjs": "^13.6.23") https://yjs.dev/ in my project like this:

import * as Y from "yjs";

from the error info, I found the project using the yjs cjs code:

│ Caught error while handling a Yjs update TypeError: Cannot read properties of undefined (reading 'splice')                              │
│     at splitItem (/home/node/app/node_modules/yjs/dist/yjs.cjs:9606:22)                                                                 │
│     at getItemCleanEnd (/home/node/app/node_modules/yjs/dist/yjs.cjs:3007:34)                                                           │
│     at Item.getMissing (/home/node/app/node_modules/yjs/dist/yjs.cjs:9892:19)                                                           │
│     at integrateStructs (/home/node/app/node_modules/yjs/dist/yjs.cjs:1615:35)                                                          │
│     at /home/node/app/node_modules/yjs/dist/yjs.cjs:1698:25                                                                             │
│     at transact (/home/node/app/node_modules/yjs/dist/yjs.cjs:3444:14)                                                                  │
│     at readUpdateV2 (/home/node/app/node_modules/yjs/dist/yjs.cjs:1686:3)                                                               │
│     at applyUpdateV2 (/home/node/app/node_modules/yjs/dist/yjs.cjs:1781:3)                                                              │
│     at Object.applyUpdate (/home/node/app/node_modules/yjs/dist/yjs.cjs:1795:58)                                                        │
│     at readSyncStep2 (/home/node/app/node_modules/y-protocols/dist/sync.cjs:107:18)

I search the yjs dist folder, it contains both cjs amd mjs code, is it possible to force the yjs using mjs code, not use the cjs? This is my project package.json:

{
  "name": "texhub-broadcast",
  "version": "1.0.29",
  "description": "",
  "main": "./dist/app.js",
  "module": "./dist/app.js",
  "types": "./dist/app.d.ts",
  "type": "module",
  "exports": {
    "./dist/websocket/conn/socket_io_client_provider": "./dist/websocket/conn/socket_io_client_provider.js",
    ".": {
      "import": "./dist/app.js"
    }
  },
  "files": [
    "dist/*"
  ],
  "scripts": {
    "test": "echo "Error: no test specified" && exit 1",
    "lint": "eslint --fix",
    "dev": "export NODE_ENV=dev && ts-node -r tsconfig-paths/register src/app.ts",
    "build": "tspc"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@socket.io/admin-ui": "^0.5.1",
    "dotenv": "^16.4.7",
    "esm-module-alias": "^2.2.1",
    "express": "^4.21.2",
    "flatted": "^3.3.2",
    "globals": "^15.14.0",
    "jsonwebtoken": "^9.0.2",
    "level": "^9.0.0",
    "leveldown": "^6.1.1",
    "levelup": "^5.1.1",
    "lib0": "^0.2.99",
    "lodash": "^4.17.21",
    "log4js": "^6.9.1",
    "meilisearch": "^0.35.1",
    "module-alias": "^2.2.3",
    "pg": "^8.13.3",
    "prom-client": "^14.2.0",
    "redis": "^4.7.0",
    "socket.io": "^4.8.1",
    "socket.io-client": "^4.8.1",
    "uuid": "^11.1.0",
    "ws": "^8.18.0",
    "y-leveldb": "^0.1.2",
    "y-protocols": "^1.0.6",
    "y-websocket": "^1.5.0",
    "yjs": "^13.6.23"
  },
  "devDependencies": {
    "@types/express": "^5.0.0",
    "@types/jsonwebtoken": "^9.0.8",
    "@types/lodash": "^4.17.15",
    "@types/node": "^22.13.8",
    "@types/pg": "^8.11.11",
    "@types/ws": "^8.5.14",
    "@typescript-eslint/eslint-plugin": "^8.22.0",
    "@typescript-eslint/parser": "^8.22.0",
    "eslint": "^9.19.0",
    "ts-node": "^10.9.2",
    "ts-patch": "^3.3.0",
    "tsc-alias": "^1.8.10",
    "tsconfig-paths": "^4.2.0",
    "typescript": "^5.7.3",
    "typescript-transform-paths": "^3.5.3",
    "vite": "^6.0.11",
    "vite-node": "^3.0.4",
    "vitest": "^3.0.4"
  }
}

Android webview javascript interface being removed on webforms partial postback

I am trying to interact with a WebForms site via a WebView inside an Android application.

I need to include a javascript interface to be able to send messages to the webview. However whenever a page does a partial postback, the interface gets removed and I get the javascript error “MyWebHost is undefined” when trying to access any of the functionality

Web Client:

public class MyWebviewClient extends WebViewClient
{

private View BusySpinner;
public String BaseUrl;

public MyWebviewClient(View busySpinner, String baseUrl)
{
    BusySpinner = busySpinner;
    BaseUrl = baseUrl;
}



@Override
public void onPageStarted(WebView view, String url, android.graphics.Bitmap favicon) {
    super.onPageStarted(view, url, favicon);
    BusySpinner.setVisibility(View.VISIBLE);
}

@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    if(url==null) { return;}

    if(url.contains("token_capture"))
    {
        view.loadUrl(BaseUrl);
        return;
    }
    
    view.addJavascriptInterface(new WebAppInterface(view.getContext()), "MyWebHost");
    BusySpinner.setVisibility(View.GONE);
}

 public class WebAppInterface 
 {

    public Context Context;

    public  WebAppInterface(Context context)
    {
        Context = context;
    }

    @JavascriptInterface
    public void HandleButtonPress()
    {
        Toast.makeText(Context, "The user pressed the button in the web view", Toast.LENGTH_LONG);
    }
    
}
}

sample interaction

<!-- works after page load, buy not after a partial postback -->
<div onclick="MyWebHost.HandleButtonPress();"> Click Me</div>

React Native Animated Header on scroll

I have been trying to find a way to be able to have a header that moves with the scroll combined with a tab switcher that snaps into position at a certain point. I have been able to get all this to work perfectly, however there is one issue I have.

The header when it has a button or a horizontal scroll they are un-interactable eg click or horizontal scroll unless I make the header a higher index then the scroll and wrap the header with pointerEvents="box-none", however this makes it so that the buttons or horizontal scroll dont trigger the vertical scroll when doing a scroll gesture on top of them.

Does anyone know a solution to this where buttons and horizontal scrolls operate as if the components were inside a scrollview? As at the moment the header view scrolls the scrollview as its absolute positioned over it, its just the buttons and horizontal scrolls that are within it that dont.

import { View } from 'react-native';
import Animated, { useAnimatedStyle, interpolate, interpolateColor } from 'react-native-reanimated';
import { TabView } from 'react-native-tab-view';

// import provider
import type { SceneRendererProps } from 'react-native-tab-view'
import { useScroll } from '~/utils/providers'

// import constants
import { Screen } from '~/components/layouts'
import { DefaultHeader } from '~/components/global'

// styles
import { Layout } from '~/styles'

// import styles
import { useStyles } from './style'

// import theme
import { useTheme } from '~/theme'

// import types
import type { IconsType } from '~/constants'
import type { TranslationString, TranslationStringWIthOptions } from '~/locales'

// define types
type ScreenWithHeaderProps = {
    headerTitle: string | TranslationString | TranslationStringWIthOptions
    headerRightIcons?: Array<{ name: keyof IconsType; onPress: () => void }>
    headerHeight?: number
    topComponentHeight?: number
    topComponent: React.ReactNode
    tabBarHeight?: number
    routes: Array<{ key: string; title: string }>
    renderTabBar: (props: SceneRendererProps) => React.ReactNode
    renderScene: (props: SceneRendererProps & { route: any }) => React.ReactNode
    activeIndex: number
    onIndexChange: (index: number) => void
}

export function ScreenCollapsableTabView({
    headerTitle,
    headerRightIcons,
    headerHeight = 0,
    topComponentHeight = 0,
    tabBarHeight = 0,
    topComponent,
    routes,
    renderTabBar,
    renderScene,
    activeIndex,
    onIndexChange,
}: ScreenWithHeaderProps) {
    // get styles file
    const styles = useStyles()

    // get theme data
    const theme = useTheme()

    // get scroll state and handler from content
    const { scrollY } = useScroll()

    const headerAnimatedStyle = useAnimatedStyle(() => ({
        transform: [
            {
                translateY: interpolate(
                    scrollY.value,
                    [0, headerHeight + topComponentHeight],
                    [0, -(headerHeight + topComponentHeight)],
                    'clamp'
                )
            },
        ],
    }))

    // header backgroundcolor animation for on scroll change
    const backgroundColorHeader = useAnimatedStyle(() => {
        return {
            backgroundColor: interpolateColor(
                scrollY.value,
                [0, 60],
                ['rgba(22, 33, 59, 0)', theme.colors.backgroundThird],
            ),
        };
    })

    // animated tab bar transform & color
    const tabBarAnimatedStyle = useAnimatedStyle(() => {
        const translateY = interpolate(
            scrollY.value,
            [0, headerHeight + tabBarHeight],
            [headerHeight + tabBarHeight, 0],
            'clamp'
        )
        const backgroundColor =
            scrollY.value <= headerHeight + tabBarHeight ? theme.colors.background : theme.colors.backgroundThird;

        const shadowStyle =
            scrollY.value <= headerHeight + tabBarHeight
                ? {
                      shadowColor: 'transparent',
                      shadowOffset: { width: 0, height: 0 },
                      shadowOpacity: 0,
                      shadowRadius: 0,
                      elevation: 0
                  }
                : {
                      shadowColor: '#000',
                      shadowOffset: { width: 0, height: 4 },
                      shadowOpacity: 0.35,
                      shadowRadius: 5,
                      elevation: 7
                  }

        return {
            transform: [{ translateY }],
            backgroundColor,
            ...shadowStyle,
        };
    })

    // render tab bar
    const tabBar = (props: SceneRendererProps) => {
        return (
            <Animated.View style={[styles.tabBarContainer, tabBarAnimatedStyle]}>{renderTabBar(props)}</Animated.View>
        )
    };

    return (
        <Screen withScroll={false}>
            <View style={styles.container}  pointerEvents="box-none">
                <View pointerEvents="box-none">
                    <Animated.View style={[{ zIndex: 3 }, backgroundColorHeader]}>
                        <DefaultHeader titleKey={headerTitle} rightIcons={headerRightIcons} enableTransparent />
                    </Animated.View>
                    <Animated.View style={[styles.topComponentContainer, headerAnimatedStyle]} pointerEvents="box-none">
                        {topComponent}
                    </Animated.View>
                </View>

                <View style={styles.childrenContainer}>
                    <TabView
                        lazy
                        removeClippedSubviews={true}
                        navigationState={{ index: activeIndex, routes }}
                        renderTabBar={tabBar}
                        style={{ flex: 1 }}
                        renderScene={renderScene}
                        onIndexChange={onIndexChange}
                        initialLayout={{ width: Layout.width }}
                    />
                </View>
            </View>
        </Screen>
    )
}

How can I export types for my npm package without /dist/ in the package path?

I’ve searched for this question and haven’t found anything that fixes my issue. Here’s the problem:

I’ve got a package called @clioplaylists/clio that’s using a src/ folder for all its code. I’m building the source code with typescript into the dist/ folder and copying package.json over into it as well. I’m using "declaration": true in my tsconfig.json file, so the types .d.ts files are getting generated correctly in the dist/ folder. Then I tried running npm publish --access public in the root directory of the project, which published everything, but once I tried and access it it’s saying certain folders are imported like import * from '@clioplaylists/clio/dist/dataplane/...', and I don’t want the /dist/ in there.

I tried cding into the dist/ folder and running npm publish --access public to publish my package only with the code in the dist/ folder (which has the package.json file in there). Everything publishes fine, except when I import the @clioplaylists/clio package in another project I can’t import anything. Attached is a picture of what the editor says is inside import * from '@clioplaylists/clio/

image showing that only 3 things are able to be imported, none of them useful

What’s the right way to publish my package such that all of my types files are included but the /dist/ folder is not included in the import path?

Tranform php code and functions in ajax/javascript request

I’ve been trying for a month to transform a php code with these functions into ajax/javascript requests but being a beginner I really have trouble moving forward.

I think I’m on the right track but I don’t know anyone who could help me and tell me if I’m wrong or not.

Here is the php code :

<?php
if(isset($_GET['ip'])){$address=$_GET['ip'];}
$port=8899;
$page = $_SERVER['PHP_SELF'];
$sec = "5";

?>
    <meta http-equiv="refresh" content="<?php echo $sec; ?>">

<?php


$rcm='~M601 S1rn';
$rim='~M115rn';
$rtm='~M105rn';
$rhm='~G28rn';
$progres='~M27rn';
$status='~M119rn';
$cal='~M650rn';

$l_on='~M146 r255 g255 b255rn';
$pause='~M25rn';
$resume='~M24rn';
$cancel='~M26rn';
$home='~G28rn';

$buf='';


 if (($socket=socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) and
      (socket_connect($socket, $address, $port)))
    {
      $text="Connection successful on IP $address, port $port";
      socket_send($socket,utf8_encode($rcm),strlen($rcm),0);
      socket_recv($socket, $bufi, 1024, 0);
      
      if(isset($_POST['LED']) && $_POST['LED']=='SWITCH'){ socket_send($socket,utf8_encode($l_on),strlen($l_on),0);socket_recv($socket, $buf, 1024, 0);}
      if(isset($_POST['PAUSE']) && $_POST['PAUSE']=='ON'){ socket_send($socket,utf8_encode($pause),strlen($pause),0);socket_recv($socket, $buf, 1024, 0);}
      if(isset($_POST['RESUME']) && $_POST['RESUME']=='ON'){ socket_send($socket,utf8_encode($resume),strlen($resume),0);socket_recv($socket, $buf, 1024, 0);}
      if(isset($_POST['STOP']) && $_POST['STOP']=='ON'){ socket_send($socket,utf8_encode($cancel),strlen($cancel),0);socket_recv($socket, $buf, 1024, 0);}
      if(isset($_POST['HOME']) && $_POST['HOME']=='ON'){ socket_send($socket,utf8_encode($home),strlen($home),0);socket_recv($socket, $buf, 1024, 0);}
      
      socket_send($socket,utf8_encode($rtm),strlen($rtm),0);
      socket_recv($socket, $buft, 1024, 0);
      
      socket_send($socket,utf8_encode($progres),strlen($progres),0);
      while(!socket_recv($socket, $bufp, 1024, 0));
      
      socket_send($socket,utf8_encode($status),strlen($status),0);
      while(!socket_recv($socket, $bufs, 1024, 0));
      
     
     // socket_recv($socket, $led, 1024, 0);
      
      socket_close($socket);
    //  echo "Prijate data:<br>";
  //  echo $bufs;         ///////////////////////DEBUG MESSAGE
    //Uprava informacii o teplote
      $buft=explode('T0:',$buft);
      $buft=explode('T1:',$buft[1]);
      $temp=explode('/',$buft[0]);
      $temp_he=$temp[0];
      $temp_hes=$temp[1];
      $buft=explode('B:',$buft[1]);
      $buft=explode('ok',$buft[1]);
      $temp=explode('/',$buft[0]); 
      $temp_bed=$temp[0];
      $temp_beds=$temp[1];    
     //uprava informacii o progrese. 
      $bufp=explode('byte',$bufp);
      $bufpp=explode('/',$bufp[1]);
      $hotovo=$bufpp[0];
      $layer=explode('Layer:',$bufp[1]);
      $layer=explode('ok',$layer[1]);
      $layer=$layer[0];
    //uprava informacii o subore
      $file=explode('CurrentFile:',$bufs);  
      $files=explode('ok',$file[1]);
      $file=$files[0];
    //Uprava informacii o stave
      $stav=explode('MoveMode:',$bufs);  
      $stavs=explode('Status: S:',$stav[1]);
      $stav=$stavs[0];
    }
  else
    $text="Unable to connect<pre>".socket_strerror(socket_last_error())."</pre>";
    
echo "<table border=1 style='width:100%'>";
echo "<tr><td colspan=3 style='width:33%' align=center>Temperature </td> <td colspan=2 style='width:33%' align=center>Progres</td><td style='width:33%' align=center>Control</td> </tr>";
echo "<tr><td>        </td><td> SET           </td><td> NOW          </td><td> File: </td><td>  $file    </td><td>State:  $stav        </td></tr>";    
echo "<tr><td>HOTEND  </td><td> $temp_hes °C  </td><td> $temp_he °C  </td><td> Done:  </td><td> $hotovo % </td><td>          </td></tr>";
echo "<tr><td>BED     </td><td> $temp_beds °C </td><td> $temp_bed °C </td><td> Layer: </td><td>  $layer   </td><td><form action='ff.php?ip=$address' method='post'>
    <button type='submit' name='LED' value='SWITCH' >LED</button><button type='submit' name='PAUSE' value='ON' >PAUSE</button><button type='submit' name='RESUME' value='ON' >RESUME</button><button type='submit' name='STOP' value='ON' >CANCEL</button><button type='submit' name='HOME' value='ON' >HOME</button>
</form></td></tr>";    
    

echo "</table>";    
echo "<br>";

//echo $text;

?>

Here is my ajax code (don’t work) :

function loadStatus() {
    const address = new URLSearchParams(window.location.search).get('ip');
    if (address) {
        $.ajax({
            url: `http://${address}:8080`,
            method: 'POST',
            data: {
                command: 'status'
            },
            success: function(data) {
                updateStatus(data);
            },
            error: function() {
                alert('Stream not available');
            }
        });
    }
}

function sendCommand(command) {
    const address = new URLSearchParams(window.location.search).get('ip');
    if (address) {
        $.ajax({
            url: `http://${address}:8080`,
            method: 'POST',
            data: {
                command: command
            },
            success: function(data) {
                updateStatus(data);
            },
            error: function() {
                alert('Unable to connect');
            }
        });
    }
}

function updateStatus(data) {
    // Assuming data is JSON and parsing it
    const status = JSON.parse(data);
    const temp_he = status.temp_he;
    const temp_hes = status.temp_hes;
    const temp_bed = status.temp_bed;
    const temp_beds = status.temp_beds;
    const hotovo = status.hotovo;
    const layer = status.layer;
    const file = status.file;
    const stav = status.stav;

    $('#temp_he').text(temp_he);
    $('#temp_hes').text(temp_hes);
    $('#temp_bed').text(temp_bed);
    $('#temp_beds').text(temp_beds);
    $('#hotovo').text(hotovo);
    $('#layer').text(layer);
    $('#file').text(file);
    $('#stav').text(stav);
}

$(document).ready(function() {
    loadStreams();
    setInterval(refreshFrames, 5000); // Refresh every 5 seconds

    $('#controlForm button').click(function(event) {
        event.preventDefault();
        const command = $(this).val();
        sendCommand(command);
    });
});

I would like to point out that this code will be made available as open source on Github once the project is completely finished.

Thanks to all the charitable souls who are willing to dedicate a few minutes of their time to help me and guide me in the right direction.

Have a good day.

How to load the image when generating PDF using Puppeteer in Node.js?

My Puppeteer version is v24.4.0.

const imgBase64 = readFileSync(imgPath).toString("base64");
const headerTemplate = `
<div style="width:100%; height: 50px;">
  <img src="data:image/png;base64,${imgBase64}" alt="logo">
</div>`;
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
await page.setContent(htmlContent, { waitUntil: "networkidle0" });
await page.pdf({
   path: outputPath,
   format: "A4",
   displayHeaderFooter: true,
   margin: { top: "390px", bottom: "150px", left: "20px", right: "20px" },
   headerTemplate: headerTemplate,
   footerTemplate: footerTemplate,
   printBackground: true,
});

await browser.close();

This is the Node.js code for generating PDF involving image in header.
But it occurs in error like this:

ProtocolError: Protocol error (Page.printToPDF): Printing failed

How to solve this issue?

External JS API when added via CustomHook to React JS its not working

Hi I am in learning phase of React JS and I am creating a Sample Web Application which is using a External JS API for my Newsletter SignUp.
I added the External JS API through CustomHook, while executing the External JS Code is not Working.
When I went through the External JS code I found few click functions are written under DOMContentLoaded and Window Load event listeners. Those Click functions are not working.
I can’t paste the entire external.js Code here but I will paste section of it.

My React JS Code

import React, { useEffect } from 'react'
import styles from './MailingList.module.css';
import UseExternalScript from '../../customHook/UseExternalScript/UseExternalScript';

const MailingList = ({ mlistValues }) => {
    UseExternalScript(['https://ww.example.com/external.js', 'https://www.example.com/external2.js'])
    return (
        <>
            <div className="ml-wrapper firstMlistForm">
                <div className="mlform">
                    <form className="mlistFormOne twostep">
                        <div className="email fieldWrap">
                            <input data-type="email" data-error-text="Please enter a valid email address" required="" className="email" placeholder="Email" name="email" />
                        </div>
                        <div className="list-values">
                        </div>
                        <div className="submit">
                            <input type="submit" className="submit mlistSubmit" value="Submit" />
                        </div>
                    </form>
                    <div className="terms">
                        <a href="#" className="terms">terms</a>
                        <p className={`terms-message fadeOut`}>T&C</p>
                    </div>
                </div>
            </div>
        </>
    )
}

export default MailingList

MyCustomHook Script
UseExternalScript.js:

import { useEffect } from 'react'

const UseExternalScript = (srcArray) => {

  useEffect(() => {
    const scritpTags = srcArray.map((src) => {
      const script = document.createElement('script');
      script.src = src;
      script.async = true;
      script.onload = () => {
        console.log(Script loaded: ${src});
      };
      document.body.appendChild(script);
      return script;
    });

    return () => {
      scritpTags.forEach((script) => {
        document.body.removeChild(script);
      });
    }

  }, [srcArray])
}

export default UseExternalScript

Some part of External JS
external.js

/****/

document.addEventListener('DOMContentLoaded', function() {
const countrySelectList = [...document.querySelectorAll(countrySelector)];
        countrySelectList.forEach(select => {
            /****/
        });

        [...document.querySelectorAll('label[for=country], label[for=Country]')].forEach((c) => {
            c.innerHTML = 'country/region';
        });
    /*****/

});
/*****/
window.addEventListener('load', function(event) {

        [...document.querySelectorAll('.ml-wrapper a.terms')].forEach((terms) => {
            terms.addEventListener('click', function(event) {
                /***/
            }, false);
        });

        [...document.querySelectorAll(formSubmitSelector)].forEach((submit_button) => {

            submit_button.addEventListener('click', function(event) {

                event.preventDefault();
    /***/

            }, false);
        });

    });

Help me in figuring out the solution.
Please note that I can’t edit the external.js Code

Disable console.log and all other console entries via Webpack?

Is it possible to prevent console.log and the like from being used at runtime by patching them using Webpack?

I know this could be done at runtime, and some obfuscators also seem to manage to do it via AST at compile time, but is there a standalone approach I could use in Webpack?

I’ve tried an obfuscator for this, but unfortunately it increases the size of our code by 20% just to disable console, which is more than all the obfuscation methods it uses for the rest of the code add. I don’t know what’s going on there, but so I’m wondering about a standalone approach.

Cannot maintain div elements with id and data-unique attributes in CKEditor5

Problem

I’m trying to add id and data-unique attributes to div elements in CKEditor5, but these attributes keep disappearing after saving or processing the content.

Configuration

I’ve configured the GeneralHtmlSupport plugin as follows:

        htmlSupport: {
          allow: [
            {
              name: /.*/,
              attributes: {
                id: true,
                'data-unique': true,
              },
              styles: true,
              classes: true
            }
          ],
          disallow: []
        },

but it failed.
Definitely given an id, but it disappears after an event like a click.

Invalid input pattern when hypen(-) is used [duplicate]

I have a valid rexp /^[a-zA-Z0-9а-яА-ЯёЁ]+([ -][a-zA-Z0-9а-яА-ЯёЁ]+)*$/ which for some reason is not accepted by html input pattern until [ ] hypen is not removed, escaping it also doesn’t seems to work.

  1. How to fix it?
  2. How to make sure that my valid shared js regexp regexp.source doesn’t fail in pattern?

Example (type and see console logs)

error: <input pattern="[a-zA-Z0-9а-яА-ЯёЁ]+([ -][a-zA-Z0-9а-яА-ЯёЁ]+)*" />

valid: <input pattern="[a-zA-Z0-9а-яА-ЯёЁ]+([ ][a-zA-Z0-9а-яА-ЯёЁ]+)*" />