Audio file does not load

i want do play an audio file useing the Audio() class in JavaScript. But the file is not loading, i get an idle state and than the download suspends.

I tried following code:

let newMediaElem = new Audio(lastSrc + '?debugload=' + Date.now());
newMediaElem.preload = 'auto';
newMediaElem.setAttribute('preload', 'auto');

let playProm = newMediaElem.play();
playProm.then(function (res) {
  console.log('playProm result: ', res);
}).catch(function (err) {
  console.log('playProm err: ', err);
});

newMediaElem.addEventListener('suspend', function () {
  console.log('TEST suspend 2 mediaElem:', newMediaElem);
  console.log('TEST suspend 2 networkState', newMediaElem.networkState);
  newMediaElem.play();
});
newMediaElem.addEventListener('stalled', function () {
  console.log('TEST stalled 2', newMediaElem.error);
});
newMediaElem.addEventListener('waiting', function () {
  console.log('TEST waiting 2', newMediaElem.error);
});
newMediaElem.addEventListener('playing', function () {
  console.log('TEST playing 2', newMediaElem.error);
});
newMediaElem.addEventListener('canplaythrough', function () {
  console.log('TEST canplaythrough 2', newMediaElem.error);
});
newMediaElem.addEventListener('canplay', function () {
  console.log('TEST canplay 2', newMediaElem.error);
});
newMediaElem.addEventListener('emptied', function () {
  console.log('TEST emptied 2', newMediaElem.error);
});
newMediaElem.addEventListener('abort', function () {
  console.log('TEST abort 2', newMediaElem.error);
});
newMediaElem.addEventListener('error', function (e) {
  console.log('TEST error 2', e);
});
newMediaElem.addEventListener('loadeddata', function (e) {
  console.log('TEST loadeddata 2', e);
});
newMediaElem.addEventListener('loadedmetadata', function (e) {
  console.log('TEST loadedmetadata 2', e);
});
newMediaElem.addEventListener('loadstart', function (e) {
  console.log('TEST loadstart 2', e);
});
newMediaElem.addEventListener('progress', function (e) {
  console.log('TEST progress 2', e);
});

I got

TEST waiting 2 null Mediaplayer.js:1238:33
TEST loadstart 2 loadstart { target: audio, isTrusted: true, srcElement: audio, currentTarget: audio , eventPhase: 2, bubbles: false, cancelable: false, returnValue: true, defaultPrevented: false, composed: false, … } Mediaplayer.js:1265:33
TEST progress 2 progress { target: audio, isTrusted: true, srcElement: audio, currentTarget: audio , eventPhase: 2, bubbles: false, cancelable: false, returnValue: true, defaultPrevented: false, composed: false, … } Mediaplayer.js:1268:33
TEST progress 2 progress { target: audio, isTrusted: true, srcElement: audio, currentTarget: audio , eventPhase: 2, bubbles: false, cancelable: false, returnValue: true, defaultPrevented: false, composed: false, … } Mediaplayer.js:1268:33
TEST suspend 2 mediaElem: <audio preload="auto" src="https://music.xn--fairtr…?debugload=1723189173149"> Mediaplayer.js:1230:33
TEST suspend 2 networkState 1

What can i do to get the audio playing?

Javascript not work properly in Loop Grid widget(Elementor Pro)

I have a loop item template, where among other things, there is a button widget (with no click on it, used just for shape and easy to use) that fetches a custom field value from the post. This value is a number between 0-100. The button is accompanied by a script that changes the color of the button based on the value in it.

Now here’s the problem:
When using this template for the loop grid widget, the script works only for the first post in the list. All other post have standard color buttons that does not depend on the value in it. All other things work fine. My only problem is to let this javascript work for every element in the loop grid widget. I tried to put the script not in the loop item template but in page where the the loop grid widget will be used, but it doesn’t work either.

The button has the ID set to ‘myButton’, and I thought that’s where the problem lies, maybe in subsequent elements of the loop grid, the buttons lose that id?

    function getColor(value) {
        const colors = {
            0: '#F50000', 1: '#F50000', 2: '#F50000', 3: '#F50000', 4: '#F50000', 5: '#F50000', 6: '#F50000', 7: '#F50000', 8: '#F50000', 9: '#F50000',
            10: '#F50000', 11: '#F50000', 12: '#F50000', 13: '#F50000', 14: '#F50000', 15: '#F50000', 16: '#F50000', 17: '#F50000', 18: '#F50000', 19: '#F50000',
            20: '#F50000', 21: '#F50000', 22: '#F50000', 23: '#F50000', 24: '#F50000', 25: '#F50000', 26: '#F50000', 27: '#F50000', 28: '#F50000', 29: '#F50000',
            30: '#F50000', 31: '#F50000', 32: '#F50000', 33: '#F50000', 34: '#F50000', 35: '#F50000', 36: '#F50000', 37: '#F50000', 38: '#F50000', 39: '#F50000',
            40: '#F50000', 41: '#F50000', 42: '#F00000', 43: '#EB0000', 44: '#E60000', 45: '#E10000', 46: '#DC0000', 47: '#D70000', 48: '#D20000', 49: '#CD0000',
            50: '#C80000', 51: '#C80A00', 52: '#C81400', 53: '#C81E00', 54: '#C82800', 55: '#C83200', 56: '#C83C00', 57: '#C84600', 58: '#C85000', 59: '#C85A00',
            60: '#C86400', 61: '#C86E00', 62: '#C87800', 63: '#C88200', 64: '#C88C00', 65: '#C89600', 66: '#C8A000', 67: '#C8AA00', 68: '#C8B400', 69: '#C8BE00',
            70: '#C8C800', 71: '#BEC800', 72: '#B4C800', 73: '#AAC800', 74: '#A0C800', 75: '#96C800', 76: '#8CC800', 77: '#82C800', 78: '#78C800', 79: '#6EC800',
            80: '#64C800', 81: '#5AC800', 82: '#50C800', 83: '#46C800', 84: '#3CC800', 85: '#32C800', 86: '#28C800', 87: '#1EC800', 88: '#14C800', 89: '#0AC800',
            90: '#00C800', 91: '#00CD00', 92: '#00D200', 93: '#00D700', 94: '#00DC00', 95: '#00E100', 96: '#00E600', 97: '#00EB00', 98: '#00F000', 99: '#00F500',
            100: '#00FA00'
        };
        return colors[value];
    }

    function updateCircle() {
        const button = document.getElementById('myButton');
        const value = parseInt(button.innerText, 10);
        const primaryColor = '#605BE5'; // primary color fixed
        const secondaryColor = getColor(value);
        button.style.backgroundImage = `linear-gradient(to bottom, ${primaryColor}, ${secondaryColor} 80%)`;
    }

    // Constantly update color
    setInterval(updateCircle, 10);
<button id="myButton">1</button>

Bootstrap 5 Carousel: How to Smoothly Transition Between Non-Adjacent Slides Using Indicators

Problem Description:

I’m using Bootstrap 5 to implement a carousel with three slides, and I’ve encountered an issue when navigating between non-adjacent slides using the indicators. Specifically, when I try to go directly from the first slide to the third slide by clicking the corresponding indicator, I want the carousel to smoothly transition through the second slide rather than jumping directly to the third. However, the transitions are not smooth, and the slides either disappear momentarily or the transition gets stuck.

This is my code I have tried.

document.addEventListener('DOMContentLoaded', function() {
    var myCarousel = document.getElementById('carouselExampleIndicators');
    var carousel = new bootstrap.Carousel(myCarousel, {
        interval: false, // Disable automatic cycling
        wrap: false      // Prevent cycling from last to first slide automatically
    });

    myCarousel.addEventListener('slide.bs.carousel', function(event) {
        var currentIndex = event.from;
        var nextIndex = event.to;

        // If the user tries to go from the first slide directly to the third
        if ((currentIndex === 0 && nextIndex === 2) || (currentIndex === 2 && nextIndex === 0)) {
            event.preventDefault(); // Prevent the default slide

            // Move to the middle slide first
            carousel.to(1);

            // Wait for the transition to finish before moving to the final slide
            myCarousel.addEventListener('slid.bs.carousel', function() {
                // Immediately transition to the final destination
                carousel.to(nextIndex);
            }, { once: true }); // Use `once: true` to ensure this only runs once
        }
    });
});
<div class="container">
  <div id="carouselExampleIndicators" class="carousel slide">
    <div class="carousel-indicators">
      <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
      <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2"></button>
      <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
    </div>
    <div class="carousel-inner">
      <div class="carousel-item active">
        <img src="https://fastly.picsum.photos/id/758/500/200.jpg?hmac=ZpJtW1JQcdvAX5aOs3xN-A1to1naMgzT_QuOPShmuhs" class="d-block w-100" alt="...">
      </div>
      <div class="carousel-item">
        <img src="https://fastly.picsum.photos/id/581/500/200.jpg?hmac=1wd_yrXA8qPktG3mqx5C1ZhTqIjgPmsXdoy1f-_xT2o" class="d-block w-100" alt="...">
      </div>
      <div class="carousel-item">
        <img src="https://fastly.picsum.photos/id/221/500/200.jpg?hmac=taeeJWTKqW59XdSyKOzl6DI-W41lNSqjxwRq0_BzFMM" class="d-block w-100" alt="...">
      </div>
    </div>
    <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev">
      <span class="carousel-control-prev-icon" aria-hidden="true"></span>
      <span class="visually-hidden">Previous</span>
    </button>
    <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="next">
      <span class="carousel-control-next-icon" aria-hidden="true"></span>
      <span class="visually-hidden">Next</span>
    </button>
  </div>
</div>
.carousel-item {
    transition: transform 1s ease-in-out;
}

.carousel-item.active {
    opacity: 1;
    transition: opacity 1s ease-in-out;
}

.carousel-item-next,
.carousel-item-prev {
    opacity: 1;
    transition: opacity 1s ease-in-out, transform 1s ease-in-out;
}

The page is refreshing when message sent ? e.preventDefault() is not working

I created a chatbot in which, first, I’ll receive a response. In the form, there is a last field that has a value, and I want to send that value as a user message. The bot is working fine, but when I click on ‘chatsubmit,’ it refreshes the page. e.preventDefault() is not working because it is false, but without false, I can’t send the values.

const submitForm = async (e, val) => {
    if (e) { e.preventDefault(); }

    if (!conversationId) {
        console.error('conversationId is not set.');
        return;
    }

    document.querySelector("#chat-submit").disabled = true;

    let x = document.forms["form-feedback-data"]["message"];
    let message = val || x.value;

    console.log('Submitting message:', message);

    // Send user message to API
    await sendToApi(conversationId, "user", message);

    if (message !== "") {
        let aud = new Audio("https://backend.aiduals.com/assets/userMusic.mp3");
        aud.play();

        // Display user message in chat window
        let userDiv = `
            <div class="aidual_chatbot_wrap">
                <div style="display: flex; align-items: center; justify-content: end;">
                    <div>
                        <span class="aidual_chatbot_date2">
                            <strong>${guestName.length > 0 ? guestName : "Guest"}</strong> ${generateDate()}
                        </span>
                    </div>
                    <div class="aidual_chatbot_wimg2">
                        <img src="${avtarUrl.length > 0 ? avtarUrl : "https://backend.aiduals.com/assets/user.png"}" alt="" />
                    </div>
                </div>
                <div class="aidual_chatbot_wchat2">
                    ${message}
                </div>
            </div>`;

        let blinkMsg = `
            <div style="display: flex; padding-left: 0px;" id="typing-feed-active">
                <span style="color: #555; font-size: 13px; font-weight: 500; display: flex; margin-top: 6px;">
                    <span style="margin-right: 5px">Do Tasks AI</span> is <span id="blinkChangeMsg" style="margin-left: 5px">typing</span>
                </span>
                <div class="typing">
                    <span></span>
                    <span></span>
                    <span></span>
                </div>
            </div>`;

        typingInterval = setInterval(() => {
            typingIndex++;
            if (typingIndex === 6) {
                typingIndex = 0;
            }
            let typingMsgData = document.getElementById("blinkChangeMsg");
            typingMsgData.innerText = arrTyping[typingIndex];
        }, 5000);

        const chatWindow = document.getElementById("mainChatWindowBlock");
        chatWindow.insertAdjacentHTML("beforeend", userDiv);
        chatWindow.insertAdjacentHTML("beforeend", blinkMsg);
        if (chatWindow.clientHeight < chatWindow.scrollHeight) {
            chatWindow.scrollBy(0, chatWindow.scrollHeight);
        }

        // Call onCreateMessage to get AI response
        onCreateMessage(message, typingInterval);

        if (!val) {
            x.value = "";
        }
    }
}

async function onFormSubmit(e) {
    e.preventDefault();
    loader.style.display = "inline-block";

    // Gather form data
    const data = {
        name: document.forms["form-data-main"]['name'].value,
        email: document.forms["form-data-main"]['email'].value,
        phone: document.forms["form-data-main"]['phone'].value,
        text: document.forms["form-data-main"]['message'].value,
    };

    // Store the guest name
    guestName = data.name;
    let value = data.text;

    removeMsg();
    document.querySelector("#form-container-box").style.display = "none";
    mainWindow.style.display = "block";
    chatBox.style.display = "block";

    try {
        // Send POST request to create a conversation
        const response = await fetch("https://dotasks.in/api/create-conversation", {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json;charset=utf-8'
            },
            body: JSON.stringify(data)
        });

        const result = await response.json();

        if (result.status) {
            conversationId = result.cid;
            console.log('The conversation id is:', conversationId);
            // Store feedData in a cookie
            feedData = { cid: conversationId };
            document.cookie = `feedData=${JSON.stringify(feedData)}`;

            // Fetch the conversation
            // await fetchChatData(conversationId);
            newFeed = feedData;
            submitForm(false, value);  // value is going from here

            // Clear form fields
            document.forms["form-data-main"]['name'].value = "";
            document.forms["form-data-main"]['email'].value = "";
            document.forms["form-data-main"]['phone'].value = "";
            document.forms["form-data-main"]['message'].value = "";
        } else {
            console.error("Failed to create conversation:", result.message);
        }
    } catch (error) {
        console.error("Error creating conversation:", error);
    } finally {
        loader.style.display = "none";
    }

};


                                    <div class="">
                                    <div class="message-input">
                                        <form class="message_input_wrap" id="form-feedback-data">
                                            <!--<span class="chat_icon"><img-->
                                            <!--        src="https://reeelapps-app.s3.us-west-2.amazonaws.com/aistaff/hire_staff_img/chat-icon.png"-->
                                            <!--        alt="" /></span>-->
                                            <input type="text" class="chat_typing_box"
                                                placeholder="Write your message..." name="message" required />
                                                
                                            <!--<div class="voice-icon-wrapper">-->
                                            <!--    <i id="start-btn" class="chat-send fa-solid fa-microphone"-->
                                            <!--        onclick="startRecognition()">-->
                                            <!--    </i>-->
                                            <!--    <i id="stop-btn" style="display:none;"-->
                                            <!--        class="chat-send fa-solid fa-pause" onclick="startRecognition()">-->
                                            <!--    </i>-->
                                            <!--</div>-->
                                                
                                            <button class="chat-send" type="submit" id="chat-submit"><img
                                                    src="https://reeelapps-app.s3.us-west-2.amazonaws.com/Reputor_ai/send.png"
                                                    alt="" /></button>
                                                    
                                                    
                                        </form>
                                    </div>

I want to submit the form first, then receive the value as user input, and the page should not refresh when I send the message.

getJSON loop in Jquery dosent return all objects

I have a specific problem.
I have one JSON file that contains all JSON files in a folder.
I am iterating through that in a function where i create an array,
I take that array and send it to another function where i for each filename in array 1
Iterate through and get all the keys and values of that JSON.

Ex: function1 , Create array from JSON

this is the JSON

[
{"file":"filename1.json"},
{"file":"filename2.json"}
]

this is the function:

function getFiles(c,sectiontype){ //This function triggers BKND asp to get all the files that is in BKND/Codes/ folder, and push out a JSON file under JSON/Codes/ folder.
    // c is the type of code ASP, PS, CMD 
    $.ajax('BKND/'+sectiontype+'.asp');
    var arrFiles=[];
    $.ajax({
        'async': false, //Set to false so that script waits for JSON to load.
        'url': 'JSON/'+sectiontype+'.json', //URL to where to pick up JSON
        'dataType': "json", //datatype
        'success': function (data) { //if it succeeds
            cFiles = data
        }
    });
    putCodeblocks(cFiles)
}

this is the second function where i take the array from first function and iterate through each file anc collect all keys and values and put create the codeblocks in HTML

function putCodeblocks(files){
    let zfiles = files.toString();
    console.log(zfiles)
    $.each(obj, function(key,value) {
      $.getJSON('BKND/Codes/'+value.file, function(data){
        $.each(data, function(index, element) {
            console.log(element.title)
        })
      })
    }); 

}

The first function works. it creates a JS array object, and i have checked that it is transferred to second function…
But in second function, i only get the first filename and then the $.each loop stops?
why?- What am i missing here?

How to Capture a Screenshot of a Cross-Origin Iframe in a Laravel App

I am developing a Laravel application that includes a feature to display 360-degree virtual tours. These tours are loaded into iframes and can be hosted on an AWS S3 bucket or another storage solution. The tours are HTML and JavaScript-based projects that showcase interactive 360-degree views.

I want to add a functionality where users can click a “Comment” button outside the iframe, which opens a sidebar with the current iframe view at the top and an “Add Comment” box below. When the user saves a comment, I need to capture a screenshot of the current iframe view and save it along with the comment.

The problem: I am running into cross-origin restrictions that prevent me from capturing a screenshot of the iframe content.

What I’ve Tried:

  • Using libraries like html2canvas to capture the screenshot, but it doesn’t work due to cross-origin policies.
  • Investigating CORS settings, but I do not have control over the iframe content to modify headers.
  • Considering server-side rendering with headless browsers, but I’m unsure how to integrate it with my current setup.

Questions:

  • how can I capture screenshots of cross-origin iframes securely and legally.

bs-datepicker style positioning

im using bs-datepicker and im not able to set its position

 <input class="form-control" #issue_date="ngModel" ngModel id="issuedate_{{row}}" name="issue_date"
                                    bsDatepicker [bsConfig]="{dateInputFormat: dateFormat, containerClass: 'theme-blue ' , orientation: 'top' }"
                                    autocomplete="off" [placeholder]="dateFormat"
                                    [(ngModel)]="rowObj.issue_date" />
                                </td>

i want it to set the datepicker above my input field
by default it is setting it at bottom

“:has” pseudo selector not working properly

I am trying to make a comment process in HTML, CSS, js, and PHP.

I have an element named .view_replies in the nested class.

If I make a sibling of its parent element and want to target it(i.e.sibling) I use the has pseudo selector but it does not work.

Can anyone tell me where I am wrong?

Following are my HTML codes:

<section class="comment_main_container">
    <!-- Total comments -->
    <div class="total_comments">
        <p>Comments</p>

        <p>6</p>

    </div>

    <!-- Add comment -->
    <form action="../partials/comment_handle" method="POST">
        <div class="add_comment">
            <div class="user_dp"><img src="../img/users_img/black-soil.jpg" alt=""></div>
            <div class="comment">
                <input type="text" name="comment" placeholder="Elaborate your concern">
                <button class="comm_btn" type="submit">comment</button>
            </div>
        </div>
    </form>



    <!-- Comments -->
    <div class="comment_container">
        <!-- Replies -->
        <div class="comment_box">
            <div class="comment_card">
                <div class="user_details">
                    <div class="user_dp">
                        <img src="../img/users_img/black-soil.jpg" alt="">
                    </div>
                    <div class="user_name">
                        <h3>@hello viewer</h3>
                    </div>
                </div>
                <p>comment7</p>
                <div class="comment_footer">
                    <div class="like">
                        <button type="submit">
                            <i class="fa-regular fa-thumbs-up"></i>
                        </button>
                        <p>50</p>
                    </div>
                    <div class="dislike">
                        <button type="submit">
                            <i class="fa-regular fa-thumbs-down"></i>
                        </button>
                        <p>5</p>
                    </div>
                    <button type="submit" class="cReplies">
                        <p>reply</p>
                    </button>
                    <button type="submit" class="dReplies">
                        <p class="view_replies active">view replies</p>
                        <p>3</p>
                    </button>
                    <div class="display-reply">
                        <form action="../partials/comment_reply_handle?cid=7" method="POST">
                            <textarea name="comment_reply" id="" class="text-reply"></textarea>
                            <button class="reply_btn" type="submit">reply</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Reply -->
    <div class="comment_box repliesView">
        <div class="comment_card">
            <div class="user_details">
                <div class="user_dp">
                    <img src="../img/users_img/black-soil.jpg" alt="">
                </div>
                <div class="user_name">
                    <h3>@hello viewer</h3>
                </div>
            </div>
            <p>reply</p>
            <div class="comment_footer">
                <div class="like">
                    <button type="submit">
                        <i class="fa-regular fa-thumbs-up"></i>
                    </button>
                    <p>50</p>
                </div>
                <div class="dislike">
                    <button type="submit">
                        <i class="fa-regular fa-thumbs-down"></i>
                    </button>
                    <p>5</p>
                </div>
                <button type="submit" class="dReplies">
                    <p>reply</p>
                </button>
                <div class="display-reply">
                    <form action="../partials/comment_reply_handle?cid=7" method="POST">
                        <textarea name="comment_reply" id="" class="text-reply"></textarea>
                        <button class="reply_btn" type="submit">reply</button>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <!-- Reply -->
    <div class="comment_box repliesView">
        <div class="comment_card">
            <div class="user_details">
                <div class="user_dp">
                    <img src="../img/users_img/black-soil.jpg" alt="">
                </div>
                <div class="user_name">
                    <h3>@hello viewer</h3>
                </div>
            </div>
            <p>reply4</p>
            <div class="comment_footer">
                <div class="like">
                    <button type="submit">
                        <i class="fa-regular fa-thumbs-up"></i>
                    </button>
                    <p>50</p>
                </div>
                <div class="dislike">
                    <button type="submit">
                        <i class="fa-regular fa-thumbs-down"></i>
                    </button>
                    <p>5</p>
                </div>
                <button type="submit" class="dReplies">
                    <p>reply</p>
                </button>
                <div class="display-reply">
                    <form action="../partials/comment_reply_handle?cid=7" method="POST">
                        <textarea name="comment_reply" id="" class="text-reply"></textarea>
                        <button class="reply_btn" type="submit">reply</button>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <!-- Reply -->
    <div class="comment_box repliesView">
        <div class="comment_card">
            <div class="user_details">
                <div class="user_dp">
                    <img src="../img/users_img/black-soil.jpg" alt="">
                </div>
                <div class="user_name">
                    <h3>@hello viewer</h3>
                </div>
            </div>
            <p>reply5</p>
            <div class="comment_footer">
                <div class="like">
                    <button type="submit">
                        <i class="fa-regular fa-thumbs-up"></i>
                    </button>
                    <p>50</p>
                </div>
                <div class="dislike">
                    <button type="submit">
                        <i class="fa-regular fa-thumbs-down"></i>
                    </button>
                    <p>5</p>
                </div>
                <button type="submit" class="dReplies">
                    <p>reply</p>
                </button>
                <div class="display-reply">
                    <form action="../partials/comment_reply_handle?cid=7" method="POST">
                        <textarea name="comment_reply" id="" class="text-reply"></textarea>
                        <button class="reply_btn" type="submit">reply</button>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <!-- Comments -->
    <div class="comment_container">
        <!-- Replies -->
        <div class="comment_box">
            <div class="comment_card">
                <div class="user_details">
                    <div class="user_dp">
                        <img src="../img/users_img/black-soil.jpg" alt="">
                    </div>
                    <div class="user_name">
                        <h3>@hello viewer</h3>
                    </div>
                </div>
                <p>comment6</p>
                <div class="comment_footer">
                    <div class="like">
                        <button type="submit">
                            <i class="fa-regular fa-thumbs-up"></i>
                        </button>
                        <p>50</p>
                    </div>
                    <div class="dislike">
                        <button type="submit">
                            <i class="fa-regular fa-thumbs-down"></i>
                        </button>
                        <p>5</p>
                    </div>
                    <button type="submit" class="cReplies">
                        <p>reply</p>
                    </button>
                    <button type="submit" class="dReplies">
                        <p class="view_replies">view replies</p>
                        <p>0</p>
                    </button>
                    <div class="display-reply">
                        <form action="../partials/comment_reply_handle?cid=6" method="POST">
                            <textarea name="comment_reply" id="" class="text-reply"></textarea>
                            <button class="reply_btn" type="submit">reply</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Comments -->
    <div class="comment_container">
        <!-- Replies -->
        <div class="comment_box">
            <div class="comment_card">
                <div class="user_details">
                    <div class="user_dp">
                        <img src="../img/users_img/black-soil.jpg" alt="">
                    </div>
                    <div class="user_name">
                        <h3>@hello viewer</h3>
                    </div>
                </div>
                <p>comment5</p>
                <div class="comment_footer">
                    <div class="like">
                        <button type="submit">
                            <i class="fa-regular fa-thumbs-up"></i>
                        </button>
                        <p>50</p>
                    </div>
                    <div class="dislike">
                        <button type="submit">
                            <i class="fa-regular fa-thumbs-down"></i>
                        </button>
                        <p>5</p>
                    </div>
                    <button type="submit" class="cReplies">
                        <p>reply</p>
                    </button>
                    <button type="submit" class="dReplies">
                        <p class="view_replies">view replies</p>
                        <p>0</p>
                    </button>
                    <div class="display-reply">
                        <form action="../partials/comment_reply_handle?cid=5" method="POST">
                            <textarea name="comment_reply" id="" class="text-reply"></textarea>
                            <button class="reply_btn" type="submit">reply</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>



</section>

Following are my CSS codes:

@import url('https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap');

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Nunito", sans-serif;
}
.comment_main_container{
    width: 100%;
    padding: 80px 16.80%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.comment_main_container .total_comments{
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    font-weight: 600;
}
.comment_main_container .add_comment{
    /* border: 1px solid red; */
    width: 100%;
    height: auto;
    gap: 10px;
    display: flex;
    margin-bottom: 25px;
}
.comment_main_container .add_comment .user_dp{
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
}
.comment_main_container .add_comment .user_dp img{
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: flex;
}
.comment_main_container .add_comment .comment{
    width: calc(100% - 50px - 10px);
    height: 50px;
    display: flex;
}
.comment_main_container .add_comment .comment input{
    width: 100%;
    height: 100%;
    border: 0;
    border-bottom: 1px solid #e9e9e9;
    outline: none;
    font-size: 18px;
}
.comment_main_container .add_comment .comment .comm_btn{
    cursor: pointer;
    outline: none;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border-radius: 30px;
    background-color: rgb(7 178 232 / 11%);
    text-transform: capitalize;
    font-size: 15px;
    color: rgb(51 51 51 / 80%);
}
.comment_container:not(:first-child) {
    margin-top: 1rem;
}
.comment_box{
    width: 100%;
    height: auto;
    position: relative;
    /* display: flex; */
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-left: 10px;
}
.comment_box:not(:first-child) {
    width: calc(100% - 1rem);
}
/* .comment_box:not(:first-child){
    display: none;
} */
/* .revel.active .comment_box:not(:first-child){
    display: flex;
} */

.revel.active ~ .comment_box{
    background-color: #000;
}
.comment_main_container .comment_box::before{
    content: "";
    background-color: rgb(170, 170, 170);
    position: absolute;
    min-height: 100%;
    width: .5px;
    left: 0;
}
.comment_main_container .comment_box:not(:first-child){
    margin-left: 1rem;
}
.comment_main_container .comment_box .comment_card{
    /* border: 2px solid red; */
    /* width: calc(100% - 20px); */
    width: 100%;
    height: 100%;
    gap: 10px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.1);
    padding: 20px;
    background-color: #fff;
    border: 1px solid rgb(0 0 0 / 12%);
    border-radius: 5px;
}
.comment_main_container .comment_box .comment_card .user_details{
    /* border: 2px solid darkgreen; */
    width: 100%;
    height: 100%;
    display: flex;
    gap: 10px;
}
.comment_main_container .comment_box .comment_card .user_details .user_dp{
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
}
.comment_main_container .comment_box .comment_card .user_details .user_dp img{
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: flex;
}
.comment_main_container .comment_box .comment_card .user_details .user_name{
    display: flex;
    width: calc(100% - 50px - 10px);
    height: auto;
    align-items: center;
}
.comment_main_container .comment_box .comment_card .user_details .user_name h3{
    text-transform: lowercase;
    font-size: 18px;
}
.comment_main_container .comment_box .comment_card .comment_footer{
    /* border: 2px solid darkgreen; */
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 20px;
}
.comment_main_container .comment_box .comment_card .comment_footer .like,
.comment_main_container .comment_box .comment_card .comment_footer .dislike{
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}
.comment_main_container .comment_box .comment_card .comment_footer .like button,
.comment_main_container .comment_box .comment_card .comment_footer .dislike button{
    background-color: transparent;
    cursor: pointer;
    outline: none;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.comment_main_container .comment_box .comment_card .comment_footer .like button:hover{
    color: #006BB7;
}
.comment_main_container .comment_box .comment_card .comment_footer .dislike button:hover{
    color: #000;
}
.comment_main_container .comment_box .comment_card .comment_footer .like button i,
.comment_main_container .comment_box .comment_card .comment_footer .dislike button i{
    font-size: 20px;
}
.comment_main_container .comment_box .comment_card .comment_footer .like p,
.comment_main_container .comment_box .comment_card .comment_footer .dislike p{
    font-size: 15px;
}
.comment_main_container .comment_box .comment_card .comment_footer .reply{
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}
.comment_main_container .comment_box .comment_card .comment_footer button{
    display: flex;
    gap: 5px;
    background-color: transparent;
    cursor: pointer;
    outline: none;
    border: none;
}
.comment_main_container .comment_box .comment_card .comment_footer button p{
    font-size: 15px;
    font-weight: bold;
    text-transform: capitalize;
}
.comment_main_container .comment_box .comment_card .comment_footer button p:nth-child(1):hover{
    color: #006BB7;
}
/* .comment_main_container .comment_box .comment_card .comment_footer .reply p{
    font-size: 15px;
} */

.display-reply{
    width: 100%;
    height: 20px;
    display: none;
}
.display-reply form{
    width: 100%;
    height: 100%;
    display: flex;
    gap: 10px;
}
.display-reply .text-reply{
    display: flex;
    width: 100%;
    height: 100%;
    border: none;
    border-bottom: 1px solid grey;
    outline: none;
}
.comment_main_container .comment_box .comment_card .comment_footer .cReplies.active ~ .display-reply{
    display: flex;
}
.comment_main_container .comment_box .comment_card .comment_footer .cReplies.active ~ .display-reply .reply_btn{
    cursor: pointer;
    outline: none;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: capitalize;
    font-size: 15px;
    font-weight: 600;
    color: #000;
}
.comment_main_container .comment_box .comment_card .comment_footer .cReplies.active ~ .display-reply .reply_btn:hover{
    color: #006BB7;
}
.comment_main_container > .repliesView {
    display: none;
}
.comment_main_container .comment_container:has(> .view_replies.active) ~ .repliesView{
    display: flex;
}

Following are my JS codes for .active class:

const viewReplies = document.querySelectorAll(".view_replies");

    viewReplies.forEach(vwRply => {
        vwRply.addEventListener("click", () => {
            vwRply.classList.toggle("active");
        });
    });

All game is that first I make .comment_box.repliesView display:none; I have the target

.comment_main_container .comment_box .comment_card .comment_footer button p.view_replies

and make a function onclick for adding an active class then again target to .comment_box.repliesView and make it display:flex;

For this, I have written the CSS:

.comment_main_container > .repliesView {
    display: none;
}

And JS for this is as follows:

const viewReplies = document.querySelectorAll(".view_replies");

    viewReplies.forEach(vwRply => {
        vwRply.addEventListener("click", () => {
            vwRply.classList.toggle("active");
        });
    });

Collapsible page to prevent reloading and staying the same when I update data

I have a collapsible webpage in a multiproject mvc solution. I have an js code:

`$(document).on("click", ".open-AddSendDialog", function () {
    var myBookId = $(this).data('id');
    $("#sendId").val(myBookId);
});
`

with this code when I click on submit button, everything works fine but it reloads the entire page and I should re open the collapsed parts again but I want to prevent that. when I use AJAX for it I get 0 as Id even when I call the required data into the AJAX code. how can I solve this problem?
this is the new js that I wrote:


`    $(document).ready(function () {
        $('#btn1').click(function (e) {
            e.preventDefault();

            var formData = {

                Id: $('#mallMaintenanceSystemId').val(),
                Statue: $('#mallMaintenanceSystem_Statue').val(),
                Note: $('#mallMaintenanceSystem_Note').val(),
                ImageFile1: $('#mallMaintenanceSystem_ImageFile1').val(),
                ImageFile2: $('#mallMaintenanceSystem_ImageFile2').val(),
                ImageFile3: $('#mallMaintenanceSystem_ImageFile3').val(),
                ImageFile4: $('#mallMaintenanceSystem_ImageFile4').val()
                
            };
            var p1 = {
                mallMaintenanceSystem : formData,

            };

            $.ajax({
                type: 'POST',
                url: '/MallAndInstruction/Send',
                data: p1,
                success: function (response) {
                    alert('Data saved successfully!');
                },
                error: function (response) {
                    alert('Error saving data!');
                }
            });
        });
    });`

btw I use both the old and the new js codes together!

In typescript, how to create promise, register handlers in this example?

I have code downstream that depends on the server listening to the port and have this code which does not compile

  const promise = new Promise<string>(); //this does not compile
  const port = 5432;
  server.listen(8000, "localhost", () => {
    logger.info(`Proxy server listening on localhost:${port}`)
    promise.resolve("success"); //this does not compile
  });

  return promise

Of course downstream via aysnc and await methods, it will wait until that promise is resolved before continuing. My other hack method is putting a sleep there instead. How to achieve this correctly? The above example is taken from scala (and java works the same with CompletableFuture) so I am confused on the typescript/javascript versions

I tried the above.

Update your com.google.android.play:core:1.10.3 Maven dependency to an Android 14 compatible version! Youle.android.play:core:1.10.3 library

When i upload to on google play console then got error like this

Update your com.google.android.play:core:1.10.3 Maven dependency to an Android 14 compatible version! Your current com.google.android.play:core:1.10.3 library is incompatible with targetSdkVersion 34 (Android 14), which introduces a backwards-incompatible change to broadcast receivers. As a reminder, from August 31, 2024, Google Play requires all new app releases to target Android 14. Update to the latest library version dependency to avoid app crashes.

I try everything i know but not resolved this issue

Here is my build.gralde code

apply plugin: ‘com.android.application’
apply plugin: ‘com.google.gms.google-services’

android {
buildFeatures {
viewBinding true
}
compileSdkVersion 34

defaultConfig {
   
    minSdkVersion 23
    targetSdkVersion 34
    versionCode 7
    versionName "1.6"
    multiDexEnabled true
    vectorDrawables.useSupportLibrary = true
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
    resources {
        excludes += ['META-INF/NOTICE.md', 'META-INF/LICENSE.md']
    }
}
lint {
    abortOnError false
    checkReleaseBuilds true
}
namespace 'com.darsenizami.ahyaululoom'

}

dependencies {
implementation fileTree(dir: ‘libs’, include: [‘*.jar’])

// AndroidX dependencies
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.vectordrawable:vectordrawable:1.2.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.navigation:navigation-fragment:2.7.7'
implementation 'androidx.navigation:navigation-ui:2.7.7'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.multidex:multidex:2.0.1'
implementation "androidx.palette:palette:1.0.0"
implementation 'androidx.preference:preference:1.2.1'

// Firebase Messaging inappmessaging
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-inappmessaging-display:21.0.0'

// Firebase database
implementation 'com.google.firebase:firebase-storage:21.0.0'
implementation 'com.google.firebase:firebase-core:21.1.1'
implementation 'com.google.firebase:firebase-config:22.0.0'
implementation 'com.firebaseui:firebase-ui-database:8.0.2'
implementation 'com.google.firebase:firebase-database:21.0.0'

// Firebase dependencies with BOM
implementation platform('com.google.firebase:firebase-bom:33.1.2')
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-inappmessaging-display'
implementation 'com.google.firebase:firebase-storage'
implementation 'com.google.firebase:firebase-core'
implementation 'com.google.firebase:firebase-config'
implementation 'com.google.firebase:firebase-database'
implementation 'com.google.firebase:firebase-analytics'

// Firebase UI
implementation 'com.firebaseui:firebase-ui-database:8.0.2'
implementation 'com.google.firebase:firebase-auth:23.0.0'

// Test dependencies
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.6.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'

// External libraries
implementation 'com.github.mjn1369:prettydialog:1.0.4'
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'com.github.bumptech.glide:glide:4.16.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.16.0'
implementation 'com.github.SanojPunchihewa:InAppUpdater:1.0.5'
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.android.volley:volley:1.2.1'
implementation files('libs/YouTubeAndroidPlayerApi.jar')
implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'
implementation 'com.google.android.gms:play-services-ads:23.2.0'
implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'

// Play Core library
//noinspection RiskyLibrary
implementation 'com.google.android.play:core:1.10.3'

}

Why does my recursive memoization function cause a ‘Maximum Call Stack Exceeded’ error in JavaScript?

While solving fabonocci problem using recursion and memoization in JavaScript, I got “Maximum Call Stack Exceeded” error when I try to run it with large inputs. To troubleshoot, I copied the solution from GeeksforGeeks (GFG) and that works correctly. However, I’m struggling to understand why my approach fails.

Here is my code

function topDown(n) {
  const modulus = 10 ** 9 + 7;
  const dp = {};
  function rec(value) {
    if (value <= 1) {
      return value;
    }
    if (dp[value] !== undefined) {
      return dp[value];
    }
    dp[value] = (rec(value - 1) + rec(value - 2)) % modulus;
    return dp[value];
  }
  return rec(n);
}

Here is working solution

function topDownTwo(n) {
  const modulus = 10 ** 9 + 7;
  const dp = {};
  function rec(value) {
    if (value <= 1) {
      return value;
    }
    if (dp[value] !== undefined) {
      return dp[value];
    }
    const ans = (rec(value - 1) + rec(value - 2)) % modulus;
    dp[value] = ans;
    return ans;
  }
  return rec(n);
}

Only difference is how value is returned from recursive function.

dp[value] = (rec(value - 1) + rec(value - 2)) % modulus;
return dp[value];

and

const ans = (rec(value - 1) + rec(value - 2)) % modulus;
dp[value] = ans;
return ans;

When I call these functions with a large value of n, like 9657, my version throws a stack overflow error, while the GFG version runs without any issues.

I’d appreciate any help in understanding the cause of this issue.

Fixing vulnerability in docker image for react project

While scanning the image using Trivy, I am getting these vulnerabilities –

enter image description here

Since the dependency is in package-lock.json, So in order to fix them, I have updated @esbuild in package.json using overrides –

"overrides": {
    "esbuild": "0.23.0"
  }

Now after scanning the image again, I am left with 1 medium vulnerability –

enter image description here

I am not sure what else I need to update to get rid of this medium vulnerability. Anyone can help me out ?