Trouble Creating Dynamic Polygons with JavaScript and CSS

I’m trying to create a polygon shape dynamically using JavaScript and CSS. I have a function that takes coordinates (x, y), radius, number of sides, and color. The function calculates the coordinates of each vertex based on these parameters and then creates a polygon using CSS `clip-path`. However, when I call this function with the desired parameters, the shape is not displaying correctly on the webpage.

Here’s the function I’m using:

const container = document.querySelector("#container");

document.querySelector("#polygon-tool").addEventListener("click", ()=>{
    drawPolygon(100, 100, 40, 3, 'blue');
})

function drawPolygon (x, y, radius, sides, color) {
    const shape = document.createElement("div");
    shape.classList.add("resizable-shape");

    // Calculate the angle between each vertex
    const angleIncrement = (2 * Math.PI) / sides;

    // Calculate the coordinates of each vertex
    const vertices = [];
    for (let i = 0; i < sides; i++) {
        const xPos = x + radius * Math.cos(angleIncrement * i);
        const yPos = y + radius * Math.sin(angleIncrement * i);
        vertices.push(`${xPos}px ${yPos}px`);
    }

    // Create the polygon path
    const polygonPath = `polygon(${vertices.join(", ")})`;

    // Apply styles
    shape.style.clipPath = polygonPath;
    shape.style.backgroundColor = color;
    shape.style.position = "absolute";
    shape.style.left = x + "px";
    shape.style.top = y + "px";

    // Add shape to container
    container.appendChild(shape);
}

Expectation: The function drawPolygon should correctly display a polygon shape on the webpage with the specified number of sides and color parameters.

Chrom DevTools does not display the id attribute of element

as shown in the below posted html, i have a label element with id idSentinelHubEndPointsLocationsLabel.
when i investigate the latter element via Chrom DevTools, it happens that that html element is not assigned to any id as shown in the attached screen-shot below, hence i cant not detect and apply any styling on that element

please let me know why the DevTools does not show the id of that label element? and how to fix this issue please

html

<template>
    <div>   
        <cds-radio-group id="idSentinelHubEndPointsLocationsContainer" name="sentinelHubEndPointsLocationsContainer" layout="" cds-layout="p-y:lg" v-show="showSentinelHubEndPointsLocationsContainer">
            <label id="idSentinelHubEndPointsLocationsLabel"> {{ tempTextSentinelHubEndPointsLocationsContainerLabel }} </label>
            <SentinelHubEndPointIsServices
                v-bind:isShowRadioBtnsSentHubEndPointIsServices="showEndPointIsServices"
                v-bind:isCheckedRadioButtonSentHubEndPointIsService="isCheckedEndPointIsServices"
                v-bind:isRadioButtonSentHubEndPointIsServicesDisabled="isDisabledEndPointIsServices">
            </SentinelHubEndPointIsServices>

            <SentinelHubEndPointIsCreodias
                v-bind:isShowRadioBtnsSentHubEndPointIsCreodias="showEndPointIsCreodias"
                v-bind:isCheckedRadioButtonSentHubEndPointIsCreodias="isCheckedEndPointIsCreodias"
                v-bind:isRadioButtonSentHubEndPointIsCreodiasDisabled="isDisabledEndPointIsCreodias">
            </SentinelHubEndPointIsCreodias>

            <SentinelHubEndPointIsCodeDE
                v-bind:isShowRadioBtnsSentHubEndPointIsCodeDE="showEndPointIsCodeDE"
                v-bind:isCheckedRadioButtonSentHubEndPointIsCodeDE="isCheckedEndPointIsCodeDE"
                v-bind:isRadioButtonSentHubEndPointIsCodeDEDisabled="isDisabledEndPointIsCodeDE">
            </SentinelHubEndPointIsCodeDE>
        </cds-radio-group>
    </div>
</template>

css:

 #idSentinelHubEndPointsLocationsContainer {
    position: absolute;
    height: 71px;
    background-color: red;
}
#idSentinelHubEndPointsLocationsLabel {
    position: absolute;
    top:1px;
    left: 0px;
    z-index: 1;
    font-size: initial;
}

screen-shot

enter image description here

Chrom DevTools does not display the id attribute of element

i am using vue3 with options api

as shown in the below posted html, i have a label element with id idSentinelHubEndPointsLocationsLabel.
when i investigate the latter element via Chrom DevTools, it happens that that html element is not assigned to any id as shown in the attached screen-shot below, hence i cant not detect and apply any styling on that element

please let me know why the DevTools does not show the id of that label element? and how to fix this issue please

html

<template>
    <div>   
        <cds-radio-group id="idSentinelHubEndPointsLocationsContainer" name="sentinelHubEndPointsLocationsContainer" layout="" cds-layout="p-y:lg" v-show="showSentinelHubEndPointsLocationsContainer">
            <label id="idSentinelHubEndPointsLocationsLabel"> {{ tempTextSentinelHubEndPointsLocationsContainerLabel }} </label>
            <SentinelHubEndPointIsServices
                v-bind:isShowRadioBtnsSentHubEndPointIsServices="showEndPointIsServices"
                v-bind:isCheckedRadioButtonSentHubEndPointIsService="isCheckedEndPointIsServices"
                v-bind:isRadioButtonSentHubEndPointIsServicesDisabled="isDisabledEndPointIsServices">
            </SentinelHubEndPointIsServices>

            <SentinelHubEndPointIsCreodias
                v-bind:isShowRadioBtnsSentHubEndPointIsCreodias="showEndPointIsCreodias"
                v-bind:isCheckedRadioButtonSentHubEndPointIsCreodias="isCheckedEndPointIsCreodias"
                v-bind:isRadioButtonSentHubEndPointIsCreodiasDisabled="isDisabledEndPointIsCreodias">
            </SentinelHubEndPointIsCreodias>

            <SentinelHubEndPointIsCodeDE
                v-bind:isShowRadioBtnsSentHubEndPointIsCodeDE="showEndPointIsCodeDE"
                v-bind:isCheckedRadioButtonSentHubEndPointIsCodeDE="isCheckedEndPointIsCodeDE"
                v-bind:isRadioButtonSentHubEndPointIsCodeDEDisabled="isDisabledEndPointIsCodeDE">
            </SentinelHubEndPointIsCodeDE>
        </cds-radio-group>
    </div>
</template>

css:

 #idSentinelHubEndPointsLocationsContainer {
    position: absolute;
    height: 71px;
    background-color: red;
}
#idSentinelHubEndPointsLocationsLabel {
    position: absolute;
    top:1px;
    left: 0px;
    z-index: 1;
    font-size: initial;
}

screen-shot

enter image description here

webpage rendering problems in iframe

I have a website made in ASP.net MVC framework like below:

// _Layout.cshtml
....
<div class='react-root'></div>
@Script('/React') 

The @Script(‘/React’) will load bundle.js, which packing many react .js files using webpack. These files determine which content should render in ‘react-root’.

Below is some react files looks like:

// app.js
...
const onCallback(view) => {setChildPage(view)};
return (
  <div Home onParentCall=(onCallback)></div>
  <div Site1 onParentCall=(onCallback)></div>
  <div Site2 onParentCall=(onCallback)></div>
  <div>{childPage}</div>
)

// Site1.js
....
const onParentCall(f) => {f(// rendered something)}
return (...)

Everything works fine if we access the website in independent browser, however, my partner found something wrong when he tried to embed my website in his webpage via iframe, nothing rendered in iframe element (or specificly, nothing rendered in ‘react-root’) and we only found Object.defineProperty called on non project in console log.

I tried to trace the stack, but since the bundle.js packed everything, it’s hard to find if there is any problem in the original react files. There is also something weird that if my partner using F12 debug mode in chrome, setting the break point where error log pop, and let iframe loading my website everything works fine again.

How to alter this code to have different values when there is no sticky top element?

I want different scrollTop values when there is no sticky top element, otherwise the layout does not work. The code works fine with the sticky element. Tried to add an if/else but i can’t seem to get it right, i have also tried AI generators but can’t get it to work.

add_action('wp_footer', function() {
    if (!defined('ELEMENTOR_VERSION')) {
        return;
    }
    ?>
    <script>
        if (stickyElement = document.querySelector('.horizontalNav')) {
            const mediaQuery = window.matchMedia('(max-width: 1024px)');
            
            if (mediaQuery.matches) {
                window.addEventListener('elementor/frontend/init', function() {
                    elementorFrontend.hooks.addFilter('frontend/handlers/menu_anchor/scroll_top_distance', function(scrollTop) {
                        return scrollTop - 80;
                    });
                });
            } else {
                if (stickyElement = document.querySelector('.horizontalNav')) {
                    window.addEventListener('elementor/frontend/init', function() {
                        elementorFrontend.hooks.addFilter('frontend/handlers/menu_anchor/scroll_top_distance', function(scrollTop) {
                            return scrollTop - 100;
                        });
                    });
                }
            }
        }
    </script>
    <?php
});

Svelte and form with dynamic inputs

I want to create a form to retrieve a person’s name and country, but with the possibility of adding several lines of the same type on client side before submitting the form. Here is the code I use.

/* This is my Person.svelte component file */

<script>
  export let uniqueId;
</script>

<div>
  <label for="firstname{uniqueId}">Name</label>
  <input type="text" id="firstname{uniqueId}" name="firstname[]" />

  <label for="country{uniqueId}">Country</label>
  <input type="text" id="country{uniqueId}" name="country[]" />
/>
</div>


/* And this is the +page.svelte file */

<script>
import Person from "./Person.svelte";
import { onMount } from "svelte";

let idCount = 0;

const addPerson = () => {
  idCount++;
  const Person = new Person({
    props: {
        uniqueId: idCount,
    },
    target: PersonForm,
    });
  };

  onMount(() => {
  const PersonForm = document.getElementById("PersonForm");
});
</script>


<form method="POST" id="PersonForm">
<Person uniqueId={idCount} />
<button type="submit">Submit</button>
</form>
<button on:click={addPerson}>Add a person</button>

I expect to have an array by putting [] in the input names but that doesn’t work : in the back-end I receive something like this where I have the same name for each data :

[
{ name: 'firstname[]', value: 'John' },
{ name: 'country[]', value: 'Texas' },
{ name: 'firstname[]', value: 'James' },
{ name: 'country[]', value: 'New York' }
]

Here’s the backend code to get the form data :

export const actions = {
    default: async ({request}) => {
        const data = await request.formData();
        console.log("Data : ", data);
        console.log(request.formData);
    }
};

Do you have any ideas to get structured data from the form ?

NodeJS-MySQL scopes

  con.query(
          `SELECT user.*  FROM user WHERE (deactivated_status= "" OR deactivated_status="False") AND user.id NOT IN (SELECT blocked_id from blocked_users WHERE userID="${result[0].id}") AND  user.id NOT IN (SELECT userID from blocked_users WHERE blocked_id="${result[0].id}") AND age BETWEEN '${preference_result[0].ageFrom}' AND '${preference_result[0].ageTo}'  AND gender='${gender}' AND   user.country IN (${array})`,
          
          function (err, results, fields) {
            if (err) {
              res.send("Fail");
              throw err;
            }
            var i=0;
        
            if(results.length>0){
                for( i=0;i<results.length;i++){
           
            
                con.query(
                  `SELECT payment_status  FROM payment WHERE userID='${result[0].id}' AND paid_to_id='${user.id}' `,
                  function(err,result_paid,fields){
                    if(err){
                    res.send("Error");
                    return;
                  }
                  **** Code to be corrected here*** 
                   results[i].payment_status=result_paid.payment_status
                })
              
                }
             }
        //  console.log(results)
           
            res.json({'results':results})
          }
        ); 
      }
      
      );
      }
    })}
    catch(e){
      res.send('Error Fetching Matching Profiles.')
  
      
    }
});
console.log(result_array)
});

So I have an sql query in the first part which gets a list of users, I then run a for loop on the first sql result list and call query on each user [i] retrieved from the first query and append a property called payment status which is the result of the second query on that particular index. However, the final result outside the mysql query functions is not being registered and no property is being appended nor can I access the index in the second query. I am guessing it has something to do with callbacks not setting the values. Kindly help me out on how I can append the property with the value of the first query , Thanks!

Refreshing module with ajax

I have working ajax code that refresh module number 158 and its class .xac-container in every 5 minutes. This module is accordion and the code is refreshing it. I need more simplified code for other module with number 312 just to refresh its class .globalnews in every 5 minutes which is not accordion and don’t have first and active states. How this can happen?

<script>
jQuery(document).ready(function($) {

window.setInterval(function(){
    update_all_msl_forms("https://mysite/", false, false, "livematch");
  }, 5*60*1000); // 5 minutes


  function reload_tabs() {
    jQuery.ajax({
      url: 'https://mysite/',
      type: "get",
      success :function(response){
        var html = jQuery(response).find('#Mod158').html();
        jQuery('#Mod158').html('');
        jQuery('#Mod158').html(html);
        jQuery('.xac-container').hide(); //Hide/close all containers
        jQuery('.xac-trigger:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container
      }
    });
  }

  window.setInterval(function(){
    reload_tabs();
  }, 300000);

  jQuery(document).on('click', '.xac-trigger', function(){
      if( jQuery(this).next().is(':hidden') ) { //If immediate next container is closed...
          jQuery('.xac-trigger').removeClass('active').next().slideUp(); //Remove all "active" state and slide up the immediate next container
          jQuery(this).toggleClass('active').next().slideDown(); //Add "active" state to clicked trigger and slide down the immediate next container
      }
      else{
          jQuery('.xac-trigger').removeClass('active');
          jQuery(this).next().slideUp();
      }
      return false; //Prevent the browser jump to the link anchor
  });
});
</script>

I am very bad with javascript and don’t have idea

Uncaught SyntaxError: Invalid or unexpected token in Hello World

I trying to find an error in a code I received for review. It triggers the following error message:

Uncaught SyntaxError: Invalid or unexpected token

It works fine in my examples and if I completely rewrite it. The Syntax seems fine to me and I have no clue where the error is coming from.

const OUTPUT = document.querySelector('output')Íž
OUTPUT.textContent = 'Hello World';
<output></output>

Find Model in Backbone

I am trying to find a model object from backbone.

For this I have made a method which is calling in loop and passing id to this method.

initializeRepairOrder: (id) ->
  @repair_order = App.Models.RepairOrder.find({ id: id })
  if _.isEqual(@repair_order, null)
    @repair_order = new App.Models.RepairOrder({ id: id })
    @repair_order.fetch({ async: false })

I am calling this method in loop. Let’s suppose we have 4 id’s in our array so this method will call four times. So issue is first 3 times if will go to if ‘condition’, but last time it will get repair_order from find.

Not understanding why this is happening for last element.

D3 selecting links while hovering nodes is not working

I am trying to make a node graph in D3 with hovering effects.
example graphics
or something like that:
D3 – force-directed-graph-component

Currently I am using: D3V4.
https://cdn.jsdelivr.net/npm/d3@4

I’d like to have a effect on connected lines and nodes, while hovering a node.
But suddenly it wont work and the debugger tell me there is no known variable defined.

For easy debugging I made the stroke-width very high.


var svg = d3.select("svg"),
    width = +svg.node().getBoundingClientRect().width,
    height = +svg.node().getBoundingClientRect().height;

// svg objects
var link, node;
// the data - an object with nodes and links
var graph;

// load the data
d3.json("data.json", function(error, _graph) {
  if (error) throw error;
  graph = _graph;
  initializeDisplay();
  initializeSimulation();
});



let div = d3.select("body").append("div")
     .attr("class", "tooltip-circles")
     .style("opacity", 0);

let mouseOver = function(d) {
  d3.selectAll(".circle")
    .transition()
    .duration(200)
    .style("opacity", .5);
  d3.select(this)
    .transition()
    .duration(200)
    .style("opacity", 1);
  div.transition()
    .duration(200)
    .style("opacity", 1);
  div.html(d.id)
    .style("left", (d3.event.pageX + 20) + "px")
    .style("top", (d3.event.pageY - 25) + "px");
  d3.selectAll(".links").filter(function(g) {
      console.log(d.id)
      console.log(g)
      return d.id === g.source || d.id === g.target;
    })
    .style("stroke-width",444)
  };

let mouseLeave = function(d) {
    d3.selectAll(".circle")
      .transition()
      .duration(200)
      .style("opacity", 1)
    d3.select(this)
      .transition()
      .duration(200)
    div.transition()
      .duration('50')
      .style("opacity", 0)
    d3.selectAll(".links")
      .transition()
      .duration('200')
      .style("opacity", 1)
      .style("stroke", "000");
  }

//////////// FORCE SIMULATION //////////// 

// force simulator
var simulation = d3.forceSimulation();

// set up the simulation and event to update locations after each tick
function initializeSimulation() {
  simulation.nodes(graph.nodes);
  initializeForces();
  simulation.on("tick", ticked);
}

// values for all forces
forceProperties = {
    center: {
        x: 0.5,
        y: 0.5
    },
    charge: {
        enabled: true,
        strength: -30,
        distanceMin: 1,
        distanceMax: 2000
    },
    collide: {
        enabled: true,
        strength: .7,
        iterations: 1,
        radius: 5
    },
    forceX: {
        enabled: false,
        strength: .1,
        x: .5
    },
    forceY: {
        enabled: false,
        strength: .1,
        y: .5
    },
    link: {
        enabled: true,
        distance: 30,
        iterations: 1
    }
}

// add forces to the simulation
function initializeForces() {
    // add forces and associate each with a name
    simulation
        .force("link", d3.forceLink())
        .force("charge", d3.forceManyBody())
        .force("collide", d3.forceCollide())
        .force("center", d3.forceCenter())
        .force("forceX", d3.forceX())
        .force("forceY", d3.forceY());
    // apply properties to each of the forces
    updateForces();
}

// apply new force properties
function updateForces() {
    // get each force by name and update the properties
    simulation.force("center")
        .x(width * forceProperties.center.x)
        .y(height * forceProperties.center.y);
    simulation.force("charge")
        .strength(forceProperties.charge.strength * forceProperties.charge.enabled)
        .distanceMin(forceProperties.charge.distanceMin)
        .distanceMax(forceProperties.charge.distanceMax);
    simulation.force("collide")
        .strength(forceProperties.collide.strength * forceProperties.collide.enabled)
        .radius(forceProperties.collide.radius)
        .iterations(forceProperties.collide.iterations);
    simulation.force("forceX")
        .strength(forceProperties.forceX.strength * forceProperties.forceX.enabled)
        .x(width * forceProperties.forceX.x);
    simulation.force("forceY")
        .strength(forceProperties.forceY.strength * forceProperties.forceY.enabled)
        .y(height * forceProperties.forceY.y);
    simulation.force("link")
        .id(function(d) {return d.id;})
        .distance(forceProperties.link.distance)
        .iterations(forceProperties.link.iterations)
        .links(forceProperties.link.enabled ? graph.links : []);

    // updates ignored until this is run
    // restarts the simulation (important if simulation has already slowed down)
    simulation.alpha(1).restart();
}



//////////// DISPLAY ////////////

// generate the svg objects and force simulation
function initializeDisplay() {
  // set the data and properties of link lines
  link = svg.append("g")
        .attr("class", "links")
        .selectAll("line")
        .data(graph.links)
        .enter().append("line")
        .attr("class",  "links" )
        .attr("target", (d) => d.target )
        .attr("source", (d) =>  d.source  )
        .style("stroke-width", (d) => d.value);


  // set the data and properties of node circles
  node = svg.append("g")
    .attr("class", "nodes")
    .selectAll("circle")
    .data(graph.nodes)
    .enter().append("circle")
    .style("stroke", (d) => d.color)
    .style("stroke-width", (d) => d.width)
    .style('fill', (d) => d.color)
    .attr("class", function(d){ return "circle" } )
    .on("mouseover", mouseOver )
    .on("mouseleave", mouseLeave )
    .call(d3.drag()
        .on("start", dragstarted)
        .on("drag", dragged)
        .on("end", dragended))
  updateDisplay();
}

// update the display based on the forces (but not positions)
function updateDisplay() {
    node
        .attr("r", forceProperties.collide.radius)
        .attr("stroke", forceProperties.charge.strength > 0 ? "blue" : "red")
        .attr("stroke-width", forceProperties.charge.enabled==false ? 0 : Math.abs(forceProperties.charge.strength)/15);

    link
        .attr("stroke-width", forceProperties.link.enabled ? 1 : .5)
        .attr("opacity", forceProperties.link.enabled ? 1 : 0);
}

// update the display positions after each simulation tick
function ticked() {
    link
        .attr("x1", function(d) { return d.source.x; })
        .attr("y1", function(d) { return d.source.y; })
        .attr("x2", function(d) { return d.target.x; })
        .attr("y2", function(d) { return d.target.y; });

    node
        .attr("cx", function(d) { return d.x; })
        .attr("cy", function(d) { return d.y; });
    d3.select('#alpha_value').style('flex-basis', (simulation.alpha()*100) + '%');
}



//////////// UI EVENTS ////////////

function dragstarted(d) {
  if (!d3.event.active) simulation.alphaTarget(0.3).restart();
  d.fx = d.x;
  d.fy = d.y;

}

function dragged(d) {
  d.fx = d3.event.x;
  d.fy = d3.event.y;
}

function dragended(d) {
  if (!d3.event.active) simulation.alphaTarget(0.0001);
  d.fx = null;
  d.fy = null;
}

// update size-related forces
d3.select(window).on("resize", function(){
    width = +svg.node().getBoundingClientRect().width;
    height = +svg.node().getBoundingClientRect().height;
    updateForces();
});

// convenience function to update everything (run after UI input)
function updateAll() {
    updateForces();
    updateDisplay();
};


I Compared many other solutions, but every other is calling all line, and this breaks the hover-end effect.
Something like:

link.style("stroke", "");", function(o) {
  return o.source === d || o.target === d
    ? '000' : 'AAA';
});   

Is not helping and I would have to make every style attribute separate.
I’d like to have a selectAll with a filter for better readability.

How to pass variables initialized in beforeEach to reusable test function outside closure

Lets imagine rather simple jasmine unit test setup

  let actions$: Subject<Action>;
  let effects: CustomEffects;

  beforeEach(() => {
    actions$ = new Subject<Action>();

    TestBed.configureTestingModule({
      providers: [
        CustomEffects,
        provideMockActions(() => actions$),
      ],
    });

    effects = TestBed.inject(CustomEffects);
  });

  
    testLoadingIndicators(
      simpleParamsPassedWithoutProblem,
      { effects, actions$ }, // <-- undefined, undefined
    );

I want to create reusable testing function (defined in other file) that will take some params and effects and actions$ variables. The problem is those last two are initialized in beforeEach so by the time they are passed to my testing fn they are not yet ready.

My end goal here is to have the testing function I can reuse across many files in my test setup. This testing function has describes and its and uses provided params to do the logic.

The usual way of writing such tests uses closure to access the variable, but this would mean declaring my test fn inside outer describe and thus making it not shareable.

how can i add validation for every fields that will show an error message using PHP

    <h2>FILL OUT THE REGISTRATION FORM</h2>
                            <form class="" method="POST" enctype="multipart/form-data">
                                    <div class="row">
                                                        <?php

                                                            $id_counter = $model->fetchIdCounter();

                                                            if ($id_counter == false) {
                                                                $id_counter = 1;
                                                                $checker = 0;
                                                            }

                                                            else {
                                                                $checker = 1;
                                                            }

                                                        ?>
                                                        <input class="form-control" type="hidden" name="r_id" value="<?php echo 'BC-'.date("Y").'-'.str_pad($id_counter + 1, 4, "0", STR_PAD_LEFT); ?>" readonly>
                                                        <div class="form-group col-4 ">
                                                            <label class="col-form-label">First Name</label>
                                                            <input class="form-control" type="text" name="fname" required maxlength="30">
                                                        </div>
                                                        <div class="form-group col-3">
                                                            <label class="col-form-label">Middle Name</label>
                                                            <input class="form-control" type="text" name="mname" maxlength="30">
                                                        </div>
                                                        <div class="form-group col-3">
                                                            <label class="col-form-label">Last Name</label>
                                                            <input class="form-control" type="text" name="lname" required maxlength="30">
                                                        </div>
                                                        <div class="form-group col-2">
                                                            <label class="col-form-label">Suffix</label>
                                                            <input class="form-control" type="text" name="suffix" placeholder="Jr/Sr" maxlength="30">
                                                        </div>
                                                        <div class="form-group col-3">
                                                            <label class="col-form-label">Gender</label>
                                                            <select class="form-control" name="gender" readonly>
                                                                <option value="Male">Male</option>
                                                                <option value="Female">Female</option>
                                                            </select>
                                                        </div>
                                                        <div class="form-group col-3">
                                                            <label class="col-form-label">Birth Date</label>
                                                            <input class="form-control" type="date" name="bdate" required>
                                                        </div>
                                                        <div class="form-group col-3">
                                                            <label class="col-form-label">Birth Place</label>
                                                            <input class="form-control" type="text" name="bplace" required maxlength="30">
                                                        </div>
                                                        <div class="form-group col-3">
                                                            <label class="col-form-label">Block</label>
                                                            <input class="form-control" type="text" name="address"  required>
                                                        </div>
                                                        <div class="form-group col-3">
                                                            <label class="col-form-label">Lot</label>
                                                            <input class="form-control" type="text" name="address2" maxlength="12" required>
                                                        </div>
                                                        <div class="form-group col-3">
                                                            <label class="col-form-label">Contact</label>
                                                            <input class="form-control" type="text" name="contact" maxlength="12" pattern="09[0-9]{9}" placeholder="09XX-XXX-XXXX" value="" required>
                                                        </div>
                                                        <div class="form-group col-3">
                                                            <label class="col-form-label">Civil Status</label>
                                                            <select class="form-control" name="civil_status">
                                                                <option value="Single">Single</option>
                                                                <option value="Married">Married</option>
                                                                <option value="Separated">Separated</option>
                                                                <option value="Widowed">Widowed</option>
                                                            </select>
                                                        </div>

                                                    
                                                        <div class="form-group col-3">
                                                            <label class="col-form-label">Occupation</label>
                                                            <input class="form-control" type="text" name="occupation"  maxlength="30" value="N/A" required>
                                                        </div>
                                                        <div class="form-group col-3">
                                                            <label class="col-form-label">Voter Status</label>
                                                            <select class="form-control" name="resident_status">
                                                                <option value="No">No</option>
                                                                <option value="Yes">Yes</option>
                                                            </select>
                                                        </div>
                                                        <div class="form-group col-3">
                                                            <label class="col-form-label">Precinct No. (If Voter)</label>
                                                            <input class="form-control" type="text" name="precinct"  maxlength="30" value="">
                                                        </div>
                                                        <div class="form-group col-3">
                                                        <label class="col-form-label">Educational Attainment</label>
                                                            <select class="form-control" name="address3">
                                                            <option value="N/A" >N/A</option>
                                                            <option value="Elementary Level" >Elementary Level</option>
                                                            <option value="Elementary Graduate" >Elementary Graduate</option>
                                                            <option value="High School Level" >High School Level</option>
                                                            <option value="High School Graduate" >High School Graduate</option>
                                                            <option value="SHS Level">SHS Level</option>
                                                            <option value="SHS Graduate">SHS Graduate</option>
                                                            <option value="College Level" >College Level</option>
                                                            <option value="College Graduate">College Graduate</option>
                                                            <option value="Vocational Graduate">Vocational Graduate</option>
                                                            <option value="Master's Graduate">Master's Graduate</option>
                                                            </select>
                                                        </div>
                                                        <div class="form-group col-3">
                                                            <label class="col-form-label">Resident Since</label>
                                                            <input class="form-control" type="date" name="res_since" required min="1900-01-01" max="<?php echo date('Y')?>-12-31">
                                                        </div>
                                                        <div class="form-group col-6">
                                                            <label class="col-form-label">Email</label>
                                                            <input class="form-control" type="email" name="email" maxlength="40" required>
                                                        </div>
                                                        <div class="form-group col-6">
                                                            <label class="col-form-label">Password</label>
                                                            <div class="input-group">
                                                                <input class="form-control" type="password" name="password" minlength="8" maxlength="40" required id="passwordField">
                                                                <div class="input-group-append" id="showPasswordBtnContainer" style="display: none;">
                                                                    <button class="btn btn-outline-secondary" type="button" id="showPasswordBtn">Show</button>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <script>
                                                            const passwordField = document.getElementById('passwordField');
                                                            const showPasswordBtnContainer = document.getElementById('showPasswordBtnContainer');
                                                            const showPasswordBtn = document.getElementById('showPasswordBtn');

                                                            passwordField.addEventListener('input', function() {
                                                                if (passwordField.value.length > 0) {
                                                                    showPasswordBtnContainer.style.display = 'block';
                                                                } else {
                                                                    showPasswordBtnContainer.style.display = 'none';
                                                                    passwordField.type = 'password'; // Ensure password is hidden when the button is hidden
                                                                }
                                                            });

                                                            showPasswordBtn.addEventListener('click', function() {
                                                                if (passwordField.type === 'password') {
                                                                    passwordField.type = 'text';
                                                                    showPasswordBtn.textContent = 'Hide';
                                                                } else {
                                                                    passwordField.type = 'password';
                                                                    showPasswordBtn.textContent = 'Show';
                                                                }
                                                            });
                                                        </script>



                                                        
                                                        <div class="form-group col-7">
                                                            <label class="col-form-label">Family Income</label>
                                                            <select class="form-control" name="income">
                                                                <option value="1">Below PHP 11,000</option>
                                                                <option value="2">PHP 11,001 to PHP 22,000</option>
                                                                <option value="3">PHP 22,001 to PHP 44,000</option>
                                                                <option value="4">PHP 44,001 to PHP 77,000</option>
                                                                <option value="5">PHP 77,001 to PHP 131,000</option>
                                                                <option value="6">PHP 131,001 to PHP 220,000</option>
                                                                <option value="7">Above 220,001</option>
                                                            </select>
                                                        </div>
                                                        <div class="form-group col-5">
                                                            <label class="col-form-label">Family Head</label>
                                                            <select class="form-control" name="family">
                                                                <option value="No">No</option>
                                                                <option value="Yes">Yes</option>
                                                                
                                                            </select>
                                                        </div>
                                                        <div class="form-group col-12">
                                                            <label class="col-form-label">Resident Status</label>
                                                            <div class="form-check">
                                                              <input class="form-check-input" type="radio" name="special_status" id="radio1" checked value="">
                                                              <label class="form-check-label" for="radio1">
                                                                None
                                                              </label>
                                                            </div>
                                                            
                                                            <div class="form-check">
                                                              <input class="form-check-input" type="radio" name="special_status" id="radio2" value="1">
                                                              <label class="form-check-label" for="radio2">
                                                                PWD
                                                              </label>
                                                            </div>
                                                            
                                                            <div class="form-check">
                                                              <input class="form-check-input" type="radio" name="special_status" id="radio3" value="2">
                                                              <label class="form-check-label" for="radio3">
                                                                Solo Parent
                                                              </label>
                                                            </div>
                                                            
                                                            <div class="form-check">
                                                              <input class="form-check-input" type="radio" name="special_status" id="radio4" value="3">
                                                              <label class="form-check-label" for="radio4">
                                                                Senior Citizen
                                                              </label>
                                                            </div>
                                                        </div>
                                                        <div class="form-group col-12">
                                                            <center><label class="col-form-label">Attach Barangay ID</label><br>
                                                            <input type="file" name="image" accept="image/*" onchange="readURL(this, '')" style="border: 0px; padding: 0px;" required></center>
                                                        </div>
                                                        <div class="form-group col-12">
                                                            <center>
                                                                <img id="display-img-" style="width: 500px; height: 300px; object-fit: cover;">
                                                            </center>
                                                        </div>
                                                        <div class="form-group col-10">
                                                            <i>
                                                            Please be informed that your registration to Barangay San Nicolas II portal will be reviewed. We will notify you via email regarding your account status.</i>
                                                        </div>
                                                        <div class="form-group col-2">
                                                            <input type="submit" class="btn btn-block green radius-xl" name="add_resident" value="REGISTER NOW">
                                                        </div>
                                                        <div class="form-group col-12">
                                                            <br><br>
                                                            <center><a href='residents.php'>Back to Login</a></center>
                                                            
                                                        </div>

                                </div>
                                                    </div>
                                                    </form>
                                                    
                                                    
                                                    <?php
                                    $category = 0;
                                    $status = 1;
                                    if (isset($_POST['add_resident'])) {
                                        $r_id = $_POST['r_id'];
                                        $fname = $_POST['fname'];
                                        $mname = isset($_POST['mname']) ? $_POST['mname'] : "N/A";
                                        $lname = $_POST['lname'];
                                        $time = strtotime($_POST['bdate']);
                                        $bdate = date('Y-m-d', $time);
                                        $gender = $_POST['gender'];
                                        $civil_status = $_POST['civil_status'];
                                        $resident_status = $_POST['resident_status'];
                                        $address1 = $_POST['address'];
                                        $address2 = $_POST['address2'];
                                        $address3 = $_POST['address3'];
                                        $bplace = $_POST['bplace'];
                                        $occupation = $_POST['occupation'];
                                        //$ext = $_POST['ext'];
                                        $res_since = $_POST['res_since'];
                                        $date = date("Y-m-d H:i:s");
                                        $contact = isset($_POST['contact']) ? $_POST['contact'] : "N/A";
                                        $suffix = $_POST['suffix'];
                                        $income = $_POST['income'];
                                        $family = $_POST['family'];
                                        
                                        $precinct = $_POST['precinct'];
                                        $special_status = $_POST['special_status'];
                                        
                                        $path = 'assets/images/id/';
                                        $unique = time().uniqid(rand());
                                        $destination = $path . $unique . '.jpg';
                                        $base = basename($_FILES["image"]["name"]);
                                        $image = $_FILES["image"]["tmp_name"];
                                        move_uploaded_file($image, $destination);

                                        

                                        $email = $_POST['email'];
                                        $digits_hash = password_hash($_POST['password'], PASSWORD_DEFAULT);


                                            $result = $model->addResidentRegister($r_id, $address3, $bplace, $occupation, $fname, $mname, $lname, $bdate, $gender, $civil_status, $address1, $address2, $res_since, $date, $resident_status, $contact, $email, $digits_hash, $income, $family, $precinct, $special_status, $unique,$suffix);

                                            if ($checker == 0 && $result == true) {
                                                $model->updateIdCounter();
                                                $model->updateIdCounter();
                                            }

                                            else if ($checker == 1 && $result == true) {
                                                $model->updateIdCounter();
                                            }
                                            
                                            echo "<script>window.open('registration-success', '_self')</script>";

                                        
                                    }

                                ?>
                        </div>
                    </div>
                </div>
            </div>

i tried to add a simple validation but when i click on the submit it just going back to the top field. i want to add validation for every fields /

i tried to add a simple validation but when i click on the submit it just going back to the top field. i want to add validation for every fields /

i tried to add a simple validation but when i click on the submit it just going back to the top field. i want to add validation for every fields /

i tried to add a simple validation but when i click on the submit it just going back to the top field. i want to add validation for every fields /

i tried to add a simple validation but when i click on the submit it just going back to the top field. i want to add validation for every fields /

i tried to add a simple validation but when i click on the submit it just going back to the top field. i want to add validation for every fields /

i tried to add a simple validation but when i click on the submit it just going back to the top field. i want to add validation for every fields /

i tried to add a simple validation but when i click on the submit it just going back to the top field. i want to add validation for every fields /

Canvas Line Rendering Issue in Windows Chrome

I draw a list of points produced with pointerMove events using the following code:

Demo here

I notice there is a subtle gap in the rendered line.

Subtle gap image

I wonder if this is a bug in Windows Chrome 121 because this issue does not occur in Windows Firefox.
Even the rendering engine used is different, such output is somewhat unexpected.
Or do I miss something fundamental?

Kendo JQuery Grid append image to PDF export

I would like to append an image at the end of a PDF export. The image should be placed after the exported grid on a new page.

Below is my code which initialises the kendo grid as well as the PDF export.

    var riskScoresGrid = $("#riskDataTable").kendoGrid({
    dataSource: {
        transport: {
            read: {
                url: "/api/Organisation/GetResidualScoresPDF",
                type: "get",
                data: model,
            }
        },
        pageSize: 20,
        schema: {
            data: function (response) {
                return response;
            },
            total: function (response) {
                return response.length;
            }
        }
    },
    columns: [
        {
            field: "SubDivision",
            title: "COB / PRU",
            width: "120px",
            attributes: { style: "text-align: center;" },
            headerAttributes: { style: "text-align: center;" }
        },
        {
            field: "Category",
            title: "Category",
            width: "120px",
            attributes: { style: "text-align: center;" },
            headerAttributes: { style: "text-align: center;" }
        },
        {
            field: "SubCategory",
            title: "Sub Category",
            template: "#= SubCategory || '-' #",
            width: "120px",
            attributes: { style: "text-align: center;" },
            headerAttributes: { style: "text-align: center;" }
        },
        {
            field: "Impact",
            title: "Impact",
            width: "100px",
            attributes: { style: "text-align: center;" },
            headerAttributes: { style: "text-align: center;" }
        },
        {
            field: "Likelihood",
            title: "Likelihood",
            width: "100px",
            attributes: { style: "text-align: center;" },
            headerAttributes: { style: "text-align: center;" }
        },
        {
            field: "Score",
            title: "Score",
            width: "60px",
            attributes: { style: "text-align: center;" },
            headerAttributes: { style: "text-align: center;" }
        },
        {
            field: "Comments",
            title: "Comments",
            headerAttributes: { style: "text-align: center;" },
            template: function (dataItem) {
                return decodeHtmlEntities(dataItem.Comments);
            }
        }
    ],
    pageable: true,
    toolbar: ["pdf"],
    pdf: {
        fileName: "exported-grid.pdf",
        allPages: true,
        avoidLinks: true,
        paperSize: "A3",
        margin: { top: "2cm", left: "1cm", right: "1cm", bottom: "1cm" },
        landscape: true,
        title: "Risk Assessment: " + entity,
        template: $("#page-template").html()
    }
});

Additionally, below is the html code for the page template:

<script type="x/kendo-template" id="page-template">
      <div class="page-template">
        <div class="header">
    <em>#=getKendoHeader()#</em>
        </div>
    </div>
</script>

I’ve tried adding an img tag to the page-template div but this adds the image on every page and it sits in front of the grid so the grid is not visible.