Owl Carousel is not working. My elements just stack up one another

HTML

<div class="col-lg-6">
                    <div class="slider1 owl-carousel">
                        <div class="slider-content">
                            <div class="slider-item set-bg" data-setbg="img/raya.jpg" >
                            </div>
                        </div>

                        <div class="slider-content">
                            <div class="slider-item set-bg" data-setbg="img/raya.jpg" >
                            </div>
                        </div>
                    </div>
                </div>

Stylesheet

    .slider1{
    display: block;
    position: relative;
    top: 300px;
    width: 800px;
    right: 90px;
    z-index: 1;
}

.slider-content{
    overflow: hidden;
    height: 500px;
}

.slider-content .slider-item{
    border-radius: 50px;
    margin-bottom: 42px;
    position: relative;
    height: 100%;
    width: 100%;
    opacity: 1;
}

.slider-content .slider-item p{
    font-size: 0.938rem;
    margin-bottom: 0;
} 

.slider-content .slider-item:after{
    position:absolute;
    content: "";
    top: 100%;
    right: 34px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 17px solid #eef6f9;
}


.slider1 .owl-dots{
    display: flex;
    display: -webkit-box;
    display: -ms-flex;
    display: -ms-flexbox;
    position: absolute;
    bottom: 37px;
    left: 0;
}

.slider1 .owl-dots .owl-dot{
    display: inline-flex;
    display: -webkit-inline-box;
    display: ms-inline-flex;
    display: -ms-inline-flexbox;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    margin-right: 7px;
    background: #eef6f9;
}

.slider1 .owl-dots .owl-dot.active{
    background: #eb2b63;
}

Js

/* Slider */
$('.slider1').owlCarousel ({
    loop:true,
    nav:false,
    dots:true,
    margin:128,
    center:true,
    items:1,
    mouseDrag:false,
    animateOut: 'fadeOutRight',
    animateIn: 'fadeInLeft',
    autoplay:true
});

My owl caorusel is not working. When I add in the picture all it does is add another picture down below the first one. There’s also no slider dots. What is the problem here?

Could it be I missed a stylesheet or js to use?

Note:
I already checked my owl carousel javascript and stylesheet and all of them are in the appropriate directories.

How to recreate google keep note

I tried to create my own notes for the school project. And I ran into some problems, I am using contentEditable for the note-taking part and it auto-generates divs. I tried to remove them with not much luck.

Html

<div id="main" contenteditable="true"></div>
<script type="text/javascript" src="static/js/note.js"></script>

JavaScript

$('#main').on('DOMSubtreeModified', function(){
        $('#main > div').children().unwrap();
    });

In this code, you have to press space twice but the bigger problem is when you try to create a new line above the text all the text below gets deleted.

also tried using replace:

$("#main div").replaceWith("<br> ")

I tried using many different options like replacing when enter got pressed…

Uploading Img to HTML canvas with proper aspect ratio

I want to upload an Img to a HTML-Canvas and want to see it immediately after uploading finished. How can I maintain the proper aspect ratio for the images?

  1. Huge images have to be resized to a given canvas size because they shouldn’t be allowed to fill the entire viewport.

  2. Small images should get a resizing, too, to fill the canvas.

  3. Only making use of HTML + CSS + vanilla JS

Thank you in advance!

Fade out (and then in) section after setInterval()

I have three image containers which show (different) images on rotation. After a set interval, I’m trying to get that section to fade out nicely, and fade the new image in.

Essentially something like:

  • Image shows
  • Starts to fade out slowly
  • Image changes when it’s faded out (so the change isn’t visual to the user)
  • New image starts to fade in

I’ve tried to achieve this by setting position.find(".employeeSlider__image").fadeOut().fadeIn();, but it’s way too fast and looks broken.

See demo here:

$(function() {

  var left = $('.employeeSlider__left');
  var mid = $('.employeeSlider__middle');
  var right = $('.employeeSlider__right');
  var images = [];

  // push images to array
  $('.employeeSlider__images').each(function() {
    var src = $(this).attr('src');
    images.push(src);
  });

  /***********/
  /* HELPERS */
  /***********/

  function changeImage(position) {
    var currentLeft = left.find('.employeeSlider__image').attr('src');
    var currentMid = mid.find('.employeeSlider__image').attr('src');
    var currentRight = right.find('.employeeSlider__image').attr('src');
    var floor = images.length - 1;

    var randomIndex = Math.floor(Math.random() * (floor - 0 + 1)) + 0;
    var randomIndexPlus = randomIndex + 1;
    var randomIndexMinus = randomIndex - 1;

    if (images[randomIndex] != currentRight && images[randomIndex] != currentMid && images[randomIndex] != currentLeft) {
      position.find('.employeeSlider__image').attr('src', images[randomIndex]);
    } else if (images[randomIndexPlus] != currentRight && images[randomIndexPlus] != currentMid && images[randomIndexPlus] != currentLeft) {
      position.find('.employeeSlider__image').attr('src', images[randomIndexPlus]);
    } else if (images[randomIndexMinus] != currentRight && images[randomIndexMinus] != currentMid && images[randomIndexMinus] != currentLeft) {
      position.find('.employeeSlider__image').attr('src', images[randomIndexMinus]);
    } else {
      position.find('.employeeSlider__image').attr('src', images[0]);
    }

    /* position.find(".employeeSlider__image").fadeOut().fadeIn(); */

  }

  /*****************/
  /* CHANGE IMAGES */
  /*****************/

  // left image
  setInterval(function() {
    changeImage(left);
  }, 3800);

  // middle image
  setTimeout(function() {
    setInterval(function() {
      changeImage(mid);
    }, 4000);
  }, 1000);

  // right image
  setTimeout(function() {
    setInterval(function() {
      changeImage(right);
    }, 4200);
  }, 2000);


});
section {
  background: lightblue;
}

.employeeSlider {
  width: 100%;
  height: 600px;
  position: relative;
  margin: 0 auto;
  width: 520px;
}

.employeeSlider__left,
.employeeSlider__middle,
.employeeSlider__right {
  border-radius: 50%;
  border: 10px solid #ffffff;
  overflow: hidden;
  position: absolute;
}

.employeeSlider__left img,
.employeeSlider__middle img,
.employeeSlider__right img {
  width: 100%;
  height: 100%;
  -o-object-fit: cover;
  object-fit: cover;
  -o-object-position: center;
  object-position: center;
}

.employeeSlider__left {
  width: 182px;
  height: 182px;
  bottom: 0;
  left: 40px;
  z-index: 2;
}

.employeeSlider__middle {
  width: 407px;
  height: 417px;
  top: 58px;
  left: 0;
  z-index: 1;
}

.employeeSlider__right {
  width: 222px;
  height: 222px;
  top: 0;
  right: 0;
  z-index: 3;
}

.employeeImages {
  display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.9.1/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.9.1/ScrollTrigger.min.js"></script>


<section class="section">

  <div class="employeeSlider">
    <div class="employeeSlider__left">
      <img class="employeeSlider__image" src="" alt="" loading="disabled">
    </div>
    <div class="employeeSlider__middle">
      <img class="employeeSlider__image" src="" alt="" loading="disabled">
    </div>
    <div class="employeeSlider__right">
      <img class="employeeSlider__image" src="" alt="" loading="disabled">
    </div>
  </div>

  <div class="employeeImages">
    <img class="employeeSlider__images" src="https://cdn2.hubspot.net/hubfs/2270223/2022/Leadership%20Profile%20Shots/Silverfin_Leadership_Joris_VanDerGutch.jpg" alt="Silverfin_Leadership_Joris_VanDerGutch" loading="lazy">
    <img class="employeeSlider__images" src="https://cdn2.hubspot.net/hubfs/2270223/2022/Leadership%20Profile%20Shots/Silverfin_Leadership_Tim_Vandecasteele.jpg" alt="Silverfin_Leadership_Tim_Vandecasteele" loading="lazy">
    <img class="employeeSlider__images" src="https://cdn2.hubspot.net/hub/2270223/hubfs/2022/Leadership%20Profile%20Shots/Silverfin_Leadership_Nikolas_Savander.jpg?width=480&amp;height=600&amp;name=Silverfin_Leadership_Nikolas_Savander.jpg" alt="Silverfin_Leadership_Nikolas_Savander"
      loading="lazy">
    <img class="employeeSlider__images" src="https://cdn2.hubspot.net/hubfs/2270223/2022/Leadership%20Profile%20Shots/Silverfin_Leadership_Natalie_Lamb.jpg" alt="Silverfin_Leadership_Natalie_Lamb" loading="lazy">
    <img class="employeeSlider__images" src="https://cdn2.hubspot.net/hubfs/2270223/2022/Leadership%20Profile%20Shots/Silverfin_Leadership_Stuart_Handley.jpg" alt="Silverfin_Leadership_Stuart_Handley" loading="lazy">
    <img class="employeeSlider__images" src="https://cdn2.hubspot.net/hubfs/2270223/2022/Leadership%20Profile%20Shots/Silverfin_Leadership_Domien_Claeys.jpg" alt="Silverfin_Leadership_Domien_Claeys" loading="lazy">
    <img class="employeeSlider__images" src="https://cdn2.hubspot.net/hubfs/2270223/2022/Leadership%20Profile%20Shots/Silverfin_Leadership_Tom_Libbrecht.jpg" alt="Silverfin_Leadership_Tom_Libbrecht" loading="lazy">
    <img class="employeeSlider__images" src="https://cdn2.hubspot.net/hubfs/2270223/2022/Leadership%20Profile%20Shots/Silverfin_Leadership_Stefaan_Arryn.jpg" alt="Silverfin_Leadership_Stefaan_Arryn" loading="lazy">
    <img class="employeeSlider__images" src="https://cdn2.hubspot.net/hubfs/2270223/2022/Leadership%20Profile%20Shots/Silverfin_Leadership_Steve_Wozniak.jpg" alt="Silverfin_Leadership_Steve_Wozniak" loading="lazy">
    <img class="employeeSlider__images" src="https://cdn2.hubspot.net/hubfs/2270223/2022/Leadership%20Profile%20Shots/Silverfin_Leadership_Louis_Verbeke.jpg" alt="Silverfin_Leadership_Louis_Verbeke" loading="lazy">
  </div>

</section>

Javascript get Google account name

I would like to have a main page in html that greets the user. I would need a name for the user tho, so I thought of retrieving the google account name or something similar that works most of the time. Is there such a thing or do i need to authorize with another application like github or discord to get a username?

How to update any property in any complex json payload in Postman?

I have a json payload with up to 50,000 lines of code. I want to be able to update any property in this response payload and send it as a request payload in the next call. How can I achieve this easily?

in my java framework I would use this piece of code below:
String updatedPayload = JsonPath.parse(responsePayload).set(“$..[?(@.id==’735401′)].displayName”, “HD Receiver”).jsonString();

With this code it doesn’t matter how huge the payload is, it will keep looking for the node with id 735401 and once the node is found it will look for the display name within that node and update it with HD Receiver”.

I want to do the same thing in postman. Any idea?

fetching a python or php file appears as sourcecode and not my desired response

Js:
fetch(‘app.py’).then(res=>res.text()).then(data=>console.log(data));

Python:
print(‘helloworld’)

console.log() shows print('helloworld') instead of helloworld

Am I not getting something here? I want the Python code to return “helloworld” to the browser’s console, but instead it sends the sourcecode. Same with php(note that php --version in cmd sends PHP Warning:'vcruntime140.dll' 14.0 is not compat..). But python appears to have no issues on my pc.

Is my problem in my code? Or what is necesary for the app.py or app.php to run when I fetch it?

Hi, I’m a young programmer, have been trying to add scripts to my server to let client-side send data to server-side, in wich server-side‘s job is to receive and write data into files to my server. Thanks

Preserving node.js built-in imports for Electron in rollup

I am making a Electron app with Svelte and Typescript.
I started with this template for that exact purpose, but it disables node.js built-in imports (like fs) in the browser/electron frontend for security.

I do not need this improved security in my project, so I am trying to get node.js fs to work in the Electron browser.
I already modified the Electron Backend script that creates the Browser to re-enable nodeIntegration, and this works: using require(“fs”) in the Electron browser console logs the fs library.

Using this in the actual typescript frontend code does not work, however. From looking at the bundled JS, it seems like rollup is assuming that the import of fs is just available as a global variable, and trying to guess its name.

When building while importing fs and path, I get the following warnings:

(!) Missing shims for Node.js built-ins
Creating a browser bundle that depends on "path". You might need to include https://github.com/snowpackjs/rollup-plugin-polyfill-node
(!) Missing global variable names
Use output.globals to specify browser global variable names corresponding to external modules
fs (guessing 'fs')
path (guessing 'path')

The first warning suggests a 404 GitHub link that seems to be a polyfill for some Node built-in libraries. This isn’t what I want, I want the real node.js fs library. It also informs me that I’m creating a browser bundle – I have tried setting the browser option of @rollup/plugin-node-resolve (used by the template) to false, but this did not help.

The second warning seems to simply inform that it’s trying to guess global variable names – which it should not, it should keep the imports.

How do I allow importing Node.js modules here? The linked template project still closely resembles my current one.
Help is greatly appreciated.

How to lock thread in javascript energy efficient?

I want to patch alert object in browser, to show additional text, but i need to await some data to show necessary content in alert. However, i can’t postpone alert call.

Also, i don’t know about way to close alert and show other alert without user action (if it exist, it can solve my problem too).

So, i have to await some data, but i can’t break alert behavior, which is block execution of the code.

To await response, i can do something like this

var start = performance.now();
while(true) {
  var time = performance.now() - start;
  if (time >= 3000) break;
}

console.log('done');

But instead check timer i will check some data.

This way should work, but this is terrible for performance, because opposite to alert which is just freeze thread and do nothing until close dialog we’ll load CPU with useless work.

Is possible freeze a thread more energy efficient?

I have to freeze thread until get some data from worker.

Please help change keys nested inside dictionary

Hello I am beginner in javascript it would be great if you could help me

topicMessage = { topic: 'some_topic', messages: [{ 'myKey': '{"data": {"my name is ":"aman", "age": 22, "my ed": "btech"}, "meta": {"myAge":24, "school":"aps"}}' }, { 'myKey2': '{ "data": { "my name is 2": "aman", "age": 22, "my ed 2": "btech" }, "meta": { "myAge2": 24, "school": "aps" } } ' }, { "myKey3": '{"data": {"my name is 3":"aman", "age": 22, "my ed 3": "btech"}, "meta": {"myAge":24, "school":"aps"}}' } ] }

here inside messaages of topicMessages in data part we have to make keys dash separated, and value for mykey, mykey2, mykey3 are in string form, so need to convert JSON.parse to object first and then again convert it back to string, can somebody please help,
eg for messages in for value of myKey, which is a string inside that for key, data, value which is again an object, here key “my name is” becomes “my-name-is”, “my ed” becomes “my-ed”

I am trying to do using this,

for(let i = 0; i < topicMessages.messages.length; i++){
    for(const [key, value] of Object.entries(topicMessages.messages[i])){
        for(const [key1, value1] of Object.entries(topicMessages.messages[i])){
            if(key1.includes(" ")){
                const newKey = key1.replace(/s+/g, "-")
                topicMessages.messages[i][key]["data"][newkey] = topicMessages.messages[i][key]["data"][key1];
                delete topicMessages.messages[i][key]["data"][key1];         
}
}
}
}

expected output:

topicMessage = { topic: 'some_topic', messages: [{ 'myKey': '{"data": {"my-name-is ":"aman", "age": 22, "my-ed": "btech"}, "meta": {"myAge":24, "school":"aps"}}' }, { 'myKey2': '{ "data": { "my-name-is-2": "aman", "age": 22, "my-ed-2": "btech" }, "meta": { "myAge2": 24, "school": "aps" } } ' }, { "myKey3": '{"data": {"my-name-is-3":"aman", "age": 22, "my-ed-3": "btech"}, "meta": {"myAge":24, "school":"aps"}}' } ] }

How to solve this DomNesting warning for js?

Warning: validateDOMNesting(…): cannot appear as a descendant of

.
at ul
at p
at div
at div
at div
at Blogs
at Routes (http://localhost:3000/static/js/bundle.js:63525:5)
at div
at App
at Router (http://localhost:3000/static/js/bundle.js:63458:15)
at BrowserRouter (http://localhost:3000/static/js/bundle.js:62268:5)

2 type: radio buttons that change color when clicked React

I want to make a component, where there are two options, and when you select one, the color of the buttons gets switched, currently, I’m trying with Inputs of type: radio, but I would like to know if there is any other way to do it with react.

import React, {useState} from 'react'

function BotonCambioPerfil() {

    const [gender, setGender] = React.useState('Famale');

    const handleCatChange = () => {
        setGender('Male');
      };
    
      const handleDogChange = () => {
        setGender('Female');
      };

  return (
    <div className='contenedorBotonCambioPerfil'>

    <RadioButton
        label="Male"
        value={gender === 'Male'}
        onChange={handleCatChange}
      />
      <RadioButton
        label="Female"
        value={gender === 'Female'}
        onChange={handleDogChange}
      />
        
        </div>
  )
}

const RadioButton = ({ label, value, onChange }) => {
    return (
      <label>
        <input type="radio" checked={value} onChange={onChange} />
        {label}
      </label>
    );
  };
  
  
export default BotonCambioPerfil

How I want the component to look

Sending image and additional info via HTTP

I want to send and image AND other text information,
I saw that for the image I need to use enctype="multipart/form-data" in the form. But doing this make me unable to see the other information needed.

 <form action="/new" enctype="multipart/form-data" method="post">
      <input type="text" id="name" value=""/>
      <input type="file" name="image" accept="image/*"  value="Compagny Logo"/>
      <input type="submit" value="Load compagny"/>
</form>

var storage = multer.diskStorage({
    destination: (req, file, callBack) => {
        callBack(null, './public/images/')
    },
    filename: (req, file, callBack) => {
        callBack(null, file.fieldname + '-' + Date.now() + path.extname(file.originalname))
    }
})
 
var upload = multer({
    storage: storage
});

router.post("/new", upload.single('image'), (req, res) => {
        console.log(req.file.filename) // work
        console.log(req.name) // does'nt work
    }
});

Is there and other enctype I need to use ?

Global error handling in Nuxt.js using onerror on other methods

I have a website which uses Nuxt.js. I want to implement global error handling when an error or uncaught error occurs.

I have injected the below script to head and also used it as plugin, but it does not work!

<script>

 window.onerror = function (e) {
    console.log('### Here I am ###', e)
    return true
 }

  window.addEventListener('error', ...)

</script>

Can’t resolve module from child folder

I’m working on a project in Nextjs and the project structure is a bit weird.
When trying to import a component, after making changes in the jsconfig.json file, things pretty much stopped working in terms of importing.

First off, this is my jsconfig.json file:

{
  "compilerOptions": {
    "baseUrl": "./",
    "paths": {
      "*": ["src/*"],
      "~": ["src/*"],
      "@/public/*": ["src/public/*"],
      "@/assets/*": ["src/assets/*"],
      "@/helper/*": ["src/helper/*"],
      "@/pages/*": ["src/pages/*"],
      "@/server/*": ["src/server/*"],
      "@/client/*": ["src/client/*"],
      "@/data/*": ["src/data/*"],
      "@/components/*": ["src/components/*"],
      "@/layouts/*": ["src/components/layouts/*"],
      "@/sections/*": ["src/components/sections/*"],
      "@/pages-components/*": ["src/components/sections/*"]
    }
  },
  "checkJs": true,
  "compilerOptions": {
    "jsx": "react"
  }
}

The project structure is as follows:

src/
  |- components/
    |- Image.js
    |- layouts/
      |- Breadcrumbs.js
  |- pages/
...etc

When trying to import the Image component from anywhere in the project it imports it properly, but if I’m in a child folder of components (like layouts is) I get the following error:

./src/components/layouts/Breadcrumbs.js
Module not found: Can't resolve '@/components/Image' in '/Users/andrewmurray/Projects/Church-BCF/react-template/Sacreva-React/src/components/layouts'

I’m curious if y’all have had this issue before and how it was fired.

Thanks!