animations not working when body set to 100% or vh

This is my portfolio website where I am trying to add smooth-scrollbar.
The smooth-scrollbar docs says to initiate scrollbar the element which will use it, should have limited height and width.
smooth-scrollbar docs
If the body is set to 100% or 100 vh, the animations on skills section progressbar and reviews section not working.
Without setting body to limited height initializing the scrollbar effects on stuck scrollbar, so I have to comment the script line in html to avoid stuck scrollbar and animations.
commented the line

Tried to initialize the scrollbar without setting body height to 100% and other units like svh, dvh but still not working.

Ajax does not return errors in div

I can’t return the results in the div with ajax and zepto.

My cod.

JS

$("#formPassword").on("submit", function (event) {
    event.preventDefault();
    var dados = $(this).serialize();
    $.ajax({
        url: getRoot() + 'controllers/controllerSenha',
        type: 'post',
        dataType: 'json',
        contentType: "application/json; charset=utf-8",
        data: dados,
        success: function (response) {
            if (response.retorno == 'success') {
                $('.retornoSen').html("E-mail send !");
            } else {
                getCaptcha();
                $('.retornoSen').empty();
                $.each(response.erros, function (key, value) {
                    $('.retornoSen').u(value + '<br>');
                });
            }

        }
    });
});

the return only appears like this
{"retorno":"erro","erros":[

Thanks, I need help. rsrs

How to get callback from PyQt6 QWebEnginePage().runJavaScript(js_code, callback)

I am currently learning PyQt6 and I am interested in learning more about the capabilities of QtWebEngine. I would appreciate if you could recommend some guides or tutorials for studying QtWebEngine. Thank you in advance for your help.
I understand that the issue lies in the fact that the img tag does not appear on the web page in time for the JavaScript findElementByClassName method to find it.

from PyQt6.QtWidgets import QApplication
from PyQt6.QtWebEngineWidgets import QWebEngineView
from PyQt6.QtCore import QUrl
import sys

def js_handle_callback(result):
    print('Result: ', type(result), result)

js_code = """
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
var img = document.getElementsByClassName('lnXdpd');
canvas.height = img.naturalHeight;
canvas.width = img.naturalWidth;
context.drawImage(img, 0, 0, img.naturalWidth, img.naturalHeight);
var base64String = canvas.toDataURL();
base64String;
"""

def js_run():
    page.runJavaScript(js_code, js_handle_callback)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    view = QWebEngineView()
    page = view.page()
    page.loadFinished.connect(js_run)
    view.load(QUrl('https://google.com'))
    view.show()
    sys.exit(app.exec())

Output:

Result:  <class 'NoneType'> None

Tried to use signal loadFinished, but it doesn’t help. The JavaScript window.addEventListener(‘load’, function(){ My Code }) also doesn’t help because the callback doesn’t wait for the ‘load’ event.

Is this the best way to use local storage when uploading to the web?

So I’m appending images in a for loop to the same page depending on the link that is being clicked on I have a logic.js file:

var liquidityImages = ["Images"
var structureImages = ["Images"];
var sndImages = ["images"]

// Function to change images
function changeImages(imagesArray) {
  // Save the selected images array to localStorage
  localStorage.setItem('selectedImages', JSON.stringify(imagesArray));
  // Navigate to the replicable-page.html
  window.location.href = 'page1.html';
}

and the appending function

document.addEventListener('DOMContentLoaded', function () {
    // Retrieve the selected images array from localStorage
    var selectedImages = JSON.parse(localStorage.getItem('selectedImages')) || [];
  
    // Call the changeImages function to append the images
    changeImages(selectedImages);
  });
  
  function changeImages(imagesArray) {
    // Clear existing images
    var imageContainer = document.getElementById('image-container');
    imageContainer.innerHTML = "";
  
    // Loop through the selected array and append images
    for (var i = 0; i < imagesArray.length; i++) {
      var imgElement = document.createElement("img");
      imgElement.src = imagesArray[i];
      imgElement.alt = "Image " + (i + 1); // Provide an alt attribute for accessibility
      imageContainer.appendChild(imgElement);
    }
  }

The question is, when i upload it to the server is this the best way or should i consider doing it differently because local storage can be a load on the page.

I tired doing it without the local storage logic and it didnt work at all

New images are not loading in NextJs 13 & 14

I have stored the images in public/images/ folder,

All the images before i run NPM RUN BUILD is working fine, But when i add new images in public folder after deployment, those images not load.

but if i clear the cache, rebuild the cache and run website again, those images work fine

Joining Accenture by breaking bond in techm [closed]

I have doubt after I join techm if Accenture joining mail comes then if I break bond and leave techm and can I join Accenture with relieving letter as I mentioned no experience in tasks list of Accenture at doc verification time?

I have doubt after I join techm if Accenture joining mail comes then if I break bond and leave techm and can I join Accenture with relieving letter?

How do I make an popup slide-out animation

I’m building a version 2 of my own website and I’m trying to make an popup slide-out animation. The problem is that I have tried making one but I always mess up and nothing makes it work. I did an slide-in animation which works but now I need an slide-out animation.

How do I make an slide-out popup animation for my popup. Would appreciate if someone would help!

Code can be seen down below:

function openPopup() {
  document.getElementById("popup").style.display = "block";
}

function closePopup() {
  document.getElementById("popup").style.display = "none";
}
.popup {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.popup-content {
  background-color: #ffffff;
  padding: 20px;
  border-radius: 5px;
  box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
  text-align: center;
  width: 400px;
  height: 400px;
  position: relative;
  right: -600px;
  top: 200px;
  animation: popUPAnimation 1s forwards;
}

@keyframes popUPAnimation {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.popup-content h1 {
  color: #333333;
  font-size: 2.5rem;
  text-align: center;
  text-decoration: underline;
}

.popup-content h2 {
  color: #333333;
  font-size: 1.3rem;
  text-align: center;
  margin-top: 10px;
}

.solid-popup {
  position: absolute;
  border-top: 1px solid #bbb;
  width: 70%;
  margin-top: 20px;
  margin-left: 40px;
}

.popup-content button {
  background: #EEEEEE;
  border: none;
  border-radius: 5px;
  padding: 5px 10px;
  margin: 10px;
  position: relative;
  top: 30px;
  cursor: pointer;
  transition: all .45s ease;
}

.popup-content button:hover {
  background: #dedede;
}

.popup-close {
  position: absolute;
  top: -10px;
  right: 5px;
  font-size: 3rem;
  cursor: pointer;
  color: #333333;
  transition: all .45s ease;
}

.popup-close:hover {
  transform: scale(1.1);
  color: #0f0f0f;
}
<button onclick="openPopup()">Open popup</button>


<div id="popup" class="popup">
  <div class="popup-content">
    <span class="popup-close" onclick="closePopup()">&times;</span>
    <h1>Sort products</h1>
    <h2>Categories</h2>
    <hr class="solid-popup">
    <div class="popup-buttons">
      <div>
        <button onclick="window.location.href='#';">General Websites</button>
      </div>
      <div>
        <button onclick="window.location.href='#';">Fivem Websites</button>
      </div>
      <div>
        <button onclick="window.location.href='#';">Custom made websites</button>
      </div>
      <div>
        <button onclick="window.location.href='#';">Ecommerce Websites</button>
      </div>
      <div>
        <button onclick="window.location.href='#';">All Websites</button>
      </div>
    </div>
  </div>
</div>

I tried making an popup in animation which worked fine and good as I expected but then I tried making an pop-out animation which didn’t work and now I’m here asking help.

Adobe PDF simple Javascript loop not looping reliably

I have this loop that simply beeps every three seconds in a PDF document level script, for testing/debugging purposes:

// Beep every three seconds and write the current time in the document's text field named "FeedbackField

function testBeepAndUpdateField() { // beep and write current time in document text field
    app.beep();

    // Update the text field with the current time
    var now = new Date();
    var field = this.getField("FeedbackField");
    if (field) {
        field.value = "Updated at: " + now.toLocaleTimeString();
    }

    app.setTimeOut("testBeepAndUpdateField()", 3333); // function calls itself every 3333 milliseconds
}

app.setTimeOut("testBeepAndUpdateField()", 2000); // calls function and delays first auto-execution when opening the document by 2 seconds

For unknown reasons, it unpredictably loops zero to four times after the document is opened, and then stops.

Here is a test document that contains the script and time display text field.

The issue only occurs in Adobe Acrobat or Reader, not in PDF-XChange Editor, for example.

Any workaround would be greatly appreciated.

I wish to play audio from an array that contains audio urls , but it is not working

const [handleSet, setHandleSet] = useState(true)
  const audioRef = useRef<HTMLAudioElement | null>(null)

  const [index, setIndex] = useState(0)

  const handleClick = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
    e.stopPropagation()
    e.currentTarget.blur()
    setHandleSet(!handleSet)
    playAudio()
  }

  const playAudio = useCallback(() => {
    if (audioRef.current) {
      if (handleSet) {
        audioRef.current.play()
      } else {
        audioRef.current.pause()
      }
    }
  }, [handleSet])

  useEffect(() => {
    const handleEnded = () => {
      setIndex(index + 1)
      playAudio()
    }

    const newAudioRef = audioRef.current

    newAudioRef?.addEventListener('ended', handleEnded)

    return () => {
      newAudioRef?.removeEventListener('ended', handleEnded)
    }
  }, [index, playAudio]) /////

/////
  <div>
            <Button onClick={handleClick}>{handleSet ? 'Play All' : 'Pause All'}</Button>
            <StyledAudio ref={audioRef} src={trendingTopics[index]?.audio_EN}>
              <track kind="captions" />
            </StyledAudio>
          </div>

I have tried a couple of things ,but they do not seem to work, I use Ref to store the src of audio files it is in and array the functionality seems to work when I manually trigger the button that is the index is updated but the autoplay functionality does not work

Creating an array in Javascript with xml data in a file

I must first state that I am not a champion in programming, although created a handy website using html, php, MySQL and some javascript. Clearly, JS is by far the language I am almost using as a baby !

I have a set of data in a xml file with the following structure (sorry for the bad characters encoding) :

*<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> 
<markers> 
 <marker lat="50.84310" lng="4.39330" name="7.7cm Sockel Flak 16 RheinMetall" category="FlakKanonen" nation="Allemagne" typecanon="Artillerie de DCA" lieu="Bruxelles - Musée Royal de l'Armée" pays="Belgique" url="../AfficheCanonGET.php?IdCanonAffiche=170" /> 
 <marker lat="43.13810" lng="-80.26170" name="15cm sFH 13 L/14" category="SchwerenKanonen" nation="Allemagne" typecanon="Artillerie lourde" lieu="Brantford (ON) - Monument" pays="Canada" url="../AfficheCanonGET.php?IdCanonAffiche=256" />  
 <marker lat="61.00500" lng="24.45780" name="10cm K 14" category="LeichtKanonen" nation="Allemagne" typecanon="Artillerie légère" lieu="Hameenlinna - Finnish Artillery Museum" pays="Finlande" url="../AfficheCanonGET.php?IdCanonAffiche=317" />  
 <marker lat="45.88740" lng="11.04740" name="7cm M 99 GebK" category="GebirgsKanonen" nation="Autriche-Hongrie" typecanon="Artillerie de montagne" lieu="Rovereto - Museo Storico Italiano della Guerra" pays="Italie" url="../AfficheCanonGET.php?IdCanonAffiche=733" /><marker lat="-35.21550" lng="149.14510" name="13cm K 09 L/35" category="SchwerenKanonen" nation="Allemagne" typecanon="Artillerie lourde" lieu=" Mitchell, ACT - AWM reserve" pays="Australie" url="../AfficheCanonGET.php?IdCanonAffiche=1519" /> 
 </markers>*

This xml file is used in a javascript code for placing markers on a GoogleMap. Well it used to since the code does not work anymore since GoogleMap migrated to APIV3, without portability of the xml importing function I was using.

I managed to rewrite the map code in the new API v3 language, but I am stuck in what is probably very simple for you : Despite reading tens of similar threads, I am unable to adapt a code in javascript to transfer these xml file data in a javascript array

Here is what I am hoping to create :

*           marqueurCanonTest4[0] = {
                latitudeCanon: "-34.94570", 
                longitudeCanon: "138.58050", 
                nomCanon: "7.7cm FK 16",
                categorieCanon: "LeichtKanonen",
                nationCanon: "Allemagne",
                typeCanon: "Artillerie légère",
                lieuCanon: "Adelaide, SA  - Keswick Barracks, Army Museum of South Australia",
                paysCanon: "Australie",
                url: "../AfficheCanonGET.php?IdCanonAffiche=1"
                };
            marqueurCanonTest4[1] = {
                latitudeCanon: "-36.14640", 
                longitudeCanon: "146.91680", 
                nomCanon: "7.7cm FK 16",
                categorieCanon: "LeichtKanonen",
                nationCanon: "Turquie",
                typeCanon: "Artillerie légère",
                lieuCanon: "Bandiana, VIC - Army Museum",
                paysCanon: "Australie",
                url: "../AfficheCanonGET.php?IdCanonAffiche=2"
                };  

etc…*

Could someone help ?

Thank you

Bernard

I have tried to use xmlhttprequest, but probably incorrectly

Nuxt module: How can I use Tailwind without breaking PrimeVue’s pre-defined style

Brief: I’m trying to start a Nuxt.js project with both Tailwind CSS and PrimeVue installed as modules. And I would like to use pre-styled PrimeVue (aka. unstyled: false). However, Tailwind seems to break PrimeVue’s pre-defined style.

Problem: Before adding @nuxtjs/tailwindcss as a Nuxt module, every PrimeVue components works fine (pic.1, pink). However, after adding it the color of every PrimeVue components gets “infected” (pic.2, blue & dark). I’ve tried changing PrimeVue’s theming but it didn’t work. How can I use both without Tailwind breaks PrimeVue?

before adding tailwind module
after adding tailwind module

Config file: nuxt.config.ts

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  devtools: { enabled: true },
  modules: [
    "nuxt-primevue",
    '@nuxtjs/tailwindcss',  // <-- add or delete this line
  ],
  primevue: {
    options: {
      unstyled: false,
    },
    importPT: { as: 'Tailwind', from: 'primevue/passthrough/tailwind' },
    cssLayerOrder: 'tailwind-base, primevue, tailwind-utilities',
  },
  css: [
    'primevue/resources/themes/lara-light-pink/theme.css',
    'assets/main.css'
  ]
})

The Vue source code app.vue:

<template>
  <div>
    <Button>uwu</Button>
    <InputText v-model="value" placeholder="Search" />
    <div class="w-10 h-10 bg-slate-500">a</div>
    <div class="w-10 h-10 bg-primary-500">a</div>
  </div>
</template>

<script lang="ts" setup>
const value = ref("");
</script>

Complete Project Source Code: https://github.com/Saplyn/nuxt-tailwind-primevue (a just-started-up project)

I’ve Tried:

Last but not least: I’m not sure if this should be an Issue at GitHub or not, so I decided to ask for help at here first. Also, if this should become an Issue, which repo should it belongs to?

Encrypt in c# and decrypt in JavaScript

I create in c# a string which is saved into a html. In some input-fields I want to “hide” some strings which should be decrypt via JavaScript implemented in the html.

In C# (encrypt)

    public static string Crypt(string text, string k = "xyz")
    {
        var result = new StringBuilder();
        for (int c = 0; c < text.Length; c++)
            result.Append((char)((UInt16)text[c] ^ (UInt16)k[c % k.Length]));
        return result.ToString();
    }

In JavaScript (decrypt)

        function crypt(input, key = "xyz") 
        {
            let result = '';
            for (let i = 0; i < input.length; i++) {
                let charCode = input.charCodeAt(i) ^ key.charCodeAt(i % key.length);
                result += String.fromCharCode(charCode);
            }
            return result;
        }

The decryption mostly works fine, but some words failed (samples in German)
erpiesen (instead of erwiesen), lässs (instead of lässt), bepegen (instead of gewesen)

Even long words works fine (for instance: usammengestellt, verbrennen, beginnen …).

Any idea or recommandation for an easy way to make words “unreadable” in c# and readable again in JavaScript?

How make partial component which share one logic?

I created baseModal for my project, which takes arguments like header , body, footer as props.

The problem is, when i have actual modal, which should have searchbar in header , and body that will response to input in Header.
Is it a way to create Header and Body components, that will share same logic

i have tried this:

import { ChangeEvent, useEffect, useState } from "react";

function useThisModal() {
  const [search, setSearch] = useState("");
  const list = ["1", "12", "3"];
  const [sorted, setSorted] = useState<string[]>([]);

  const handleSearch = (e: ChangeEvent<HTMLInputElement>) => {
    setSearch(e.target.value || "");
  };

  useEffect(() => {
    setSorted(prev => list.filter((item) => item.startsWith(search)));
    
  }, [search]);

  return { sorted, handleSearch };
}

export function Header() {
  const { handleSearch } = useThisModal();
  return <input onChange={handleSearch} type="text" />;
}

export function Body() {
  const { sorted } = useThisModal();
  return <div>{sorted.map((item) => <div key={item}>{item}</div>)}</div>;
}

but in that case i create new instance of hook in each component…
the way i have came to is just use react context, but maybe someone know easier way or more concise

Discord Bot – Chunksize – Messagesize

I’m currently testing my own Discord bot and taking my first steps in Java. It is supposed to split messages that are longer than 2000 characters. It works too. But then the bot crashes immediately. I get the following error message.

DiscordAPIError[50006]: Cannot send an empty message
    at handleErrors (C:[email protected]:722:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.runRequest (C:[email protected]:1120:23)
    at async SequentialHandler.queueRequest (C:[email protected]:953:14)
    at async _REST.request (C:[email protected]:1266:22)
    at async TextChannel.send (C:discordchatbotnode_modulesdiscord.jssrcstructuresinterfacesTextBasedChannel.js:155:15) {
  requestBody: {
    files: [],
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      embeds: undefined,
      components: undefined,
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: undefined,
      flags: undefined,
      message_reference: { message_id: '1185890520967430184', fail_if_not_exists: true },
      attachments: undefined,
      sticker_ids: undefined,
      thread_name: undefined
    }
  },
  rawError: { message: 'Cannot send an empty message', code: 50006 },
  code: 50006,
  status: 400,
  method: 'POST',
  url: 'https://discord.com/api/v10/channels/1127282162018832404/messages'

Here is my full Code. I worked from a video that is 3 months old. Everything works fine there. I think the error is in the “Chunksize” section. Here is the Video:
https://youtu.be/EUlnKW6Yy94?t=1146

require('dotenv/config');
const { Client } = require('discord.js');
const { OpenAI } = require('openai');

const client = new Client ({
    intents: ['Guilds', 'GuildMembers', 'GuildMessages', 'MessageContent'],    
});

client.on('ready', () => {
    console.log('The Bot is online.');
});

const IGNORE_PREFIX = "!";
const CHANNELS = ('1127282162018832404')

const openai = new OpenAI ({
    apiKey: process.env.OPENAI_KEY,
})

client.on('messageCreate', async (message) => {
    if (message.author.bot) return;
    if (message.content.startsWith(IGNORE_PREFIX)) return;
    if (!CHANNELS.includes(message.channelId)) return;

    await message.channel.sendTyping();

    const sendTypingInterval = setInterval(() => {
        message.channel.sendTyping();
    }, 5000);

    let conversation = [];
    conversation.push({
        role: 'system',
        content: 'Beim heiligen Klabautermann. Was willst du von mir?'
    });

    let prevMessages = await message.channel.messages.fetch({ limit: 10});
    prevMessages.reverse();

    prevMessages.forEach((msg) => {
        if (msg.author.bot && msg.author.id !== client.user.id) return;
        if (msg.content.startsWith(IGNORE_PREFIX)) return;

        const username = msg.author.username.replace(/s+/g, '_').replace(/[^ws]/gi, '');

        if (msg.author.id === client.user.id) {
            conversation.push({
                role: 'assistant',
                name: username,
                content: msg.content,
            });

            return;
        }

        conversation.push({
            role: 'user',
            name: username,
            content: msg.content,
        })
    })

    const response = await openai.chat.completions
        .create({
            model: 'gpt-3.5-turbo',
            messages: conversation,
        })
        .catch((error) => console.error('OpenAI Error:n', error));
    
    clearInterval(sendTypingInterval);

    if (!response) {
        message.reply("Beim heiligen Klabautermann. Ich habe gerade ein wenig Stress. Gib mir einen Moment.");
        return;
    }
    
    const responseMessage = response.choices[0].message.content;
    const ChunkSizeLimit = 2000;

    for (let i = 0; i < responseMessage.length; i += ChunkSizeLimit) {
        const chunk = responseMessage.substring(i, i + ChunkSizeLimit);

        await message.reply(chunk);
    }

    message.reply();

});

client.login(process.env.TOKEN);