I have a video on my page. How can I add a zoom-out and zoom-in button to the video I’ve published on the page in Vue.js? I made the time-slider.
Category: javascript
Category Added in a WPeMatico Campaign
How can I edit this TextField?
I have an Material UI text field which is populated by a nested JSON object pulled from an API.
Text is displaying in the textField just fine, but it cannot be changed. It is not accepting any new text.
{questions['Days']?.map((row) => (
<TextField
fullWidth
multiline
className="text-field"
value={row?.Response || ''}
onChange={(e) => {
setQuestions((prev) => { return { ...prev, Response: e.target.value };
});
}}
variant="outlined"
margin="normal"
label={row['Question']}
/>
))}
An Example of my JSON:
{
"Days": [
{
"Question": "What day is it today?",
"Response": "Wednesday"
}
],
"Time": [
{
"Question": "What time was it when you answered this question?",
"Response": "11:45 am"
}
]
}
Is it possible to use one method to create textFields for multiple nested JSON objects rather than hard coding them?
How to create a visual diff view of a tree of files in JavaScript
Is there any library in JavaScript to show differences between two trees of files?
I want to show one tree with my actual version of a project and another tree with the remote version. I want to highlight the changes between both trees: the files that are modified, deleted or added in my local version vs. my remote version.
How to add Multi background files in Exteiosn v3 [duplicate]
// in v2 mode we can use this
"background": {
"scripts": [
"background.js", "url.js", "bg.js", "setcookie.js", "jquery.js"
] },
//but in v3 mode we have only one script
"background": {
"service_worker": "service-worker.js", "type": "module" },
i have 4-5 backgroud file for different events how i can add these file in V3 menifest
How to deconstruct an array and put it into the “main” array?
How can i deconstruct an array, and put it into the array which is getting mapped on, then continue sorting on that?
Basicly the array looks the following after filtering it:
[
[‘traitName’, ‘value’],
[‘traitName’, [‘value01’, ‘value02’, ‘value03’ …]
],
…
]
What i want to do is check every trait, and check if the first index is an array, then deconstruct that, and put it into this array like this:
[
[‘traitName’, ‘value’],
[‘traitName’, value01],
[‘traitName’, value02],
[‘traitName’, value03],
..
],
…
]
Then i can continue sorting on this array.
Object.entries(nft)
.filter((val: any) => val[0] !== 'Attributes' && data.attributes[val[0]] !== undefined)
.sort((a: any, b: any) => {
if (typeof a[1] === 'number') return Infinity;
return (
data.attributes[a[0]]?.values[a[1]]?.distribution - data.attributes[b[0]]?.values[b[1]]?.distribution
);
})
I need to this between the filter and sorting i think.
change the value of object inside a list
My code’s output is like this:
let myArray = [{"num": "2", "name": "Jhon"}, {"num": "1", "name": "Sara"}, {"num": "2", "name": "Domnic"}, {"num": "3", "name": "Bravo"}]
How can I access value of num in each field of the list and if num: 2, change its value to 5?
How can i create react popup video player through button onclick method
i am working on reactjs ag-grid and react video player. first of all i create json file with following data and video path links
db.json :
{
"users": [
{
"id": 1,
"name": "Manoj",
"email": "[email protected]",
"phone": "9876543210",
"videolink": "/home/fraction/Downloads/agGrid-crudOperation/server/Fraction.mp4"
},
{
"name": "Vikas Kumar",
"email": "[email protected]",
"phone": "+9876543210",
"videolink": "/home/fraction/Downloads/agGrid-crudOperation/server/Fraction.mp4",
"id": 5
}
]
}
After that i create ag-grid table with action button method after creating grid table

And pass video link to Play button and print it in console as well.
function App() {
const actionButton=(params)=>{
console.log(params)
}
const [gridApi, setGridApi] = useState(null)
const [tableData, setTableData] = useState(null)
const [open, setOpen] = React.useState(false);
const [formData, setFormData] = useState(initialValue)
const handleClose = () => {
setOpen(false);
setFormData(initialValue)
};
const url = `http://localhost:3000/users`
const columnDefs = [
{ headerName: "ID", field: "id" },
{ headerName: "Name", field: "name", },
{ headerName: "Email", field: "email", },
{ headerName: "Phone", field: "phone" },
{ headerName: "VideoLink", field: "videolink" },
{
headerName: "Actions", field: "videolink", cellRendererFramework: (params) => <div>
<Button variant="contained" size="medium" color="primary" onClick={()=> actionButton(params)} >Play</Button>
{/* <Button variant="outlined" color="secondary" onClick={() => handleDelete(params.value)}>Delete</Button> */}
</div>
}
]
i tried to pass video link to react video player and i am used to create react video player with this link
now to how to play videos in react popup video player whenever i click play or update button
Thank in advance
Uncaught (in promise) TypeError: data.map is not a function [closed]
I get data from a csv file but it got error: “Uncaught (in promise) TypeError: data.map is not a function”
d3.csv("http://127.0.0.1:8887/data.csv", function(data) {
xScale.domain(data.map(function(d) {
return d.year;
}));
yScale.domain([0, d3.max(data, function(d) {
return d.value;
})]);
g.append("g")
.attr("transform", "translate(0," + height + ")")
.call(d3.axisBottom(xScale));
g.append("g")
.call(d3.axisLeft(yScale).tickFormat(function(d) {
return "$" + d;
}).ticks(10));
Can someone help to solve this issue?
how does (=+ ) works in javascript [duplicate]
i have this code and i dont know what does =+ means it does not work like += hence
x+=y adds y value to x but x=+ it looks like its replace x value with y value
var counters= document.querySelectorAll('.counter');
counters.forEach(counter => {
counter.innerText= '0' ;
const updateCounter = ()=> {
const target =+ counter.getAttribute('data-target')
const c = +counter.innerText
const increasment = target/200;
if(c<target) {
counter.innerText = c+increasment ;
setTimeout(updateCounter,5)
}
else {
counter.innerText=target
}
}
updateCounter();
})
JavaScript: Trying to find near tourist attractions, program isn’t using current location but seemingly random location
So I’ve been trying to make a program that shows you near tourist attractions. The problem I am encountering is that the program is showing me seemingly random attractions, in complete disregard for my current location and the entered radius. I think that the problem should lie in the following code:
function getNearbyPlaces(position) {
console.log(position + "##############################");
request = {
location: position,
radius: '300',
query: ['tourist_attraction']
};
service = new google.maps.places.PlacesService(map);
service.textSearch(request, callback);
I’d love some ideas on how to solve this issue and how to get this code working. Be aware I am pretty new to JavaScript!
Http Request working in Browser and with curl but not in Flutter or Postman
I am making a flutter app and i am using an express.js Backend. I set it up and it works fine when using it on localhost but not when deploying it to an ubuntu server. Postman then just instantly says “Socket hang up”. When using curl or putting it into the browser everything just works fine. Any ideas what could be wrong?
how to pop an item from a list of child schema in nodeJS with mongoDB & mongoose?
I have created my mongoose user_schema like below
const mongoose = require('mongoose')
const interactions = require('./interaction').schema
const Schema = mongoose.Schema;
const UserSchema = new Schema({
name: String,
email: { type: String, unique: true, required: true },
password: { type: String, required: true, },
dob: Date,
address: { type: Schema.Types.ObjectId, ref: 'Address' },
profile_pic: String,
resume: { type: Schema.Types.ObjectId, ref: 'Resume' },
interactions: [interactions]
})
module.exports = mongoose.model("User", UserSchema)
and this is the interaction_schema
const mongoose = require('mongoose')
const helpers = require('../utils/helpers.js')
const Schema = mongoose.Schema;
const InteractionSchema = new Schema({
interaction_type: {
type: String,
enum: helpers.interaction_choices,
default: helpers.interaction_choices.liked
},
interacted_with: { type: String, required: true },
}, {
timestamps: true
})
module.exports = mongoose.model("Interaction", InteractionSchema)
For the interaction_choice, I have used a const variable like this
const interaction_choices = {
sent: 'sent',
liked: 'liked',
rejected: 'rejected',
incoming: 'incoming',
connected: 'connected',
}
module.exports = { interaction_choices }
Now, to add a new interaction I am doing this
async function sendRequest(senderId, recieverId) {
const senderUpdates = {
interaction_type: helpers.interaction_choices.sent,
interacted_with: senderId,
};
const recieverUpdates = {
interaction_type: helpers.interaction_choices.incoming,
interacted_with: recieverId,
};
try {
await User.findByIdAndUpdate(senderId, {
$push: {
interactions: senderUpdates,
},
});
} catch (error) {
console.log("Sender Error : " + error);
return false;
}
try {
await User.findByIdAndUpdate(recieverId, {
$push: {
interactions: recieverUpdates,
},
});
} catch (error) {
console.log("Reciever Error : " + error);
return false;
}
return true;
}
Till now, everything is working as per my expectations. But now I am stuck on removing one specific interaction for a user, based on the interacted_with field of interaction_schema. Please guide me what should I do to do so. Thank you so much.
How can I find the element that would have been targeted by a given fragment identifier?
When a browser navigates to an URL like http://example.com/#foo, it scrolls to the element identified by #foo; this element of the URI is called a fragment identifier. Suppose I have a fragment identifier for an element on the current page, which I have not yet navigated to. How can I find out which DOM node would have been targeted by it?
- It’s not enough to use
document.getElementById, because a fragment identifier#foocan also target an old-style anchor,<a name="foo">, which this method misses. - It’s not correct to use
document.getElementsByNameeither, because that would find non-anchors like<input>or<textarea>nodes, and miss elements identified by theid=attribute. - Since I have not navigated at the fragment, I cannot use
document.querySelector(':target')either.
Is there a reliable way to find which DOM node would have been targeted by fragment identifier that catches all cases? If the solution uses querySelector, I would of course like it to be robust against unusual characters found within identifiers, however deprecated they may be.
show objects from array 1 sec and hide 1 second in Java Script
I have a hard time finding the right answer to this question.
I have an array with 10 objects. I created each object as its own div.
I want to show each div for 1 sec the hide it for 1 sec then show the next one and so on until all 10 objects been showed once, then I want to show a next button.
I understand I need set interval and set timeout, but I dont know how?
JavaScript regexp negative overhead with non-alphanumerical characters
In JavaScript have code like:
const text = 'starttext <- code1 -> middletext <- code2 -> endtext';
And I want to get:
starttext middletext endtext
First I tried:
text.replace(/<- .+ ->/, '');
But it returns:
starttext endtext
… because it matches:
< ""anything"" >
But I need to match:
< ""anything but >"" >
So I tried negative overhead:
text.replace(/<- (?!->).+ ->/, '');
… but it works only with alphanumeric characters for me.
How can I make it work with ->?