Issue with Sorting French Dates in DataTables

I’m working on a React application using DataTables to display data. I’m using two additional plugins: one for French language support and another for date sorting (ultimate-datetime-sorting). The issue is that date sorting works perfectly in English, but I’m having trouble sorting dates correctly when they are in French.

The dates are not sorting correctly when displayed in French. Everything works fine in English. I tried using moment.js to set the locale to French and a plugin for sorting, but the issue persists.

How can I fix this issue with sorting dates in French? Is there a better approach to handling multilingual date formats and sorting with DataTables and React?

import moment from "moment";
import "moment/locale/fr";

// Function to translate English months to French
export function translateFrenchMonth(dateStr) {
  const translatedMonths = {
    Jan: "Janv",
    Fev: "Févr",
    Mars: "Mars",
    Avr: "Avr",
    Mai: "Mai",
    Juin: "Juin",
    Juil: "Juil",
    Aout: "Août",
    Sept: "Sept",
    Oct: "Oct",
    Nov: "Nov",
    Dec: "Déc",
  };

  const translatedDateStr = dateStr.replace(
    /(Jan|Fev|Mars|Avr|Mai|Juin|Juil|Aout|Sept|Oct|Nov|Dec)/g,
    (match) => translatedMonths[match]
  );

  return translatedDateStr;
}

export function updateDateFormat(data) {
  return data?.map((item) => {
    const tm = translateFrenchMonth(item.timestamp);
    const timestamp = item?.timestamp && moment(tm, userTimeFormat);

    return {
      ...item,
      timestamp,
    };
  });
}

const userLanguage = baja.getLanguage();
if (userLanguage === "en") {
  moment.locale("en");
} else {
  moment.locale("fr");
}

const columnDefs = [
  {
    language: userLanguage,
    type: "date",
    targets: 0,
    render: function (data) {
      return moment(data).local().format(userTimeFormat);
    },
  },
];

// Applying translated date format
const dataTable = utils.updateDateFormat(data);

<StyledDataTable
  ...
  data={dataTable}
  columnDefs={columnDefs}
/>

slick carousel inside accordion is broken when setting the variableWidth to false?

If you click the Collapsible Group Items #1 the slick inside of it is broken when setting the variableWidth: false. But if you set it to variableWidth: true it is working fine.

Here is the bootstrap doc https://bootstrapdocs.com/v3.3.5/docs/javascript/

See the codes below:

$(function() {
    $('.step-slider-a').slick({
      slidesToShow: 4,
      slidesToScroll: 1,
      arrows: true,
      infinite:false,
      dots: false,
      variableWidth: false,
      responsive: [
        {
          breakpoint: 992,
          settings: {
            slidesToShow:3,
          }
        },
        {
          breakpoint: 768,
          settings: {
            draggable:true,
            slidesToScroll:1,
            slidesToShow:1,
            centerMode:false,
            arrows: true,
            dots: false,
          }
        }
      ]
    });
    // $('a[data-toggle="collapse"]').on('shown.bs.collapse', function () {
    //   $('.step-slider-a').slick('setPosition');
    // })
});
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/slick/slick.css" />
    <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/slick/slick-theme.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">


<div class="container">
  <div class="row">
    <div class="col-xs-12">
      <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
        <div class="panel panel-default">
          <div class="panel-heading" role="tab" id="headingOne">
            <h4 class="panel-title">
              <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="false" aria-controls="collapseOne">
                Collapsible Group Item #1
              </a>
            </h4>
          </div>
          <div id="collapseOne" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">
            <div class="panel-body">
              <div class="row step-slider-a">
                <div class="col-lg-3" style="width: 200px;">
                  <div>Content 1</div>
                </div>
                <div class="col-lg-3" style="width: 200px;">
                  <div>Content 2</div>
                </div>
                <div class="col-lg-3" style="width: 200px;">
                  <div>Content 3</div>
                </div>
                <div class="col-lg-3" style="width: 200px;">
                  <div>Content 4</div>
                </div>
                <div class="col-lg-3" style="width: 200px;">
                  <div>Content 5</div>
                </div>
                <div class="col-lg-3" style="width: 200px;">
                  <div>Content 6</div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="panel panel-default">
          <div class="panel-heading" role="tab" id="headingTwo">
            <h4 class="panel-title">
              <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
                Collapsible Group Item #2
              </a>
            </h4>
          </div>
          <div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
            <div class="panel-body">
              Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
            </div>
          </div>
        </div>
        <div class="panel panel-default">
          <div class="panel-heading" role="tab" id="headingThree">
            <h4 class="panel-title">
              <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
                Collapsible Group Item #3
              </a>
            </h4>
          </div>
          <div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
            <div class="panel-body">
              Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js" type="application/javascript"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/slick/slick.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

About readymade template for project

My Question is that if i use the readymade customize template from any site who allow us , these template is frontend based and i use it for a customer, they have some legal issue if any ambiguity please share with me , and secondly how can live in google , it is necessary to join with some backends programming live PHP , or attached with the server, and if i have not a necessary then i choose any domain or hosting.
Thanks

i simply asked the question, hope my answer will give very soon…

Is there is way to change default translucent image by browser when onDragStart event fire

I hope you’re all doing well, and I appreciate your attempts to help. What I’m trying to do here is practice and improve my skills, so I decided to create a simple drag-and-drop function for an existing list. I’m using the react-beautiful-dnd library as a reference. However, I’m currently facing an issue with the translucent image that the browser generates by default during the drag event. I can only hide this image, but when looking at the react-beautiful-dnd library, the full element appears without any effects. I still don’t know how to display the full element, as they do in the Beautiful Drag & Drop library. Can you help me with this?

I will include two images to illustrate what I mean. In my image, you can see that the transparency of the dragged element changes, unlike what happens in the Beautiful DnD library, as shown in the second image.

image 1 from my code

screen shoot of my app

image 2 from react-beautiful-dnd
screen shot of react-beautiful-dnd

Black Screen Issue When Accessing Back Camera in JavaScript

I’m developing a web application that allows users to switch between the front and back cameras on their device. While the front camera works fine, I’m encountering an issue where the back camera only shows a black screen.

camera.js
// wwwroot/camera.js

let currentStream = null;

async function openCamera(facingMode) {
    if (currentStream) {
        currentStream.getTracks().forEach(track => track.stop());
    }

    try {
        const constraints = {
            video: {
                facingMode: facingMode
            }
        };
        const stream = await navigator.mediaDevices.getUserMedia(constraints);
        currentStream = stream;
        document.getElementById('videoFeed').srcObject = stream;
        console.log(`Camera opened with facing mode: ${facingMode}`);
    } catch (err) {
        console.error('Error accessing camera: ', err);
    }
}

function stopCamera() {
    if (currentStream) {
        currentStream.getTracks().forEach(track => track.stop());
        currentStream = null;
    }
}


async function startVideo(src) {
    try {
        const permission = await checkCameraPermission();
        if (permission === 'prompt' || permission === 'granted') {
            navigator.getUserMedia(
                { video: true, audio: false },
                function (localMediaStream) {
                    let video = document.getElementById(src);
                    video.srcObject = localMediaStream;
                    video.onloadedmetadata = function (e) {
                        video.play();
                    };
                },
                function (err) {
                    console.error('Error accessing camera:', err);
                    throw err; // Propagate the error
                }
            );
        } else {
            console.error('Camera permission denied.');
        }
    } catch (error) {
        console.error('Error starting video:', error);
    }
}
function getFrame(src, dest, dotnetHelper) {
    let video = document.getElementById(src);
    let canvas = document.getElementById(dest);

    // Check if the video and canvas elements exist before drawing the image
    if (video && canvas) {
        canvas.getContext('2d').drawImage(video, 0, 0, 150, 150);

        // Resize the image on the canvas
        let resizedCanvas = document.createElement('canvas');
        resizedCanvas.width = 200; // Set desired width
        resizedCanvas.height = 200; // Set desired height
        let ctx = resizedCanvas.getContext('2d');
        ctx.drawImage(canvas, 0, 0, resizedCanvas.width, resizedCanvas.height);

        // Convert the resized image to base64 JPEG format
        let dataUrl = resizedCanvas.toDataURL("image/jpeg");

        // Invoke the .NET method with the resized image data
        dotnetHelper.invokeMethodAsync('ProcessImage', dataUrl);
    } else {
        console.error('Video or canvas element not found.');
    }
}


function stopVideo(src) {
    let video = document.getElementById(src);

    // Check if the video element exists before stopping
    if (video) {
        if ('srcObject' in video) {
            let tracks = video.srcObject.getTracks();
            tracks.forEach(track => track.stop());
            video.srcObject = null;
        } else {
            video.src = '';
        }
    } else {
        console.error('Video element with ID ' + src + ' not found.');
    }
}

function closeCamera() {
    if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
        navigator.mediaDevices.getUserMedia({ video: true })
            .then(function (stream) {
                // Stop all tracks
                let tracks = stream.getTracks();
                tracks.forEach(track => track.stop());
            })
            .catch(function (error) {
                console.error('Error closing the camera: ', error);
            });
    } else {
        console.error('getUserMedia is not supported on this browser.');
    }
}
Razorpage
@using MudBlazor
@inject IJSRuntime JSR
@inject ISnackbar Snackbar

<div>
    <MudDialog Style="overflow: hidden;">
        <DialogContent>
            <MudCard Class="pa-2">
                <MudCardContent>
                    <div style="display: flex; justify-content: center; align-items: center;">
                        <video id="videoFeed" width="600" height="300"></video>
                    </div>
                    <canvas class="d-none" id="currentFrame" width="150" height="150"></canvas>
                    <div style="display: flex; justify-content: center; margin-top: 16px;">
                        <MudIconButton Icon="@Icons.Material.Filled.CameraAlt" Color="Color.Primary" Size="Size.Large" OnClick="@Save" />
                        <MudButton OnClick="ToggleCamera" Color="Color.Primary">@buttonText</MudButton>
                        <MudIconButton Color="Color.Error" Icon="@Icons.Material.Filled.Cancel" Size="Size.Large" OnClick="@Cancel" />
                    </div>
                </MudCardContent>
            </MudCard>
        </DialogContent>
    </MudDialog>
</div>

@code {
    [CascadingParameter] MudDialogInstance MudDialog { get; set; }
    [Parameter] public string ImageUri { get; set; }
    private bool isFrontCamera = true;
    private string buttonText = "Open Back Camera";
    private DotNetObjectReference<CameraDialog> oCounter;
    private string frameUri;

    private bool nestedVisible = false;
    private bool isVideoStarted = false;

    protected override async Task OnInitializedAsync()
    {
        try
        {
            await JSR.InvokeVoidAsync("startVideo", "videoFeed");
          
            isVideoStarted = true;
        }
        catch (Exception ex)
        {
            Snackbar.Add("Camera access is denied. Please allow access to the camera.", Severity.Error);
        }
    }
    private async Task ToggleCamera()
    {
        if (isFrontCamera)
        {
            await OpenCamera("environment");
            buttonText = "Open Front Camera";
        }
        else
        {
            await OpenCamera("user");
            buttonText = "Open Back Camera";
        }
        isFrontCamera = !isFrontCamera;
    }

    private async Task OpenCamera(string facingMode)
    {
        await JSR.InvokeVoidAsync("openCamera", facingMode);
    }
    private async Task Save()
    {
        if (!isVideoStarted)
        {
            Snackbar.Add("Camera access is denied. Please allow access to the camera.", Severity.Error);
            MudDialog.Cancel();
            return;
        }

        if (oCounter == null)
            oCounter = DotNetObjectReference.Create(this);

        try
        {
            await JSR.InvokeAsync<string>("getFrame", "videoFeed", "currentFrame", oCounter);
            await JSR.InvokeVoidAsync("stopVideo", "videoFeed");
            isVideoStarted = false;
            MudDialog.Close(DialogResult.Ok(frameUri));
        }
        catch (Exception ex)
        {
            if (ex.Message.Contains("Cannot read properties of null (reading 'getTracks')"))
            {
                Snackbar.Add("Camera access is denied. Please give camera permission in the browser settings.", Severity.Error);
                MudDialog.Cancel();
            }
            else
            {
                Snackbar.Add($"An error occurred while capturing the image. Please try again. Error details: {ex.Message}", Severity.Error);
                MudDialog.Cancel();
            }
        }
    }

    [JSInvokable]
    public async Task ProcessImage(string imageString)
    {
        frameUri = imageString;
        StateHasChanged();

        var parameters = new DialogParameters { { "ImageUri", frameUri } };
        var options = new DialogOptions { FullWidth = true };
    }

    private async Task Cancel()
    {
        if (isVideoStarted)
        {
            try
            {
                await JSR.InvokeVoidAsync("stopVideo", "videoFeed");
                isVideoStarted = false;
                MudDialog.Cancel();
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("Cannot read properties of null (reading 'getTracks')"))
                {
                    MudDialog.Cancel();
                }
                else
                {
                    MudDialog.Cancel();
                }
            }
        }
    }
}

What I Have Tried I tried adding a delay between stopping the current stream and starting the new one. I added console logs to debug the flow, but still facing issues. Expected Behavior The back camera should activate immediately after clicking the “Rotate Camera” button without showing a black screen.

Actual Behavior The back camera either shows a black screen or takes multiple clicks to activate. I’m testing this on multiple devices, and the issue persists across different browsers and devices. Camera permissions are granted properly. Any Help or Suggestions? I’d appreciate any help or suggestions to resolve this issue. Thank you!

The problem of the server not working outside the file

I got the build by typing pkg . –targets node18-win-x64 in the terminal to get the build of the backend part of my project that I created using Node.js. The main problem here is that while there is no problem when the server is inside the files, there is a problem in seeing the modules when the server is taken out of the file. What could be the solution to this?

I tried to change dependencies but i didn’t get any result from this

“Like” Button on SharePoint Page Analytics Not Persisting

I’m facing an issue with the “like” button feature in the page analytics section of our SharePoint site. When I interact with the “Do you like using page analytics?” button, it seems to register my input. However, when I navigate away and return to the analytics page, the like count doesn’t appear to persist, as if my interaction wasn’t recorded.

To troubleshoot, I’ve tried the following:

  • Clearing the browser cache and cookies

  • Using different browsers and devices

Despite these efforts, the issue persists. I was expecting the like count to be saved and reflected accurately upon revisiting the page. Any insights or solutions to resolve this issue would be highly appreciated!

How To Add Canva Button (“Free Design With Canva”) My Own Vue Js Application OutSide Of China?

I want to add a “Free Design With Canva” button in my Vue.js app. When users visit my website, they will see an image that I provide. If a user wants to edit this image according to their own requirements, they can click the “Free Design With Canva” button.

Here’s what I need:

The user should not need any authentication to edit the image in Canva.

When the user clicks the “Free Design With Canva” button, a window should open within my website, allowing the user to edit the image.

After editing, the user can click a “Finish It” button in Canva, which will redirect them back to the same page on my website with the edited image.

I saw that the “Design With Canva” button API is currently only available in China. How can I access this API from another country?

If that’s not possible, how can I implement a similar system in my own app? Please guide me on how to do this from scratch in my Vue.js application.

Below, I have attached some examples to illustrate what I’m looking for. Please provide guidance on how to achieve this from scratch in my Vue.js application.

Step: 1Step: 2Step: 3

I saw that the “Design With Canva” button API is currently only available in China. How can I access this API from another country?

If that’s not possible, how can I implement a similar system in my own app? Please guide me on how to do this from scratch in my Vue.js application.

Below, I have attached some examples to illustrate what I’m looking for. Please provide guidance on how to achieve this from scratch in my Vue.js application.

Shapes going out of proportion in responsive canvas

I am trying to learn Konva.js to build a game and one of my biggest priorities is that the canvas should be responsive in width and height. I have managed to achieve that but when I resize my browser, the shapes strech out of proportion. I have a few guesses that I have to update the X and Y of the shape when the window resizes, but being new to this framework, I don’t have a idea how to implement that.
This is my code-

<!DOCTYPE html>
<html>

<head>
    <script src="https://unpkg.com/[email protected]/konva.min.js"></script>
    <meta charset="utf-8" />
    <title>Konva Responsive Canvas Demo</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            overflow: hidden;
            background-color: #f0f0f0;
            height: 100vh;
        }

        #stage-parent {
            width: 100%;
            height: 100vh;
        }
    </style>
</head>

<body>
    <div id="stage-parent">
        <div id="container"></div>
    </div>
    <script>
        let sceneWidth = 1000;
        let sceneHeight = 1000;

        let stage = new Konva.Stage({
            container: 'container',
            width: sceneWidth,
            height: sceneHeight,
        });

        let layer = new Konva.Layer();
        stage.add(layer);

        let circle = new Konva.Circle({
            radius: 50,
            fill: 'red',
            x: stage.width() / 2,
            y: stage.height() / 2,
        });
        layer.add(circle);

        let rect = new Konva.Rect({
            fill: 'green',
            x: stage.width() - 100,
            y: stage.height() - 100,
            width: 100,
            height: 100,
        });
        layer.add(rect);

        function fitStageIntoParentContainer() {
            const container = document.querySelector('#stage-parent');

            let containerWidth = container.offsetWidth;
            let containerHeight = container.offsetHeight

            let scaleX = containerWidth / sceneWidth;
            let scaleY = containerHeight / sceneHeight;

            stage.width(sceneWidth * scaleX);
            stage.height(sceneHeight * scaleY);
            stage.scale({ x: scaleX, y: scaleY });
        }

        fitStageIntoParentContainer();
        window.addEventListener('resize', fitStageIntoParentContainer);
    </script>
</body>

</html>

Navbar toggle:active issue

Currently i am facing an issue with my desired CSS effects. So currently the problem i am facing is that i have a navbar toggle which is in the color black, when i click on the navbar toggle i want it so that when it expands, the navbar background color will be red, then when i click on it and retract the navbar, the color will went from red back to black. But current issue is it only turns red once i click on it, when i release it will turn back to black. The script i was suggested is this below.

[Retract image](https://i.sstatic.net/51eTxqsH.png)

[Expand image](https://i.sstatic.net/G9d5gCQE.png)

[Navbar toggle when click/holding click](https://i.sstatic.net/TMFRw5GJ.png)

PHP Laravel

<header class="header header_style_01">
    <nav class="megamenu navbar navbar-default">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" id="toggle-button" data-toggle="collapse" data-target="#navbar"
                    aria-expanded="false" aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="/"><img src="images/logos/smsGuru_logo.png"
                        height="60px" alt="sms guru" title="cheap sms"></a>
            </div>



            <div id="navbar" class="navbar-collapse collapse">
                <!-- <ul class="nav navbar-nav" style="margin-top: 8px;margin-left: 550px;"> -->
                <!-- <li><a class="active" href="index.html">Home</a></li> -->
                <!--     <li><a href="features.html">Features </a></li>
                    <li><a href="domain.html">Domain</a></li>
                    <li><a href="hosting.html">Hosting</a></li>
                    <li><a href="pricing.html">Pricing</a></li>
                    <li><a href="testimonials.html">Testimonials</a></li>
                    <li><a href="contact.html">Contact</a></li> -->

                <!--  <li><h1 class="contact_me"><b><a href="http://360.my/w/60123240066">+6012 324 0066</a></b></h1></li> -->
                <!-- <li><h1 class="contact_me"><b><a href="http://360.my/w/60123240066">+6012 324 0066</a></b></h1></li> -->

                <!-- </ul> -->
                <ul class="nav navbar-nav navbar-right">
                    <li>
                        <h1 class="contact_me"><b><a
                                    href="https://wa.me/60123240066?text=I+would+like+to+inquire+about"
                                    target="_blank">+6012 3240 066</a></b></h1>
                    </li>
                    <!-- <li><a class="btn-light btn-radius btn-brd log" href="#" data-toggle="modal" data-target="#login"><i class="fa fa-unlock"></i> Register</a></li> -->
                    <li><a class="btn-light btn-radius btn-brd log" href="https://sms.360.my/developers/v3.0"><i
                                class="fa fa-file"></i> API</a></li>
                    <li><a class="btn-light btn-radius btn-brd log" href="https://sms.360.my/register"><i
                                class="fa fa-unlock"></i> Register</a></li>
                    <!-- <li><a class="btn-light btn-radius btn-brd log" href="#" data-toggle="modal" data-target="#login"><i class="fa fa-lock"></i> Login</a></li> -->
                    <li><a class="btn-light btn-radius btn-brd log" href="https://sms.360.my/login"><i
                                class="fa fa-lock"></i>
                            Login</a></li>
                </ul>
            </div>
        </div>
    </nav>
</header>

custom.css file below

 .header_style_01 {
    background-color: #2d3032;
    display: block;
    left: 0;
    padding: 15px 20px 5px !important;
    position: relative;
    right: 0;
    top: 0;
    width: 100%;
    z-index: 111;
}

.navbar-default .navbar-toggle {
    border-color: #2d3032;
    color: #fff !important;
    background-color: #2d3032 !important;
}
.navbar-default .navbar-toggle:active{
    background-color: #DD0000 !important;
    border-color: #DD0000;
}
.navbar-default .navbar-collapse,
.navbar-default .navbar-form {
    border-color: transparent;
}

Script in index.blade.php

<script>
document.addEventListener('DOMContentLoaded', function() {
    var button = document.getElementById('toggle-button');
    var navbarCollapse = document.getElementById('navbar');

    // Toggle 'active' class when the button is clicked
    button.addEventListener('click', function() {
        // Use a timeout to wait for the collapse animation to complete
        setTimeout(function() {
            if (navbarCollapse.classList.contains('in') || navbarCollapse.classList.contains('show')) {
                button.classList.add('active');
            } else {
                button.classList.remove('active');
            }
        }, 350); // Adjust delay to match the Bootstrap collapse animation duration
    });

    // Add 'active' class when the navbar is shown
    navbarCollapse.addEventListener('shown.bs.collapse', function() {
        button.classList.add('active');
    });

    // Remove 'active' class when the navbar is hidden
    navbarCollapse.addEventListener('hidden.bs.collapse', function() {
        button.classList.remove('active');
    });
});
</script>.

I place this code at the index.blade.php same with the code. But it still wont work. Tell me how can i resolve this issue?

At first is i use navbar toggle:hover. But the effect is when i click on it it will stay red. but if i click on the toggle again, it will stay red, and it will stay red unless i click on area outside the navbar.

Get response from CHATGPT using extension

I am trying to create a chrome extension which gets response from ChatGPT. I am not ready to pay for an API key. So i tried to use an iframe. But got a “frame-ancestor” error, and solved that using Framer extension which makes this easy. But now I am unable to send questions as i am restricted from accessing a cross-origin frame.

Cannot access iframe content: DOMException: Failed to read a named property ‘document’ from ‘Window’: Blocked a frame with origin “http://127.0.0.1:5500” from accessing a cross-origin frame.at window. Onload (http://127.0.0.1:5500/i.html:26:59)

Is there any other way to solve this problem or use ChatGPT in my extension?
I tried using Gemini API and I was able to get 60 responses per mkinute but I want to integrate ChatGPT in my extension.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <iframe  style="width: 1000px; height: 1000px;"  id="myIframe"
  src="https://chatgpt.com/"></iframe>
<button id="myBtn">Click me</button>
<script>

window.onload = function() {
            var iframe = document.getElementById('myIframe');
            try {
                var iframeDocument = iframe.contentWindow.document;
                var content = iframeDocument.body.innerHTML;
                console.log(content);
            } catch (e) {
                console.error('Cannot access iframe content:', e);
            }}
</script>
</body>
</html>

This is the code i am currently working on and I am unable to solve the error.

Fail to update state React [duplicate]

I’m following a tutorial to get Items from localStorage, this is the code:

export const CartProvider = ({ children }) => {
  const [cartItems, setCartItems] = useState([]);
  // Load cart items from local storage on component mount
  useEffect(() => {
    const storedCartItems = JSON.parse(localStorage.getItem("cartItems")) || [];
    console.log('Loaded cart items from localStorage:', storedCartItems);
    setCartItems(storedCartItems);
    console.log('Cart items:', cartItems);
  }, []);
  // Save cart items to local storage whenever cartItems state changes
  useEffect(() => {
    localStorage.setItem("cartItems", JSON.stringify(cartItems));
  }, [cartItems]);

So the problem is storedCartItems has the Items in it but the cartItems not get updated, it log out as blank[]. Please help.

Here is the console logging

JavaScript class not working on external file

(https://i.sstatic.net/wPIwfXY8.png)(https://i.sstatic.net/YFTflaOx.png)(https://i.sstatic.net/68IP9mBM.png)

I’m facing an error- if i create the class APIfeature in my tourcontroller.js file,it works just fine but whenever i try to take that class to another file and export then require it,it doesnt give me any data whenever i try to send a request from postman..

Tried to send request,but not getting any results back.