How can I have a JSDoc interface with static properties & methods?

The following is an interface.

/**
 * @interface
 */
class ISomething {
  /**
   * @return {number}
   */
  static aMethod() {
    throw new Error('not implemented');
  }

  /**
   * @type {Object}
   */
  static property;
}

The following is an implementation, and no errors happen if I don’t add the static items.

/**
 * @implements {ISomething}
 */
class Implementation {
  // forgot to implement the static items
  // no errors in VSCode
}

What I want is to similar to how interfaces work but for static items that can be accessed with respect to the class instead of object. I want some error if I forget to implement a static method. Any workarounds and hacks are appreciated.

How to Send Authentication Token from Frontend using Both Fetch & Ajax to Restful API Backend?

I am currently working with django restframwork, I am on my training period. I created a api for lottery management system using DRF and in this restful api i added IsAuthenticated permission class. Now i am creating demo project for this api, now i am using ajax for requests & sending authorization using btoa. but i am sure that this is not a professional method. I wanted to learn how to send the authorization token to backend with username and password. & also how to achieve same in reactjs as i am little bit familiar with react js and working on it as well.


function ajaxCall(type, url, data, callback) {
  /**Common Method to handle all the Ajax Requests */
  $.ajax({
    url: url,
    type: type,
    data: data,
    headers: {
    "Authorization": "Basic " + btoa(USERNAME + ":" + PASSWORD)
  },
    success: function (response, status, xhr) {
      console.log(response);
      console.log(xhr);
      if (xhr.status != 204) {
        if (callback) {
          callback(response);
        }
      }
    },
    error: function (xhr, status, error) {
      console.error("Error occurred:", xhr.responseText, status, error);
    },
  });
}

AR.js Image Recognition Not Working After Training with Marker Generator and Need to use images without Frame

I’m working on a Web AR project using AR.js and AFrame. First I used MindAR.js but it didn’t work Well.So, I trained images using the AR.js Marker Generator (link here), but the app doesn’t recognize the image even after training(.patt). The marker also has a frame and I need to continue without that too. Here I attached my sample project’s code.

What I’ve tried:

  • Used the Marker Generator tool to train images.

  • Implemented a simple app with the trained image in the web app by following this source code.

So, I want to create a web app that works on the web, so it’s accessible to everyone without needing native apps. So because of these problems, I’m thinking of moving to separate web projects with ARKit for iOS and ARCore for Android.
My questions are,

  • How can I fix the image recognition issue with AR.js?

  • Also, how to use images without the Frames and is it possible?

  • Should I consider ARKit/ARCore for this or is there a better solution for web-based AR?

  • Can I develop a Web App using Unity3D for this senario? (It would be better if I could do the RnD part and create a sample project for free)

<!– begin snippet: js hide false console: true babel: false babelPresetReact: true babelPresetTS: false –>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <meta name="theme-color" content="#000000" />
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
    <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
    <link rel="icon" type="image/png" href="/favicon.png" />
    <script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script>
    <script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar.js"></script>
    <title>React App</title>
  </head>

  <body>
    <a-scene embedded arjs>

      
<!-- This market works well -->
      <a-marker type="pattern" url="https://raw.githubusercontent.com/flippedcoder/blog-examples/main/clear-world/pattern-check.patt">
        <a-entity gltf-model="https://raw.githubusercontent.com/MasterLWA/AR-with-Mind-JS/main/public/assets/scenenew.glb"
                  scale="0.4 0.4 0.4" 
                  position="0 0 -1" 
                  rotation="0 0 0">
        </a-entity>
      </a-marker>

      
<!-- Marker which by me is not working -->
      <a-marker type="pattern" url="https://raw.githubusercontent.com/MasterLWA/AR-with-Mind-JS/main/public/assets/scene2.patt">
        <a-entity gltf-model="https://raw.githubusercontent.com/MasterLWA/AR-with-Mind-JS/main/public/assets/Elephant.glb" 
                  scale="0.5 0.5 0.5" 
                  position="0 0.5 -0.5" 
                  rotation="0 90 0">
        </a-entity>
      </a-marker>

      
<!-- Camera Entity -->
      <a-entity camera></a-entity>
    </a-scene>

    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
  </body>
</html>

<!– end snippet –>

Highly Appreciate your help. TIA

WordPress 6.6 Gutenberg “paste” event propagation from inner WYSIWYG editor

I have a custom Gutenberg plugin which adds a custom block with React Quill editor in said block. Before 6.6 version if I pasted content in Quill editor things would work as expected – content will be added into the WYSIWYG area. However since updating WordPress to version 6.6 now paste event seems to propagate further into Gutenberg code where instead of adding copied content into WYSIWYG it adds the content as a simple “Paragraph” type block completely replacing custom active block with Quill in it.

Is there some obvious configuration option that can be changed in WordPress or Gutenber in order to prevent paste event propagating from the Quill editor further into Gutenberg?

How to send patch request in Mongodb using node JS when there is no frontend?

I need to develop an backend service of sending details of comic book. The project only has backend and no frontend
I have made APIs for adding , getting and deleting the data
But i don’t know how to edit details using patch request when there is no frontend
My idea is to send request like this->

localhost3000/editcomic/:_comicID/{send the body}

The body is the input in Postman which i want to send
Like if i want to change the year then i will send

{
"year" : "1960}
}

By sending this only year will change and nothing else
How can i do this?

Cannot use ‘insertAdjacentHTML’ inside a JSON fetch

So I’m creating this script that goes trough a list of ahref links,

  • checks if they’re a github.com link,
  • fetches a JSON file based on that github link,
  • and prepends a <strong>2024-10-20</strong> element with the date key from this JSON file.

The problem is, if I console.log(jsonResponse.date) the JSON response, inside of this fetch, the date appears to be outputted, as a string.
But when I try to use it on a insertAdjacentHTML I get an error.

TypeError: Cannot read properties of undefined (reading ‘insertAdjacentHTML’)
at getSuggestions (scripts.js:78:17)

Which points to this line: gitLinks[i].insertAdjacentHTML


Here is my code:

HTML:

<div class="page-content">
    <ul>
        <li><a href="//github.com/NoahY/q2a-badges">Badges Plugin</a>. Provides user badges which recognize users' activities and achievements.</li>
        <li><a href="//github.com/amiyasahu/q2a-breadcrumbs">Breadcrumbs Widget</a>. Displays navigational breadcrumbs showing the path to the currently viewed page.</li>
        <li><a href="//github.com/arjunsuresh/q2a-betterpoints">Better Points</a>. Extends the default point system by adding points for giving comments, receiving comment upvotes/downvotes.</li>
    </ul>
</div>

JS:

const gitLinks = document.querySelectorAll('.page-content li a[href*="https://github.com/"]');

let jsonDates = [];

for(var i=0; i<gitLinks.length; i++) {
    const getGithubHref = gitLinks[i].getAttribute('href');

    const githubDomain = 'https://github.com/';
    const githubRepository = getGithubHref.slice(getGithubHref.indexOf(githubDomain) + githubDomain.length);
    const githubJSON = 'https://raw.githubusercontent.com/' + githubRepository + '/master/metadata.json';
    
    const getDates = async () => {
        try {
            const response = await fetch('https://raw.githubusercontent.com/amiyasahu/q2a-breadcrumbs/master/metadata.json');
            if(response.ok){
                let jsonResponse = await response.json();
                console.log(jsonResponse.date);
                
                gitLinks[i].insertAdjacentHTML(
                    'beforebegin',
                    `<strong>${jsonResponse.date}</strong>`,
                );
                
                jsonDates.push(jsonResponse.date);
            }
        }
        catch(error) {
            console.log(error);
        }
    }
    getDates();
}

console.log(jsonDates);

  • I’ve also tried to push the responses to and empty array jsonDates, but it doesn’t work either. The array returns empty.
  • If I move the gitLinks[i].insertAdjacentHTML outside the fetch, it prepends normally.
    I can’t figure out what the problem is.

Get custom property in addLayer ‘layout’ – works selectively

I’m using Mapbox GL JS to create custom maps with travel-tours and I have following “strange” error:

That’s my “code”:

const transportIconGeoJsonData = {
    'type': 'FeatureCollection',
    'features': [
        {
            'type': 'Feature',              
            'geometry': {
                'type': 'Point',
                'coordinates': [-59.492456, 13.074603]
            },
            'properties': {
                'icon': 'planeIcon',
                'rotate': true,
                'alignment': 'map'
            }
        },
        {
            'type': 'Feature',              
            'geometry': {
                'type': 'Point',
                'coordinates': [-60.992936, 14.020228]
            },
            'properties': {
                'icon': 'shipIcon',
                'rotate': false,
                'alignment': 'viewport'
            }
        },
    ]
};


map.on('load', () => {
    map.addSource('transportSourceIcon', {
        'type': 'geojson',
        'data': transportIconGeoJsonData
    });

    map.addLayer({
        id: 'transport-icon',
        type: 'symbol',
        source: 'transportSourceIcon',
        layout: {
            'icon-image': ['get', 'icon'], // <- works perfectly!
            'icon-size': 0.5,
            'icon-rotate': ['get', 'rotation'], // <- works perfectly!
            'icon-rotation-alignment': ['get', 'alignment'], // <- does not work ...
            'icon-allow-overlap': true,
            'icon-ignore-placement': true
        }
    });
});

I’m able to get properties “icon” and “rotation” but not “alignment”.
Console show’s:

Error: layers.transport-icon.layout.icon-rotation-alignment: data expressions not supported

How is it possible? What am I missing?!

Thanks for help!

If I try to output property manually in console like:
console.log(transportIconGeoJsonData.features[0].properties.alignment);

Work’s perfectly and show’s “map” or “viewport” (if ..features.[1])

Chrome extension declarativeNetRequest, updateDynamicRules, id for new rule being added is never unique

I wanna make a chrome/edge extension that whenever a URL request is made (like googling, or entering something like a search or a site into the URL bar), checks whether it contains certain keywords, and blocks the request if it does.

So far all the syntax is correct, but I keep getting an error on the Rule.id property, and I cannot find out why.

(async () => {
  await chrome.declarativeNetRequest.updateDynamicRules(
    // options
    {
        // Rule[]
        addRules: [
            // Rule
            {
                action: {
                    type: "block"
                },
                // RuleCondition
                condition: {
                    // string
                    urlFilter: "*youtube|test1*"
                },
                id: 1
            }
        ]
    }
  );
})();

A “fix” is to remove the parameter parenthes at the end of the async function (because updateDynamicRules() is a promise), but then its not a function so nothing gets executed.
Another thing I’ve tried, which shows the problem isn’t the Rule.id itself, is setting the id as both 1, 2, and twice a random number – every time i get “Error: Rule with id x does not have a unique ID.” and error pointer thing pointing at line 22, which btw is where the code ends.

To display this webpage correctly, resubmit the data you entered earlier. By doing this, you will repeat any action this page previously performed

this issue related to history.back(), then later I replace with window.location.replace(document.referrer) in my local.
finalize in UAT environment, the issue still there.

also tried with history.go(-1) / window.location.href=”, but failed

now I will try this,

if (typeof window.history.replaceState === 'function') {
    window.history.replaceState(null, null, window.location.href);
}

I need other ways to counter this resubmission issue except from above.

Cannot show autocomplete suggestions method of Sequelize.define when export and require

[Question]
IDE vscode, I have been using Sequelize define model but it doesn’t show the right method when I export to controller. What an I missing?


Node 18 project-commonjs

struct

          [+] dbConfig
         -- config1.js
          [+] Model
          - model1.js
          - model2.js
          ....
          - index_model.js
        
          [+] Controller
          - model1Controller.js

model1.js


      module.exports = function(sequelize, DataTypes) {
        const model1 = sequelize.define('model1', {
          id: {
            autoIncrement: true,
            type: DataTypes.INTEGER,
            allowNull: false,
            primaryKey: true
          },
          name: {
            type: DataTypes.STRING(100),
            allowNull: true
          }
        }, {
          sequelize,
          tableName: 'table1',
          schema: 'dbo',
          timestamps: false
        });
      return model1  
      };

config1.js


      const { Sequelize } = require('sequelize');
      const sequelize = new Sequelize(
          DB_NAME,
          DB_ACC,
          DB_PASS,
          {
            host:  DB_HOST,
            port: 1231,
            dialect: 'mssql',
            dialectOptions: ...  
          }
        
        );
      module.exports = sequelize;

index_model.js

 
      var {Sequelize, DataTypes , Model} = require("sequelize");
      var sequelize  = require("../dbConfig/config1");
      var  _model1 = require("./model1");
      function initModels(sequelize) {
        const Mode1 = _model1(sequelize,DataTypes )
      }
      module.exports = initModels;
      module.exports.initModels = initModels;
      module.exports.default = initModels;

Controller/model1Controller.js

      var {Sequelize, DataTypes , Model} = require("sequelize");
      var  {initModels} = require("../Model/index_model");

      //issue: it's not show method of Model such as: findAll, .... 
      initModels.model1.????

method of model

I need to show autocomplete suggestions method when calling model in controller

Why do I need an else statement to check for keys in an object in Javascript?

I’m doing Leetcode Question Number 49..

I entered this but it did not work.

var groupAnagrams = function(strs) {
    if (strs.length <= 1) {
        return [strs]
    }

    const hashMap = {}

    for(let i = 0; i < strs.length; i++) {
        const currentKey = strs[i].split('').sort().join('')

        if (hashMap[currentKey]) {
            hashMap[currentKey].push(strs[i])
        }

        hashMap[currentKey] = [strs[i]]
    }

    return Object.values(hashMap)
};

Then I asked ChatGPT and it asked me to put it in an else statement

var groupAnagrams = function(strs) {
    if (strs.length <= 1) {
        return [strs]
    }

    const hashMap = {}

    for(let i = 0; i < strs.length; i++) {
        const currentKey = strs[i].split('').sort().join('')

        if (hashMap[currentKey]) {
            hashMap[currentKey].push(strs[i])
        } else {
            hashMap[currentKey] = [strs[i]]
        }
    }

    return Object.values(hashMap)
};

It works, but I don’t get why/how it works. Why does it need to be in an else statement? Is it because I’m not returning anything? I thought the event loop will skip the command inside the if statement if the condition is not met?

How do I make my navbar items vertical while letting the logo and icon stay on top

It’s my first time doing some responsive design and I use this as an excercise. But after trying this for several hours I’m desperate now. So I have a simple Navbar with a logo at the left corner, four nav-items in the middle and three buttons at the right.

When the viewport is reaching a width of 912px, I hide the nav-items in the middle. Now only the Logo at the left stays and the three buttons at the right are replaced with a burger menu icon.

When I click on the hamburger menu icon, the nav-items should appear and stack vertically below the logo and menu icon. But they are just appearing somewhere between the the logo and the menu. At this point I’m too unexperienced to resolve the issue. So I’m kindly asking for help.

Link to JSFiddle: https://jsfiddle.net/0nrc1wq4/1/

<html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="preconnect" href="https://fonts.googleapis.com">
        <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
        <link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap"
          rel="stylesheet">
        <link rel="stylesheet" type="text/css" href="navbar.css" />
    </head>

<body>
    <header>
        <nav>
            <img src="../images/logo-small.svg" alt="Logo" id="icon-logo" class="corner-item-left" />
            <ul>
                <li class="nav-item"><a class="nav-link" href="#Willkommen">Willkommen</a></li>
                <li class="nav-item"><a class="nav-link" href="#Wohnen">Wohnen</a></li>
                <li class="nav-item"><a class="nav-link" href="#Kleinwalsertal">Kleinwalsertal</a></li>
                <li class="nav-item"><a class="nav-link" href="#Kontakt">Kontakt</a></li>
            </ul>
            <ul>
                <li class="icon-item"><button class="icon-button" id="icon-phone"><img src="../images/icon-phone.svg" alt="Telefon"/></button></li>
                <li class="icon-item"><button class="icon-button" id="icon-contact"><img src="../images/icon-contact.svg" alt="Kontakt"/></button></li>
                <li class="icon-item"><button class="icon-button corner-item-right" id="icon-booking"><img src="../images/icon-booking.svg" alt="Buchen"/></button></li>
            </ul>
            <button class="burger-menu-button" id="burger-menu">☰</button>
        </nav>
    </header>

    <script>
        const burgerMenu = document.getElementById("burger-menu");
        const logo = document.getElementById("icon-logo");
        const navUl = document.querySelector("nav ul");

        function toggleMenu() {
            toggleLogo();
            toggleBurgerMenuIcon();
            toggleNavVisibility();
        }

        function toggleLogo() {
                if (logo.src.includes("logo-small.svg")) {
                    logo.src = "../images/logo-filled.svg";
                } else {
                    logo.src = "../images/logo-small.svg";
                }
        }

        function toggleBurgerMenuIcon() {
            if (burgerMenu.innerHTML === "☰") {
                burgerMenu.innerHTML = "✖";
            } else {
                burgerMenu.innerHTML = "☰";
            }
        }

        function toggleNavVisibility() {
            navUl.classList.toggle("nav-visible");
        }

        burgerMenu.addEventListener("click", toggleMenu);
    </script>
</body>

HTML & JS:

Thank you in advance!

ticket accept auotmation in service now

I’m researching on how we can automate ticket acceptance in servicenow.

Scenario:-
For example if there is an outage and getting 1k+ tickets opened in servicenow and team is not able accept the tickets in servicenow within the SLA.

I need some opinion on how we can we automate this .For a specific assignment group if they are getting 10 – 100 tickets at the same time , the ticket should automatically and accept and send a notification to the assign and the entire members in the team that these tickets has been automatically accepted.

looking for suggestions and opinion on this…….