hello every one please help me how to create this app on javaScript
vide link >>>> javaScript app
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
Category Added in a WPeMatico Campaign
hello every one please help me how to create this app on javaScript
vide link >>>> javaScript app
let a=10,b=15;
Compare two numbers without using the if / else expression or the triple operator
I want to search inside the variable, but I don’t want it to search for letters as an
example :
const myText = "Hi Here We go";
console.log(myText.includes("Here")) // true
console.log(myText.includes("ere")) // false
console.log(myText.includes("Here We")) // true
console.log(myText.includes("go")) // true
console.log(myText.includes("i")) // false
While working on multiple timezones, I have a case where I create shifts in multiple timezones, now users apply for those shifts.
It’s highly time-sensitive. Now what I want to take input of which timezone the shift is in (example Australia/Sydney)
Solution : Now while before saving it into the database I am converting the timezone to UTCoffset meaning in example Australia/Sydney timezone I am setting offset with - example Australia offset is 600 then -600 setting the offer and storing into the db.
const getUTCOffset = timezone => Intl.DateTimeFormat([], {timeZone: timezone, timeZoneName: 'shortOffset'}).formatToParts().find(o => o.type === 'timeZoneName').value.match(/-?d+/)[0]*60;
(getUTCOffset('Australia/Sydney'))
Is there anything I am missing here? What could be the optimal solution for this?
i’m creating this app https://custom.speedjersey.com/designer/index.html?token=OUlDNC9EVXErTEhOTkNjRDVCekZRZz09 for designing a jersey. Now, it’s working just fine using desktop, but i wanted to make it work on mobile too. Selecting the text and logo is fine,but i can’t move the text and logo around.
here’s how i try to move the object
if (e.target !== this.upperCanvasEl) {
var positionOnScene;
if (isMobile == true) {
positionOnScene = getPositionOnSceneTouch(raycastContainer, e);
if (positionOnScene) {
pointer.x = positionOnScene.x;
pointer.y = positionOnScene.y;
}
} else {
positionOnScene = getPositionOnScene(raycastContainer, e);
if (positionOnScene) {
pointer.x = positionOnScene.x;
pointer.y = positionOnScene.y;
}
}
}
on desktop it’s working since its event was mousemove but on mobile the event was touchmove but it didn’t move.
here’s how i get the position of an object on mobile
function getPositionOnSceneTouch(sceneContainer, evt) {
var array = getMousePosition(sceneContainer, evt.changedTouches[0].clientX, evt.changedTouches[0].clientY);
onClickPosition.fromArray(array);
var intersects = getIntersects(onClickPosition, object.children);
if (intersects.length > 0 && intersects[0].uv) {
var uv = intersects[0].uv;
intersects[0].object.material.map.transformUv(uv);
return {
x: getRealPosition("x", uv.x),
y: getRealPosition("y", uv.y),
};
}
return null;
}
and here’s on desktop
function getPositionOnScene(sceneContainer, evt) {
var array = getMousePosition(sceneContainer, evt.clientX, evt.clientY);
onClickPosition.fromArray(array);
var intersects = getIntersects(onClickPosition, object.children);
if (intersects.length > 0 && intersects[0].uv) {
var uv = intersects[0].uv;
intersects[0].object.material.map.transformUv(uv);
return {
x: getRealPosition("x", uv.x),
y: getRealPosition("y", uv.y),
};
}
return null;
}
the difference is only on clientX & Y value.
i was thinking that here’s the problem begins
function onTouch(evt) {
evt.preventDefault();
const positionOnScene = getPositionOnSceneTouch(raycastContainer, evt);
if (positionOnScene) {
const canvasRect = canvas._offset;
const simEvt = new MouseEvent(evt.type, {
clientX: canvasRect.left + positionOnScene.x,
clientY: canvasRect.top + positionOnScene.y,
});
canvas.upperCanvasEl.dispatchEvent(simEvt);
}
}
here i use touch but i register the event as mouseevent. Should i change it to touchevent? any thought would be very helpful
I have a div in charge of scrolling (let’s call it div-scroll) and another one inside of that where the content is (div-content), then the problem is the following: the div-scroll is blocking me from clicking and selecting the content of div-content. I first used a pointer-events none in the div-scroll, but it disabled the scroll, so I made a mousedown event to set the pointer event value to none, and a mouseup to set it to auto, but that didn’t work either. I don’t know what else I can try to do so that I can both click and select the content and scroll, can you help me? one more thing, I can’t invert the situation and leave the div-scroll with pointer events none and put an onscroll to enable it, because in the div-scroll there is a clickable scrollbar
One more thing, I can’t invert the situation and leave the div-scroll with pointer events none and put an onscroll to enable it, because in the div-scroll there is a clickable scrollbar
I want to get a drop down but i am not getting it. The api is being called but its not being diaplayed on dropdown. I an new to react can any one rewrite the code for me.
import React,{useState} from 'react';
import axios from 'axios';
function App() {
const handleSelect=()=> {
axios
.get("https://cdndemo-api.co-vin.in/api/v2/admin/location/states")
.then((response) => {
console.log(response.data);
setState(response.data);
});
}
const [state, setState] = useState([]);
return <div>
<select onChange={handleSelect}
>
click
<option value="">Choose a user</option>
{state?.states?.map((value) => {
return (
<div>
<option value={value.state_name} key={value.state_id}>{value.state_name}</option>
</div>
);
})}
</select>
</div>;
}
export default App
If the title is not clear…I have BIG function that I want its return value. But I also wanted to get what it’s doing in the middle of the execution. I can see that by doing console.log…but is there a way to capture that and display it in the HTML ? Thanks
I’m trying to call the following function to console.log the time and caption. I’m still having difficulty with ‘return’. The function works perfectly, it just doesn’t return time and caption values to the console log function. Thank you for your help!
console.log(youtubevideo('fakeytid'));
function youtubevideo(videoid) {
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://www.googleapis.com/youtube/v3/videos?id='+videoid+'&part=contentDetails&key=' + 'APIKEY',
'headers': {
}
};
//Return time:
request(options, function (error, response) {
if (error) throw new Error(error);
responsebody = response.body;
var json = JSON.parse(responsebody);
var caption = json.items[0].contentDetails.caption;
var time = json.items[0].contentDetails.duration
var time = json.items[0].contentDetails.duration;
var time = time.replace(/PT|S/g, '');
var time = time.split(/M|H/);
var time = time.map(function(item) {
return parseInt(item, 10);
});
var time = time[0]*60 + time[1];
return time, caption
});
return time, caption
}
let reqBody = "";
req
.on("data", (chunk) => {
reqBody += chunk.toString();
})
.on("end", () => {
const body = new URLSearchParams(reqBody);
res.end("ok");
});
I’m trying to access the request’s body using NodeJS without Express but for some reason, I could not run res.end("ok");.
I am pretty new to JavaScript and I am working on this practice question that asks to create a function that returns the keys out of an object (without using the object.keys method). I have tried a few different iterations of the following code, and would appreciate a nudge in the right direction toward solving this problem!
function keys(obj) {
let firstLoop = [];
let newObj = Object.entries(obj);
for (let i = 0; i <= newObj.length; i ++){
firstLoop.push(newObj[i]);
return firstLoop;
}
for (let j = 0; j < firstLoop.length; i ++){
return firstLoop[j];
}
}
I’m trying to load 3 CSV files and save the stringified objects into the local storage. 3 CSV files combined does not exceed memory of 2MB.
The program successfully saves 3 CSV files into the localStorage when the user clicks on the button(id=”submit_files”). However, the LocalStorage shows that it only saved either one or two when the page is refreshed.
I noticed that all 3 stringified objects were stored in the localStorage when I added “e.preventDefault();” in the event handler for the button to stop from refreshing the page on its own. However, the localStorage shows that there’s only either one or two saved objects in random when refreshed.
The logic of code seems right, but it looks like there’s something that I don’t know about the LocalStorage. I’m suspecting that there’s an issue with the global variables when the page gets refreshed. What am I missing?
HTML:
<form>
<label for="tag_csv"> Upload "tag_list.csv" file : </label>
<input type="file" id="tag_csv" accept=".csv" required>
<label for="radar_csv"> Upload "radar_list.csv" file : </label>
<input type="file" id="radar_csv" accept=".csv" required>
<label for="decisions_csv"> Upload "tag_decisions.csv" file : </label>
<input type="file" id="decisions_csv" accept=".csv" required>
<button type="submit" id="submit_files"> Upload File </button>
</form>
JS:
let tag_list;
let radar_list;
let decisions_list;
// Check if csv objects are saved in to local storage.
// If true, set all three global variables to the csv objects respectively.
$(document).ready( function(){
if (isCsvLoaded()) {
console.log("csv is loaded")
// Initialize tag_list, radar_list, decisions_list
retrieveObjects()
} else {
console.log("Not enough csv in localstorage")
}
})
const submit_button = document.getElementById('submit_files');
submit_button.addEventListener('click', (e) => {
createDict();
// e.preventDefault();
})
function retrieveObjects() {
tag_list = JSON.parse(localStorage.getItem('tag_list'));
radar_list = JSON.parse(localStorage.getItem('radar_list'));
decisions_list = JSON.parse(localStorage.getItem('decisions_list'));
}
// Use this function to parse all three CSV files and store them in local storage.
async function createDict() {
console.log("createDict()")
try {
let parsed_tag_list = await parseCSV('#tag_csv')
let tag_list_serialized = JSON.stringify(parsed_tag_list)
localStorage.setItem("tag_list", tag_list_serialized)
let parsed_radar_list = await parseCSV('#radar_csv')
let radar_list_serialized = JSON.stringify(parsed_radar_list)
localStorage.setItem("radar_list", radar_list_serialized)
let parsed_decisions_list = await parseCSV('#decisions_csv')
let decisions_list_serialized = JSON.stringify(parsed_decisions_list)
localStorage.setItem("decisions_list", decisions_list_serialized)
} catch (err) {
console.log(err)
}
};
I’m a beginner of js. I wanna update a text as long as the value of a slider changes. Since the slider might be changed without click, I decide to use .onchange to detect if the value of the slider is changed. However, it doesn’t work. The text is only be updated if the change of the slider is made by clicking. I’m wondering if there is a good way to detect any change of the slider? Thanks!
btw I also have tried the .oninput but I got the same result:(.
I can pass the value of my select-options but I change my mind and want to pass the value first on the button for onClick function.. Thanks
import { useSelector,useDispatch } from "react-redux";
const Purchase=()=>{
const products= useSelector(state=>state.products);
const dispatch = useDispatch();
const purchaseHandler=(e)=>{
let pName = e.target.options[e.target.selectedIndex].text;
let price = e.target.value;
let obj = {pName,price};
dispatch({type:'PURCHASE',payLoad:obj});
}
return(
<div>
<select onChange={(e)=>purchaseHandler(e)}>
{
products.map((product,index)=>{
return(
<option value={product.price} key={index}>
{product.pName} - ${product.price}
</option>
)})
}
</select>
<button onClick={purchaseHandler} className="addToCart">Add to Cart</button>
</div>
)
}
export default Purchase;
If I generate the first 500 NFT images on the first day and another 500 NFT images second day Json number starts from 01-500 for the second 500 images. However, I need to create these images starting from 501-1000(JSON number) for the second 500 images in Visual studio code using the Hashlip program? https://stackoverflow.com/users/1693192/petr-hejda,https://stackoverflow.com/users/5437524/antony-ng,https://stackoverflow.com/users/9938317/riov8,https://stackoverflow.com/users/15089965/dimitri-bourreau