what are best practice for optimizing website performance and reducing page load time? [closed]

To optimize web performance and reduce page load time, focus on these best practices. Firstly, minimize HTTP requests by combining multiple files into one and reducing the use of external resources. Compress images and use modern formats like WebP to reduce file sizes without compromising quality.

Enable browser caching to store static resources locally, reducing the need for repeated downloads. Utilize asynchronous loading for non-essential scripts to prevent them from blocking the rendering of the page. Employ lazy loading for images so they load only when they come into the viewport.

Optimize your CSS and JavaScript by minimizing and compressing code. Utilize critical CSS to prioritize loading essential styles for initial page rendering. Consider deferring the loading of non-essential scripts until after the page has loaded.

How can I reflect this value in the menu?

<script>
    document.addEventListener('DOMContentLoaded', function () {
        // Tüm içerikleri gizle
        var allContents = document.querySelectorAll('.content');
        allContents.forEach(function (content) {
            if (!content.classList.contains('initially-hidden')) {
                content.style.display = 'none';
            }
        });
    });



    var groupId; // Global groupId değişkeni
    var deviceId;

    function showContent(contentId, currentGroupId,currentDeviceId) {
        var allContents = document.querySelectorAll('.content');
        allContents.forEach(function (content) {
            content.style.display = 'none';
        });

        groupId = currentGroupId;
        deviceId = currentDeviceId;// showContent çağrıldığında groupId'ı güncelle

        var selectedContent = document.getElementById(contentId);
        if (selectedContent) {
            selectedContent.style.display = 'block';
        }
    }

    function createAuthorizationGroups(count) {
        var authMenu = document.getElementById("subMenuAuth");
        authMenu.innerHTML = '';

        for (var i = 1; i <= count; i++) {
            var groupItem = document.createElement("li");
            groupItem.className = "list-group-item";

            var groupLink = document.createElement("a");
            groupLink.href = "#";
            groupLink.className = "menu-item";
            groupLink.setAttribute("data-toggle", "collapse");
            groupLink.setAttribute("data-target", "#subSubMenuAuth" + i);
            groupLink.setAttribute("onclick", "showContent('groupContent', " + i + ")");
            groupLink.innerHTML = "GROUP-" + i + " <span class='arrow'>&#9660;</span>";

            var subMenu = document.createElement("ul");
            subMenu.id = "subSubMenuAuth" + i;
            subMenu.className = "list-group list-group-flush collapse";

            groupItem.appendChild(groupLink);
            groupItem.appendChild(subMenu);

            authMenu.appendChild(groupItem);

            // Her grup için bir alt öğe oluştur
            //var subItem = document.createElement("li");
            //subItem.className = "list-group-item";
            //var subLink = document.createElement("a");
            //subLink.href = "#";

            //subLink.setAttribute("onclick", "showContent('deviceContent', " + i + ")");
            //subLink.innerHTML = "Alt Öğe " + i;
            //subItem.appendChild(subLink);
            //subMenu.appendChild(subItem);
        }


    }



    function saveContent() {
        // Get values from the form
        var ipAddress = document.getElementById("ipAddress").value;
        var port = document.getElementById("port").value;
        var devCount = document.getElementById("deviceCount").value;
        var communucationType = document.getElementById("comType").value;
        var deviceType = document.getElementById("deviceType").value;
        var deviceAddress = document.getElementById("deviceAddress").value;

        // Perform actions with the values (e.g., save to database, update UI, etc.)
        console.log("Group ID: " + groupId);
        console.log("IP Address: " + ipAddress);
        console.log("Port: " + port);
        console.log("Device Count " + devCount);
        console.log("Communucation Type: " + communucationType);
        console.log("Device Type: " + deviceType);
        console.log("Device Address: " + deviceAddress);


        // Update the menu item text with IP & Port information
        var groupMenuItem = document.querySelector('.menu-item[data-target="#subSubMenuAuth' + groupId + '"]');
        if (groupMenuItem) {
            groupMenuItem.innerHTML = "GROUP-" + groupId + " (" + ipAddress + ":" + port + ") <span class='arrow'>&#9660;</span>";
        }



        // Create device items based on the device count
        var deviceCountInput = document.getElementById("deviceCount");
        var deviceCount = parseInt(deviceCountInput.value);
        createDeviceItems(deviceCount);


        


        // Bu fonksiyon, seçilen cihaz türüne göre özel metni döndürür


        // Bu fonksiyon, deviceType değerini güncelleyerek createDeviceItems fonksiyonunu çağırır.


    }

    function createDeviceItems(count) {
        // Clear existing device items
        var deviceMenu = document.getElementById("subSubMenuAuth" + groupId);
        if (!deviceMenu) {
            console.error("Device menu not found!");
            return;
        }

        deviceMenu.innerHTML = '';

        // Create new device items based on the count
        for (var i = 1; i <= count; i++) {
            var deviceItem = document.createElement("li");
            deviceItem.className = "list-group-item";
            deviceItem.setAttribute("data-target", "#deviceTarget" + i);

            var deviceID = "deviceID_" + i;
            console.log("Device ID:" + deviceID);

            var deviceLink = document.createElement("a");
            deviceLink.href = "#";

            // Get dynamic values from form elements
            var deviceType = document.getElementById("deviceType").value;
            var deviceAddress = document.getElementById("deviceAddress").value;

            deviceLink.innerHTML = deviceType + "(" + deviceAddress + ")";
            deviceLink.setAttribute("onclick", "showContent('deviceContent', '" + deviceID + "')");

            deviceItem.appendChild(deviceLink);

            var deviceMenuItem = document.querySelector('.menu-item[data-target="#deviceTarget' + deviceID + '"]');
            if (deviceMenuItem) {
                deviceMenuItem.innerHTML = deviceType + deviceID;
            }

            try {
                deviceMenu.appendChild(deviceItem);
            } catch (error) {
                console.error("Error adding device item:", error);
                console.log("deviceItem:", deviceItem);
                console.log("deviceMenu:", deviceMenu);
            }
        }
    }





    document.addEventListener('DOMContentLoaded', function () {
        var authGroupCount = document.getElementById("authGroupCount").value;
        createAuthorizationGroups(authGroupCount);
    });

    document.getElementById("btnSave").addEventListener('click', function () {
        var authGroupCountInput = document.getElementById("authGroupCount");
        var authGroupCount = parseInt(authGroupCountInput.value);
        createAuthorizationGroups(authGroupCount);

    });

    document.getElementById("btnCreate").addEventListener('click', function () {
        var deviceGroupCountInput = document.getElementById("deviceCount");
        var deviceGroupCount = parseInt(deviceGroupCountInput.value);
        createDeviceItems(deviceGroupCount);

    });






</script>
    body {
        display: flex;
        min-height: 100vh;
    }

    .container-fluid {
        display: flex;
        flex-direction: row;
        width: 100%;
    }

    .menu {
        width: 250px;
        background-color: transparent;
        padding: 20px;
    }

        .menu a {
            text-decoration: none;
            color: #495057;
            display: block;
            padding: 5px 0;
        }

            .menu a:hover {
                color: #007bff;
            }

        .menu .list-group-item {
            cursor: pointer;
        }

            .menu .list-group-item:hover {
                background-color: #e9ecef;
            }

            .menu .list-group-item.active {
                background-color: #007bff;
                color: #fff;
            }

            .menu .list-group-item .arrow {
                float: right;
            }

    .content {
        display: none;
    }

        .content h5 {
            margin-bottom: 20px;
        }

    .form-group {
        margin-bottom: 20px;
    }
<div class="container-fluid">
    <!-- Sol Taraftaki Menü -->
    <div class="menu">
        <div id="treeMenu">
            <ul class="list-group list-group-flush">
                <li class="list-group-item">
                    <a href="#" class="menu-item" data-toggle="collapse" data-target="#subMenuAuth" onclick="showContent('authorizationContent')">
                        Authorization Device Groups
                        <span class="arrow">&#9660;</span>
                    </a>
                    <ul id="subMenuAuth" class="list-group list-group-flush collapse">
                        <li class="list-group-item">
                            <a href="#" class="menu-item" data-toggle="collapse" data-target="#subSubMenuAuth1" onclick="showContent('groupContent')">
                                GROUP-1
                                <span class="arrow">&#9660;</span>
                            </a>
                            <ul id="cihazAuth" class="list-group list-group-flush collapse">
                                <li class="list-group-item">
                                    <a href="#" class="menu-item" data-toggle="collapse" data-target="#deviceTarget" onclick="showContent('deviceContent')">
                                        CİHAZ
                                        <span class="arrow">&#9660;</span>
                                    </a>
                                </li>

                            </ul>
                        </li>
                    </ul>
                </li>

                <li class="list-group-item">
                    <a href="#" class="menu-item" data-toggle="collapse" data-target="#subMenuCPU" onclick="showContent('cpuContent')">
                        CPU Groups
                        <span class="arrow">&#9660;</span>
                    </a>
                    <ul id="subMenuCPU" class="list-group list-group-flush collapse">
                        @*<li class="list-group-item">
                                <a href="#" class="menu-item" data-toggle="collapse" data-target="#subSubMenuCPU1" onclick="showContent('groupContent')">
                                    GROUP-3
                                    <span class="arrow">&#9660;</span>
                                </a>
                                <ul id="subSubMenuCPU1" class="list-group list-group-flush collapse">
                                    <li class="list-group-item"><a href="#">Alt Öğe 3.1</a></li>
                                    <li class="list-group-item"><a href="#">Alt Öğe 3.2</a></li>
                                </ul>
                            </li>*@
                    </ul>
                </li>
            </ul>


        </div>
    </div>

    <!-- Sağ Taraftaki İçerik Bölümü -->
    <!-- AUTH CONTENT-->
    <div class="content" id="authorizationContent">
        <div class="form-group row">
            <label class="col-sm-3 col-form-label">Explanation:</label>
            <div class="col-sm-9">
                <textarea class="form-control" rows="4" placeholder="Enter explanation"></textarea>
            </div>
        </div>

        <div class="form-group row">
            <label class="col-sm-3 col-form-label">Authorization Device Group Count:</label>
            <div class="col-sm-9">
                <input type="number" class="form-control" placeholder="Enter count" id="authGroupCount">
            </div>
        </div>

        <div class="form-group row">
            <label class="col-sm-3 col-form-label">CPU Group Count:</label>
            <div class="col-sm-9">
                <input type="number" class="form-control" placeholder="Enter count" id="cpuGroupCount">
            </div>
        </div>

        <div class="form-group row">
            <div class="col-sm-12 text-end">
                <button type="button" class="btn btn-primary" id="btnSave" onclick="saveContent()">Save</button>
            </div>
        </div>
    </div>

    <!-- GROUP CONTENT-->
    <div class="content" id="groupContent">
        <div class="form-group row">
            <label class="col-sm-3 col-form-label">Communication Type:</label>
            <div class="col-sm-9">
                <select class="form-control" id="comType">
                    <option>TCP/IP</option>
                    <option>Serial Port(COM)</option>
                </select>
            </div>
        </div>

        <div class="form-group row">
            <label class="col-sm-3 col-form-label">IP & Port:</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" placeholder="IP Address" id="ipAddress">
            </div>
            <div class="col-sm-1 text-center">:</div>
            <div class="col-sm-4">
                <input type="number" class="form-control" placeholder="Port" id="port">
            </div>
        </div>

        <div class="form-group row">
            <label class="col-sm-3 col-form-label">Device Count:</label>
            <div class="col-sm-9">
                <input type="number" class="form-control" placeholder="Device Count" id="deviceCount">
            </div>
        </div>

        <div class="form-group row">
            <div class="col-sm-12 text-end">
                <button type="button" class="btn btn-primary" id="btnSave" onclick="saveContent()">Save</button>
            </div>
        </div>
    </div>


    <!-- Device Content-->
    <div class="content" id="deviceContent">
        <h5>Device Count</h5>

        <div class="form-group row">
            <label class="col-sm-3 col-form-label">Device Type:</label>
            <div class="col-sm-9">
                <select class="form-control" id="deviceType">
                    <option></option>
                    <option>ABC1</option>
                    <option>ABC2</option>
                    <option>ABC3</option>
                    <option>ABC4</option>
                    <option>ABC5</option>
                    <option>ABC6</option>
                    <option>ABC7</option>
                    <option>ABC8</option>
                    <option>ABC9</option>
                    <option>ABC10</option>
                </select>
            </div>
        </div>

        <div class="form-group row">
            <label class="col-sm-3 col-form-label">Device Address:</label>
            <div class="col-sm-9">
                <input type="text" class="form-control" placeholder="Device Address" id="deviceAddress">
            </div>
        </div>

        <div class="form-group row checkbox-group">
            <label class="col-sm-3 col-form-label">Options:</label>
            <div class="col-sm-9">
                <div class="form-check">
                    <input class="form-check-input" type="checkbox" value="" id="disableCheckbox">
                    <label class="form-check-label" for="disableCheckbox">
                        Disable this device
                    </label>
                </div>
            </div>
        </div>

        <div class="form-group row">
            <div class="col-sm-12 text-end">
                <button type="button" class="btn btn-primary" id="btnCreate" onclick="saveContent()">CREATE</button>
            </div>
        </div>

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

As you can see, the GROUP number increases according to the entered value. Afterwards, when you click on the group option in the menu, an input page appears. If you enter the IP and Port values we entered and click on the save button, these values will be reflected in the GROUP expression in the menu (for example, GROUP-1 (192.168…..: 3333)) in the submenu according to the “device count” number. The element, namely device, is formed. When you click on the Device option, an input screen appears again. The device name value and address value we selected on this screen should be reflected in the menu. For example, ” ABC1 (35)”. What happens here is that when you select the device and press the “CREATE” button, it is not reflected in the menu, but when you select the device and press the “SAVE” button on the GROUP page, it is reflected, but the result is as I show you in the screenshot. A selected device is reflected in the entire device menu. This should not be the case, each device should have a separate input page so that the value selected for each device is different (as in the screenshot).

Now, its like this

But it should be like this

How can I transfer data from HTML to embedded system without internet?

I need to do this from the light control button on the HTML page and give the light adjustment data to my friend, who is an embedded system engineer, without internet. How can I transfer the light control data in HTML to my friend in the simplest way and without the internet? (HTML and microcontroller will be on the same device, so if I create an SQL file without internet, it can read it)

Sending data from HTML to an embedded system microcontroller

is there a way to know when an html element moves

I need to know when an html element moves within its parent, so that I can position other elements accordingly. The reasons the element can move is that its content changes, or some other elements, which may not be its descendants, are added or moved.
So far, the only solution I can think of is to use a MutationObserver at the common ancestor level, and then compare every location of every element to its memorised position.
But that seems overkill to me….
Any other idea?
(I am using React so an existing React Hook would do the job, but I can live with plain JS)

Problem in CesiumJS left double click camera

everybody! I’m adding to Entity Wall and Polyline. I also specify Model in the properties of the Entity. I have checkboxes that enable and disable Wall and Polyline. When they are enabled, when you double-click on an Entity, the camera points to the center of the Wall or Polyline. I need the camera to capture the Entity when double clicking on the Entity. What could be the reason?

I tried to find some property, but there is no such thing. Has anyone encountered this problem?

Set Postion Code:

const hpr = new HeadingPitchRoll(Math.toRadians(item.Q + 270), 0, 0);
  
      
      let position = Cartesian3.fromDegrees(
        item!.L * Math.DEGREES_PER_RADIAN,
        item!.B * Math.DEGREES_PER_RADIAN,
        item!.H                                  
      ) as Cartesian3;
    
      
      let orientation = Transforms.headingPitchRollQuaternion(
        position as Cartesian3,
        hpr
      ) as unknown as Ellipsoid;

Create Entity Code:

let entity = new Entity({
          id: item.UID,
          position: Cartesian3.fromDegrees(
            item!.L * Math.DEGREES_PER_RADIAN,
            item!.B * Math.DEGREES_PER_RADIAN,
            item!.H
          ) as Cartesian3,
          orientation: new CallbackProperty(() => {
            return orientation;
          }, false),
          model: model,
          objectType: objectType,
        });

Create Wall Code:

let wall = new WallGraphics({
            material: MColor(item.color, 0.1),
            outline: true,
            outlineColor: Color.GREY,
            show: false,
            positions: new CallbackProperty(() => {
              let points
              if (objectType === EntitiesTypes.Air) {
                points = WallData!.get(item!.UID)
              }
              return Cartesian3.fromDegreesArrayHeights(points);
            }, false),
          });
    entity.wall = wall;

I was looking for a property of Entity, Wall and edit this.

Getting data from nested array of objects, by comparing some number with object ID. And display it on webpage. JavaScript + HTML

Hi stackoverflow members, new in JS, trying to search some info through Internet, but unsuccesfully. So, I have a nested array of objects. I need to display some data based on my number. Lets say i have a number from 1-8. And if this number = arr1.Id, after I get in output arr1.Id + arr1.Address + P_min + P_max, then CombinedPointsIDs also comparing with all arr1.Id and outputed info with CombinedpointsIDs + Address + P_min + P_max. Unfortunately I cant explain better than before, so i posted an image with expected output. Thx for help.

let number = 1;

const arr1 = [
{
"Id": 1,
"Address": "noMatter1",
"P_min": 2.5,
"P_max": 6,
"CombinedPointsIDs": [2, 8, 4, 3]
},
{
"Id": 2,
"Address": "noMatter2",
"P_min": 6,
"P_max": 10,
"CombinedPointsIDs": [1, 5, 6, 3]
},
{
"Id": 3,
"Address": "noMatter3",
"P_min": 3.6,
"P_max": 6,
"CombinedPointsIDs": [4, 7, 5]
},
{
"Id": 4,
"Address": "noMatter4",
"P_min": 4.5,
"P_max": 6.5,
"CombinedPointsIDs": [3, 8, 6, 5]
},
{
"Id": 5,
"Address": "noMatter5",
"P_min": 2.5,
"P_max": 4.5,
"CombinedPointsIDs": [3, 4, 3, 2, 1]
},
{
"Id": 6,
"Address": "noMatter6",
"P_min": 4.5,
"P_max": 6.5,
"CombinedPointsIDs": [1, 5, 4, 7]
},
{
"Id": 7,
"Address": "noMatter7",
"P_min": 5,
"P_max": 7.5,
"CombinedPointsIDs": [1, 2, 8]
},
{
"Id": 8,
"Address": "noMatter8",
"P_min": 3,
"P_max": 5,
"CombinedPointsIDs": [2, 3, 5]
}
]

combinedPointsData+= 
                `
                
                `

document.getElementById("combined-points").innerHTML = combinedPointsData;

A html code:

<!DOCTYPE html>
<html lang="en">
<head>
</head>

<body>

<div class="container" id="container">
    <div id="combined-points">
    </div>
</div>

</body>
</html>

I tried to do some code in JS but I always get something i dont want to.

Im expecting to get something like that on webpage:

webpage example

Can’t call canvas update event with js in QWebChannel

This sends data from qt c++ to js via qwebchannel to draw on ‘canvas’. The data is passed with the correct value, but the canvas redraw event does not occur.

If I call the ‘drawCanvas’ function within the same javascript file, I can perform all actions. However, when calling the js function in C++, the canvas does not redraw.

Check out the code below.

  // js
   function drawCanvas(imageData){        
        console.error("data "+value);
        var canvas = document.getElementById("myCanvas");
        var context = canvas.getContext("2d");

        context.fillStyle = "yellow";
        context.fillRect(0, 0, canvas.width, canvas.height);
        context.font="48px serif";
        context.fillStyle = "black";
        context.fillText("Text "+imageData, 10, 50);

        if(imageData.length > 0 ){
            console.error("Image Data Length: " + (imageData ? imageData.length : "Undefined"));
        }

    }

 var i = 0;
    window.addEventListener('resize', function(){        
        drawCanvas(++i);
    });

enter image description here

It is explained with pictures as follows:

[enter image description here]

(https://i.stack.imgur.com/wimQu.jpg)

When you call the drawCanvas function in background.cpp, the following code is executed. This has been confirmed to be the correct value.

function drawCanvas(imageData){        
        console.error("data "+value);  << result: data 12323423  // correct value

I called the drawCanvas function with success in background.cpp, but why doesn’t fillText() run?
How can I solve this?

Thanks for reading.

This is what I tried.

// header
class CBackground
{
private:
    _BACKGROUNDHEADER_ m_bkgndHeader;

    static QWebEngineView* s_webView;
    static QWebChannel* m_webChannel;

    QString htmlPath = QFileInfo(__FILE__).dir().absolutePath() + "/canvas.html";

    ...
public: 
    onDraw();
    ....
}

// .cpp

bool CBackground::onDraw()
{
   if(!m_pBkgndImage->isNull()){

        if (m_pBkgndImage->colorSpace().isValid()){
            m_pBkgndImage->convertToColorSpace(QColorSpace::SRgb);
        }

        QPoint point(0,0);
        point.rx() = m_bkgndHeader.Left;
        point.ry() = m_bkgndHeader.Top;

        QVariant imageVariant = QVariant::fromValue(*m_pBkgndImage);

        imageObject = new QObject();
        imageObject->setProperty("imageData", imageVariant);

        m_webChannel->registerObject("imageObject", imageObject);

        int imageSizeInBytes = m_pBkgndImage->bytesPerLine() * m_pBkgndImage->height();

        QByteArray imageDataArray(reinterpret_cast<const char*>(m_pBkgndImage->bits()), imageSizeInBytes);

        **QString jsCode = QString("drawCanvas('%1');").arg(imageDataArray.size());
        // s_webView is static variable 
        s_webView->page()->runJavaScript(jsCode);**

        if(!m_pBkgndImage->isNull()){
            delete m_pBkgndImage;
            m_pBkgndImage = nullptr;
        }
      
        m_webChannel->deregisterObject(imageObject);
        imageObject->deleteLater();

        return true;

    } else {
        QMessageBox::information(nullptr, "Drawing Image", "Failed 412");
        return false;
    }

    return false;
}

 // canvas.html
  function drawCanvas(imageData){        
        console.error("data "+value);
        var canvas = document.getElementById("myCanvas");
        var context = canvas.getContext("2d");

        context.fillStyle = "yellow";
        context.fillRect(0, 0, canvas.width, canvas.height);
        context.font="48px serif";
        context.fillStyle = "black";
        context.fillText("Text "+imageData, 10, 50);

        if(imageData.length > 0 ){
            console.error("Image Data Length: " + (imageData ? imageData.length : "Undefined"));
        }

    }
    
    window.addEventListener('resize', drawCanvas);

Inquiry Regarding Time Restrictions in react-multi-date-picker

I’m currently working with react-multi-date-picker and I’m facing a challenge regarding time restrictions, specifically with the TimePicker component. I’ve explored the documentation and found that there are no apparent props like minTime and maxTime available.

My goal is to restrict the selection of time within a specific range (e.g., from 8:00 AM to 6:00 PM), and after 6:00 PM, it should roll over to 8:00 AM of the next day.

Could anyone provide guidance on how to implement time restrictions or if there are any workarounds within the react-multi-date-picker library? Your insights and assistance would be greatly appreciated.

Thank you in advance for your help!

Data binding does not work in a Vue project with v-network-graph

I guess the cause of the problem is in my implementation. I pushed my code, but the main parts these:

I created a very basic VueJS project. Added a typescript package. Created a data.ts file and put there this:

export const nodes = {1: { name: "wheel_speeds", edgeWidth: 1, hue: 200 },
2: { name: "velocities", edgeWidth: 1, hue: 160 },};

export const edges = [];

After I added the graph template

      <div>
        <v-network-graph class="graph" :nodes="nodes" :edges="edges" />
      </div>

Later, I want to fill it:

          for (const property in this.selected_parameters) {

            const create_node = {};
            create_node.name = this.selected_parameters[property].name;

            nodes[this.selected_parameters[property].name] = create_node
          }

During the running the node will be extended. You can see the default vaules and the new ones together:

debugging the nodes structure
Here, the first two raw the default ones and only this two is visible. Nodes, below is the newly added.

But later, I have only the two default ones on the screen. The re-rendering is missing.

I did a minimal change on the tutorials and I see no further error msg. The nodes is also added here:

<script>
import axios from 'axios';
import { nodes, edges, size, hues } from "./data";

export default {
  data() {
    return {
      nodes,
....

I followed tutorials like this. I also updated the node.js and the npm to the latest one, because yesterday I saw an error msg and it disappeared after it.

I configured in tsconfig.json:

"allowJs": true,

This is my config:

{
  "name": "client",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview"
  },
  "dependencies": {
    "axios": "^1.6.2",
    "bootstrap": "^5.3.2",
    "source-map-support": "^0.5.21",
    "typescript": "^5.3.2",
    "v-network-graph": "^0.9.13",
    "vue": "^3.3.4",
    "vue-router": "^4.2.5"
  },
  "devDependencies": {
    "@vitejs/plugin-vue": "^4.4.0",
    "vite": "^4.4.11"
  }
}

Why image rest to its original position when touched or pinched for 2nd time after zoom by pinch in swiperjs

Hi i’m facing a problem of image reset when touched or tried to pinch for 2nd time time.

I’m using swiper-js version :

"swiper": "^9.0.0",

Here is what i’m doing :

  1. Zoomed to 30% by pinching now left both finger
  2. Again tried to zoom to from 30% to 50% by pinching again as soon image is touched it reset this is the problem i’m facing

Here is what i have tried:

  <swiper ref="swiperZoomRef" :modules="swiperModules" :zoom="{ maxRatio: 10, minRatio: 0.2 , zoom: true}" :config="swiperConfig">

       <swiper-slide>
           <div class="swiper-zoom-container">
              <img :src="imagePath"/>
            </div>
      </swiper-slide>

  </swiper>


 <script>
         import { Swiper , SwiperSlide} from "swiper/vue";
         import { Zoom } from "swiper";
         import "swiper/css";
         import "swiper/css/zoom";
         import "swiper/css/bundle";

         export default {
              components:{Swiper, SwiperSlide},
               data(){
                  return {
                      swiperConfig : {
                             zoom: true,
                      },
                     swiperModules:[Zoom],
                 }
               },
          }
   </script>

Angular Material table not showing data from API call

I am stuck trying to figure out why my mat-table is not showing my data…
I am using Angular 15 and angular material 15

Here is my HTML component code:

          <mat-divider></mat-divider>
          <table mat-table [dataSource]="terjatveTable" class="mat-elevation-z8">
            <!-- Name Column -->
            <ng-container matColumnDef="name">
              <th mat-header-cell *matHeaderCellDef>Name</th>
              <td mat-cell *matCellDef="let element">{{ element.series.name }}</td>
            </ng-container>

            <!-- Series Column -->
            <ng-container matColumnDef="series">
              <th mat-header-cell *matHeaderCellDef>Value</th>
              <td mat-cell *matCellDef="let element">{{ element.series.value }}</td>
            </ng-container>

            <tr mat-header-row *matHeaderRowDef="displayedColumnsTableOne"></tr>
            <tr mat-row *matRowDef="let row; columns: displayedColumnsTableOne;"></tr>
          </table>

here is the componenent.ts file code:

 displayedColumnsTableOne: string[] = ['name', 'series'];
 terjatveTable: terjatveTableData[];

  getSingleCustomerTerjatveChartData() {
    const id = Number(this.route.snapshot.paramMap.get('id'));
    this.customerService.getSingleCustomerTerjatveChartData(id).subscribe(
      (data: any) => {
        if(data.error) {
          this.errorMessage = true;
        } else {
          this.terjatveTable = data;
        }
      },
      (error) => {
        console.log('Error', error);
        this.terjatveTable = null;
        this.errorMessage = error.error === 'No data';
      });
  }

and here is the example of data I get from api call:

[
    {
        "name": "51399",
        "series": [
            {
                "name": "0-30 dni",
                "value": 12026.899999999999636202119290828704833984375
            },
            {
                "name": "30-60 dni",
                "value": 1293.259999999999990905052982270717620849609375
            },
            {
                "name": "60-90 dni",
                "value": 0
            },
            {
                "name": "90-180 dni",
                "value": 629.98000000000001818989403545856475830078125
            },
            {
                "name": "180+ dni",
                "value": 129.729999999999989768184605054557323455810546875
            }
        ]
    }
]

Unable to download PDF file using playwright with js because it’s open in preview mode in Chrome browser

I am facing an issue where I am unable to download a PDF file because it opens in the preview mode in the Chrome browser
i want to enable this option using playwright with JS so i can download directly without opening the preview

import { test, expect } from '@playwright/test';
const { chromium } = require('playwright');
test.only('test', async () => {

    const browser = await chromium.launch({
        args: ['--disable-pdf-extension'],
      });
    
      const context = await browser.newContext({
        acceptDownloads: true, // Enable automatic download handling
      });

  // Navigate to the page containing the PDF link
  const page = await context.newPage();
  await page.goto('https://example.com');
  await page.getByRole('textbox', { name: 'Email' }).fill('[email protected]');
  await page.getByRole('textbox', { name: 'Email' }).press('Tab');
  await page.getByPlaceholder('Password').fill('admin123');
  await page.getByPlaceholder('Password').press('Enter');
  await page.getByRole('link', { name: 'Qa testing Learning', exact: true }).click();
  await page.getByText('Subscribers').click();
  const pdfLink = page.getByRole('row', { name: 'pdf' }).getByRole('link');
  await pdfLink.click();

  await page.pause();
  
});

Integrating Mizu Webphone Library API into React JS Project

I am currently working on a React JS project and have integrated the Mizu webphone library by placing the Webphone folder in my public directory. I’ve utilized the softphone.HTML file within my React component through the tag. However, I am now seeking guidance on utilizing the Mizu Webphone library’s API directly in my React project from scratch.

Could someone provide insights or best practices on how to effectively integrate the Mizu Webphone library’s API within a React JS application? Any advice on initializing the API and handling its functionalities in a React context would be greatly appreciated.

Thanks in advance!