I would like that when an element is loaded in the for loop a function is automatically executed.
my code
I want when the canvas element is loaded. That then the function viewSparkling is called.
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
Category Added in a WPeMatico Campaign
I would like that when an element is loaded in the for loop a function is automatically executed.
my code
I want when the canvas element is loaded. That then the function viewSparkling is called.
Actually I am new to cp ! So to read input from the files and display it on the other output file i am following this template!
process.stdin.resume();
process.stdin.setEncoding("utf-8");
//
let standardInputString = "";
let currentLine = 0;
//
process.stdin.on("data", (rawData) => {
standardInputString += rawData;
});
process.stdin.on("end", (_) => {
standardInputString = standardInputString
.trim()
.split("n")
.map((line) => {
return line.trim();
});
main();
});
function readline() {
return standardInputString[currentLine++];
}
function print(data) {
console.log(data);
}
function main() {
let a = readline();
print(a);
}
But For running this file i used “node file.js < input.txt >output.txt” this command! But then i get the following error !
At line:1 char:18
+ node template.js < input.txt > output.txt
+ ~
The '<' operator is reserved for future use.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : RedirectionNotSupported
But the man in tutorial did the same but he didn’t get any error!
tutorial link: https://www.youtube.com/watch?v=feDyXKQkSj0 at (11:26 time)
I wanted all the fields Price, Quantity, Total alligned in a single row like in the above screenshot attached.How can i achieve that?I am newbie in designing. Any hep to fix this is appreciated.The full code snippet along with css is available here: https://jsfiddle.net/wfgx02st/ .Please have a look.
<div id="app">
<div id="cart">
<div id="head">
<h3>Shopping Cart</h3>
<div id="price">Price</div>
<div id="quantity">Quantity</div>
<div id="total">Total</div>
</div>
</div>
<div id="buy-box">
<div class="row">
<form action="" method="POST">
<img src="" style="height: 100px;"/>
<h4>Beer Bottle</h4>
<p>$25</p>
<input type="hidden" name="product_id" value="1">
<input type="hidden" id="session_id" name="session_id" value="1">
<input type="hidden" name="user_id" value="1">
<div><input type="number" name="quantity" value="5" style="width: 7%;height:3%" ></div>
<div class="totalprice">$25</div>
<div class="" style="display: flex;flex-direction: row;">
<button type="submit" class="option2" style="border: none;background: white;color: deeppink;">Add To Cart</button>
</div>
</form>
<form action="" method="POST">
<input type="hidden" name="session_id" value="6">
<input type="hidden" name="user_id" value="2">
<div class="">
<button type="submit" class="option2" style="border: none;background: white;color: deeppink;">Remove</button>
</div>
</form>
</div>
</div>
<form action="" method="POST">
<div style="margin: 10px;"> <h5 >Sum: 50</h5></div>
</form>
</div>
Google Maps map view is available but the satellite view is not shown. When I load the application, for a moment satellite view is shown and it disappears(visible for only a split second).
<script src="//maps.googleapis.com/maps/api/js?key=<API_KEY>&v=3.46" type="text/javascript"></script>
This issue happens when I change the version from 3.45 to 3.46. This issue happens even I changed the versions 3.47,3.48,3.49.
In the console I’ve shown these errors,
GET http://maps.googleapis.com/maps/api/mapsjs/gen_204?csp_test=true 403 (Forbidden)
GET http://khm0.googleapis.com/kh 400 (Bad Request)
GET http://khm1.googleapis.com/kh 400 (Bad Request)
Please help me to fix this issue
I have searched through various sites but still can’t figure out how web-based editors work.
Can anyone please fill me up about the working techniques of a web-based editor like Monaco, Codemirror, Ace, etc?
It’s my goal to make a web-based editor. Any help appreciated.
I need to have an editor field, for which I have used react-quill, but I need it to show suggestions when a user types something inside the editor. Now the react-autosuggest has a prop called ‘renderInputComponent’ to which we can pass an input component. But the problem is, that it doesn’t work with react-quill. When I pass a react-quill component to the autosuggest, it doesn’t call the onSuggestionsFetchRequested method and doesn’t display the suggested results.
This is my autosuggest component:
import React, { useState } from 'react';
import Autosuggest from 'react-autosuggest';
import { quillModules, quillFormats } from 'constants/defaultValues';
import ReactQuill from 'react-quill';
const getSuggestionValue = (suggestion) => suggestion.name;
const renderSuggestion = (suggestion) => <div>{suggestion.name}</div>;
const ReactAutoSuggest = ({ data, value, placeholder, onChange }) => {
const [valueState, setValueState] = useState(value);
const [dataState] = useState(data || []);
const [suggestions, setSuggestions] = useState([]);
const getSuggestions = (val) => {
if (val) {
const inputValue = val.trim().toLowerCase();
const inputLength = inputValue.length;
return inputLength === 0
? []
: dataState.filter(
(d) => d.name.toLowerCase().slice(0, inputLength) === inputValue
);
}
return dataState;
};
const changeInput = (val, result) => {
setValueState(val);
onChange(val);
};
const onSuggestionsFetchRequested = ({ value: val }) => {
setSuggestions(getSuggestions(val));
};
const onSuggestionsClearRequested = () => {
setSuggestions([]);
};
const inputProps = {
placeholder: placeholder || '',
value: valueState,
onChange: changeInput,
};
const EditorInput = () => {
return (
<ReactQuill
value={valueState}
theme="snow"
name="emailPayload"
onChange={(val) => {
//val is the value generated from react-quil, for example if you
//type s inside react-quill, val would be '<p>s</p>'
let doc = new DOMParser().parseFromString(val, 'text/xml');
let result = doc.firstChild.innerHTML;
//result is the text value extracted from val, for example
//if you type s in react-quill, result would be 's' itself
changeInput(val, result);
}}
modules={quillModules}
formats={quillFormats}
/>
);
};
return (
<Autosuggest
renderInputComponent={EditorInput}
suggestions={suggestions}
onSuggestionsFetchRequested={onSuggestionsFetchRequested}
onSuggestionsClearRequested={onSuggestionsClearRequested}
getSuggestionValue={getSuggestionValue}
renderSuggestion={renderSuggestion}
inputProps={inputProps}
theme={{
container: 'autosuggest',
input: 'form-control',
inputOpen: 'react-autosuggest__input--open',
suggestionsContainer: 'react-autosuggest__suggestions-container',
suggestionsContainerOpen:
'react-autosuggest__suggestions-container--open',
suggestionsList: `react-autosuggest__suggestions-list ${
suggestions.length ? 'show' : ''
}`,
suggestionFocused: 'active',
suggestion: 'react-autosuggest__suggestion',
}}
/>
);
};
export default ReactAutoSuggest;
This is how I used my ReactAutoSuggest component:
<ReactAutoSuggest
value={suggestion}
onChange={(e) => {
setSuggestions(e);
}}
data={[
{
name: 'apple',
},
{
name: 'banana',
},
{
name: 'pear',
},
{
name: 'cherry',
},
]}
/>
where ‘suggestion’ is a simple state:
const [suggestion, setSuggestions] = useState('');
In case you need to know, inside the ReactAutoSuggest I have used 2 constant values quillModules, quillFormats which are:
export const quillModules = {
toolbar: [
['bold', 'italic', 'underline', 'strike', 'blockquote'],
[
{ list: 'ordered' },
{ list: 'bullet' },
{ indent: '-1' },
{ indent: '+1' },
],
['link', 'image'],
['clean'],
],
};
export const quillFormats = [
'header',
'bold',
'italic',
'underline',
'strike',
'blockquote',
'list',
'bullet',
'indent',
'link',
'image',
];
How do I make the suggestion list appear inside in the react-quill component?
There is already a question answering related to this topic: Word Add-in Get full Document text?
However, this method can’t extract the indicator/bullet points.
Is there a way we can do this? I expect the text to be exactly the same as we manually select all then copy a Word document.
The reason behind this: I’m building a question bank from a microsoft word document. Several tools offer text extraction, however, it usually ignores the bullet point.
I use keywords like A. B. C. D. etc to detect the choices. However, if the author writing choices using indicator/bullet point, this method fails.
I can get the value of id but data-id shows this error,
Uncaught ReferenceError: id is not defined
My code,
<ul id="highscores"></ul>
<script>
var hst = document.getElementById("highscores");
var highScores = [
{ id: "1",name: "Maximillian", score: 1000 },
{ id: "2",name: "The second guy", score: 700 },
{ id: "3",name: "The newbie!", score: 50 }
];
function deleteById ( self ){
console.log(self.id);
console.log(self.data-id);
}
for (var i = 0; i < highScores.length; i++) {
hst.innerHTML +=
"<li >" +"<a data-id='test' id="+highScores[i].id + " href='#' onclick='deleteById(this)'>x</a>" +
highScores[i].name +
" -- " +
highScores[i].score +
"</li>";
}
</script>
I want to create a fully dynamic form for user registration and i want the fields and option will be dynamic from database. after form fill i will save in a row format in table usersdata
Field table
After upgrading my Xcode to 13.3 I’ve noticed a change that doesn’t allow my react-native app to be added in my phone using the release mode option from “Edit Schema” anymore. I can add it to my iPhone just fine and be able to use it, but after I disconnect from the same wifi it doesn’t work anymore. Basically, the way it used to work is by following the next steps:
Go to Xcode
1) Click on Product
2) Click on Scheme
3) Click on Edit Schema
4) Finally choose release option instead of Debug option, then run it and that was it.
This way I didn’t have to be connected to the same wifi all the time, and simply go to anywhere that I wanted and be able to use my app just fine.
I want to do the same but I see a different screen now: when I go to “Edit Schema”
Can anyone point me in the right direction so I can release my app and not having to be connected to the same wifi all the time? Thanks a lot in advance!
I’m developing Chrome extension and I have too much eventListener for buttons. How to make the most efficient trigger for buttons?
I have been trying to render items from flatlist, the components render correctly, however, the space between the rendered components are too much. Spaces I am sure that I did not create. Also, the last item on the flatlist does not display completely as the flatlist will not scroll to the bottom of the item. please see my code and screenshot below
Component
import { View, Text, StyleSheet, Image } from "react-native";
import { FontAwesome, MaterialCommunityIcons } from "@expo/vector-icons";
export default function PostComponent() {
return (
<View
style={{
width: "90%",
backgroundColor: "blue",
marginVertical: 10,
alignSelf: "center",
}}
>
<View
style={{
height: "20%",
width: "100%",
backgroundColor: "white",
flexDirection: "row",
marginBottom: 5,
paddingHorizontal: 5,
}}
>
<View
style={{
width: "30%",
height: "100%",
borderRadius: 50,
overflow: "hidden",
}}
>
<Image
style={{ width: "100%", height: "100%" }}
source={require("../assets/imggg.jpg")}
/>
</View>
<View
style={{
width: "70%",
height: "100%",
justifyContent: "center",
padding: 10,
}}
>
<Text style={{ fontSize: 20, fontWeight: "bold" }}>Jane Doe</Text>
<Text style={{ fontSize: 15, fontStyle: "italic" }}>
Something Casual
</Text>
</View>
</View>
<View style={{ width: "100%", backgroundColor: "white" }}>
<View style={{ overflow: "scroll" }}>
<Text style={{ textAlign: "justify" }}>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime
mollitia, molestiae quas vel sint commodi repudiandae consequuntur
voluptatum laborum numquam blanditiis harum quisquam eius sed odit
fugiat iusto fuga praesentium optio, eaque rerum!
</Text>
</View>
<View
style={{
width: "100%",
}}
>
<Image
style={{ width: "100%" }}
source={require("../assets/imggg.jpg")}
/>
</View>
</View>
<View
style={{
flexDirection: "row",
justifyContent: "space-evenly",
paddingTop: 10,
}}
>
<FontAwesome name="heart" size={35} color="black" />
<MaterialCommunityIcons name="poker-chip" size={35} color="#e6b800" />
<FontAwesome name="comment" size={35} color="black" />
</View>
</View>
);
}
const styles = StyleSheet.create({});
Render
import { View, Text, StyleSheet, Image, FlatList } from "react-native";
import PostComponent from "../../Components/PostComponent";
import { auth, db, storage } from "../../firebase";
import { collection, query, getDocs, orderBy } from "firebase/firestore";
const postData = [];
async function getPosts() {
const q = query(collection(db, "Posts"), orderBy("postTime"));
const querySnapshot = await getDocs(q);
querySnapshot.forEach((doc) => {
// doc.data() is never undefined for query doc snapshots
postData.push({ id: doc.id, ...doc.data() });
});
}
function Posts() {
const [loading, setLoading] = useState(true);
useEffect(() => {
getPosts()
.then(() => {
setLoading(false);
})
.catch((e) => console.log(e));
}, []);
const renderPosts = ({ item }) => <PostComponent />;
if (loading) {
return <Text>Loading Posts</Text>;
}
return (
<View style={{ backgroundColor: "pink", height: "100%" }}>
<FlatList data={postData} renderItem={renderPosts} />
</View>
);
}
const styles = StyleSheet.create({});
export default Posts;
I am trying to make whatsapp clone by watching tutorial of cleverprogrammer youtube channel and at 2:54:00 timestamp, link is this : https://www.youtube.com/watch?v=pUxrDcITyjg. I am getting this error in console
Cannot read properties of undefined (reading ‘user’) . The above error occurred in the component: . Please help me with this, providing all the information below. Thanks.
import React,{useState} from "react";
import './App.css';
import Sidebar from './Sidebar';
import Chat from './Chat'
import {BrowserRouter as Router,Routes,Route} from "react-router-dom";
import Login from "./Login"
import { useStateValue } from "./StateProvider";
function App() {
const [{ user }, dispatch] = useStateValue(); **<<<Problem is here**
return (
<div className="app">
{
!user?(<Login />):( **<<<Using it here**
<div className="app_body">
<Router>
<Sidebar />
<Routes>
<Route path='/rooms/:roomId' component={ <Chat />} />
<Route path='/' component={ <Chat />} />
</Routes>
</Router>
</div>
)
}
</div>
);
}
export default App;
Here is the login file where it is setting value in user
import React from 'react';
import "./Login.css";
import Button from '@mui/material/Button';
import {auth,provider} from "./firebase";
import {useStateValue} from "./StateProvider";
import { actionTypes } from './reducer';
function Login() {
const [{},dispatch] = useStateValue();
const signIn = () =>{
auth.signInWithPopup(provider)
.then((result)=>{
dispatch({
type: actionTypes.SET_USER,
user: result.user, **<<<User is given value here**
});
})
.catch((error) =>alert(error.message));
};
return (
<div className='login'>
<div className='login_container'>
<img src='https://upload.wikimedia.org/wikipedia/commons/thumb/6/6b/WhatsApp.svg/479px-WhatsApp.svg.png' alt='whatsapplogo'/>
<div className='login_text'>
<h1>Sign in to whatsapp</h1>
</div>
<Button onClick={signIn}>
Sign In with Google
</Button>
</div>
</div>
)
}
export default Login;
Here is the stateprovider file
import React,{createContext,useContext,useReducer} from 'react'
export const StateContext = createContext();
export const StateProvider = ({
reducer,intialState,children
}) =>(
<StateContext.Provider value={useReducer(reducer,intialState)}>
{children}
</StateContext.Provider>
);
export const useStateValue = () => useContext(StateContext);
reducer file
export const initialState = {
user : null,
};
export const actionTypes = {
SET_USER : "SET_USER",
};
const reducer = (state,action) => {
console.log(action);
switch(action.type){
case actionTypes.SET_USER:
return{
...state,
user : action.user,
};
default:
return state;
}
};
export default reducer;
if (conv_details.settings.min === null ||
conv_details.settings.min === "undefined" ||
conv_details.settings.max === null ||
conv_details.settings.max === "undefined") {
details_data.push({
field_label: conv_details.label,
description: conv_details.description,
field_name: conv_details.field_name,
content_types: conv_details.bundle,
type: conv_details.field_type,
min: "",
max: "",
});
} else {
details_data.push({
field_label: conv_details.label,
description: conv_details.description,
field_name: conv_details.field_name,
content_types: conv_details.bundle,
type: conv_details.field_type,
min: conv_details.settings.min,
max: conv_details.settings.max,
});
}
I was writing an if else condition for checking the max and min value that is max or min value contain null or undefined or not if it contain null or undefined then the max or min value should be assign with "" but writing one condition is good in If else condition
but as you can see here I have wrote 4 condition in if statement and it is checking only for null condition but I want for undefined also
I came to know that if I put all my condition in Array list then it will automatically check if the condition satisfy or not
So I wrote all the condition in one Array list but don’t know how to call it in If statement to check the condition
let testArray=[`conv_details.settings.min === null`,
`conv_details.settings.min === "undefined"`
`conv_details.settings.max === null`
`conv_details.settings.max === "undefined"`];
if(testArray.includes()){
details_data.push({
field_label: conv_details.label,
description: conv_details.description,
field_name: conv_details.field_name,
content_types: conv_details.bundle,
type: conv_details.field_type,
min: "",
max: "",
});
} else {
details_data.push({
field_label: conv_details.label,
description: conv_details.description,
field_name: conv_details.field_name,
content_types: conv_details.bundle,
type: conv_details.field_type,
min: conv_details.settings.min,
max: conv_details.settings.max,
});
}
I don’t know what is the right way to declare the Array.includes in if statement to satisfy all my condition as I am new to node js and JavaScript