enter image description hereimgur.com/h55HG.png
Category: javascript
Category Added in a WPeMatico Campaign
JS animation behind text
How can I mask web animation background with texts?
We have an animation like this. And it should fill the text layers.
Thanks for the help.
I have to make this in Webflow, but any idea could help!
Change a date’s timezone to UTC without changing the date itself
Say if the date is:
var now = new Date(); // Tue Apr 19 2022 13:12:41 GMT+0530
I need to change only the timezone to UTC. so Tue Apr 19 2022 13:12:41 GMT+0000 in above case.
Things like toISOString() gives actual UTC i.e. modified date value after adjusting the offset.
Curl to Axios – Problem with implementing working curl request with provided certificates
I have been trying to implement working curl request in Axios (Node.js) but with no success.
Working curl request looks like this (I can’t share exact request as API is private):
curl --cacert server.pem --cert client.pem:123password456 -i -H "accept:application/json" -H "content-Type:application/json" "https://example.endpoint.com/"
So I have these two files, server certificate server.pem and client certificate client.pem with password 123password456. When I run this curl request, I get successful response (200 OK). However, that is not the case with my Axios implementation in Node.
My axios request in node looks like this:
const axios = require("axios");
const https = require("https");
const fs = require("fs");
const httpsAgent = new https.Agent({
cert: fs.readFileSync("./client.pem"),
passphrase: "123password456",
ca: fs.readFileSync("./server.pem"),
rejectUnauthorized: false
});
const axiosInstance = axios.create({
httpsAgent: httpsAgent
});
let response = await axiosInstance.get("https://example.endpoint.com/");
When I run the code above in Node, it instantly throws Axios error:
Error: socket hang upn at connResetException (node:internal/errors:691:14)...
Error object:
{
code:'ECONNRESET'
message:'socket hang up'
isAxiosError:true
...
}
I have tried it with various edits (for example not using axios instance and using only axios object). Thank you very much for any help
TypScript Class Generics and Polymorphic attributes
I’m having difficulty with Generics & Polymorphic attributes. Am I doing something crazy?
I’ve stripped down this code pretty far. I have two (or more) classes (WelcomeTemplate & AddToAccountTemplate) that extend a base class (TemplateContext). Each implement their own shape of shape of context. The goal is when EmailService when initialized, it will take in the name of the template and typescript will be aware of what context is therefor needed given the template.
For example:
new EmailService("WelcomeTemplate", {
signupUrl: 'https://test.com',
});
However within EmailService when initializing the template I get the following two TypeScript errors which have me scratching my head. I’ve fiddled with several approaches, but keep landing back at these errors.
Argument of type 'AddToAccountContext | WelcomeContext' is not assignable to parameter of type 'AddToAccountContext & WelcomeContext'.
and
AddToAccountTemplate' is assignable to the constraint of type 'Template', but 'Template' could be instantiated with a different subtype of constraint 'AddToAccountTemplate | WelcomeTemplate'.
Naturally AddToAccountContext | WelcomeContext and AddToAccountContext & WelcomeContext conflict. But I’m not certain why typescript is concluding & given I’m doing Templates[Key] which from generics which I believe should have the types for just at Key not a merged type for all Keys.
Is there just a better way to organize subclasses for this scenario?
Here is a TypeScript Playground. It may be simpler to fiddle with there.
Thanks for taking a look with me!
interface ITemplate<Context> {
readonly context?: Context;
}
type TemplateContext = {};
class Template implements ITemplate<TemplateContext> {
public context = {};
}
type AddToAccountContext = {
loginUrl: string;
accountName: string;
};
class AddToAccountTemplate extends Template {
constructor(context: AddToAccountContext) {
super();
this.context = context;
}
public context: AddToAccountContext;
}
type WelcomeContext = {
signupUrl: string;
};
class WelcomeTemplate extends Template {
constructor(context: WelcomeContext) {
super();
this.context = context;
}
public context: WelcomeContext;
}
const templates = Object.freeze({
WelcomeTemplate,
AddToAccountTemplate,
});
type Templates = typeof templates;
class EmailService<
Key extends keyof Templates,
Template extends InstanceType<Templates[Key]>,
Context extends Template["context"],
> {
templateName: Key;
context: Context;
template: InstanceType<Templates[Key]>;
constructor(templateName: Key, context: Context) {
this.templateName = templateName;
this.context = context;
const TemplateClass = templates[this.templateName];
this.template = new TemplateClass(this.context); // Error: Argument of type 'AddToAccountContext | WelcomeContext' is not assignable to parameter of type 'AddToAccountContext & WelcomeContext'.
}
}
How to make input field editable on a button click separately in React?
I have some data coming from database which I have shown on the UI. But I want to make those field editable on a button click. I have added images below for better understanding.
After Clicking The Edit Button

As you can see from the pictures I want something like this: When I click on the edit button the corresponding field get editable and the edit button change to save button. And when clicking the save button data will be submitted to an API, and the view will be change as before. How Can I do that.
This is my simple Code
<div className="col-sm-10 d-flex align-items-center">
<input
className="form-control mx-1"
value={item.name}
disabled
/>
<div className="text-end">
<i
style={{ color: "blue" }}
className="fas fa-edit d-block"
></i>
</div>
</div>
Awkward Behaviour in JavaScript [duplicate]
I have an Array that looks like this.
ETH: [
[ 1571967200, 'DEPOSIT', 'ETH', 0.68364 ],
[ 1571967189, 'WITHDRAWAL', 'ETH', 0.493839 ],
[ 1571967110, 'DEPOSIT', 'ETH', 0.347595 ],
[ 1571966982, 'WITHDRAWAL', 'ETH', 0.266166 ],
[ 1571966641, 'DEPOSIT', 'ETH', 0.899781 ],
[ 1571966421, 'DEPOSIT', 'ETH', 0.218207 ],
[ 1571966410, 'DEPOSIT', 'ETH', 0.205472 ],
[ 1571966250, 'WITHDRAWAL', 'ETH', 0.761543 ],
[ 1571966124, 'DEPOSIT', 'ETH', 0.66315 ],
[ 1571965892, 'DEPOSIT', 'ETH', 0.554933 ]
],
XRP: [
[ 1571967150, 'DEPOSIT', 'XRP', 0.693272 ],
[ 1571967067, 'WITHDRAWAL', 'XRP', 0.393786 ],
[ 1571966896, 'WITHDRAWAL', 'XRP', 0.81984 ],
[ 1571966868, 'WITHDRAWAL', 'XRP', 0.969999 ],
[ 1571966849, 'WITHDRAWAL', 'XRP', 0.650535 ],
[ 1571966763, 'DEPOSIT', 'XRP', 0.588537 ],
[ 1571966749, 'DEPOSIT', 'XRP', 0.109955 ],
[ 1571966399, 'DEPOSIT', 'XRP', 0.537373 ],
[ 1571966054, 'DEPOSIT', 'XRP', 0.709244 ],
[ 1571965945, 'DEPOSIT', 'XRP', 0.157443 ]
],
This code below loops through the array and adds all deposits and subtracts the withdrawals then groups the result using the Token name.
for(groupName in groupedResult) {
const accumulated = groupedResult[groupName].reduce((acc, curr)=>{
acc[curr[1]] += curr[3];
return acc; // ← return the accumulator to use for the next round
}, {DEPOSIT: 0, WITHDRAWAL: 0})
// console.log(groupName, accumulated);
groupedBalance[groupName] = {
Balance: accumulated['DEPOSIT'] - accumulated['WITHDRAWAL']
};
}
Here is the result
{
ETH: { Balance: 2.05123 },
XRP: { Balance: -0.03833600000000059 },
BTC: { Balance: 3.688666 }
}
The code below loops through the grouped balance, makes an API call to get the exchange rates using the Token name. That’s where the awkwardness begins.
for (Gname in groupedBalance){
console.log(Gname);
axios.get('https://min-api.cryptocompare.com/data/price?fsym=' + Gname + '&tsyms=USD&api_key=a437b4c681a4107')
.then(response => {
console.log(Gname);
groupedApiResult[Gname] = {
LastestBalance: ((groupedBalance[Gname].Balance * response.data.USD))
};
})
.catch(error => {
// console.log(error);
});
}
The first console.log(Gname); ouputs the following result.
PS E:Command Line> get-transactions
ETH
XRP
BTC
The Second console.log(Gname); within the axios request, outputs the following result
PS E:Command Line> get-transactions
BTC
BTC
BTC
Why am I getting diffrent results yet, they are within the same for Loop?
Here is the Entire Code
let csvData =[];
let res = 0;
let groupedResult =[] ;
const groupedBalance = {};
const groupedApiResult = {};
inputStream.pipe(new CsvReadableStream({ parseNumbers: true, parseBooleans: true, trim: true }))
.on('data', (row)=> {
csvData.push(row);
})
.on('end', function () {
groupedResult = csvData.reduce((acc, curr) => {
if(!acc[curr[2]]){
acc[curr[2]] = [];
}
acc[curr[2]].push(curr);
return acc;
},[]);
for(groupName in groupedResult) {
const accumulated = groupedResult[groupName].reduce((acc, curr)=>{
acc[curr[1]] += curr[3];
return acc; // ← return the accumulator to use for the next round
}, {DEPOSIT: 0, WITHDRAWAL: 0})
groupedBalance[groupName] = {
Balance: accumulated['DEPOSIT'] - accumulated['WITHDRAWAL']
};
}
for (Gname in groupedBalance){
// console.log(Gname);
axios.get('https://min-api.cryptocompare.com/data/price?fsym=' + Gname + '&tsyms=USD&api_key=a437b4c681a49c9b45382a38c319ed0a795b9180041154d9dc5702e534e72107')
.then(response => {
groupedApiResult[Gname] = {
LastestBalance: ((groupedBalance[Gname].Balance * response.data.USD))
};
})
.catch(error => {
// console.log(error);
});
}
});
console.log( groupedBalance);
Another thing, on the last line, when i console.log( groupedBalance); out side the fo loop, I get a blank array but with the for loop, it shows the contents of the array. Why is it behaving like this? Is there i Javascript concept im missing?
How to do mapping in reactjs if data is fetch in other file?
I have created a fileone.js file and I am trying to fetch the API data in this file as given below
import React, { Component, Suspense, lazy } from "react";
import axios from "axios";
import { ApiUrlConstant } from '../../../../utils/ApiUrlConstant';
import { getTokenu, isLoginu } from "../../../../utils/Token";
const Course = lazy(()=> import('../../../Course'));
const CourseDetails = lazy(()=> import('../../../CourseDetails'));
import Switch from "react-bootstrap/esm/Switch";
import PublicRoute from "../../../Route/Publicroute";
import FallBack from "../../FallBack/FallBack";
import "./Courses.scss";
class fileone extends Component {
constructor(props) {
super(props);
this.state = {
load: false,
checkPaid: true,
page: 0,
};
this.token = getTokenu();
}
setLoader = () => {
this.setState({ load: !this.state.load });
};
componentDidMount() {
axios.get(ApiUrlConstant.getApiFullUrl("course.feed"),
{
headers: {
Authorization: "Token " + this.token
}
})
.then((res) => {
this.setState({ User: res.data.results[0].user_detail.username, load: false });
this.setState({ Paid: res.data.results[0].user_paid, load: false });
this.setState({ CoursList: res.data.results[0].courses_list, load: false });
})
.catch((error) => {
this.setState({ error: error, load: false });
});
};
render() {
return (
<div className="course-main-feed">
<Suspense fallback={<FallBack />}>
<Switch style={{ paddingLeft: "0px" }}>
{ this.state.User && (this.state.Paid == true) ? <>
<PublicRoute restricted={false} component={Course} path="/paidcourses" handleToast={this.props.handleToast} exact/>
<PublicRoute restricted={false} component={CourseDetails} path="/paidcourses/:paidcourse_id" handleToast={this.props.handleToast} />
</>: null }
</Switch>
</Suspense>
</div>
);
}
}
export default fileone;
In the given code as we can see there is a line inside componentdidmount this.setState({ CoursList: res.data.results[0].courses_list, load: false }); in this line there are n number of courses object list. I am trying to map this courses_list in another file. I tried with the below code but I seems like the data is not getting in this
import React, { Component } from 'react'
import "./Course.scss";
export class Course extends Component {
constructor(props) {
super(props);
this.myRef = React.createRef();
this.state = {
data: [],
load: false,
error: null,
next: "",
prev: "",
menu: false,
};
}
setLoader = () => {
this.setState({ load: !this.state.load });
};
renderArticlesFeed = () => {
if (this.state.CoursList === 0)
return (
<div style={{ width: "100%", display: "flex", justifyContent: "center", color: "#f3990f" }}>
<span>No Courses to display!</span>
</div>)
return this.state.CoursList && this.state.CoursList.map((item, i) => {
return (
<div className="" style={{width: "100%", margin: "none"}} key={item.id}>
<div className="course-feed-column">
<div className="">
{item.title}
</div>
</div>
</div>
);
}
)
};
render() {
const { data, error, load } = this.state;
return (
<div>
{this.renderArticlesFeed()}
</div>
)
}
}
export default Course
I am not able to get the value of {item.id} and {item.title}. Any help from anyone will be appreciated.
How to make fields non required in yup?
I want to know how to make other fields non required if one is statisfied. In my condition name and register number are mandatory but other fields are not mandatory how to do this?. Other fields like net, iit ,etc. should not be mandatory.
Below is the code
const schema = yup.object().shape({
register: yup.string()
.required('This is required')
.matches(/^[0-9b]+$/, 'Only numbers requires'),
name: yup.string()
.required('This is required')
.matches(/^[A-Za-zs]+$/, 'Only character requires'),
net: yup.string()
// .required('This is required')
.nullable().notRequired().matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
// .matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
iit: yup.string()
// .required('This is required')
.nullable().notRequired().matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
// .notRequired()
// .matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
slet: yup.string()
// .required('This is required')
// .notRequired()
// .matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
.nullable().notRequired().matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
gate: yup.string()
// .required('This is required')
// .notRequired()
// .matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
.nullable().notRequired().matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
gmat: yup.string()
// .required('This is required')
// .notRequired()
// .matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
.nullable().notRequired().matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
cat: yup.string()
// .required('This is required')
// .notRequired()
// .matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
.nullable().notRequired().matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
gre: yup.string()
// .required('This is required')
// .notRequired()
// .matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
.nullable().notRequired().matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
jam: yup.string()
// .required('This is required')
// .notRequired()
// .matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
.nullable().notRequired().matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
ielet: yup.string()
// .required('This is required')
// .notRequired()
// .matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
.nullable().notRequired().matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
toefl: yup.string()
// .required('This is required')
// .notRequired()
// .matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
.nullable().notRequired().matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
civil: yup.string()
// .required('This is required')
// .notRequired()
// .matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
.nullable().notRequired().matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
state: yup.string()
// .required('This is required')
// .notRequired()
// .matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
.nullable().notRequired().matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
others: yup.string()
// .required('This is required')
// .notRequired()
// .matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
.nullable().notRequired().matches(/^[^-s][a-zA-Z0-9_s-]+$/,'enter proper details'),
});
If anyone has the idea please comment below. Thanks in advance!
Javascript Recursive functions for array of JSON objects to update or delete from array based on id key
I’m trying to create 2 recursive functions to “loop” over an array of JSON objects – like below. I think the 2 functions are “similar” but they do two different things.
Function 1 should update the JSON – which could be ever field in the “found” object and return the “new” array of objects, so the function needs to identify the appropriate object by .id
Function 2 needs to identify the appropriate object by .id BUT to delete that object and again return the “new” array of objects.
I’ve tried a number of ways (below the array of JSON objects) – but to no avail, I cannot get the new object to return
To note even if each object has varying/different keys THERE WILL ALWAYS BE AN id KEY –
[
{
"type":"section",
"name":"Section 1",
"hassection":[
{
"type":"section",
"id":1,
"name":"Section 1 child section 1",
"hasMenuItem":
[
{
"type":"item",
"id":2,
"name":"Item 1",
"prices":
{
"type":"price",
"price":"15.95"
},
"description":"Blah Blah..."
},{
"type":"item",
"id":3,"name":
"Item 2",
"prices":[
{
"type":"price",
"price":"24.95"
},{
"type":"price",
"price":"13.95"
}
],
"description":"Blah Blah..."
}
]
},{
"type":"section",
"id":4,
"name":"Section 1 child section 2",
"hasitem":[
{
"type":"item",
"name":"Item 3",
"prices":
{
"type":"price","price":"14.50"
},
"description":"Blah Blah..."
},{
"type":"item",
"id":5,
"name":"Item 4",
"prices":
{
"type":"price",
"price":"14.50"
},
"description":"Blah Blah..."
}
]
},
]},{
"type":"section",
"name":"Section 2",
"hassection":[
{
"type":"section",
"id":6,
"name":"Section 2 child section 1",
"hasitem":[
{
"type":"item",
"id":7,
"name":"Item 5",
"prices":
{
"type":"price",
"price":"15.95"
},
"description":"Blah Blah..."
},
{
"type":"item",
"id":8,
"name":"Item 6",
"prices":
{
"type":"price",
"price":"13.95"
},
"description":"Blah Blah..."
}
]
}
]}
]
My update function
function updateNestedObj(obj,updates) {
const updateToApply = updates.find(upd => upd.id === obj.id);
if (updateToApply) {
// UPDATE THE OBJ
}
for(let k in obj) {
if (typeof(obj[k]) === 'object') {
// LOOP THROUGH THE OBJECT
updateNestedObj(obj[k], updates);
}
}
return updateToApply
}
My Delete function
function deleteNestedObj(obj, updates) {
const updateToApply = updates.find(upd => upd.id === obj.id);
if (updateToApply) {
delete upd;
}
for(let k in obj) {
if (typeof(obj[k]) === 'object') {
deleteNestedObj(obj[k], updates);
}
}
}
I just cannot fathom out how to “work them” – thanks in advance, any help much appreciated.
Refactoring the React/Javascript code based on a specific suggestion
I’m currently looking to refactor the belwo code based the following sugestions but I’m not sure how to go about it.
Suggestions:
- please create your code based on data added by the user (alertDetails.alertMessage)(alertDetails is an object which is attached).
- code goes through all user languages (all defined modalities(delmethod) even if users don’t add them
- please create a function to encapsulate this logic (or at least please use useMemo)
- What is the benefit of using map here? Array.map returns a new array, but this feature is not used here. Please check other methods for loops provided
code
const delmethod = ['all', 'email', 'sms', 'fax', 'voice', 'voicemail', 'pager', 'pagerTwoWay'];
let languages = organizationLocales?.map(a => a.locale);
let variables = alertDetails.variables?.map(k => k.name);
variables?.splice(1, 4);
let bodyContainsVariables = false;
languages?.length &&
languages.map(lang => {
delmethod.map(i => {
variables.map(variable => {
if (alertDetails.alertMessage?.[`${lang}`]?.[i]?.includes(`[[placeholder:${variable}]]`)) {
bodyContainsVariables = true;
}
});
});
});
What I tried:
let dellmethod= Object.keys(alertDetails?.alertMessage).map(w=>w.alertMessage);
let languages = Object.keys(alertDetails?.dellmethod.map(j=>j.dellmethod).map(z=>z.languages));
I tried accessing the dellmethod and languages from alertDetails objects like this but couldn’t succeed.
Object structure: alertDetails–>alertMessage–>lang–>String(delvery methods eg:all, email, sms etc)–>message body.
I just would like to refactor my code based on the suggestion, thanks I appreciate any help.
How to use docusaurus with Fluent UI?
I am now working on Docusaurus (which is a static site generator) with Fluent UI, and I don’t know how to setup SSR for Fluent UI, there’s no any useful information on Internet.
What I’ve known:
Fluent UI use a lib called merge-styles to achieve its CSS-in-JS support. merge-styles will generate CSS class for each style set, and these classes must be written into HTML <head></head> tag to be active. This lib uses an ID counter which will add an ID suffix to each class. In general, both mergeStyles and mergeStyleSets call will generate some CSS classes, and in server-side and client-side, the value of ID counter may be different. Docusaurus is a pure static site generator which has a building bundle without any server code. It will pre-execute all codes on building and uses the result of each page as final generated html file. So, in building process, Fluent UI seems generated a set of stylesheets with a set of IDs, and if I use:
import {Stylesheet, resetIds} from "@fluentui/react";
// These codes are run on the server side.
resetIds();
let stylesheet = Stylesheet.getInstance();
let serializedStylesheet = stylesheet.serialize();
let rules = stylesheet.getRules(true);
// Inject rules into generated codes as <style data-merge-styles="true">{rules}</style>
let script = `
window.FabricConfig = window.FabricConfig || {};
window.FabricConfig.serializedStylesheet = ${serializedStylesheet};
`;
// Inject script into generated codes as <script>{script}</script>
I actually will get another set of classNames and rules with totally different ID, and that makes my page looks a mess.
I saw another way is renderStatic, but I think I cannot use it because I cannot get the real root component of Docusaurus page.
I know that Stylesheet is an object which is registered in a variable named _global, and this variable is initialized in the file Stylesheet.ts. This initialization process will first check if there is an object called window.FabricConfig and then assign it or an empty object to _global. When we call getInstance(), this function will search _global for an existing Stylesheet object, and if there’s no such object, it will initialize a brand new instance with all properties have a same value {}. So, what is confusing me is:
- Why the client uses a new Stylesheet object instead of the one I’ve already injected to the page’s window? (I can make sure that the injected codes are executed before all other scripts)
- The Stylesheet object is initialized with all properties are
{}, so, where the values of Stylesheet object that I injected come from? - How could I get the actual Stylesheet object used in server-side rendering?
I hope there could be some experts of this question could do me a favour. Thanks.
Javascript – convert object of object into array and use the key inside array
I have an object of objects which I have converted into an array, I now want to use the key of each item into the array as a separate value.
The code I have tried.
let data = {
99: {
"avg": [1,2],
"min": [],
"max": []
},
100: {
"avg": [50,10],
"min": [],
"max": []
},
120: {
"avg": [42,8],
"min": [],
"max": []
},
}
var arr = Object.keys(data).map(function (key) {
return { [key]: data[key] };
});
arr.forEach(element => {
element.sensor = Object.keys(element);
});
console.log(arr);
And the output is
[
{
"99": {
"avg": [
1,
2
],
"min": [],
"max": []
},
"sensor": [
"99"
]
},
{
"100": {
"avg": [
50,
10
],
"min": [],
"max": []
},
"sensor": [
"100"
]
},
{
"120": {
"avg": [
42,
8
],
"min": [],
"max": []
},
"sensor": [
"120"
]
}
]
But I want the expected output to be like this.
[
{
{
"99": {
"avg": [1, 2],
"min": [],
"max": [],
"sensor: 99"
}
{
"100": {
"avg": [50, 10],
"min": [],
"max": [],
"sensor: 100"
}
{
"120": {
"avg": [42, 8],
"min": [],
"max": [],
"sensor: 120"
}
}
]
Page redirect using call back function in javascript
I have created a validate function in Javascript for validation the form. Now I want to create another function redirect which is to be used as a call back function to redirect to another html page after form validation..how to do that??
Find All valid tags in a html string using regex
/<(s*!–s*.ko|w|/w|s*!–s*/ko)+/g
Above regex is partially correct, It finds all valid tags but it also reads the commented out lines which should be excluded.
enter image description here
This div should not be picked as it is a commented out lines, but regex should not exclude correct knockout syntax.
