Javascript/SVG – draw a clock hand pointing to the cursor, then be able to get/set it as a percentage

I’d like a clock-like object that points to the cursor position from the centre of the clock and reports/sets the position of the ‘hand’ in terms of its percentage around the circle.

I’ve gotten as far as the following, which has these problems:

  1. calculating the angle of the ‘hand’ is relative to the whole svg, not the circle. The circle might be in any position within the svg viewbox, so calculating the angle would be relative to the centre of that circle.
  2. the ‘0’ percentage is at the 3 o’clock position rather than 12 o’clock.
// Get SVG and clock hand elements
const svg = document.getElementById('clock-svg');
const clockHand = document.getElementById('clock-hand');
const pc = document.getElementById('pc');
const handLength = 40; // clock hand length, matches the r of the circle
const circleX = 100;
const circleY = 100;

// listen to percentage spin control input event
pc.addEventListener('input', function(event) {
  changePercentage(event.target.value);
});

// Add mousemove event listener
svg.addEventListener('mousemove', function(event) {

// Calculate mouse position relative to the SVG
const svgRect = svg.getBoundingClientRect(); // TODO make it relative to the position of the circle inside the SVG
const mouseX = event.clientX - svgRect.left; // TODO do I need to convert the DOM event coordinates to SVG coordinates?
const mouseY = event.clientY - svgRect.top;

// Calculate angle of the mouse position relative to the center of the clock
let angle = Math.atan2(mouseY - 100, mouseX - 100);  // TODO what happens when the document is scrolled? clientX and clientY are relative to the viewport, not the document?

updateHand(angle);

// Calculate percentage of the circle completed
let percentage = (angle / (2 * Math.PI)) * 100;

// angle is negative when mouse is on the left side of the clock, lets adjust for that
if (percentage < 0) percentage += 100;

// set the percentage input control
document.getElementById('pc').value = parseInt(percentage,10);
});

function changePercentage(percentage) {

  // Calculate angle based on percentage
  const angle = (percentage / 100) * 2 * Math.PI;
  updateHand(angle);
  
}

// Update clock hand position for the angle
function updateHand(angle) {
  const handX = circleX + handLength * Math.cos(angle);
  const handY = circleY + handLength * Math.sin(angle);
  
  clockHand.setAttribute('x2', handX);
  clockHand.setAttribute('y2', handY);
}
<input type="number" id="pc" min="0" max="100" value="0">
<br>
<svg id="clock-svg" width="250" height="300" viewBox="50 50 250 150" style="border:1px solid black">
    <rect x="0" y="0" width="100%" height="100%" fill="lightgrey" />
    <circle cx="100" cy="100" r="40" fill="none" stroke="black" stroke-width="2" />
    <line id="clock-hand" x1="100" y1="100" x2="120" y2="120" stroke="black" stroke-width="2" />
</svg>

My rusty math has only gotten me this far, i need to remove a half radian somewhere yes? How do I make the angle relative to the centre of the circle not the size of the svg object?

Filter deep nested JSON object array in Javascript using lodash [closed]

I am working on hybrid application using AngularJS and Angular 8. I have dropdown filter with nested list and input search filter.I am trying to use lodash library for deep filtering but unable to get it work.

Here is the sample JSON Object array

var objArr = {
    "page_size": 100,
    "total": 5,
    "size": 5,
    "page_offset": 0,
    "items": [
        {
            "name": "Program Governance",
            "status": "active",
            "id": "PL-Ca3d6c3bf060",
            "created_by": "191ad6043e2e",
            "created_time": 1535619902.0,
            "subcategories": [
                {
                    "name": "Risk & Issue Management",
                    "status": "active",
                    "id": "PL-Ca9ab6aed051",
                    "created_by": "191ad6043e2e",
                    "created_time": 1543489628.0,
                    "subcategories": []
                },
                {
                    "name": "Process & Tools",
                    "status": "active",
                    "id": "PL-Ca1fd776d743",
                    "created_by": "191ad6043e2e",
                    "created_time": 1565863427.0,
                    "subcategories": []
                },
                {
                    "name": "Planning",
                    "status": "active",
                    "id": "PL-Caeb46a6dce6",
                    "created_by": "191ad6043e2e",
                    "created_time": 1535620426.0,
                    "subcategories": []
                },
                {
                    "name": "Monitoring & Tracking",
                    "status": "active",
                    "id": "PL-Caeb46a6d1b2",
                    "created_by": "191ad6043e2e",
                    "created_time": 1535620426.0,
                    "subcategories": []
                },
                {
                    "name": "Compliance to Standards",
                    "status": "active",
                    "id": "PL-Ca0c8335afc6",
                    "created_by": "191ad6043e2e",
                    "created_time": 1535621467.0,
                    "subcategories": []
                }
            ]
        },
        {
            "name": "Engineering Maturity",
            "status": "active",
            "id": "PL-Ca3891dbcd9c",
            "created_by": "191ad6043e2e",
            "created_time": 1535620156.0,
            "subcategories": [
                {
                    "name": "Requirements Management",
                    "status": "active",
                    "id": "PL-Ca53e3a3f610",
                    "created_by": "191ad6043e2e",
                    "created_time": 1535620405.0,
                    "subcategories": []
                },
                {
                    "name": "Technical Solution Management",
                    "status": "active",
                    "id": "PL-Ca6b44070713",
                    "created_by": "191ad6043e2e",
                    "created_time": 1565863770.0,
                    "subcategories": []
                },
                {
                    "name": "Quality Assurance",
                    "status": "active",
                    "id": "PL-Cac7a654f1c9",
                    "created_by": "191ad6043e2e",
                    "created_time": 1535620387.0,
                    "subcategories": []
                },
                {
                    "name": "CI/CD Management",
                    "status": "active",
                    "id": "PL-Ca7ba190bcca",
                    "created_by": "191ad6043e2e",
                    "created_time": 1565863878.0,
                    "subcategories": []
                }
            ]
        },
        {
            "name": "Team Management",
            "status": "active",
            "id": "PL-Ca009c852e4a",
            "created_by": "191ad6043e2e",
            "created_time": 1535619879.0,
            "subcategories": [
                {
                    "name": "Technical Expertise",
                    "status": "active",
                    "id": "PL-Ca6c3344d6cf",
                    "created_by": "191ad6043e2e",
                    "created_time": 1565864050.0,
                    "subcategories": []
                },
                {
                    "name": "Team Design",
                    "status": "active",
                    "id": "PL-Ca414304c958",
                    "created_by": "191ad6043e2e",
                    "created_time": 1535620904.0,
                    "subcategories": []
                },
                {
                    "name": "Team Engagement",
                    "status": "active",
                    "id": "PL-Cafe3fcd7218",
                    "created_by": "191ad6043e2e",
                    "created_time": 1535620895.0,
                    "subcategories": []
                },
                {
                    "name": "Team Fulfillment",
                    "status": "active",
                    "id": "PL-Ca59511f47d7",
                    "created_by": "191ad6043e2e",
                    "created_time": 1565863978.0,
                    "subcategories": []
                },
                {
                    "name": "Domain Expertise",
                    "status": "active",
                    "id": "PL-Ca375bc31659",
                    "created_by": "191ad6043e2e",
                    "created_time": 1535620915.0,
                    "subcategories": []
                }
            ]
        },
        {
            "name": "Client Management",
            "status": "active",
            "id": "PL-Ca03453473e2",
            "created_by": "191ad6043e2e",
            "created_time": 1535619885.0,
            "subcategories": [
                {
                    "name": "Client Satisfaction",
                    "status": "active",
                    "id": "PL-Da414304c960",
                    "created_by": "PR-EmQR61tch032",
                    "created_time": 1535620904.0,
                    "subcategories": []
                },
                {
                    "name": "Stakeholder Management",
                    "status": "active",
                    "id": "PL-Ca7ff7f293a5",
                    "created_by": "191ad6043e2e",
                    "created_time": 1535621056.0,
                    "subcategories": []
                },
                {
                    "name": "Value Strategy",
                    "status": "active",
                    "id": "PL-Ca632e3b4005",
                    "created_by": "191ad6043e2e",
                    "created_time": 1535621083.0,
                    "subcategories": []
                },
                {
                    "name": "Contract Management",
                    "status": "active",
                    "id": "PL-Ca632e8a41a7",
                    "created_by": "191ad6043e2e",
                    "created_time": 1535621083.0,
                    "subcategories": []
                }
            ]
        },
        {
            "name": "Financials",
            "status": "active",
            "id": "PL-Ca49906fcb17",
            "created_by": "191ad6043e2e",
            "created_time": 1535619853.0,
            "subcategories": [
                {
                    "name": "Revenue",
                    "status": "active",
                    "id": "PL-Ca873f87fde3",
                    "created_by": "191ad6043e2e",
                    "created_time": 1535620651.0,
                    "subcategories": []
                },
                {
                    "name": "Labor Expenses",
                    "status": "active",
                    "id": "PL-Ca5ecf370d0f",
                    "created_by": "191ad6043e2e",
                    "created_time": 1535620664.0,
                    "subcategories": []
                },
                {
                    "name": "Other Expenses",
                    "status": "active",
                    "id": "PL-Ca1b195c5dfe",
                    "created_by": "191ad6043e2e",
                    "created_time": 1535620679.0,
                    "subcategories": []
                }
            ]
        }
    ]
}

what I am trying to achieve is that for example if i type “Revenue” or any other subcategories name in the input search box then it should only display object matching that input search box data and filtering out others and vice versa.

example : input search —> Revenue

data to display is given below

{
            "name": "Financials",
            "status": "active",
            "id": "PL-Ca49906fcb17",
            "created_by": "191ad6043e2e",
            "created_time": 1535619853.0,
            "subcategories": [
                {
                    "name": "Revenue",
                    "status": "active",
                    "id": "PL-Ca873f87fde3",
                    "created_by": "191ad6043e2e",
                    "created_time": 1535620651.0,
                    "subcategories": []
                }
            ]
        }

Screenshot
List View

Is there any solution to achieve this using lodash or without it, as I am completely stuck in this ?

Nodejs express middleware handle dynamic routes

I am creating a NodeJS Express app and I have routes like

    //Check authorization middleware for specification routes. This will check users have access to specifications
    app.use('/api/auth/specification',SpecificationEp.checkAuthorization)

    app.get('/api/auth/specification/get/:companyId/:projectId?', SpecificationEp.getSpecificationByCompanyIdOrProjectId);
    // Remove specifications from project and specification collection
    app.get('/api/auth/specification/delete/:companyId/:projectId?', Util.withErrorHandling(SpecificationEp.deleteSpecificationById));

In my SpecificationEp.checkAuthorization middleware function I need companyId and projectId. But it is not possible right now. So I cannot reuse this middleware. How can I do that. Is there any way to solve this.

Thank you

currently for SpecificationEp.checkAuthorization, projectId and companyId is undefiend. I think it is expected because in middleware route there is no such dynamic parameters.

I want to reuse that middlware SpecificationEp.checkAuthorization. Please help me. Thank you

How we can add text in twitter’s comment section ( twitter pro ) using java script? [closed]

let a = document.getElementsByClassName('public-DraftStyleDefault-block')[0].childNodes[0];
    const wordToInsert = generatedResponse;  // generatedResponse is my text that generated by API

    a.innerHTML = wordToInsert;
    const inputEvent = new Event('input', {
        bubbles: true,
        cancelable: true
    });
    a.dispatchEvent(inputEvent);

As per above variable “a” contain a twitter comment section and in that I want to place my text that generate by API when I click a button.

When open a post there is a one button that added by DOM methods that display with twitter’s default comment button and when click that button text successfully added to comment section and see immediately inside normal twitter account but inside pro account of twitter can’t see the text in comment section immediately.

In pro account need to move back and if again visit same post then I can see the text in comment section.

this JS function is not properly showing all the files in the hierarchy

function toggleSubMenu(element) {
    var ulElement = element.querySelector('ul.submenu');
    if (ulElement) {
        // Toggle the clicked submenu
        ulElement.classList.toggle('show');

        // Display all sibling ul elements inside the same li
        var siblingUlElements = Array.from(element.parentNode.children)
            .filter(child => child.tagName.toLowerCase() === 'ul' && child.classList.contains('submenu'));
        siblingUlElements.forEach(function (siblingUl) {
            if (siblingUl !== ulElement) {
                siblingUl.classList.toggle('show', ulElement.classList.contains('show'));
            }
        });

        // Display all nested li elements
        var nestedLiElements = ulElement.querySelectorAll('li');
        nestedLiElements.forEach(function (nestedLi) {
            nestedLi.style.display = ulElement.classList.contains('show') ? 'list-item' : 'none';
        });

        // If it's a top-level li, hide/show all other sibling top-level ul elements
        if (element.parentNode.tagName.toLowerCase() === 'li') {
            var topParentLi = element.parentNode.closest('li');
            var topSiblingUlElements = Array.from(topParentLi.parentNode.children)
                .filter(child => child.tagName.toLowerCase() === 'ul' && child.classList.contains('submenu') && child !== ulElement);
            topSiblingUlElements.forEach(function (topSiblingUl) {
                topSiblingUl.classList.remove('show');
            });
        }
    }
}

this is the js function that is supposed to show or hide the nested ul, li’s

         basically when I select bruhloon ,  it drops down to its folder showing the kabob.rar  however it does not show the other folders next to it.               they are however showing up in the html    just not as shown

this is the php script that generates the list.

Function generateUsersMenu($path, $isTopLevel = true) {
        $folders = glob($path . '/*', GLOB_ONLYDIR);

        // Add 'show' class only for top-level ul
        $ulClass = $isTopLevel ? 'show' : '';

        echo '<ul class="submenu ' . $ulClass . '">';

        foreach ($folders as $folder) {
            $folderName = basename($folder);
            echo '<li onclick="toggleSubMenu(this)"><strong>' . $folderName . '</strong>';

            $files = glob($folder . '/*.*');
            if (!empty($files)) {
                echo '<ul class="submenu">'; // Do not include 'show' class for submenus
                foreach ($files as $file) {
                    $fileName = basename($file);
                    $fileExtension = pathinfo($file, PATHINFO_EXTENSION);

                    if (in_array($fileExtension, ['txt', 'md', 'cs', 'cpp', 'c','.ini'])) {
                        echo '<li>';
                        echo '<a href="#" onclick="displayFile(event, '' . $fileExtension . '', '' . $file . '')">' . $fileName . '</a>';
                        echo '</li>';
                    } 
                    else if (in_array($fileExtension, ['xtbl'])) {
                        echo '<li>';
                        echo '<a href="#" onclick="displayFile(event, '' . $fileExtension . '', '' . $file . '')">' . $fileName . '</a>';
                        echo '</li>';
                    }
                    else if (in_array($fileExtension, ['lua'])) {
                        echo '<li>';
                        echo '<a href="#" onclick="displayLuaFile('' . $file . '')">' . $fileName . '</a>';
                        echo '</li>';
                    }
                    else if (in_array($fileExtension, ['zip', 'rar'])) {
                        echo '<li><a href="' . $file . '" download>' . $fileName . '</a></li>';
                    } else {
                        echo '<li><a href="' . $file . '" download>' . $fileName . '</a></li>';
                    }
                }
                echo '<div class="comment-board" id="comment-board-' . $folderName . '">';
        echo '<h3>Comments</h3>';
        // Call the PHP function to get comments for the current item
        $comments = getCommentsForItem($folderName);
        foreach ($comments as $comment) {
            // Display comments
            echo '<div class="comment">';
            echo '<strong>User:</strong> ' . $comment['user_id'] . '<br>';
            echo $comment['comment_text'] . '<br>';
            echo '<em>' . $comment['timestamp'] . '</em>';
            echo '</div>';
        }
        echo '</div>';
                echo '</ul>';
            }

            // Recursively display subfolders without 'show' class
            generateUsersMenu($folder, false);

            echo '</li>';
        }

        echo '</ul>';
    }

and here is some child nodes demonstrating when bruhloon is selected.

<li onclick="toggleSubMenu(this)" style="display: list-item;"><strong>bruhloon</strong><ul class="submenu show"><li style="display: list-item;"><a href="users/mods/sr1/bruhloon/Kabob_2.rar" download="">Kabob_2.rar</a></li><div class="comment-board" id="comment-board-bruhloon"><h3>Comments</h3></div></ul><ul class="submenu "><li onclick="toggleSubMenu(this)" style="display: list-item;"><strong>misc</strong><ul class="submenu"><li style="display: list-item;"><a href="#" onclick="displayFile(event, 'xtbl', 'users/mods/sr1/bruhloon/misc/store_weapons.xtbl')">store_weapons.xtbl</a></li><div class="comment-board" id="comment-board-misc"><h3>Comments</h3></div></ul><ul class="submenu "></ul></li><li onclick="toggleSubMenu(this)" style="display: list-item;"><strong>misc2</strong><ul class="submenu"><li style="display: list-item;"><a href="#" onclick="displayFile(event, 'xtbl', 'users/mods/sr1/bruhloon/misc2/store_weapons.xtbl')">store_weapons.xtbl</a></li><div class="comment-board" id="comment-board-misc2"><h3>Comments</h3></div></ul><ul class="submenu "></ul></li><li onclick="toggleSubMenu(this)" style="display: list-item;"><strong>preload_lower</strong><ul class="submenu"><li style="display: list-item;"><a href="users/mods/sr1/bruhloon/preload_lower/p_kab.peg_xbox2" download="">p_kab.peg_xbox2</a></li><li style="display: list-item;"><a href="users/mods/sr1/bruhloon/preload_lower/p_kab.smesh_xbox2" download="">p_kab.smesh_xbox2</a></li><div class="comment-board" id="comment-board-preload_lower"><h3>Comments</h3></div></ul><ul class="submenu "></ul></li></ul></li>

i tried a few different things… but some of those changes ended up causing every single folder and file in the heirarchy to show without slowing opening them as i go down… i dont want them to all be open .. just the children of the subfolder i dropped down… then i should be able to drop down the misc folder which will then show more files… etc,etc,etc… thank you

Add a class to table by JavaScript with conditions

Can anyone tell me how I can add the CSS class “bestvalue” to our table (which is dynamically injected into page so don’t have access to html) for all table rows with a quantity of 300 or more listed? In our example below, that would be the last 2 rows.

<table class="lb-vd-table">
  <thead class="lb-vd-table-head">
    <tr class="vd-table-head-row">
      <th class="lb-vd-table-head-text">QUANTITY</th>
      <th class="lb-vd-table-head-text">PRICE</th>
    </tr>
  </thead>
  <tbody class="lb-vd-table-body">
    <tr class="lb-vd-table-body-row">
      <td class="lb-vd-table-body-text">100</td>
      <td class="lb-vd-table-body-text"><span class="money">$4.00</span></td>
    </tr>
    <tr class="lb-vd-table-body-row">
      <td class="lb-vd-table-body-text">200</td>
      <td class="lb-vd-table-body-text"><span class="money">$3.00</span></td>
    </tr>
    <tr class="lb-vd-table-body-row">
      <td class="lb-vd-table-body-text">300</td>
      <td class="lb-vd-table-body-text"><span class="money">$2.00</span></td>
    </tr>
    <tr class="lb-vd-table-body-row">
      <td class="lb-vd-table-body-text">400</td>
      <td class="lb-vd-table-body-text"><span class="money">$1.00</span></td>
    </tr>
  </tbody>
</table>

Would adding it with JS be the best way?

split single invoice pdf file into multiple pdf files with varying pages using nodejs pdf lib

I’m trying to split the single invoice PDf file into multiple pdf files. an invoice can span across more than1 page and few invoice may be taking just one page. I want to split the pdf file into multiple pdf files as soon as it detects some keyword like invoice as top text on page

I’m using below code to split the file into multiple here it is splitting every page on pdf file into separate file, but i want to split based on the text at the top of the page like “invoice” because few invoices could be taking more than a page

const fs = require('fs');
const PDFDocument = require('pdf-lib').PDFDocument;

async function splitPdf(pathToPdf) {

    const docmentAsBytes = await fs.promises.readFile('C:\Users\Downloads\ilovepdf_merged.pdf');

    // Load your PDFDocument
    const pdfDoc = await PDFDocument.load(docmentAsBytes)

    const numberOfPages = pdfDoc.getPages().length;

    for (let i = 0; i < numberOfPages; i++) {

        // Create a new "sub" document
        const subDocument = await PDFDocument.create();
        // copy the page at current index
        const [copiedPage] = await subDocument.copyPages(pdfDoc, [i])
        subDocument.addPage(copiedPage);
        const pdfBytes = await subDocument.save()
        await writePdfBytesToFile(`file-${i + 1}.pdf`, pdfBytes);

    }
}

function writePdfBytesToFile(fileName, pdfBytes) {
    return fs.promises.writeFile(fileName, pdfBytes);
}

(async () => {
    await splitPdf("./path-to-your-file.pdf");
})();

How to blur rest of the element when someone hover one of them using CSS & JS

<section class="menu-container">
  <p id="option-one" class="menu-option">Option One</p>
  <p id="option-two" class="menu-option">Option Two</p>
  <p id="option-three" class="menu-option">Option Three</p>
  <p id="option-foure" class="menu-option">Option Four</p>
</section>

I have four menu elements with those IDs (option-one, option-two, option-three, option-foure).

When someone hovers over one of them they blur the rest of the options using JS or CSS either the options before or after the hovered element are all blurred but not the hovered element.

How to extract multiple object keys from a JSON file to a new object array using Javascript? [duplicate]

My apologies if this is a really obvious thing to do, I am very new to programming and for the life of me I cannot find the answer to this problem or work it out myself…

I am working with a JSON file that has huge amount of useless object elements. I would like to reduce them down to a new Object Array/JSON variable.

If I’m working with this data as an example:

[
  {
    "_id": "65cd85ac9ad72fc2e7b5cfb8",
    "index": 0,
    "guid": "b3635428-0f5d-4283-99a4-f6d1426febda",
    "isActive": false,
    "balance": "$2,102.10",
    "picture": "http://placehold.it/32x32",
    "age": 40,
    "eyeColor": "brown",
    "name": "Levy Fletcher",
    "gender": "male",
    "company": "ARCHITAX",
    "email": "[email protected]",
    "phone": "+1 (815) 463-2005"
  },
  {
    "_id": "65cd85ac1ec82cc1746bf11a",
    "index": 1,
    "guid": "87025f30-f45d-4989-930b-9c4c426786fe",
    "isActive": false,
    "balance": "$3,434.62",
    "picture": "http://placehold.it/32x32",
    "age": 39,
    "eyeColor": "green",
    "name": "Thomas Kelly",
    "gender": "male",
    "company": "DOGNOST",
    "email": "[email protected]",
    "phone": "+1 (800) 510-2849"
  },
  {
    "_id": "65cd85acf8e2150fb0bd0af9",
    "index": 2,
    "guid": "54b55746-1013-4405-9d8e-5f526e1979b8",
    "isActive": true,
    "balance": "$2,700.90",
    "picture": "http://placehold.it/32x32",
    "age": 35,
    "eyeColor": "blue",
    "name": "Stacie Pratt",
    "gender": "female",
    "company": "MULTRON",
    "email": "[email protected]",
    "phone": "+1 (965) 448-2778"
  }
]

I would like to be able to extract potentially using an array like this:

relevantData = ["age", "name", "email"]

My desired outcome would be this:

[
  {
    "age": 40,
    "name": "Levy Fletcher",
    "email": "[email protected]",
  },
  {
    "age": 39,
    "name": "Thomas Kelly",
    "email": "[email protected]",
  },
  {
    "age": 35,
    "name": "Stacie Pratt",
    "email": "[email protected]",
  }
]

How to change the path of background-image in css modules of Next.js v14 when dev and build

I am using Next.js v14 to create a page with the configuration in the attached image.

enter image description here

In index.module.scss, I am using an image for the background.

Below is a portion of the code.

    &::before {
        left: 0;
        background: url(/img/pc/index_hero_bg1.png) 0 0 repeat-x;
    }

    &::after {
        right: 0;
        background: url(/img/pc/index_hero_bg2.png) 0 0 repeat-x;
    }

The image specified in url is in /public/img, so the image path in url starts at /img.

I want to change the path of url in index.module.scss in npm run dev and npm run build.

The dev is localhost:3000, so I can leave it as it is, but for the build I want it to be on the second level sampledomain.com/path-to-site/.

No search, no blog post, and no answer using Chat GPT.

For example, the answer was to put the environment variable in front of the path, but I get an error.

Also, I don’t know how to configure webpack in next.config.js, because I have no knowledge of webpack.

How to display modified text from data member in :items object array for item-title in v-select (Vuetify) dropdown list?

I am new to Vue and I am currently working with Vuetify to build dropdown “v-select”.

If there is a way, that will be great! Otherwise, I am thinking of creating new array and covert data for some members in objects and copy them to new array and set that array as :items in v-select.

Here is my code

<v-select 
    label="Select a permission to copy"
    variant="underlined"
    item-title="resource"
    no-data-text="No permission to choose from"
    :items="permissionsToCopy"
    v-model="selectedPermissionToCopy"
    return-object
>
</v-select>

for resource in item-title, i want to display like
if it is resource == company_user_licence then I want to display item-title to be Licence Permission: User

I have looked for ways to customize template for item-title, so far i have found ways to make templates for item-text and item-value, not item-title.

Please let me know if the question is not clear or need more details. Thank you!

Stripe Integration Error Unable to parse client secret

I’m using react ts and stripe js to create a checkout form, this is my code:

const [clientSecret, setClientSecret] = useState('');

  useEffect(() => {
    fetch("/create-checkout-session", {
      method: "POST",
    })
      .then((res) => res.json())
      .then((data) => setClientSecret(data.clientSecret));
  }, []);

  return (
    <div id="checkout">
      {clientSecret && (
        <EmbeddedCheckoutProvider
          stripe={stripePromise}
          options={{clientSecret}}
        >
          <EmbeddedCheckout />
        </EmbeddedCheckoutProvider>
      )}
    </div>
  )
  
    

But I’m getting this error when I try to run the form:

Uncaught (in promise) IntegrationError: Unable to parse client secret. Please ensure you are using a valid embedded Checkout client secret.

The secret I’m passing is a string but still get the error no matter what I try.

Thanks in advance.

Polyfill for PerformanceObserver API to Implement Server Traffic Measurement

I’m currently utilizing the PerformanceObserver API to measure server traffic for given endpoints on the client side. However, I’m exploring alternative solutions due to potential limitations or lack of support in certain environments.
Here’s the code snippet for reference:

const observer = new PerformanceObserver((list) => {
  list.getEntries().forEach((entry) => {
    const request = entry.responseEnd - entry.requestStart;
    console.log('Request time:', request);
  });
});

observer.observe({ type: "resource", buffered: true });

// Simulating a fetch request
const endpoint = 'https://example.com/api/data';

fetch(endpoint, {
  method: 'GET',
  mode: 'no-cors'
})
  .then(response => response.json())
  .then(data => console.log('Data received:', data))
  .catch(error => console.error('Error:', error));

In my actual application, there might be several endpoints(servers) to measure the traffic of and it’s crucial to account for the time a request spends in the task queue.
Are there alternative solutions or approaches that can effectively handle this requirement?

Create a signature field within adobe with javascript and have it execute once signed without the properties dialog box

I’m trying to create a signature field within adobe acrobat, which executes another code once it’s digitally signed without going to properties and selecting the “run once signed”. I have the initial part of my code which I use Action Wizard to execute javascript allowing me to create the signature field. However, the second part of my code continues to run with the initial code and does not wait until the field is signed. For better clarity my initial code will create the signature field and once signed will create a text field on the upper right hand corner of my page.

I have used MouseUp actions but my goal is to have the second part of my code run once signed and not just by clicking on the field.