Create a cookie with the secure and httonly flags to display a banner

I premise I am fairly inexperienced in php and javacript, but I am trying to create a small website for myself.

In this website, I want to display a small banner with some text inside when a new user enters my website (whichever the webpage is) for the first time. The banner has the following characteristics:

  1. When displayed for the first time, it remains on the screen for 7 seconds (so the user can read it)
  2. After its disappearance, the user can continue to browse the website and pages without seeing the banner anymore.

To do so, I thought to create a plugin (for WORDPRESS) that creates a cookie, let’s call it banner_read. After the banner disappers, the cookie is created and the presence of the cookie does not cause the banner to be created. The cookie is only valid for the session (session cookie).

The first time I created the banner and the cookie via javascript code, also setting the ‘secure’ flag. The javascript code checks for the existence of the cookie and if it does not exist it creates the banner (with its settings). If I limit myself to this, the code works. In particular, the banner is displayed for seven seconds and the cookie is created after its disappearance, whichever is the first webpage displayed by the user.

Then, to be on the safe side and also out of curiosity, I wanted to set the ‘httponly’ flag as well, but from what I understand, it has to be done through php code, since the javascript code (to check the existence of the cookie) does not work if the httponly flag is set.

I have tried to create some php code to check the existence of the cookie and create it and javascript code to display the banner, but the code does not seem to work. In particular, the banner is not displayed and the cookie is created immediately.

Maybe for this simple cookie I don’t need both the flags, but not knowing the subject in depth, I would like to play it safe.

First code – I report here the javascript code that works (the CSS file for styling is external):

<?php
/*
Plugin Name: Custom Cookie Manager
*/

if (!defined('ABSPATH')) {
    exit;
}


// Enqueue styles and scripts
function custom_cookie_manager_enqueue_styles() {
    wp_enqueue_style('custom-cookie-manager-style', plugins_url('css/custom-cookie-manager.css', __FILE__));
}
add_action('wp_enqueue_scripts', 'custom_cookie_manager_enqueue_styles');

// Add the cookie banner
function custom_cookie_manager_banner() {
    ?>
    <script type="text/javascript">
        document.addEventListener('DOMContentLoaded', function() {
            if (!document.cookie.split('; ').find(row => row.trim().startsWith('banner_read='))) {
                var banner = document.createElement('div');
                banner.id = 'cookie-banner';
                banner.className = 'cookie-banner';
                banner.innerHTML = '<p>TEXT HERE</p>';
                document.body.appendChild(banner);
                
                setTimeout(function() {
                    banner.classList.add('hide');
                    document.cookie = "banner_read=true; path=/; Secure; SameSite=Strict";
                }, 7000); // 7 seconds
            }
        });
    </script>
    <?php
}
add_action('wp_footer', 'custom_cookie_manager_banner');
?>

Second code – Here the PHP and Javascript code that does not work:

<?php
/*
Plugin Name: Custom Cookie Manager
*/

if (!defined('ABSPATH')) {
    exit;
}

// Enqueue styles and scripts
function custom_cookie_manager_enqueue_styles() {
    wp_enqueue_style('custom-cookie-manager-style', plugins_url('css/custom-cookie-manager.css', __FILE__));
}
add_action('wp_enqueue_scripts', 'custom_cookie_manager_enqueue_styles');

// Add the cookie banner
function custom_cookie_manager_banner() {
    if (!isset($_COOKIE['banner_read'])) {
        ?>
        <script type="text/javascript">
            document.addEventListener('DOMContentLoaded', function() {
                var banner = document.createElement('div');
                banner.id = 'cookie-banner';
                banner.className = 'cookie-banner';
                banner.innerHTML = '<p>TEXT HERE</p>';
                document.body.appendChild(banner);
                
                setTimeout(function() {
                    banner.classList.add('hide');
                }, 7000); // 7 seconds
            });
        </script>
        <?php

        // Set cookie with HttpOnly and Secure flags
        setcookie('banner_read', 'true', 0, "/", "", true, true); // session cookie
    }
}
add_action('wp_footer', 'custom_cookie_manager_banner');
?>

Here is the CSS fyle:

/* css/custom-cookie-manager.css */
.cookie-banner {
    position: fixed;
    bottom: 0;
    width: 100%;
    background-color: #000;
    color: #fff;
    text-align: center;
    height: auto;
    z-index: 1000;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 20px 0 20px;
    box-sizing: border-box;
}

.cookie-banner.hide {
    visibility: hidden;
}

I have tried to create some php code to check the existence of the cookie and create it and javascript code to display the banner, but the code does not seem to work. In particular, the banner is not displayed and the cookie is created immediately.

I expect the second to work as well as the first one.

Deloitte USI vs KPMG which to choose [closed]

I have received an offer letter from Deloitte USI for an advisory analyst trainee position in risk and finance advisory with a total package of 4lpa including bonuses. I also have an offer letter from KPMG for an analyst role (related to software development) with a package of 5lpa plus bonuses. I’m very confused about which offer to accept. I need help making a decision about whether to join Deloitte or KPMG. I want to choose the firm that offers better salary prospects and valuable learning experiences in the future.

waiting in javascript context using dart

the goal is to be able to wait for dart code to process and receive its output in the javascript context but i am not being able to.

I am not able to wait with dart:js (code1).
I am able to wait using flutter_js(code2) .
the issue with flutter_js is that it does not work with flutter web.

is is possible to wait with dart:js or another package that works with flutter web?

i found this stack overflow that is similar ::

How to asynchronously call JavaScript in Flutter?

How to get callback or return value from async JS function to Dart in Flutter Web?

https://github.com/dart-lang/sdk/issues/50530

the second and third link were exatactly what i was looking for a think but i dont understand what the answer was.

any help is greatly appreciated it/

code1::

import 'package:flutter/material.dart';
import 'dart:js' as js;
import 'package:flutter/material.dart';
class JsCompilerUtil {
  Future<bool?> process_client_script({
    required String script,
    required Map<String, dynamic> current,
  }) async {
    js.JsObject jsObject = js.JsObject.jsify(current);
    js.context['c'] = jsObject;
    // js.context['c'] = current;
    var result = js.context.callMethod("eval", [script]);
    return result;
  }
}
class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});
  @override
  State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
  JsCompilerUtil jsCompilerUtil = JsCompilerUtil();
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    *initialize*data();
  }
  Future<void> *initialize*data() async {
    String script = """
console.log("Hi from js, this is the inputed name: "+c.name);
var res = c.dummyWait();
console.log("res:")
""";
    Map<String, dynamic> current = {
      "name": "Juan",
      "dummyWait": dummyWait
    };
    final res = await jsCompilerUtil.process_client_script(script: script, current: current);
  }
  @override
  Widget build(BuildContext context) {
    return SizedBox();
  }
  Future<String> dummyWait() async {
    print("dummyWait()n");
    await Future.delayed(const Duration(seconds: 1));
    return 'MESSAGE FROM DART';
  }
}

output of code1::

Restarted application in 28ms.
The debugEmulateFlutterTesterEnvironment getter is deprecated and will be removed in a future release. Please use `debugEmulateFlutterTesterEnvironment` from `dart:ui_web` instead.
Hi from js, this is the inputed name: Juan
dummyWait()
res:

code2:

import 'package:flutter/material.dart';
import 'package:flutter_js/flutter_js.dart';
import 'dart:convert';

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  late JavascriptRuntime flutterJs;

  @override
  void initState() {
    super.initState();
    flutterJs = getJavascriptRuntime();
    _setupJavaScriptBridge();
  }

  void _setupJavaScriptBridge() {
    flutterJs.onMessage('dummyAwait', (args) async {
      String result = await dummyAwaitFunction();
      return result;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('JavaScript in Dart'),
      ),
      body: Center(
        child: ElevatedButton(
          onPressed: _logic,
          child: Text('Run JavaScript'),
        ),
      ),
    );
  }

  Future<void> _logic() async {
    String result = await runJavaScript();
    print("JavaScript result: $result");
  }

  Future<String> runJavaScript() async {
    // Dart map
    final current = {"name": "juan"};

    // Convert Dart map to JSON string
    String jsonString = jsonEncode(current);

    // JavaScript script to parse JSON string, call Dart function, and print result
    String script = '''
      var current = JSON.parse('$jsonString');
      async function waitForDart() {
        var res = await sendMessage('dummyAwait');
        console.log("INSDE OF JS: " + res);
        return res;
      }
      waitForDart();
    ''';

    // Evaluate JavaScript script
    JsEvalResult jsResult = await flutterJs.evaluateAsync(script);

    return jsResult.stringResult;
  }

  Future<String> dummyAwaitFunction() async {
    await Future.delayed(const Duration(seconds: 1));
    return 'MESSAGE FROM DART';
  }
}

How to access a static JSON file from the server from a react app

I have a static JSON file in my apache server and I want my react application to access the static JSON file and show its content

The idea behind is I have a Terms and Condition page in my application my react application will cover all the skeleton (App bar, logo, Navigation buttons ..) of the T&C page but I want the content of my T&C page to be loaded from the static JSON file that I place on my server so that if I want to make any change to the T&C I only update the JSON file and no need to rebuild my application

FYI – I am using create react app and not webpack

How do I achieve this?

How to Dynamically Set Tooltip Background Colors in amCharts 5 PieChart?

I’m trying to set up a PieChart using amCharts 5, and I want to dynamically pass a color parameter to the tooltip so that each tooltip displays a different background color for each slice of the chart (as shown in the diagram). I have tried multiple approaches and events, but nothing seems to be working for me.

<script src="https://cdn.amcharts.com/lib/5/index.js"></script>
<script src="https://cdn.amcharts.com/lib/5/percent.js"></script>
<div id="chartdiv"></div>
<script>
    // Create root and chart
    var root = am5.Root.new("chartdiv");
    var chart = root.container.children.push(
        am5percent.PieChart.new(root, {
            layout: root.verticalHorizontal
        })
    );

    // Define data
    var data = [{
        country: "France",
        sales: 100000,
        color: am5.color(0x87CEEB)
    }, {
        country: "Spain",
        sales: 160000,
        color: am5.color(0x228B22)
    }, {
        country: "United Kingdom",
        sales: 80000,
        color: am5.color(0xFF7F50)
    }];

    // Create series
    var series = chart.series.push(
        am5percent.PieSeries.new(root, {
            name: "Series",
            valueField: "sales",
            categoryField: "country"
        })
    );

    series.data.setAll(data);

    let tooltip = am5.Tooltip.new(root, {
        getFillFromSprite: false
    });

    tooltip.get("background").setAll({
        fill: am5.color(0xeeeeee)
    });

    series.set("tooltip", tooltip);

</script>

enter image description here

Multiple Folder Image Minipulation

I have created an image tool which crops, scales, resizes. I now want to create a bulk image feature where it will take multiple folders with images inside, extract the images and then creates the a new folder with the original file name and put’s the processed images back into the folders created.

I’m 95% there with creating this tool but I’m stuck on trying to process multiple folders which is where it’s going wrong.

I’ve managed to get it so I can process one folder, extract the images, create a new folder with the original file name and put the processed image back into that folder.

I’m stuck on what to do next. I have tried searching the problem but I think my situation is a bit niche so I didn’t find much. So if anyone has a solution that would be much appreciated.

My specific question is:
How can I modify my current code to correctly process multiple folders, extract the images, and place the processed images back into the respective new folders?

document.addEventListener('DOMContentLoaded', function() {
  const folderInput = document.getElementById('folderInput');
  folderInput.addEventListener('change', function() {
    updateSelectedFilesPreview('folderInput', 'bulk_selectedFilesPreview');
    console.log('Folder input changed. Files selected:', folderInput.files.length);
  });
});

function processFolderImages() {
  const folderInput = document.getElementById('folderInput');
  const output = document.getElementById('bulk_output');
  const finalSize = 2000;
  const maxScaleSize = 1900;
  const compressionQuality = 0.5;

  const zip = new JSZip();
  const promises = [];

  const oldButton = document.querySelector('.download-bulkimg-button');
  if (oldButton) {
    output.removeChild(oldButton);
  }

  const folderMap = {};

  // Iterate through the selected files and categorize them by their folder paths
  for (let i = 0; i < folderInput.files.length; i++) {
    const file = folderInput.files[i];
    const filePath = file.webkitRelativePath || file.relativePath || file.name;
    const folderPath = filePath.substring(0, filePath.lastIndexOf('/'));

    console.log(`Processing file: ${file.name}`);
    console.log(`File path: ${filePath}`);
    console.log(`Folder path: ${folderPath}`);

    if (!folderMap[folderPath]) {
      folderMap[folderPath] = [];
    }

    folderMap[folderPath].push(file);
  }

  console.log('Folder map:', folderMap);

  for (const folderPath in folderMap) {
    const files = folderMap[folderPath];
    const folder = zip.folder(folderPath);

    console.log(`Processing folder: ${folderPath}`);

    files.forEach(file => {
      const reader = new FileReader();

      promises.push(
        new Promise((resolve) => {
          reader.onload = function(e) {
            console.log(`Reading file: ${file.name}`);
            const img = new Image();
            img.src = e.target.result;
            img.onload = function() {
              console.log(`Image loaded: ${file.name}`);
              const cropCanvas = document.createElement('canvas');
              const cropCtx = cropCanvas.getContext('2d');
              const {
                left,
                top,
                width,
                height
              } = getBoundingRectangle(img);

              cropCanvas.width = width;
              cropCanvas.height = height;
              cropCtx.drawImage(img, left, top, width, height, 0, 0, width, height);

              const scaleCanvas = document.createElement('canvas');
              const scaleCtx = scaleCanvas.getContext('2d');
              let scaleWidth, scaleHeight;
              if (width > height) {
                scaleWidth = maxScaleSize;
                scaleHeight = (height / width) * maxScaleSize;
              } else {
                scaleWidth = (width / height) * maxScaleSize;
                scaleHeight = maxScaleSize;
              }

              scaleCanvas.width = scaleWidth;
              scaleCanvas.height = scaleHeight;
              scaleCtx.drawImage(cropCanvas, 0, 0, width, height, 0, 0, scaleWidth, scaleHeight);

              const canvas = document.createElement('canvas');
              const ctx = canvas.getContext('2d');
              const canvasSize = finalSize;
              canvas.width = canvasSize;
              canvas.height = canvasSize;

              let sourceWidth, sourceHeight;
              if (scaleWidth > scaleHeight) {
                sourceWidth = canvasSize;
                sourceHeight = (scaleHeight / scaleWidth) * canvasSize;
              } else {
                sourceWidth = (scaleWidth / scaleHeight) * canvasSize;
                sourceHeight = canvasSize;
              }

              const xOffset = (canvasSize - sourceWidth) / 2;
              const yOffset = (canvasSize - sourceHeight) / 2;

              ctx.fillStyle = 'white';
              ctx.fillRect(0, 0, canvasSize, canvasSize);
              ctx.drawImage(scaleCanvas, 0, 0, scaleWidth, scaleHeight, xOffset, yOffset, sourceWidth, sourceHeight);

              canvas.toBlob(function(blob) {
                console.log(`Image processing complete: ${file.name}`);
                compressImage(blob, compressionQuality, function(compressedBlob) {
                  folder.file(file.name, compressedBlob);
                  resolve();
                });
              }, 'image/jpeg', 1);
            };
          };

          reader.readAsDataURL(file);
        })
      );
    });
  }

  Promise.all(promises).then(() => {
    console.log('All images processed. Generating ZIP...');
    if (!document.querySelector('.download-folder-img-button')) {
      zip.generateAsync({
        type: 'blob'
      }).then(function(content) {
        console.log('ZIP generated.');
        const button = document.createElement('button');
        button.innerText = 'Download';
        button.classList.add('download-bulkimg-button');
        button.addEventListener('click', function(event) {
          event.preventDefault();
          const a = document.createElement('a');
          a.href = URL.createObjectURL(content);
          a.download = 'processed-images.zip';
          a.style.display = 'none';
          document.body.appendChild(a);
          a.click();
          document.body.removeChild(a);
        });
        output.appendChild(button);
      }).catch(error => {
        console.error('Error generating ZIP:', error);
        output.innerHTML = 'An error occurred while generating the ZIP.';
      });
    }
  }).catch(error => {
    console.error('Error processing images:', error);
    output.innerHTML = 'An error occurred during processing.';
  });
}

function getBoundingRectangle(img) {
  const offscreenCanvas = document.createElement('canvas');
  const offscreenCtx = offscreenCanvas.getContext('2d');
  offscreenCanvas.width = img.width;
  offscreenCanvas.height = img.height;
  offscreenCtx.drawImage(img, 0, 0);

  const imageData = offscreenCtx.getImageData(0, 0, offscreenCanvas.width, offscreenCanvas.height);
  const data = imageData.data;

  let left = offscreenCanvas.width;
  let top = offscreenCanvas.height;
  let right = 0;
  let bottom = 0;

  for (let y = 0; y < offscreenCanvas.height; y++) {
    for (let x = 0; x < offscreenCanvas.width; x++) {
      const index = (y * offscreenCanvas.width + x) * 4;
      if (data[index] !== 255 || data[index + 1] !== 255 || data[index + 2] !== 255) {
        left = Math.min(left, x);
        right = Math.max(right, x);
        top = Math.min(top, y);
        bottom = Math.max(bottom, y);
      }
    }
  }

  const width = right - left;
  const height = bottom - top;

  console.log(`Bounding rectangle - left: ${left}, top: ${top}, width: ${width}, height: ${height}`);

  return {
    left,
    top,
    width,
    height
  };
}

function compressImage(blob, quality, callback) {
  const img = new Image();
  img.src = URL.createObjectURL(blob);
  img.onload = function() {
    const canvas = document.createElement('canvas');
    const ctx = canvas.getContext('2d');
    canvas.width = img.width;
    canvas.height = img.height;
    ctx.drawImage(img, 0, 0);
    canvas.toBlob(function(compressedBlob) {
      console.log('Image compressed.');
      callback(compressedBlob);
    }, 'image/jpeg', quality);
  };
}
<div id="bulkContent" class="tab-content">
  <div class="imageContent-centrecontainer" style="margin-left: 150px;">
    <p class="header-card">Bulk Image Tool</p>
    <div class="imagecontent-container">
      <div class="imageform-container">
        <form>
          <div class="custom-input-container">
            <!-- Updated input for folder selection -->
            <label for="folderInput" class="custom-button">
                                <i class="fa-solid fa-cloud-arrow-down" style="display: grid; justify-content: center;"></i>
                                Drag &amp; Drop Or Select
                            </label>
            <div id="fileList" class="file-list"></div>
            <!-- Folder input -->
            <input type="file" id="folderInput" class="custom-input" webkitdirectory multiple>
          </div>
          <button class="custom-button-process" type="button" onclick="processFolderImages()">Process Images</button>
          <div id="bulk_output"></div>
        </form>
      </div>
    </div>
  </div>
  <div class="imgdisplay-container">
    <div class="imgpreview-container" id="dragAndDropArea">
      <div id="bulk_selectedFilesPreview">

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

Javascript Drag and drop children without triggering dragstart for parent

I have HTML like this

<details draggable="true" open="">
<summary>author</summary>
<div draggable="true">name</div>
<div draggable="true">company</div>
</details>

I want seperate “dragstart” event listeners for the divs and a third for the containing block when i start my cursor on summary.

Currently div.addEventListener("dragstart", (event) => {}) also fires the event for the parent when the child divs are dragged. I did try event.stopPropagation but that makes the drop stop working when i drop onto a rich text field (the dataTransfer data doesn’t transfer).

Error: apiRequestContext.get: getaddrinfo ENOTFOUND Playwright

I’m trying to execute this API test:

import { test } from "@playwright/test";

test("health check request", async ({ request }) => {
  await request.get(`<my-url>`);
});

When I execute this test I’m getting Error: apiRequestContext.get: getaddrinfo ENOTFOUND <my-url> error.

Full Error Message:

Error: apiRequestContext.get: getaddrinfo ENOTFOUND <my-url>
Call log:
  - → GET <my-url>
  -   user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.6533.17 Safari/537.36
  -   accept: /
  -   accept-encoding: gzip,deflate,br


    at testsexample.spec.ts:4:17

I’ve tried with demo apps and then the test ran just fine, so my machine probably OK.

From what I’ve found about this error message it looks like node related error, but as I’ve already mentioned, I’ve tested with other demo API apps and no error occur.

Domain Masking (?) and Security

If I have www.mydocs.com where people make & host documents which can be shared with people e.g.

www.mydocs.com/doc1

However, they may want it to look like it’s come from their site, so rather than the above it may be

documents.customsite.com/doc1

I believe this can be achieved with the customer putting in a cname within their DNS ? Is this called domain masking?

My question…

Ultimately the customer wants to make it so their documents are not publically available. If they do the cname/domain masking can they then put security in place to ensure they have to be logged in to documents.customsite.com or because its “redirecting” to my site are they limited in what they can do?

can I block someone from just putting a Cname/domain masking to a site, but still allow the site to be embedded in an iframe?

Create a login/signup page which toggles the visual display based on the button clicked

New to this, trying to create a page for login and signup with two side by side forms. The with the left button the left form toggles display on and the right form toggles display off, and viceversa.
I am using html, css JS, bootstrap
So far I’m happy with the display, though it is not responsive yet. However having trouble with the toggle function, since It’s my first time trying it. I know I must be doing so many things wrong.
Here is a visual: enter image description here

I had tried using the form-popup class (I think it’s necessary?) and the modal class, but it ruined my entire formatting.

Buttons:

    <div class="d-flex justify-content-center align-items-center" id="loginBtn">
                <a class="btn btn-secondary" onclick="openForm()" id="login-button" href="/signup-login">Login </a>
                <a class="btn btn-secondary" onclick="openForm2()" id="signup-button" href="/signup-login">Sign Up </a>
            </div>

Login/Signup page:

<jsp:include page="include/header.jsp"/>

<link rel="stylesheet" href="/assets/css/signup-login.css">


<script>
    function openForm() {
        document.getElementById("myForm").style.display = "block";
            document.getElementById("myForm2").style.display = "none";
    }

    function openForm2() {
        document.getElementById("myForm2").style.display = "block";
        document.getElementById("myForm").style.display = "none";
    }

</script>


<div id="main-wrapper" class="container" style="background: #467678;padding-top: 3rem">
    <div class="row justify-content-center" style="background: violet">
        <div class="col-xl-10" style="background: lightgoldenrodyellow">
            <div class="card-body p-0" style="background: #a3d4f6">
                <div class="row no-gutters" style="background: darkseagreen">
                    <div class="col-6 form-container" style="background: #eab29c"> <!-- Add margin-right here -->

                        <div class="p-5">
                            <div class="mb-5">
                                <h2 class="font-weight-bold text-theme">Sign Up</h2>
                            </div>
                            <p class="text-muted mt-2 mb-5"></p>

                            <form>
                                <div class="form-group">
                                    <label for="exampleInputEmail1">Email address</label>
                                    <input type="email" class="form-control" id="exampleInputEmail1">
                                </div>
                                <div class="form-group mb-5">
                                    <label for="exampleInputPassword1">Password</label>
                                    <input type="password" class="form-control" id="exampleInputPassword1">
                                </div>
                                <button type="submit" class="btn btn-theme">Sign Up</button>
                                <button type="button" class="btn cancel" onclick="closeForm2()">Close</button>
                            </form>
                        </div>
                        <p class="text-muted text-center mt-3 mb-0">Have an account? <a href="" class="text-primary ml-1" onclick="openForm2()">register</a>
                    </div>
                    <div class="col-6 pl-3 form-container" style="background: #9ceaea"> <!-- Change this line -->
                        <div class="p-5">
                            <div class="mb-5">
                                <h2 class="font-weight-bold text-theme">Login</h2>
                            </div>

                            <p class="text-muted mt-2 mb-5">Log in by entering your email address and password.</p>

                            <form>
                                <div class="form-group">
                                    <label for="exampleInputEmail2">Email address</label>
                                    <input type="email" class="form-control" id="exampleInputEmail2">
                                </div>
                                <div class="form-group mb-5">
                                    <label for="exampleInputPassword2">Password</label>
                                    <input type="password" class="form-control" id="exampleInputPassword2">
                                </div>
                                <button type="submit" class="btn btn-theme">Login</button>
                                <a href="#" class="forgot-link float-right text-primary">Forgot password?</a>
                                <button type="button" class="btn cancel" onclick="closeForm2()">Close</button>
                            </form>
                        </div>
                        <p class="text-muted text-center mt-3 mb-0">Don't have an account? <a href=""
                                                                                              class="text-primary ml-1"
                                                                                              onclick="openForm()">register</a>
                 </div>
                    </div>
                    <!-- end card-body -->
                </div>
                <!-- end card -->
                </p>

                <!-- end row -->

            </div>
            <!-- end col -->

        </div>
        <!-- Row -->
    </div>
</div>

Can you force a nested svg element to not be cut by other svg elements that are after it in the stacking order

enter image description here

It’s an svg map of countries and some of them you can click and a popup appears. With javascript I’m adding a svg element centered pins to the respective element country yet as you can see from the image, it gets cut by other countries. That is because there are other countries below the current one in the svg file – the stacking order.

Alas I’d hope for an easy way to force them to be on top of every country or perhaps it’s more complicated?

Tools to ensure a third-party npm package library has unit-testing

Let’s keep this question focused on the tools/services that ensure third-party Javascript/Typescript code is tested and can be run for all packages in a monorepo / or flat repo at scale (for up to 100k packages).

Generic Health requirements

  • has tests and code coverage

  • tests / coverage is passing for that release.

  • has static types and uses strict mode (typescript)

  • issues – number frequency

  • deprecation / archive status

  • security risks (from internal dependencies and base cod e)

  • age of files

  • esm support

  • contributors/maintainers(more the better)

  • stars (github)

Why ask about this?

At scale having thousands (to millions) of packages it becomes increasingly more time consuming to track down deprecated and un-tested / unmaintained codebase as a repo ages.

Add on the complexity of multiple projects and it quickly consumes an entire day/week/month for an upgrade looking through things on a surface level and then diving deeper.

*Ideally it would be great to identify problematic / untested packages in usage and then flag the package and let the user know that they need to manually add testing for that node module (and contribute it) or consider an alternative.
*

The ideal solution would do the following (and maybe nothing does this yet)

  • tracks down a package from the host repo url, reports the code testing coverage. Likely attempting to grab it from a testing badge and as a fallback building it…and possibly running the suites (very expensive and error prone).
  • codesmell on how tests are written.
  • reports
    • coverage and test badging
    • package age
    • repo archive status
    • reports last publish date
    • Reports known security issues.
  • generates a possible solution
  • scales and runs for all packages. Brought within node_modules
  • allows for splitting production VS develop dependencies in analysis.
  • provides suggestions and potential alternatives to archived/deprecated/unsecure packages
  • has a way to report this health easily to the associated git hosted repo. (github at minimum)
  • running the same check twice should return similar results. (if this is generative Ai this probably will not meet expectations)

I have looked at

  • dependabot – it does not look for tests nor does it have a way to run or scrape testing results from badges on a github Readme.

Module build Failed in Angular

“I am using the ng s command and the ng build –configuration command, but I am getting an error.

To solve this:-

I removed the node_modules directory and then reinstalled it, but I am still getting an error.As mentioned below screnshot

Delete node_modules folder :-

Add the following lines to your package.json’s dependency section:

"@babel/generator": "7.22.5",

"@babel/parser": "7.22.5",

"@babel/traverse": "7.22.5",

Run npm install
Then ng serve

(https://i.sstatic.net/COsAtzrk.png)