admin_enqueue_scripts not load script

I’m creating a plugin to load my JS code on admin pages. In __construct in my class I use:

add_action('admin_enqueue_scripts', array($this, 'zhngroup_enqueue_scripts'));

And this is my zhngrupa_enqueue_scripts method:

     public function zhngrupa_enqueue_scripts() {
         // Get order iD
         $order_id = $this->order_id;

         // If the order ID is still 0, please complete the process
         if ($order_id === 0) {
             return;
         }

         wp_register_script( 'zhngrupa-script', 'https://smiel.pl/wp-content/uploads/2023/06/zhngrupa_send_message_button_script.js', array('jquery'), true, true );
         // Add JavaScript directly in your PHP code
         wp_enqueue_script( 'zhngroup-script' );

         // Pass data to JavaScript
         wp_localize_script('zhngroup-script', 'zhngroupScriptParams', array(
             'nonce' => wp_create_nonce('zhngrupa_expired_service_nonce'),
             'order_id' => $order_id,
         ));

     }

Unfortunately in my code my JS file is not loaded. Strangely enough, on the test version of WordPress, not the production version, my entire project works without any problems. Please help.

I checked through an external plugin and my method is actually connected to the admin_enqueue_scripts hook

I tried to debug the code, tested it on a local WordPress instance with the same version as in production. On the trial version, everything works without any problems.

Unfortunately, no results. My JS code is not loading into the page at all. I checked it in the page code preview.

How can I supercede the heirarchies of JS and CSS for an HTML component to display correctly?

I’m attempting to reformat a JS file (called “Loader.JS”) and reversion it. This JS file creates a menu populated with clickable items. Upon clicking an item, an overlay appears with a more detailed version of the item, and a button that links to an external page. In the previous version, the JS file declared all HTML elements inside the document and using the “appendChild()” to add the elements to the screen. These elements were then styled inside the CSS portion of a WordPress extension called Avada. In this new version of the file, I am wanting the document to reference a CSS document in my files and have Loader.JS reference the CSS file at the bottom.

My problem lies in the overlay of Loader.JS. In the first version (for sake of ease, I’ll refer to it as V1), the entirety of the overlay was declared in an “.innerHTML” statement which defined the hierarchy of the overlay, including an image, a name, description, cost, and the button to the external link. When transitioning to my new version (V2), the same concept was kept, except the .innerHTML statement was defined using literals. In V2, the overlay is super ceding everything, and clicking on the button does not trigger the external link, rather it closes the overlay, which is set for anything outside the button.

Upon clicking an item, which triggers an overlay, a call is made to a function which passes the item’s properties (GroupingID, ItemID, cost, ItemLocation). This function sets the properties of the items this way:

  document.getElementById('overlay-menuitem-name').innerHTML = MenuItem.vcMenuItemName;
    document.getElementById('overlay-menuitem-description').innerHTML = MenuItem.vcMenuItemDescription;
    menuSettings[r].bMenuItemCostPopup && (document.getElementById('overlay-menuitem-cost').innerHTML = '$' + i);
    document.getElementById('orderButton').setAttribute('onclick', 'addToOrder(' + ItemID + ',' + ItemLocation);

However, the function “addToOrder()” is never being reached, because the item overlay is super ceding any input, and a click closes the overlay.

Here is how the overlay HTML structure is declared in v1:

<div class="myNav">
   <div class="overlay-content">
    <div class="overlay-menuitem" style="background:#FFF;">
        <a href="javascript:void(0)" class="overlay-close" onclick="closeNav()">&times;</a>
        <div id="overlay-img"></div>
                <div id="overlay-menuitem-name"></div>
        <div id="overlay-menuitem-description"></div>
        <div id="overlay-menuitem-cost"></div>
        <button id="overlay-menuitem-order" class="overlay-order-button"></button>
    </div>
   </div>
</div>

Here is how the overlay HTML structure is declared in v2:

<div class="myNav">
  <div onclick="closeNav();" class="overlay-content">
        <div class="overlay-menuitem">
                    <div class="img-box">
                        <div id="overlay-img" style="width: 100%; border-top-right-radius: 18px !important; border-top-left-radius: 18px !important;"</div>
                    <a href="javascript:void(0)" class="overlay-close" onclick="closeNav()">&times;</a>
                    </div>
                    <div id="overlay-menuitem-name"></div>
                    <div id="overlay-menuitem-description"></div>
                    <div id="overlay-menuitem-cost"></div>
                    <div id="orderButton" class="orderButton" style="display: inline-flex;">
                            <button id="overlay-menuitem-order" class="overlay-order-button">
                                ORDER ONLINE
                            </button>
                    </div>
            </div>
      </div>
</div>

All of the v1 CSS code was transferred just as it was to the v2 CSS sheet. No change was made. All other CSS code works, except the areas I have detailed.

Here is the CSS code for the overlay-content, which is triggering the closing:

.overlay-content {
    position: absolute; 
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); 
    text-align: center;
    z-index: -1 !important;
}

Here is the CSS code for the orderButton:

.orderButton {
    font-family: "Open Sans", sans-serif;
     font-size:16px;
     Background: #212326;
     background-size:contain;
     width:200px;
     height:45px;
     border:none;
     cursor:pointer; 
     cursor:hand;
     margin-top:12px;
     margin-bottom: 30px;
     color: #FFF;
     font-weight: 500;
     letter-spacing:.5px;
     border-radius: 4px;
 }

I’ve tried z-Index, I’ve tried reformatting the entire HTML heirarchy, and I have no clue what is happening. Any solutions would be welcomed and appreciated!

Why is my event listener clearing right after it gets added? [closed]

when I watch my inspector (safari) it adds the event icon/text by the element then disappears.

Here is the code I’m using:

const userElements = document.querySelectorAll(".user");
userElements.forEach((element) => {
  const username = element.getAttribute("data-username");
  element.addEventListener("click", function () {
    changeUser(username);
  });
});

const removeUserElements = document.querySelectorAll(".remove-icon");
removeUserElements.forEach((element) => {
  const username = element.getAttribute("data-username");
  element.addEventListener("click", function (event) {
    removeUser(username, event);
  });
});

GLSL Shader Gaussian blur looking rough #2

I have written my own shader that implements Gaussian blur on the frame. and everything works well, including the edge treatment. But for some reason, the blur looks rough and as if streaks/artifacts are visible. I’ll give you a screenshot of how it looks and how it should look. Just in case, I will give you additional information that the rendering is on canvas 530×70. the blur in u_radius is 40. the blur I’m trying to achieve is 40.

That’s what I got

render

What am I trying to achieve

filter

here is my GLSL vertex and fragment shader code

<canvas id="control1" width="530" height="70" style="transform: rotateX(180deg); filter: saturate(1);" class="control"></canvas>
 var canvas = document.getElementById('control1');
    var canvas1 = document.createElement('canvas')
    canvas1.width = 530
    canvas1.height = 70
    var ctx = canvas1.getContext('2d', { willReadFrequently: true });
    var gl = canvas.getContext('webgl');

       const vertexShader = gl.createShader(gl.VERTEX_SHADER);
       gl.shaderSource(vertexShader, `
           attribute vec2 position;
           void main() {
               gl_Position = vec4(position, 0.0, 1.0);
           }
       `);
       gl.compileShader(vertexShader);
   
       const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
       gl.shaderSource(fragmentShader, `
       precision mediump float;
       uniform sampler2D u_image;
       uniform vec2 u_resolution;
       uniform float u_radius;
       
       float gaussian(float x, float sigma) {
           return exp(-0.5 * x * x / (2.0 * sigma * sigma)) / (sqrt(2.0 * 3.14159) * sigma);
       }
       
       vec2 mirror(vec2 st) {
           vec2 mirrored = mod(st, 2.0);
           return mix(mirrored, 2.0 - mirrored, step(1.0, mirrored));
       }
       
       void main() {
           vec2 st = gl_FragCoord.xy / u_resolution;
           vec4 color = vec4(0.0);
           float totalWeight = 0.0;
       
           for (int i = -9; i <= 9; i++) {
               for (int j = -9; j <= 9; j++) {
                   vec2 offset = vec2(float(i), float(j)) / u_resolution;
                   float distance = length(offset);
                   float weight = gaussian(distance, u_radius);
                   color += texture2D(u_image, mirror(st + offset)) * weight;
                   totalWeight += weight;
               }
           }
       
           gl_FragColor = color / totalWeight;
       }   
       `);
       gl.compileShader(fragmentShader);
      if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {
        console.log('Error: ' + gl.getShaderInfoLog(fragmentShader));
    }
 
       const program = gl.createProgram();
       gl.attachShader(program, vertexShader);
       gl.attachShader(program, fragmentShader);
       gl.linkProgram(program);
   
       gl.useProgram(program);
   
       const positionLocation = gl.getAttribLocation(program, 'position');
       const positionBuffer = gl.createBuffer();
       gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
       gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
           -1.0, -1.0,
           1.0, -1.0,
           -1.0, 1.0,
           -1.0, 1.0,
           1.0, -1.0,
           1.0, 1.0
       ]), gl.STATIC_DRAW);
       gl.enableVertexAttribArray(positionLocation);
       gl.vertexAttribPointer(positionLocation, 2, gl.FLOAT, false, 0, 0);

       const resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
       const radiusLocation = gl.getUniformLocation(program, 'u_radius');
       gl.uniform2f(resolutionLocation, canvas.width, canvas.height);
       gl.uniform1f(radiusLocation, 40);
   
       gl.drawArrays(gl.TRIANGLES, 0, 6);

video.onplaying = function() {
    var $this = this;
    (function loop() { 
        if (!video.paused && !video.ended) { 

        ctx.clearRect(0, 0, canvas.width, canvas.height);

        ctx.fillRect(0, 0, canvas.width, canvas.height);
         
                var intersection = getIntersection($this, canvas);
                var ratio = calculateAspectRatioFit($this.videoWidth, $this.videoHeight, $this.getBoundingClientRect().width, $this.getBoundingClientRect().height)
                ctx.save();
                ctx.rect(intersection.x, intersection.y, ratio.width, ratio.height); 
                ctx.clip(); 
                
                ctx.globalAlpha = 1;
                ctx.drawImage($this, intersection.x, intersection.y, ratio.width, ratio.height);
                
                ctx.restore(); 
                ctx.globalAlpha = 1.0;
   
                var dataTexture = gl.createTexture();
                var imageData = ctx.getImageData(0, 0, canvas1.width, canvas1.height);
                const imageLocation = gl.getUniformLocation(program, 'u_image');
                gl.activeTexture(gl.TEXTURE0);
                gl.bindTexture(gl.TEXTURE_2D, dataTexture);
                gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, imageData);
                gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
                gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
                gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
                gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
                gl.uniform1i(imageLocation, 0);

                gl.drawArrays(gl.TRIANGLES, 0, 6);
                setTimeout(loop, 1000 / 30);
        }
    })();

}

I tried to change the radius (u_radius) and samples, and it seems that increasing the samples to 100 and a radius of 0.1 I achieved an approximate effect. but it’s still not what I need and it looks bad. It’s as if the blur is applied only on the x-axis.

How to update Javascript to support Limited availability functions

I have a JavaScript project where node -v is the latest version v21.6.2, however, when developing on my local pc, I am unable to do Set.prototype.difference() as described here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/difference

unable to function Set difference on local pc

My chrome browser currently supports this function as shown in this screenshot.

Chrome browser supports Set difference

How can I update my local javascript such that it supports these functions with “Limited availability”?

match all subitems in a string as different matches with regexp

I have a string and need to end up with an object that count all apples for every name, my struggle was to get separate match for each apple they took

In the part <@Viktor><@Kate>took:apple::apple: I wanna get two matches instead of 1, and more if there would be more apples like <@Viktor><@Kate>took:apple::apple::apple::apple:

const message = 'I had :apple::apple::apple::apple: :apple:<@Viktor><@Kate>took:apple::apple: and later <@viktor> took again:apple:but not <@kate>';

const result {
     viktor: 3,
     kate: 2
}

used this to handle the problem, but it wasn`t accepted by the interviewer coz I used join&split later. The task was to solve this problem only with regexp.

function countGifts(text) {
    let result = {}
    let names = ['viktor', 'kate']
    names.forEach(name=>{
        let regex =  new RegExp(`(${name}).*?(:apple:)+`, "gi")
        result[name] = text.match(regex).join('').split(':apple:').length-1
    })
    return result
}
console.log(
    countGifts(message)
);

I`m new to regexp, and would appreciate alternative solutions and hints for articles with complex examples, coz all I found was pretty easy

is it puppeteeer bug?

 const puppeteer = require('puppeteer');

 let browser;
  browser = await puppeteer.launch({
    headless:false,
  //executablePath: chromium.path
  args: [
    //'--start-maximized'
  ]
  /*,
  args: [
    '--no-sandbox',
    '--disable-setuid-sandbox',
    '--disable-dev-shm-usage',
    '--disable-accelerated-2d-canvas',
    '--no-first-run',
    '--no-zygote',
    '--single-process',
    '--disable-gpu'
  ]*/

  const pageINIT = await browser.newPage();
  await pageINIT.setDefaultNavigationTimeout(0);
  await pageINIT.goto("https://www.youtube.com", {timeout: 0, waitUntil: 'domcontentloaded'});

I use the above code to load puppeteer yet I get a look like this

enter image description here

is this a bug, i’ve been trying but it doesn’t go away. Also I am using it in headless mode for tests, I realized there was something wrong and this happens.

How does Google groups conversations in Google chat spaces by topics?

I am aware that Google is currently upgrading all their chat spaces to inline threads but am curious about the data/chat model Google uses to group conversations by topics. I like to replicate the same feature for learning purposes.

I have browsed through the Google chat api’s Message data model but couldn’t find anything that gives me clue how messages a grouped by topics.

The first screenshot on this page shows how Google’s “group conversation by topic” interface looks like.

Users can start a new message and every reply to that message will be grouped together.

Lets assume that the chat message data model looks like this:

id, sender, space, text, createdBy, updatedBy, emoji, etc...

and lets assume that a user sends a new message (i mean not replying to an existing message). Does Google behind the scene create somthing like a topic entity and assign the new message to the topic? My guess is that a new message is assigned to a new topic and all replies to the message will also be assigned the same topic as the first message. This will allow Google to group all messages with the same topic.

Any ideas or pointers to articles or tutorials will be appreciated

Problem in textfield and prenventing enter key making new line

the picture

Like you see here the text is insered in the middle of the text area.

the CSS code :

.form-control {
    height: 300px;
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    appearance: none;
    border-radius: 0.375rem;
    transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
    }

the JSX code : <input type="textfield" class="form-control" id="text" name="comment">

that’s my first problem the second one is that, i made a a function that prevent submitting when the user hit the enter button, but the problem is that he could not go to a new line :
the function is :

 const handleKeyPress = (event)=>{
    if (event.key === 'Enter') {
      event.preventDefault();
      
      return false;
    }
  } 

Javascript days between days of an array

I’m setting up a basic booking service for a customer and I’m using js/php and sql to populate a jquery datepicker/calendar to show which days are already booked. The way its setup is I’ve got a table with booked dates(yy/mm/dd) and what I do is a pull all the booked date data from the table column of the selected product into an array and then throw that at my javascript to disable those days in the calendar. The issue I’ve come up with is that the minimum booking time for a customer is 1week/7days. So if a customer books for 7 days and then another one books 2 days after that booking is done, I get left with 2 free days in my calendar that can’t really be used since minimum booking is 7 days.

What I’m trying to do now is find a way to compare all these dates and see if anyway in between there’s a short time span than 7 days. After I can find where these short time span are I can just add the dates into the “not available dates” array.

I did look at the jquery datepicker documentation but came up short with any answers

this is what I’m currently using to disable the dates. var dates contains an array of dates (yy/mm/dd) so that the datepicker can disable them.

            var dates = disabledDates;
            $( "#datePicker" ).datepicker('destroy').datepicker({ // initializing datepicker
                minDate: 0,
                dateFormat: "yy-mm-dd",
                beforeShowDay: function(date)
                {
                    var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
                    return [dates.indexOf(string) == -1];
                }
             });

next.js fetch cause infants api request

this code is from next js documentation which you can also find in the below link:
https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating
when i fetched an api using this method it causes infinite api request.

async function getData() {
  const res = await fetch('https://api.example.com/...')
  // The return value is *not* serialized
  // You can return Date, Map, Set, etc.
 
  if (!res.ok) {
    // This will activate the closest `error.js` Error Boundary
    throw new Error('Failed to fetch data')
  }
 
  return res.json()
}
 
export default async function Page() {
  const data = await getData()
 
  return <main></main>
}

we cannot use the useeffect because it is server component.

Why isn’t the theme changing

Description:

I’ve implemented a theme switching button in my React application to toggle between light and dark themes. However, I’m encountering an issue where clicking the button doesn’t result in the theme changing as expected.

Here’s the relevant code snippet from my application:

import React, { useState } from 'react';
import RecruitmentList from './components/RecruitmentList';
import './App.css';

function App() {
  const [darkMode, setDarkMode] = useState(false);

  const toggleDarkMode = () => {
    setDarkMode(!darkMode);
  };

  return (
    <div className={`App ${darkMode ? 'dark-mode' : 'light-mode'}`}>
      <header className="App-header">
        <div className="mode-switcher" onClick={toggleDarkMode}>
          <div className={`toggle ${darkMode ? 'toggle-dark' : 'toggle-light'}`} />
        </div>
        <RecruitmentList />
      </header>
    </div>
  );
}

export default App;
.App {
  text-align: center;
}

.App-logo {
  height: 40vmin;
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  .App-logo {
    animation: App-logo-spin infinite 20s linear;
  }
}

.App-header {
  background-color: #282c34;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: calc(10px + 2vmin);
  color: white;
}

.App-link {
  color: #61dafb;
}

@keyframes App-logo-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.mode-switcher {
  position: absolute;
  top: 20px;
  right: 20px;
  cursor: pointer;
}

.toggle {
  width: 60px;
  height: 30px;
  background-color: #ccc;
  border-radius: 15px;
  transition: all 0.3s ease;
}

.toggle-light {
  background-color: #ddd;
}

.toggle-dark {
  background-color: #333;
}

.toggle::after {
  content: '';
  position: absolute;
  width: 26px;
  height: 26px;
  background-color: #fff;
  border-radius: 50%;
  top: 50%;
  transform: translateY(-50%);
  transition: all 0.3s ease;
}

.toggle-light::after {
  left: 4px;
}

.toggle-dark::after {
  left: calc(100% - 30px);
}

Despite clicking the “Toggle Theme” button, the theme remains unchanged. I’ve checked the event handling and state updating logic, but I can’t seem to identify the issue.

Could someone please help me understand why the theme isn’t changing when the button is clicked? Any insights or suggestions would be greatly appreciated. Thank you!

light
dark

How to update a collection item without removing non existing values send on the query?

Given this simple example, an item saved as:

{
  "test": {
    "a1": "a1"
  }
}

When i call collection.updateOne with $set and the following object:
await collection.updateOne(doc, {$set: {"test": {"a2": "a2"}}}, {upsert: true});
it replaces the saved test object to:

{
  "test": {
    "a2": "a2"
  }
}

The a1 key will no longer exist as it also does not exist in the object sent.

I’m trying to update saved items with the values passed in the object **without ** removing non-existing values, I mean:
{"test": {"a2": "a2"}} would make the item be updated to:

{
  "test": {
    "a1": "a1",
    "a2": "a2"
  }
}

I have written a function to recursively parse objects/arrays and build a query for this use case.

In my mind it looks like a mess and I’m not sure if it’s correct:

// The function attempts to parse arrays and objects recursively and recreate the query
function buildUpdateQuery(object, prefix = '') 
{
    let updateQuery = {};

    for (let [key, value] of Object.entries(object))
    {
        let newPrefix = prefix ? `${ prefix }.${ key }` : key;

        if (Array.isArray(value)) 
        {
            for (let i = 0; i < value.length; i++) 
            {
                let arrayPrefix = `${newPrefix}.${i}`;
                if (typeof value[i] === 'object' && value[i] !== null)
                    updateQuery = {...updateQuery, ...buildUpdateQuery(value[i], arrayPrefix)};
                else
                    updateQuery[arrayPrefix] = value[i];
            }
        }
        else if (typeof value === 'object' && value !== null)
            updateQuery = {...updateQuery, ...buildUpdateQuery(value, newPrefix)};
        else
            updateQuery[newPrefix] = value;
    }

    return updateQuery;
}

export const set = async (req, res /*key, object*/) =>   // Using mongodb and express
{
    try
    {
        const [collection, key] = req.body.key.split("|");
        if (collection === undefined || key === undefined)
            return res ? res.send('fail') : 'fail'

        const doc = buildUpdateQuery(req.body.object);
        let r = await db.collection(collection).updateOne({ [key]: { $exists: true } }, { $set: doc }, { upsert: true });

        r = r.modifiedCount ? 'ok' : 'fail';
        return res ? res.send(r) : r
    }
    catch (error)
    {
        console.log(`n[set]n${ JSON.stringify(req.body, null, 2) }nn`, error);
        return res ? res.send('fail') : 'fail'
    }
}

Calling the set function with:

{"key": "vars|test", "object": {"test": {"a2": "a2"}}}

at const doc = buildUpdateQuery(req.body.object);

doc is {test.a2: 'a2'} and it indeed updates

{"test": {"a1": "a1"}} to {"test": {"a1": "a1"},{"a2":"a2"}}

I’m afraid it could mess up a collection at some time, maybe parsing something wrong.

I’m aware that i could first get the existing object with:

const document = await db.collection(collection).findOne({ [key]: { $exists: true } });

and then modify it with the new values, but that’s not what I’m looking for.

Is there any built-in method in MongoDB for such a thing?

If not, is the buildUpdateQuery correct or there’s any other better approach for this use case?

Buttons keep moving down the page every time the content inside them changes CSS

I was trying to make a game of Noughts and Crosses in HTML, Javascript and CSS but every time I pressed on a button to change it’s content, the button jumped down the page. Buttons keep moving down the page every time the content inside them changes CSS. Here is the code:

let grid = ["-", "-", "-", "-", "-", "-", "-", "-", "-"];
let clicked = [true, true, true, true, true, true, true, true, true];
let turn = 'X';
function win(player) {
  document.getElementById('ptu').innerHTML = "Player " + turn + " wins";
  for (var i = 0; i < 9; i++) {
      clicked[i] = false;
  }
}
document.getElementById('ptu').innerHTML = "Turn: X";
    
function change(button, id) {
    if (clicked[id]) {
        document.getElementById(button).innerHTML = turn;
        grid[id] = turn;

        clicked[id] = !clicked[id];
        if (turn == 'X') {
            document.getElementById('ptu').innerHTML = "Turn: O";
        } else {
            document.getElementById('ptu').innerHTML = "Turn: X"
        }

        if (grid[0] == turn && grid[1] == turn && grid[2] == turn) {
            win(turn);
        } else if (grid[0] == turn && grid[3] == turn && grid[6] == turn) {
            win(turn);
        } else if (grid[6] == turn && grid[7] == turn && grid[8] == turn) {
            win(turn);
        } else if (grid[8] == turn && grid[5] == turn && grid[2] == turn) {
            win(turn);
        } else if (grid[0] == turn && grid[4] == turn && grid[8] == turn) {
            win(turn);
        } else if (grid[2] == turn && grid[4] == turn && grid[6] == turn) {
            win(turn);
        } else if (grid[1] == turn && grid[4] == turn && grid[7] == turn) {
            win(turn);
        } else if (grid[3] == turn && grid[4] == turn && grid[5] == turn) {
            win(turn);
        }
        if (turn == 'X') {
            turn = 'O';
        } else {
            turn = 'X';
        }
    }
}
button {
                display: inline-block;
                padding: 10px 20px;
                background-color: #007bff;
                color: #fff;
                border: none;
                cursor: pointer;
                transition: background-color 0.3s;
                min-width: 50px;
                min-height: 50px;
                max-width: 50px;
                max-height: 50px;
                border-color: #000;
            }
            button:hover {
                background-color: #0056b3;
            }
            .restart {
                display: inline-block;
                padding: 10px 20px;
                background-color: #007bff;
                color: #fff;
                border: none;
                cursor: pointer;
                transition: background-color 0.3s;
                min-height: 0px;
                max-width: 100px;
                border-color: #000;
                border-radius: 12px;
            }
            html {
                font-family: sans-serif;
            }
<html>
    <head>
    </head>
    <body>   
        <button onclick="change('1', '0')" id="1"></button><button onclick="change('2', '1')" id="2"></button><button onclick="change('3', '2')" id="3"></button><br>
        <button onclick="change('4', '3')" id="4"></button><button onclick="change('5', '4')" id="5"></button><button onclick="change('6', '5')" id="6"></button><br>
        <button onclick="change('7', '6')" id="7"></button><button onclick="change('8', '7')" id="8"></button><button onclick="change('9', '8')" id="9"></button><br>
        <p id="ptu"></p>
        <p id="pwi"></p>
        <button class="restart" onclick="clicked = [true, true, true, true, true, true, true, true, true]; grid = ['-', '-', '-', '-', '-', '-', '-', '-', '-']; turn = 'X'; document.getElementById('1').innerHTML = ''; document.getElementById('2').innerHTML = ''; document.getElementById('3').innerHTML = ''; document.getElementById('4').innerHTML = ''; document.getElementById('5').innerHTML = ''; document.getElementById('6').innerHTML = ''; document.getElementById('7').innerHTML = ''; document.getElementById('8').innerHTML = ''; document.getElementById('9').innerHTML = ''; document.getElementById('ptu').innerHTML = 'Turn: X'; ">Restart</button>
    </body>
</html>

The code is meant to make the buttons just change to either ‘X’ or ‘O’.

why adding a link remove my div css style

Hi here is a code(used in elementor):

<div id="work1acc" class="jet-toggle__control elementor-menu-anchor" data-toggle="1" role="button" tabindex="0" aria-controls="jet-toggle-content-2101" aria-expanded="false" data-template-id="false">
                                <div class="jet-toggle__label-icon jet-toggle-icon-position-right"><span class="jet-toggle__icon icon-normal jet-tabs-icon"><svg xmlns="http://www.w3.org/2000/svg" width="88" height="88" viewBox="0 0 88 88" fill="none"><circle cx="44" cy="44" r="44" fill="#F16204"></circle><path d="M59.5 44C59.5 44.828 58.828 45.5 58 45.5H45.5V58C45.5 58.828 44.828 59.5 44 59.5C43.172 59.5 42.5 58.828 42.5 58V45.5H30C29.172 45.5 28.5 44.828 28.5 44C28.5 43.172 29.172 42.5 30 42.5H42.5V30C42.5 29.172 43.172 28.5 44 28.5C44.828 28.5 45.5 29.172 45.5 30V42.5H58C58.828 42.5 59.5 43.172 59.5 44Z" fill="#FCCCAC"></path></svg></span><span class="jet-toggle__icon icon-active jet-tabs-icon"><svg xmlns="http://www.w3.org/2000/svg" width="88" height="88" viewBox="0 0 88 88" fill="none"><circle cx="44" cy="44" r="44" fill="#FCCCAC"></circle><path d="M58 45.5H30C29.172 45.5 28.5 44.828 28.5 44C28.5 43.172 29.172 42.5 30 42.5H58C58.828 42.5 59.5 43.172 59.5 44C59.5 44.828 58.828 45.5 58 45.5Z" fill="#F16204"></path></svg></span></div><div class="jet-toggle__label-text">Graphic designer<br><span class="shortexplain">more than 100 project,2 years experience</span></div>                         </div>
                            <div id="jet-toggle-content-2101" class="jet-toggle__content" data-toggle="1" role="region" data-template-id="false">
                                <div class="jet-toggle__content-inner"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et sed do eiusmod temp</p></div>
                            </div>

now when i add and before and after this code to make this whole code clickable it remove all styles!

i cant figure it out