How do I get my button the right ? The moment I try to shift it to right ot left outside of the slide it vanishes, I have also used z-index as well

How do I get my buttons the right on left? The moment I try to shift it to right or left outside of the slide it vanishes, I have also used z-index as well.
They will show up on the slide but not outside of it
Like this, the button is disappearing if I try to move it past the slide component,I have shared codes as well. Please let me know. Thanks

enter image description here

const slides = document.querySelectorAll(".slide");
const btnLeft = document.querySelector(".slider-btn-left");
const btnRight = document.querySelector(".slider-btn-right");

let currentSlide = 0;
let maxSlide = slides.length;

console.log(slides);

// const goToSlide = function (slide) {
//   slides.forEach(
//     (s, i) => (s.style.transform = `translateX(${(i - slide) * 100}%)`)
//   );
// };

function nextSlide() {
  if (currentSlide === maxSlide - 1) {
    currentSlide = 0;
  } else {
    currentSlide++;
  }

  slides.forEach(
    (el, i) => (el.style.transform = `translateX(${(i - currentSlide) * 100}%)`)
  );
}

function prevSlide() {
  if (currentSlide === 0) {
    currentSlide = maxSlide - 1;
  } else {
    currentSlide--;
  }
  slides.forEach(
    (el, i) => (el.style.transform = `translateX(${(i - currentSlide) * 100}%)`)
  );
}

btnRight.addEventListener("click", nextSlide);

btnLeft.addEventListener("click", prevSlide);
* TESTIMONIAL SECTION */
.section-customers {
  padding: 9.6rem 0;
  background-color: #fed2d2;
}

.customers-heading-question,
.customer-weight-lost,
.customers-heading-answer {
  color: rgb(82, 82, 82);
}

.customers-illust {
  padding-bottom: 4.8rem;
}

.customers-text {
  display: flex;
  flex-direction: column;
  gap: 3rem;
  justify-content: center;
}

.customers-text .customer-weight-lost {
  font-size: 2rem;
}

.customers-text .customer-weight-lost span {
  color: #a12222;
}

.customer-img {
  max-width: 100%;
  height: 10rem;
  width: 10rem;
  border-radius: 50%;
  box-shadow: rgba(6, 24, 44, 0.4) 0px 0px 0px 2px,
    rgba(6, 24, 44, 0.65) 0px 4px 6px -1px,
    rgba(255, 255, 255, 0.08) 0px 1px 0px inset;
}

.caraseoul {
  position: relative;
  height: 35rem;
  max-width: 60rem;
  margin: 0 auto;
  overflow: hidden;
}

.testimonial {
  color: black;
}

.slide {
  position: absolute;
  width: 100%;
  text-align: center;
  padding: 2rem 0;

  background-color: white;
  border: 5px solid #a12222;
  transition: transform 1s;
  overflow: hidden;
}

.slide::after {
  content: "WHAT THE FUCK";
  position: absolute;
  left: -10%;
  top: 12%;
  font-size: 1.6rem;
  font-weight: 500;
  background-color: violet;
  padding: 2rem 6rem;
  transform: rotate(315deg);
}

.slider-btn {
  position: absolute;
  background-color: rgb(255, 166, 166);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem;
  border: none;
  z-index: 99999;
  top: 50%;
}

.slider-btn-left {
  left: 0%;
  transform: translate(50%, -50%);
}
.slider-btn-right {
  right: 0%;
  transform: translate(50%, -50%);
}

.testimonial-text {
  font-size: 1.2rem;
  margin: 2rem;
  margin-top: auto;
}

.testimonial-author {
  font-size: 2rem;
  font-weight: 400;
  margin-bottom: 0.6rem;
  color: navy;
}

.testimonial-status {
  font-size: 1.8rem;
}

.testimonial-status span {
  color: #a12222;
  font-weight: 600;
}

.btn-icon {
  height: 2.4rem;
  width: 2.4rem;
  stroke: #a12222;
}
          <div class="caraseoul">
            <div class="slide">
              <img
                src="./images/customers/ryan-hoffman.jpg"
                alt="alexander"
                class="customer-img"
              />
              <blockquote class="testimonial">
                <p class="testimonial-text">
                  Lorem ipsum dolor sit amet consectetur adipisicing elit.
                  Ratione excepturi sint sequi laborum, nostru,excepturi sint
                  sequi laborum, nostru,excepturi sint sequi laborum, nostru
                </p>
                <p class="testimonial-author">Ryan Hoffman</p>
                <p class="testimonial-status">
                  <span>30 </span>kgs lost in 7 months
                </p>
              </blockquote>
            </div>
            <div class="slide">
              <img
                src="./images/customers/alexander.jpg"
                alt="alexander"
                class="customer-img"
              />
              <blockquote class="testimonial">
                <p class="testimonial-text">
                  Lorem ipsum dolor sit amet consectetur adipisicing elit.
                  Ratione excepturi sint sequi laborum, nostru,excepturi sint
                  sequi laborum, nostru,excepturi sint sequi laborum, nostru
                </p>
                <p class="testimonial-author">Alexander Hamilton</p>
                <p class="testimonial-status">
                  <span>10 </span>kgs lost in 2 months
                </p>
              </blockquote>
            </div>
            <div class="slide">
              <img
                src="./images/customers/edward.jpg"
                alt="alexander"
                class="customer-img"
              />
              <blockquote class="testimonial">
                <p class="testimonial-text">
                  Lorem ipsum dolor sit amet consectetur adipisicing elit.
                  Ratione excepturi sint sequi laborum, nostru,excepturi sint
                  sequi laborum, nostru,excepturi sint sequi laborum, nostru
                </p>
                <p class="testimonial-author">Cristina Niosi</p>
                <p class="testimonial-status">
                  <span>23 </span>kgs lost in 6 months
                </p>
              </blockquote>
            </div>
            <div class="slide">
              <img
                src="./images/customers/edward.jpg"
                alt="alexander"
                class="customer-img"
              />
              <blockquote class="testimonial">
                <p class="testimonial-text">
                  Lorem ipsum dolor sit amet consectetur adipisicing elit.
                  Ratione excepturi sint sequi laborum, nostru,excepturi sint
                  sequi laborum, nostru,excepturi sint sequi laborum, nostru
                </p>
                <p class="testimonial-author">Cristina Niosi</p>
                <p class="testimonial-status">
                  <span>23 </span>kgs lost in 6 months
                </p>
              </blockquote>
            </div>
            <div class="slide">
              <img
                src="./images/customers/edward.jpg"
                alt="alexander"
                class="customer-img"
              />
              <blockquote class="testimonial">
                <p class="testimonial-text">
                  Lorem ipsum dolor sit amet consectetur adipisicing elit.
                  Ratione excepturi sint sequi laborum, nostru,excepturi sint
                  sequi laborum, nostru,excepturi sint sequi laborum, nostru
                </p>
                <p class="testimonial-author">Cristina Niosi</p>
                <p class="testimonial-status">
                  <span>23 </span>kgs lost in 6 months
                </p>
              </blockquote>
            </div>
            <div class="slide">
              <img
                src="./images/customers/edward.jpg"
                alt="alexander"
                class="customer-img"
              />
              <blockquote class="testimonial">
                <p class="testimonial-text">
                  Lorem ipsum dolor sit amet consectetur adipisicing elit.
                  Ratione excepturi sint sequi laborum, nostru,excepturi sint
                  sequi laborum, nostru,excepturi sint sequi laborum, nostru
                </p>
                <p class="testimonial-author">Cristina Niosi</p>
                <p class="testimonial-status">
                  <span>23 </span>kgs lost in 6 months
                </p>
              </blockquote>
            </div>
            <div class="slide">
              <img
                src="./images/customers/edward.jpg"
                alt="alexander"
                class="customer-img"
              />
              <blockquote class="testimonial">
                <p class="testimonial-text">
                  Lorem ipsum dolor sit amet consectetur adipisicing elit.
                  Ratione excepturi sint sequi laborum, nostru,excepturi sint
                  sequi laborum, nostru,excepturi sint sequi laborum, nostru
                </p>
                <p class="testimonial-author">Cristina Niosi</p>
                <p class="testimonial-status">
                  <span>23 </span>kgs lost in 6 months
                </p>
              </blockquote>
            </div>
            <button class="slider-btn slider-btn-right">
              <svg
                xmlns="http://www.w3.org/2000/svg"
                fill="none"
                viewBox="0 0 24 24"
                stroke-width="1.5"
                stroke="currentColor"
                class="btn-icon"
              >
                <path
                  stroke-linecap="round"
                  stroke-linejoin="round"
                  d="M8.25 4.5l7.5 7.5-7.5 7.5"
                />
              </svg>
            </button>
            <button class="slider-btn slider-btn-left">
              <svg
                xmlns="http://www.w3.org/2000/svg"
                fill="none"
                viewBox="0 0 24 24"
                stroke-width="1.5"
                stroke="currentColor"
                class="btn-icon"
              >
                <path
                  stroke-linecap="round"
                  stroke-linejoin="round"
                  d="M15.75 19.5L8.25 12l7.5-7.5"
                />
              </svg>
            </button>
          </div>

Regex to detect deformed words

I need to detect if a string contains a specific word like “Hello”.

  • Hello -> yes
  • HhhheeeEEEElllLLLLoooOOOO -> Yes
  • hell0 -> yes
  • h e l l o / h. e .l .L . o -> Yes
  • h@@$$eee///LLL!!!ooo -> yes

My attempt:

let string = "h@@$$eee///LLL!!!ooo";

if (string.match(/bhellob/i)) {
      console.log("Yes");
} else {
      console.log("No");
}

Destructured variables over properties

const parent = document.querySelector('.parent');
const { children } = parent;
parent.firstElementChild.textContent = 'help';

How will you write the last line parent.firstElementChild.textContent = 'help'; as destructured variables?

Just trying to make sure that I satisfy the eslint rule to use destructured variables over properties.

How do I display Javascript variable using

According to the chrome console there are no problems however there are as my variable is “undefined” despite it being set as “0”

I have used the following resources:
Resource 1
Resource 2

I am trying to make it so when the user clicks my image it will add +1 to the points variable (Game.points) here is my code (for context purposes):

<!DOCTYPE html>

<script>
function Game() {
var points = "0"
document.getElementById("myText").innerHTML = Game.points;

}
</script>
<center>  <img onclick="Game.points = Game.points + 1" src="https://static.wikia.nocookie.net/villains/images/5/5d/Frieza.png/revision/latest?cb=20200625063534" width="350px"> </center>
<body onload="Game()">

    <h1>"The value for number is: " <span id="myText"></span></h1>

Thank you, sir or ma’am for reading this and I hope you can help me and have a good rest of your day 🙂

Return data from database and show in calendar

I’m creating a calendar for event bookings. The calendar is already working at the event registration level. I’m having trouble then showing the events registered in the database on the calendar.
To show the data in the database I am trying this way:

var datta = [
   {PequenoAlm:  "Peq_Almoço", Valencia: "Teste1", Ano: "2023", Mes: "6", Dia: "27", },
];

var verif = [];
var verif1 = [];
var verif2 = [];
var verif3 = [];
var verif4 = [];
for (var i = 0; i < datta.length; i++) {
  var PequenoAlm = datta[0].PequenoAlm;
  var Valencia = datta[0].Valencia;
  var Ano = datta[0].Ano;
  var Mes = datta[0].Mes;
  var Dia = datta[0].Mes;
  
  verif.push(PequenoAlm);
  verif1.push(Valencia);
  verif2.push(Ano);
  verif3.push(Mes);
  verif4.push(Dia);
}
    
 var event_data = {
   "events": [
     {
       "occasion": verif,
       "invited_count": verif1,
       "year": verif2,
       "month": verif3,
       "day": verif4,
       "cancelled": true
     }
   ]
 };

The problem is that it doesn’t show any information on the calendar.

I leave the complete code of how I am doing it and with the part of the code that I am trying to return the data from the database to the calendar.

code

Can you help overcome this difficulty?

Hash change in browser history with Laravel / Inertia Vue

I’m building a form with Inertia/ Vue.js that is split in multiple tabs.

I would like that clicking on a tab changes the current hash in history so the user is redirected to the current tab after refreshing the page.

The first solution I thought about was to simply use history.replaceState() when clicking on a tab:

history.replaceState(null, '', `#${selectedTab.slug}`)

The problem is that Inertia keeps its own state in memory and as soon as I change a value in the form the hash is changed back to its original state.

The second solution I thought about was using Inertia’s router but it makes an unnecessary request to the server.

router.visit(`#${selectedTab.slug}`, {
  preserveScroll: true,
  preserveState: true,
  replace: true,
})

Is there any way to tell Inertia to change only the URL in the state object?

What does “Uncaught (in promise) Object” mean?

I have such an error. How it can be corrected and debugged. I want the code to stop when there is a problem.
My code

export function postRequestOtpCode(phone: string, token: string): CancellableAxiosPromise {
  axios.defaults.baseURL = ARGO_ENV.API_APPLICATION_URL;
  return API.post('/otp/request-otp-code', { phone: `7${getCleanPhoneNumber(phone)}`, token }, {});
}


async function requestOtpCode(phone: string, captchaToken?) {
  try {
    clearTimer();
    setOtpLoading(true);
    const res = await postRequestOtpCode(phone, captchaToken);
    setOtpState(OTPstate.SHOW);
    startTimer();
    return res;
  } catch (err) {
    throw handleError(err);
  } finally {
    setOtpLoading(false);
  }
}

enter image description here

Error in React Native: ReadableNativeArray cannot be cast to com.facebook.react.bridge.ReadableMap when using react-native-chart-kit

I’m encountering an error in my React Native application when I attempt to fetch daily stock price data from the AlphaVantage API and display it using react-native-chart-kit.

The specific error message is ReadableNativeArray cannot be cast to com.facebook.react.bridge.ReadableMap, which prevents the chart from being displayed and leaves it in a “Loading…” state.

Here is the relevant part of my code:


// Fetching stock data and setting state
const fetchStockData = async () => {
  const response = await fetch(`https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=${symbol}&outputsize=compact&apikey=${key}`);
  const json = await response.json();
  const stockData = json['Time Series (Daily)'];
  const dates = Object.keys(stockData);
  const prices = dates.map(date => parseFloat(stockData[date]['4. close'])).filter(price => !isNaN(price));
  const datasets = [
    {
      data: prices
    }
  ];
  setData({ labels: dates, datasets });
}

// Rendering chart
return (
  <View>
    {data.datasets && data.datasets.length > 0 ?
      <LineChart
        data={data}
        width={300} 
        height={220}
        yAxisLabel="$"
        chartConfig={{
          backgroundColor: "#e26a00",
          backgroundGradientFrom: "#fb8c00",
          backgroundGradientTo: "#ffa726",
          decimalPlaces: 2,
          color: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`,
          labelColor: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`,
          style: {
            borderRadius: 16
          },
          propsForDots: {
            r: "6",
            strokeWidth: "2",
            stroke: "#ffa726"
          }
        }}
        bezier
        style={{
          marginVertical: 8,
          borderRadius: 16
        }}
      />
      :
      <Text>Loading...</Text>
    }
  </View>
);

The arrays prices and dates appear to contain the expected, valid values based on my logging, but the LineChart component fails to interpret the data object properly. Assistance on this issue is required.

I’m not sure why this is happening and how I should go about debugging it. Could there be an issue with the way I’m structuring the data for the LineChart component? Or could there be a compatibility issue between these libraries?

Codeigniter 4 unique name validation

My problem is that I have a modal and the input contains the value from the database. When I press the update button, the unique name validation check if the name already exists in the database. However, if I don’t change it, it also checks the unique name validation, which I don’t want to happen.

Here is the form.

<form action="<?= base_url('users/createRole'); ?> " method="post">
<div class="modal-body">
    <input type="hidden" name="roleID" id="roleID">
    <div class="mb-3">
        <label for="inputRoleName" class="form-label">Rolle hinzufügen</label>
        <input type="text" class="form-control" id="inputRoleName" name="inputRoleName" placeholder="Role Name">
    </div>
</div>
<div class="modal-footer">
    <button type="submit" class="btn btn-primary">Rolle speichern</button>
    <button type="button" class="btn btn-light" data-bs-dismiss="modal">Schließen</button>
</div>
</form>
        $(".btnEditRole").click(function() {
            const roleID = $(this).data('id');
            const inputRoleName = $(this).data('role');
            $('#modalTitle').html('Update Data Role');
            $('.modal-footer button[type=submit]').html('Update rolle');
            $('.modal-content form').attr('action', '<?= base_url('users/updateRole') ?>');
            $('#roleID').val(roleID);
            $('#inputRoleName').val(inputRoleName);
            $('.modal').on('hidden.bs.modal', function() {
                location.reload(); // Refresh the page when modal is closed
            });
        });

Here is the Function.

public function updateRole()
{
if (!$this->validate(['inputRoleName' => ['rules' => 'is_unique[user_role.role_name]']])) {
    session()->setFlashdata('notif_error', '<b>Das Hinzufügen eines neuen Benutzers ist fehlgeschlagen</b> Der Benutzer existiert bereits! ');
    return redirect()->to(base_url('users'));
}
$updateRole = $this->userModel->updateRole($this->request->getPost(null, FILTER_UNSAFE_RAW));
if ($updateRole) {
    session()->setFlashdata('notif_success', '<b>Benutzerdaten erfolgreich aktualisieren</b> ');
    return redirect()->to(base_url('users'));
} else {
    session()->setFlashdata('notif_error', '<b>Benutzerdaten konnten nicht aktualisiert werden</b> ');
    return redirect()->to(base_url('users'));
}
}

How to integrate the code to Next.js from Codepen

I am integrating HTML, CSS and Javascript into Next.js framework from codepen.
I want to add this to my application. I created a style.module.css for storing the CSS code. Before the return of page.jsx I pased the Javascript and the return part of the function pasing the HTML code. Although the visual does show, it can’t be animated.

Also, the .body inside style.module.css seem not working at all. How can I solve it? And what is the proper way to integrate all these three scripts into Next.js framework?

Inside /app folder, I created a folder that includes page.jsx and style.module.css.
Inside page.jsx, I used

"use client" 
import React from "react"; 
import styles from "./style.module.css" 
import anime from "animejs";

Inside a function from page.jsx, I pasted the Javascript code, and inside the return of the function, I pasted the HTML code.

Inside the style.modue.css, I pasted the CSS code.

Optional parameter cypress

I have a command i wish to put a value optional for it.

For example, i may have a select, sometimes i have to scroll on it to get a value and sometimes not.
Without the scroll:

Cypress.Commands.add('selectValue', (option) => {
 cy.getBySel('select').within(()
=> {
    cy.getBySel('options').contains(option).click();
});

With the scroll:

Cypress.Commands.add('selectValue', (option) => {
   cy.getBySel('select')
      .scrollTo('bottom', { duration: 1000 })
      .within(() => {
        cy.getBySel('options').contains('option').click();
      });

But since i do not scroll all the time, is there a way i can add the scroll part optional in my command instead of adding another command for it?

Thank you

How do I log the time of day by season in vanilla JS?

Hi so i made a Basic JS Clock this is the HTML for it:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JS CLOCK</title>
    <link rel="stylesheet" href="style.css">
    <script src="app.js" defer></script>
</head>
<body>
    <div class="wrapper">
        <h2 id="timer" class="timer">
        </h2>
    </div>
</body>
</html>

My problem is that i wrote a a code in JS that should console log the time of the day for example: Sunrise,Daytime,Sunset,Night Time. Depending on what season it is and what is the time.

A general sunrise sunset times in central europe is
Summer:

Sunrise: Around 05:00 to 06:00
Sunset: Around 20:30 to 21:30

I wrote the code for it but it dosent seem to be working.

Here is the whole JS code that i wrote. I cant find what im missing its probably the if Statments aren’t correct. If someone could help me i would really appriciate it.

//ALL THE ELEMENTS STORED
let date, h, m, s, month, season, timeOfDay,pH,pM,pS;
let timer = document.getElementById("timer");
//RAINBOW COLORS

function showTime() {
  date = new Date();
  h = date.getHours();
  m = date.getMinutes();
  s = date.getSeconds();
  month = date.getMonth();

  h = h < 10 ? "0" + h : h;
  m = m < 10 ? "0" + m : m;
  s = s < 10 ? "0" + s : s;

  pH = parseInt(h);
  pM = parseInt(m);
  pS = parseInt(s);

  
  timer.innerText = `${h}:${m}:${s}`;
  setTimeout(showTime, 1000);
  checkTimeOfDay(); 
  
  
}

showTime();

switch (month) {
case 11:
case 0:
case 1:
    season = "winter";
    break; 
case 2:
case 3:
case 4:
    season = "spring"; 
    break;
case 5:
case 6:
case 7:
    season = "summer";
    break;
case 8:
case 9:
case 10:
    season = "autumn";
    break;
}

function checkTimeOfDay() {
    if (season === "summer") {
      if ((pH === 5 && pM >= 30) || (pH === 6 && pM <= 30)) {
        console.log("It's sunrise");
      } else if (pH >= 6 && ((pH < 20 && pM <= 30) || (pH === 20 && pM === 0))) {
        console.log("It's day time");
      } else if (
        (pH === 20 && pM >= 30) ||
        (pH === 21 && pM === 0) ||
        (pH === 21 && pM === 30)
      ) {
        console.log("It's sunset");
      } else if (pH >= 21 || (pH < 7 && pM >= 30)) {
        console.log("It's night");
      }
    }
  }
  






Anyone know how to make an next and previous button on my pagination

Anyone know how to make an next and previous button on my pagination? i want to add the laquo and raquo in the pagination section and add a script to it but i dont know how can anyone teach me i’m a beginner

Here is the line of code:

<div class="pagination_section">
<a href="#" onclick="showPages('1')">1 </a><a href="#" onclick="showPages('2')">2 </a><a href="#" onclick="showPages('3')">3 </a><a href="#" onclick="showPages('4')">4 </a><a href="#" onclick="showPages('5')">5 </a><a href="#" onclick="showPages('6')">6 </a><a href="#" onclick="showPages('7')">7 </a>
</div>

Here is the js:

function showPages(id){
  var totalNumberOfPages = 7;
  for(var i=1; i<=totalNumberOfPages; i++){
    if(document.getElementById('page'+i)) {
      document.getElementById('page'+i).style.display='none';
    }
  }
  if (document.getElementById('page'+id)) {
    document.getElementById('page'+id).style.display='block';
  }
};