Regex testing a string with uppercase letters, lowercase letters, numbers, special symbols, with no whitespace

I’m trying to evaluate a js string with a regex function that will detect the above mentioned criterias except for the symbols part, as I only need to evaluate if dots or underscores are in the string. An example is this:

mfv.3djtSewe5jCrg19A_fkdrOe8LG2zL7cY1oK4lEN5m3z6jh9bvpUlnxfP4qdbAwhuUruN_uKRv6trcROqXm4P

and the regex I’m using is this:

/^(?!.*s+$)(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[_.]).+$/

I’m new to javascript let alone regex matching and I’m not entirely sure how to do this.

Trouble splitting a string in JavaScript using regular expressions

I am VERY new to regex in js and having a very hard time manipulating them to do what I am looking for.

I have a series of strings that I am trying to strip of unusual characters, spaces, newlines, etc. and put them into arrays where each entry is a word consisting of only alphanumeric characters.

For example:

let testString = "this*is " + "an" +" test string "
test = testString.split(/W/)  
console.log(test)

Yields [ 'this', 'is', 'a', '', 'test', 'string', '' ]

But ideally I would like it to yield [ 'this', 'is', 'a', 'test', 'string']

I can achieve the desired result by adding .filter(word => word !== '') to the end, but I am wondering if there is a way to do this using only regular expressions? Also would it be necessary to add a global flag to the regex?

Thanks in advance for any input!

Angular service not updating component html element

I have a property in an object in an Angular service that is bound to a text field in a component’s html.

When the property is updated by the service, the new value is not showing in the html element until I click on the element.

I cannot figure out why the new value isn’t immediately showing in the text field without having to click on the element to get the new value.

The console.log message in the update function shows that the object is updated correctly, it’s just that the data is not making it through to the form field until the element is clicked.

The code is below:

parent.component.html

<input [(ngModel)]="service.selectedMarker.data" type="text" />

service.service.ts

public serviceObj = {} as any;

...

updateObj() {
    this.serviceObj.data = 'new value';
    console.log('this.serviceObj = ', this.serviceObj);
}

...

How to do in right way small React JS App [closed]

There is an app, like Scrum game

enter image description here

every developer can select card with task difficulty estimation and unveil it for another devs in Scrum room.

FrontEnd Apps communicate with each other with backend Node.js script via WebSocket.

FrontEnd App is built with jQuery and it works well.

I was tasked to rebuild it with React JS.
I started with cards and stacked almost immediately.

Question is how to build App architecture to not use huge and deep global state but use component dependent states?

My approach :

class scrumPoker {

constructor() {

    this.selfCardStates = [
        { n : 1, value : 0, state : 'inactive' },
        { n : 2, value : 1, state : 'inactive' },
        { n : 3, value : 10, state : 'inactive' },
        { n : 4, value : 50, state : 'inactive' },
    ];
    this.cardRefs = [];
    this.selfCardStates.map( ( card, i ) => {
        this.cardRefs[i] = useRef( null );
    } );
    this.tools = toolBox = new toolBoxClass();

}

renderSingleCard = ( cardState ) => {

    const [ card, setCard ] = useState( cardState );
    const state = ( card.state == 'inactive' ) ? 'active' : 'unveiled';

    return (
        <div key={card.n} ref={this.cardRefs[card.n]} className="single-card"
             onClick={ () => {
                setCard( { n: card.n, value: card.value, state: state } );
                this.cardRefs[card.n].current.className = 'single-card ' + state;
             } }>
            <div className="card-n">{card.n}</div>
            <div className="card-value">{card.value}</div>
            <div className="card-state">{card.state}</div>
        </div>
    );

}

renderCards = () => {

    let cards = [];
    cards = this.selfCardStates.map( ( cardState, i ) => {
        return this.renderSingleCard( cardState, i )
    } );

    return (
        <div className="cards-box">{cards}</div>
    );

}

renderMainPage = function() {
    return (
        <React.Fragment>
            <this.renderCards />
            <div className="test-box">
                <button onClick = { () => {
                    this.selfCardStates = [
                        { n : 4, value : 20, state : 'active' },
                        { n : 3, value : 30, state : 'active' },
                        { n : 2, value : 50, state : 'active' },
                        { n : 1, value : 100, state : 'active' },
                    ];
                } }>test</button>
            </div>
        </React.Fragment>
    );
}

}

I expect to update state of all of 4 cards by button click, so I expect to see new cards set, but nothing happens.

cardRefs is used for CSS manipulating, it is secondary stuff.

Where is the convenience of React JS and how to re-build class to have ability to rebuild Cards set in reactive way by button click ( or Websocket answer receiving in real App ) ?

I do not understand how to organize my App to have flexibility with states manipulation and not to build large deep-nested almost global State ?

In terms of this App it means will be added another modules ( to create room, to handle WS requests, to add / remove user etc. ) and I do not see how to complete it without large deep-nested State.

How to structure App in right way ?

On page load Accordion tab open

I am working with a WordPress site and I am using an accordion addon. I would like for the first accordion tab to be open when a user loads the page. How/where can I do that? Is it in the backend of the site somewhere?

Also, do I need to be using javascript or jquery for this?

Thanks!

Cannot read property of undefined (reading ‘remove’) after appending child in ul

I don’t know what is wrong with this code. When I append app child to the tag and when I try to click the delete button of the appended child it shows me this error.

if you have a solution then provide me or give me suggestion to do this task

Cannot read properties of undefined (reading ‘remove’).

You can check the code as well.

HTML Code.

<!DOCTYPE html>
<html>
  <head>
    <title>Javascript + DOM</title>
    <link rel="stylesheet" type="text/css" href="style.css" />
  </head>
  <body>
    <h1>Shopping List</h1>
    <p id="first">Get it done today</p>
    <input id="userinput" type="text" placeholder="enter items" />
    <button id="enter">Enter</button>
    <ul>
      <li class="bold red" random="23">
        Notebook <button class="deleteButton">Delete</button>
      </li>
      <li>Jello <button class="deleteButton">Delete</button></li>
      <li>Spinach <button class="deleteButton">Delete</button></li>
      <li>Rice <button class="deleteButton">Delete</button></li>
      <li>Birthday Cake <button class="deleteButton">Delete</button></li>
      <li>Candles <button class="deleteButton">Delete</button></li>
    </ul>
    <script type="text/javascript" src="script.js"></script>
  </body>
</html>

JavaScript Code.

var button = document.getElementById("enter");
var input = document.getElementById("userinput");
var ul = document.querySelector("ul");
var li = document.querySelector("li");
var deleteButton = document.getElementsByClassName("deleteButton");
var liAll = document.querySelectorAll("li");

function inputLength() {
  return input.value.length;
}

function createListElement() {
  var li = document.createElement("li");
  li.appendChild(document.createTextNode(input.value));

  const returnedLi = createDeleteButtonElement(li);

  ul.appendChild(returnedLi);
  input.value = "";
  strikeThroughOnClick();
  deleteOnClick();
}

function createDeleteButtonElement(li) {
  var button = document.createElement("button");
  button.appendChild(document.createTextNode("Delete"));
  button.classList.add("deleteButton");
  li.appendChild(button);
  return li;
}

function addListAfterClick() {
  if (inputLength() > 0) {
    createListElement();
  }
}

function addListAfterKeypress(event) {
  if (inputLength() > 0 && event.keyCode === 13) {
    createListElement();
  }
}

function strikeThrough(i) {
  liAll[i].classList.contains("done")
    ? liAll[i].classList.remove("done")
    : liAll[i].classList.add("done");
}

function deleteItem(i) {
  //   console.log();
  liAll[i].remove();
  //   this.parentNode.remove();
}

function deleteOnClick() {
  for (let i = 0; i < deleteButton.length; i++) {
    deleteButton[i].addEventListener("click", () => deleteItem(i));
  }
  return deleteButton;
}

function strikeThroughOnClick() {
  for (let i = 0; i < liAll.length; i++) {
    liAll[i].addEventListener("click", () => strikeThrough(i));
  }
  return liAll;
}

button.addEventListener("click", addListAfterClick);

input.addEventListener("keypress", addListAfterKeypress);

strikeThroughOnClick();
deleteOnClick();

404 on create_intent via solidus_stripe gem

Trying to integrate v3 intents , followed the readme but i keep getting thoses errors on js side :

Feature Policy: Skipping unsupported feature name “payment”. v3:1:78187
Feature Policy: Skipping unsupported feature name “payment”. v3:1:78325
Feature Policy: Skipping unsupported feature name “payment”. v3:1:178554

and when i submit the test card informations :

POSThttps://_my_web_site_url.com/stripe/create_intent [HTTP/1.1 404 Not Found 897ms]

I keep searching for what kind of integration error i could’ve done but nothing , i have the feeling it lack a memeber of the posting url
all mentions in stripe’s doc are specifying a version in them .

i’am running

rails 5.2.6 on ruby 2.7 with:
solidus (2.10.5)
solidus_api (= 2.10.5)
solidus_backend (= 2.10.5)
solidus_core (= 2.10.5)
solidus_frontend (= 2.10.5)
solidus_sample (= 2.10.5)
solidus_api (2.10.5)
solidus_stripe (4.2.0)


config.static_model_preferences.add(
Spree::PaymentMethod::StripeCreditCard,
'stripe_env_credentials',
secret_key:'sk_test_aksdhflkajsgdflkuasgdf',
publishable_key: 'pk_test_kjhga;lihglkashglasd',
stripe_country: 'FR',
v3_elements: false,
v3_intents: true,
)

And the stripe static conf has been selected in the backend’s payment page .

THanks in advance for reading / helping .

HTML5 video: Get textTracks from youtube, netflix, etc when there are no children elements

Looking at the documentation for HTMLMediaElement.textTracks, it looks like subtitle/caption tracks should be nested under <video> elements. This allows you to call .textTracks on a video reference to get access to subtitles/captions.

I’ve found a number of smaller sites where this works and is setup as expected (ie: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/track). However, on bigger sites like Netflix and Youtube, this doesn’t appear to work. In fact, their video elements typically have no children at all from what I can see.

This returns an empty list for a call like document.querySelector("video").textTracks:
enter image description here

Is there not a standard way of handling subtitles/captions? Can someone explain why big sites do this differently from the documentation above, and if there’s another easy way to access their subtitles/captions? I’d like to build a browser extension that reacts based off of the captions in a video.

React Native useEffect works on file save

I am developing a video chat app using react-native-voximplant, everything works, but when the app loads first time, the login functionality is happening inside the useEffect. So, the problem is, when my HomeScreen mounts, the useEffects’ should fire and I should get logged in voximplant sdk and now if I tap on call icon, the following is shown in the console:

When HomeScreen mounts:

LOG Client: emit: no handlers for event: AuthResult
LOG Error while trying to login to voximplant:  {"code": 491, "name": "AuthResult", "result": false}
LOG Client: emit: no handlers for event: ConnectionEstablished

Now when I tap on call to make a call:

// after a second...

WARN Possible Unhandled Promise Rejection (id: 0):
"NOT_LOGGED_IN"

Now when I hit save (ctrl+s), I get logged in and now if I make a call, it works! I don’t know what I am doing wrong here. Is something wrong with useEffect or I’m doing something wrong?

The HomeScreen code:

import {Voximplant} from 'react-native-voximplant';

const HomeScreen = () => {
  const voximplant = Voximplant.getInstance();

  useEffect(() => {
    const signInToVoximplant = async () => {
      try {
        const fqUsername = '...'; // credentials are correct, don't worry about them.
        const password = '...';
        await voximplant.login(fqUsername, password);
      } catch (error) {
        console.log('Error while trying to login to voximplant: ', error);
      }
    };
    signInToVoximplant();
  }, []);

  useEffect(() => {
    const connect = async () => {
      const status = await voximplant.getClientState();
      if (status === Voximplant.ClientState.DISCONNECTED) {
        await voximplant.connect();
      } else if (status === Voximplant.ClientState.LOGGED_IN) {
        console.log('[INFO] VOXIMPLANT CONNECTED');
        return;
      }
    };
      connect();
    }, []);
  }
  
  return ...

The call will only work if I hit ctrl+s i.e. save the file, otherwise it will throw Unhandled Promise rejection... because it is not logged in, however I have written/provided the login inside the useEffect.

display sticky div if within viewport

I am basing my code off of this thread Displaying a div once its within the viewport

I have a parent div that is half way down the page, within that parent div I want to display a sticky footer div, but only when viewport is showing parent div. I have tried 4 different tutorials so far with no luck.

page structure is this

HEADER

HERO

CONTENT RIGHT-SIDE(id=”wrap-vs”)

CONTENT-FULL-WIDTH

FOOTER

So when RIGHT-SIDE is within view, I want to display a sticky div within it, you can’t see RIGHT-SIDE when page loads, you need to scroll down to it, also when we are below it, I want to sticky div to go away.

This is my code so far

//HTML
<div id="wrap-vs">
    <div class="tabs">
        right-side content sticky div
    </div>
</div>
 
//CSS
#wrap-vs{
    height: 100%;
    background-color: yellow;
}

.tabs {
    position: fixed;
    bottom: 0;
}

// JS

var targetdiv = document.querySelector('.tabs');
console.log(targetdiv);
targetdiv.style.display = "none";

function CheckIfVisible(elem, targetdiv){
        
        var ElemPos = elem.getBoundingClientRect().top;
        targetdiv.style.display = (ElemPos > 0 && ElemPos < document.body.parentNode.offsetHeight)?"block":"none";
    }
    
    window.addEventListener("onscroll", function(){
        var elem = document.querySelector('#wrap-vs');
        
        CheckIfVisible(elem, targetdiv);
    });
    

866-517-1058 Chase Bank customer service

Chase customer service is available at five different phone numbers. Their general customer support number is 866-517-1058. You can contact this number 24 hours a day, seven days a week. The average waiting time is 20 minutes. It is best to call at 9:05 am.

To get targeted help, you can contact numbers specifically for mobile banking, freedom cards, and lost cards. You can also find a separate number for international customer service. Calling a targeted help number will increase the chances of resolving your problem fast.

For mobile banking concerns, call 866-517-1058. This number has a hold time of about 20 minutes. It is preferable to call this number at 10:15 a.m. To quickly get a live person, dial 0.

Contact 866-517-1058 for freedom card concerns. It takes 50 minutes or even longer for someone to answer the phone. This can be a real pain, so try to call at 10:15 a.m. for the shortest possible hold time.

Contact866-517-1058 for lost cards. On average, the waiting time is 20 minutes. Calling this number is free of charge, and it is most time-efficient to dial it at 9:45 a.m.

International callers can contact 866-517-1058. At the time of writing, the hold time was 20 minutes. This number is not toll-free. It is best to call it at 10:15 a.m.

how do I delay the exiting from a function in javaScript? [duplicate]

my problem is that I need to wait a bit before returning the value.
the function is returning the variable x before the var updates (or at least I think that it’s the problem).

var x; //now it's undefined
  con.connect(function(err) {
    if (err) throw err;
    con.query("SELECT * FROM usrs", function (err, result) {
      if (err) throw err;
      x= result; //trying to update x
  });
});
  return x; //returns undefined(because it doesn't have enough time to change so it stays like it was at the beginning)

defaultExpandAllRows antd table react with fetch not working

i use Ant Design table as ui

what’s wrong with my code, table using local data can be automatically expanded, but it’s different for the results from fetch can’t automatically expand with the same code

what am i missing here?

i can’t explain with good language, look at my sandbox https://codesandbox.io/s/defaultexpandallrows-antd-table-f1okb

this code will automatically expand

  const data = [
  {
    key: 55,
    name: "John Brown sr.",
    xchildren: [
      { key: 73, address: "New York No. 2 Lake Park" },
      { key: 46, address: "New York No. 2 Lake Park" },
    ],
  },
];

 <Table
      dataSource={data}
      defaultExpandAllRows={true}
      key={data.key}
      expandable={{
        expandedRowRender: (record) => (
          <Table pagination={false} dataSource={record.xchildren}>
            <Column title="Address" dataIndex="address" key="address" />
          </Table>
        ),
      }}
    >
      <Column title="name" dataIndex="name" key="key" />
    </Table>

this will not automatically expand table

fetch = () => {
    fetch(`https://api.jsonbin.io/b/61e6fd62ba87c130e3eaa7ef`)
      .then((res) => res.json())
      .then((data) => {
        console.log(data);
        this.setState({
          dataJSON: data,
        });
      });
  };

  <Table
           <Table
      dataSource={dataJSON}
      defaultExpandAllRows={true}
      key={data.key}
      expandable={{
        expandedRowRender: (record) => (
          <Table dataSource={record.xchildren}>
            <Column
              pagination={false}
              title="Address"
              dataIndex="address"
              key="address"
            />
          </Table>
        ),
      }}
    >
      <Column title="name" dataIndex="name" key="key" />
    </Table>

full code

import React from "react";
import ReactDOM from "react-dom";
import "antd/dist/antd.css";
import { Table,version } from "antd";
const { Column } = Table;

const data = [
  {
    key: 55,
    name: "John Brown sr.",
    xchildren: [
      { key: 73, address: "New York No. 2 Lake Park" },
      { key: 46, address: "New York No. 2 Lake Park" },
    ],
  },
];

class App extends React.Component {
  state = {
    dataJSON: [],
  };

  componentDidMount() {
    const { pagination } = this.state;
    this.fetch({ pagination });
  }

  fetch = () => {
    fetch(`https://api.jsonbin.io/b/61e6fd62ba87c130e3eaa7ef`)
      .then((res) => res.json())
      .then((data) => {
        console.log(data);
        this.setState({
          dataJSON: data,
        });
      });
  };

  render() {
    const { dataJSON } = this.state;
    return (
      <>
      antd version: {version}
      <p>will automatically expand</p>
        <Table
          dataSource={data}
          defaultExpandAllRows={true}
          key={data.key}
          expandable={{
            expandedRowRender: (record) => (
              <Table pagination={false} dataSource={record.xchildren}>
                <Column title="Address" dataIndex="address" key="address" />
              </Table>
            ),
          }}
        >
          <Column title="name" dataIndex="name" key="key" />
        </Table>
        <hr />
        <p> will not automatically expand</p>
        <Table
          dataSource={dataJSON}
          defaultExpandAllRows={true}
          key={data.key}
          expandable={{
            expandedRowRender: (record) => (
              <Table dataSource={record.xchildren}>
                <Column
                  pagination={false}
                  title="Address"
                  dataIndex="address"
                  key="address"
                />
              </Table>
            ),
          }}
        >
          <Column title="name" dataIndex="name" key="key" />
        </Table>
      </>
    );
  }
}

ReactDOM.render(<App />, document.getElementById("container"));

thank you…

Why does my website keep showing old index.html, style.css, app.js…?

I have a problem that I can’t solve. I’m new to web-developing, and I coded my first web-site, bought a domain and hosting, and added my files to the public.html folder.

Whenever I change the code, either in css or js and delete the previous files in the public.html folder and then add new ones under the same name with which the code was changed, when I load the site, either by phone or desktop the site looks and all elements remain the same that I haven’t changed the code at all, if I change the names of the html, css and js files, I link them and insert them that way, it only shows me a list of files in the public.html folder. The only time the code update works is when I open the site in incognito mode for browsers.

My assumption is that there are some problems with cookies and cached data, but even when I delete them in browser, the code is not updated but the site uses old files.

Does anyone know some solution to my problem, otherwise I use domain and hosting from hostinger and I haven’t changed any settings in domen and hosting since I bought it.

Thank you all.