Dropzone JS not working with multiple input Laravel

i have multiple input, textarea and select i need multiple image upload so i try dropzone js and in controller request there is no file

i use autoProcessQueue: false and its not working but if i don’t use it upload but i don’t get data in request file

Problem is how can i get request file from dropzone

this is dropzone script

 <script>
Dropzone.options.dropzone = 
{
    // The configuration we've talked about above
    url: "{{ route('product.store') }}",
    headers: {
    'x-csrf-token': "{{ csrf_token() }}",
    },
    // autoProcessQueue: false,
    uploadMultiple: true,
    parallelUploads: 100,
    maxFiles: 100,

    // The setting up of the dropzone
    init: function() {
    var myDropzone = this;
    var formData = new FormData();
    // First change the button to actually tell Dropzone to process the queue.
    $("#prodcutCreate").click(function (e){
        // Make sure that the form isn't actually being sent.
        var formData = new FormData(this);
        e.preventDefault();
        e.stopPropagation();
        myDropzone.processQueue();
    });
    
    // Listen to the sendingmultiple event. In this case, it's the sendingmultiple event instead
    // of the sending event because uploadMultiple is set to true.
    this.on("sendingmultiple", function() {
    // Gets triggered when the form is actually being sent.
    // Hide the success button or the complete form.

    // formData.append("name", $("#name").val());
    // formData.append("slug", $("#slug").val());
    // formData.append("description", $("#description").val());
    // formData.append("ideal_for", $("#ideal_for").val());
    // formData.append("main_ingredients", $("#main_ingredients").val());
    // formData.append("gender_id", $("#gender_id").val());
    // formData.append("brand_id", $("#brand_id").val());
    // formData.append("categories", $("#categories").val());
    });
    this.on("successmultiple", function(files, response) {
    // Gets triggered when the files have successfully been sent.
    // Redirect user or notify of success.
    console.log('success');
    console.log(files);
    console.log(response);
    });
    this.on("errormultiple", function(files, response) {
    // Gets triggered when there was an error sending the files.
    // Maybe show form again, and notify user of error
    console.log(false);
    console.log(files);
    console.log(response);
    });
    }
}

this is controller i dd the request but no file

public function store(Request $request){dd($request); }

this is form i have other input fileds too

<form method="POST" action="{{ route('product.store') }}" enctype="multipart/form-data">
<div class="col-span-4 dropzone" id="dropzone"></div>

this is from $request

files: SymfonyComponentHttpFoundationFileBag 
{#46 
    #parameters: []
}

thanks

why it didn’t catch the rejected promise?

I was wondering why the try-catch block couldn’t catch the promise rejected from foo.

Frustrated, need help. Thanks in advance.

function addTask(task) {
  setTimeout(() => {
    task.resolver()
  }, 1000)
}

function foo() {
  return new Promise((resolve, reject) => {
    const task = {
      resolver: function() {
        reject('task failed')
      }
    }
    addTask(task)
  })
}

function test() {
  try {
    foo()
  } catch (e) {
    console.error(e)
  }
}

// Uncaught (in promise) task failed
test()

What’s wrong with cancelling a Promise like this?

I have a (“micro-task”?) queue which tasks are promises. You can schedule them like this:

const task = schedule(queue, _ => {
    return /* valuable stuff */;
}).then(value => { /* do stuff with value */ });

now let’s say that at some point I figure I don’t need to do this task. I could just issue:

task.cancel()

I read about it being not possible to cancel promises in ES6 or something like that. But why can’t I just help myself as follows?

function schedule(queue, fn) {
    let index;
    const promise = new Promise((resolve, reject) => {
        index = queue.push(() => {
            try {
                resolve(fn());
            } catch(error) {
                reject(error);
            }
        });
    });
    promise.cancel = () => {
        queue[index] = _ => {}; // just replace that callback with a no-op
    }
    return promise;
}

What is wrong with that?

Would it lead to some kind of memory leak because there is a Promise that remains pending forever? There is no longer a handle to the resolver function. Does the Promise hold on to the resolver function? And if so, does it use a weak reference? How do Promises keep themselves from being garbage collected if nobody is holding on to them, but they are simply expecting the then() or finally() to be called?

knowing when option from multiple select box is selected in apache cordova

I am trying to run some code in javascript in an apache cordova app when an option from a multple select box is selected. The code works perfectly in a normal browser, but not in an apache cordova app. Why?

HTML:

<select multiple="multiple" class="multiple_select_class" onclick="multi_select_onclick();">
  <option value='1'>subject1</option>
  <option value='2'>subject2</option>
  <option value='3'>subject3</option>
  <option value='3'>subject3</option>
</select>

JS:

function multi_select_onclick()
{
    console.log('number of options: ' + $('.multiple_select_class option').length );

    $(".multiple_select_class option").off().on( "click", function(e)
    {
        console.log('option klicked');
        
        //more code here
    });
}

In an apache cordova App, ‘option klicked’ never shows in the console, but in a regular browser, it does.

Change of pictures over and over by using setInterval

Dears,

I have written some codes to make the pictures keep changing from time to time. I also want to have a fade in effect each of the picture. However, it happens to me that only the first time i turn on the browser that moment i can see the fade in effect of the first picture, then i can only see the pictures keep changing, but no fade in effect at all. Below is my code, please feel free to tell me where i get wrong and how to correct it. Thanks.

<!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>Change Pictures</title>
<style>
body {
height:100vh;
}

#picture {
background-repeat: no-repeat;
background-position: center;
background-size: 400px 400px;
width:80%;
margin:auto;
height: 80%;
opacity: 0;
}

#picture.fadein {
opacity: 1;
transition: opacity 2s linear;
}

</style>
</head>
<body>
<div id="picture"></div>
<script>
setInterval(changepcs,3000);
var opacity = 0;
var arrindex = 0;
var arr1 = ["p1.jpg","p2.jpg","p3.jpg","p4.jpg","p5.jpg"];
function changepcs() {
if(arrindex == arr1.length){arrindex = 0};
let abc = document.getElementById("picture");
let address = arr1[arrindex];
abc.style.backgroundImage = `url(${address})`;
opacity = Number(window.getComputedStyle(abc).getPropertyValue("opacity"));
abc.className = "fadein";
arrindex++;
}
</script>
</body>
</html>

Load recent messages, not all messsages Firebase chat-app

I am building an app with chat etc. The problem is when I am fetching the chat I am displaying all of the messages in a particular chat. I would like to display just the recent ones (e.g. 20 last messages). I got no clue how to code it, I did some reasearch but I didn’t find anything helpful.

I am using Firebase and JS (with no frameworks). All messages I have are in my database, when I am fetching the chat I am getting all of them from Firebase.

That’s how it looks like right now.

// chat-fetching
  fetchChat = db.ref("messages/" + username + "/" + receiver + "/");
  listener = fetchChat.on("child_added", function (snapshot) {
      const messages = snapshot.val();
      var msg;
      if(messages.usr == receiver) {
        msg = "<div class='msg rcvd'>" + urlify(messages.msg) + messages.file + "</div>";  
        document.getElementById("messages").innerHTML += msg;
      } else {
        msg = "<div class='msg sent'>" + urlify(messages.msg) + messages.file + "</div>";
        document.getElementById("messages").innerHTML += msg;
      }

Validating name in visual studio code

var userName = input.question('Please enter your name: '); //Asking User to enter their Name.
while (userName.includes('.')) {
    console.log ("Invalid Name!");
    var userName = input.question('Please enter your name: '); //Asking User to enter their Name.
}

Above code will ask the user his/her name and store it in “userName”. Then it will validate using .includes to check unwanted characters and numbers.

I want to validate if userName has numbers or unwanted characters such as “?/.,;'[]{}|&^%@” etc. I have tried using .includes and validate if a name has “.” However, I’m not sure how to go about from there to validate the rest.

Is there a solution to this?

Exclude class from this code or find how to show slide out cart anyways

I have this JS (jQuery) + CSS code that helps me achieve a hidden header on scrolling down, but the problem starts when the side cart is open, as when scrolling down the side cart gets minimized as well. ( and when scrolling up shows up) It looks bad and I was wondering how to fix this. Not a coder, just learning from the web. Can someone point in the right direction?

The code I am using for the header:

document.addEventListener('DOMContentLoaded', function() {
jQuery(function($){
var mywindow = $(window);
var mypos = mywindow.scrollTop();
mywindow.scroll(function() {
if (mypos > 40) {
if(mywindow.scrollTop() > mypos) {
$('#transparentsticky').addClass('headerup');
} else {
$('#transparentsticky').removeClass('headerup');
}
}
mypos = mywindow.scrollTop();
}); }); });

</script>
<style>
#transparentsticky{
-webkit-transition: transform 0.5s ease;
transition : transform 0.5s ease;
}
.headerup{
transform: translateY(-150px); /*adjust this value to the height of your header*/
}
</style>

image example

save and recall into database with php

 <input type="text" id="REI1" maxlength="4" onfocusout="TextBoxAway(this.id);" name="REI1">

I have about 8 of these and I have this function to make it uppercase. It will also get rid of texbox formating on focus lost.

function TextBoxAway(id) {
  if (document.getElementById(id) == null){
    return
  }
  else {
    var x = document.getElementById(id);
    x.value = x.value.toUpperCase();
  }
}

I need to try to get all 8 of these input boxes to update in a sql database with php every time they are changed (Focus Lost). I also need them to reshow up when the user is logged in so it will be saved with a user id. Any Help would be appreciated.

Threejs Renderer canvas does not fit assigned div

I am trying to display a threejs scene inside nested div. Even changing renderer size, I keep having the canvas occupy too much space.

Initializing renderer:

// Init renderer
renderer = new THREE.WebGLRenderer({
antialias: true,
// canvas: document.getElementById("buildingDisplay")
})
renderer.setPixelRatio(window.devicePixelRatio)
renderer.setSize(document.getElementById("buildingDisplay").getBoundingClientRect().width, 
document.getElementById("buildingDisplay").getBoundingClientRect().height)
document.getElementById("buildingDisplay").appendChild(renderer.domElement)

The canvas containing the scene (in the ‘buildingDispplay’ div) has a size that fills the whole parent div.

HTML div structure:

<div id="parent" style="display:flex; width: 100%; height: 100%;">
    <div id="blastMapID" style="height: 100%;">
        <button type="button" id="expTA" style="margin-top: 100px;"><strong>LoadTargetArea</strong></button>
    </div>
    <div id="buildingDetails" style="display:none;  width: 100%; height: 100%; border:1px solid black;">      
        <button id="closeDiv">Close</button>
        <div id="buildingDisplay" style="width: 100%; height: 60%; background-color: rgb(187, 187, 187);">
            <!-- <canvas id="renderCanvas" style="width: 100%; height: 100%;"></canvas> -->
        </div>
        <div id="statsDisplay" style="width: 100%; height: 40%; background-color: rgb(255, 255, 255);"></div>
    </div>
</div>

How can i fix ‘TypeError: Converting circular structure to JSON’ during QUERY

I want to select some data in my database but i can’t

First insert and update is success

but select func response err

Below is the error history.

/Users/Project/gitlab.co.kr/dev/api-server/node/node_modules/express/lib/response.js:1150
: JSON.stringify(value);
       ^
TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Query'
    |     property '_timer' -> object with constructor 'Timer'
    --- property '_object' closes the circle
    at JSON.stringify (<anonymous>)
    at stringify (/Users/Project/gitlab.co.kr/dev/api-server/node/node_modules/express/lib/response.js:1150:12)
    at ServerResponse.json (/Users/Project/gitlab.co.kr/api-server/node/node_modules/express/lib/response.js:271:14)
    at ServerResponse.send (/Users/Project/gitlab.co.kr/api-server/node/node_modules/express/lib/response.js:162:21)
    at /Users/Project/gitlab.co.kr/dev/api-server/node/dist/controller/video/VideoController.js:111:26
    at step (/Users/Project/gitlab.co.kr/dev/api-server/node/dist/controller/video/VideoController.js:33:23)
    at Object.next (/Users/Project/gitlab.co.kr/dev/api-server/node/dist/controller/video/VideoController.js:14:53)
    at fulfilled (/Users/Project/gitlab.co.kr/dev/api-server/node/dist/controller/video/VideoController.js:5:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v18.3.0

And Below is the My code.

    public Select = async (videoDTO?: VideoDTO): Promise<SearchResponseType> => {
        const Id: string = videoDTO.getId();
        const Time: string = videoDTO.getTime();
        
        const resultData = await this.Connection.query(SelectQuery, [Id, Time], (err: any, result: any) => {
            if (err) {
                Logger.error(`Select : ${err}`);
                return;
            }
            return result;
        });
        // console.log("@")
        
        const ResponseSelect: SearchResponseType = {
            status: 200,
            message: 'SELECT VIDEO SUCCESS',
            data: {
                result: resultData,
            },
        };
        
        return ResponseSelect;
    };

plz somebody help me

How can I generate duplicate copies of an image for large nft collection with corresponding json metadata file?

I’m trying to find a way to modify Hashlips NFT collection generator code or come up with another solution that will take my initial image and duplicate it to the amount I want my NFT collection to be and have the corresponding json file with metadata.

I have attempted to use Hashlips generator code to generate multiple images from the same image but it seems to only work when you have multiple layers.

I’m planning on utilizing thirdweb.com to upload to ipfs and for the site’s ease of use with managing your smart contract.

An example of a similar project on Opensea that has the same pass for all nfts would be Proof. https://opensea.io/collection/proof-collective

Here is a link to hashlips code: https://github.com/HashLips/hashlips_art_engine

Styling stripe p24 element for mobile in Next/React

Has anyone tried to style p24 element on mobile? When I apply styles via options prop those are being applied to the dropdown on desktops only, when I open the dropdown on mobile it looks like pure html.

this is my component

export const P24Component = () => {
  return (
    <section className="w-full">
      <P24BankElement
        className="w-full p-3 shadow-sm bg-transparent border border-b-purple border-l-purple relative z-10"
        options={{
          iconStyle: "solid",
          classes: { focus: "bg-purple" },
          style: {
            base: {
              padding: "12px",
              fontFamily: "Anonymous Pro, sans-serif",
              fontSize: "16px",
              fontSmoothing: "antialiased",
              backgroundColor: "#E1EDED",
            },
          },
        }}
      />
    </section>
  );
};

Thanks