2018-10-22         Violet

How do I get a number to render in my UI with a space after every 4 characters?

I have a 16 digit property that comes back for example(1234123412341234). I would like it to render on my UI with a space every 4 number characters for example(1234 1234 1234 1234). I'm using Angular JS so I'm looking for a way to accomplish this. I'm pretty sure it's either a custom Angular filter or regex related, but my knowledge of either and how to implement it is limited. AngularJS filter is easy to setup. Just accept one parameter and apply any JS formatting on it. Here is a working example:var app = angular.module('myApp', []);app.filter('myFilter', function() { ...

 javascript                     3 answers                     41 view
 2018-10-22         Archer

Scrape a text that was written by javascript from website

I am using BeautifulSoup to scrape character info from a website. When trying to get the win rate of a character, BeautifulSoup can't find it.When I inspect the text, it is listed as under . All I can find in the sites source code and all that BeautifulSoup finds is "ranking-stats-placeholder".This is the code I am currently using.import bs4from urllib.request import urlopen as uReqfrom bs4 import BeautifulSoup as soupmy_url = "https://u.gg/lol/champions/darius/build/?role=top"#opening up connection, grabbing the pageuClient = uReq(my_url)page_html = uClient.read()uClient....

 javascript                     2 answers                     76 view
 2018-10-22         Hermosa

Integrate Single Page application into WordPress

I have lots of basic single page applications which have html, css, js files I would like to publish them on wordpress. I can add them like external website but when I used this, I have to add all static parts (header, menu, footer etc) to the app.html file. And I have to do this for each application. This is not sustainable and good solution for sure. This is why I am looking for some way to add this page after menu in wp like other pages. I would like to give you folder hierarchy to concrete the problem. || - apps || - || - app1 || - || - || - app1.html || - || ...

 javascript                     2 answers                     97 view
 2018-10-22         Ula

Regex match string which does not fully consist of angular expressions

I've the pleasure to find all strings in our projects which are not angularjs expressions because we're going multi language (so every string which is not fully between curly braces).What I wanna do is build a regex which matches all strings, which have no angular expressions (or part of the string is no angular expression).The var names describe which should match (yes) and which shouldn't (nope).var yes = "test";var nope = "{{xyz}}";var yes = "test {{xyz}}";var nope = "{{::xyz}}";var nope = "{{xyz}} {{abc}}"; //as whitespace is okayTried a lot of different stuff using neg...

 javascript                     2 answers                     12 view
 2018-10-22         Otis

how to test private function outside react component

I have a private function outside component. It sounds more convenient to do test for function alone better than test it inside MyComponent, but it's private not exported.function func(){ return something;}export default class MyComponent extends Component {render <SomeComponent someProp={func()} />}I use mocha and enzyme for test and I wonder if there is anyway to test private function rather than test it inside the component. func is defined in module scope. It's not possible to reach variables outside the scope they were defined in JavaScript.Even if func were e...

 javascript                     2 answers                     13 view
 2018-10-22         Ruby

Sliding Menu in React

I want to create a file separator styled menu in react. I'm not very familiar with css, so i need a starting point. I have found many such menu components but all of them are full page.I dont understand how to create the shape of the component, if it were a simple rectangle it would be possible, but the shape is the rectangle plus the button, i dont know how to manage that.It will look something like this :Alter clicking on "Filter Menu", it will slide into view: That is actually a CSS/HTML only question.However, to develop from scratch:Draw a two column table and have ...

 javascript                     2 answers                     14 view
 2018-10-22         Samantha

React : new date() shows date of client machine rather than server

This question already has an answer here: What time zone does the Javascript new Date() use? 4 answers That is how javascript date works. Please refer to MDN docs for Date for more details. Also checkout the the parameters you can send to customize it. If no arguments are provided, the constructor creates a JavaScript Date object for the current date and time according to system settings for timezone offset Where Date is called as a constructor with more than one argument, the speci...

 javascript                     1 answers                     15 view
 2018-10-22         Eunice

Argument of type 'any[]' is not assignable to parameter of type 'A'. Property 'a' is missing in type 'any[]'

I'm a very beginner in TypeScript and now I'm trying to understand how interfaces works in a Class Method of React Component. I created a simple case for it, but it does not work. I always gets an error like in this post title.I'll be pleased for any help.import React, { Component } from 'react'interface A { a: any[]}class Test extends Component { _getName = (a: A) => { return a } render() { const a = [] return ( <div>{this._getName(a)}</div> ) }}export default Test this._getName(a) expects a to be of type A. A is defined as an object...

 javascript                     3 answers                     16 view
 2018-10-22         Zenobia

Click on <a> text to checked input

How can I make sure that when I click on the text in <a> the checkbox is activated? Now when someone click on the text of the checkbox the drop down menu closes.This is a simple snippet:<div id="divChooseMacro" class="dropdown-menu" aria labelledby="choose-macro"> <a class='dropdown-item' data-value='pippo' style='cursor: pointer;'> <input type='checkbox' value='pippo'/>&nbsp; pippo </a></div>I try to set a cursor: pointer in the tag <a> but without success I suggest you to use label tag to relate it to the che...

 javascript                     2 answers                     31 view
 2018-10-22         Edward

how to display file input buttons multiple times with image preview?

I am working with laravel 5.6 and I have image upload button with my form. currently it is using upload single file with image thumbnail preview.<h3>Upload images</h3><input type="file" id="files" name="files[]" multiple />jquery<script > $(document).ready(function() { if (window.File && window.FileList && window.FileReader) { $("#files").on("change", function(e) { var files = e.target.files, filesLength = files.length; for (var i = 0; i < filesLength; i++) { ...

 javascript                     1 answers                     32 view
 2018-10-22         Selena

Datatables colReorder saving WITHOUT statesave

I am using datatables and am using colReorder and need to save the state of the columns without using statesave(I am not allowed to use localcache). I do however have a preference table in my database for storing this kind of information in JSON format.I have looked at colReorder.order() which looks like what I need to get the order.What I'm thinking so far is on a column change, call colReorder.order() and place that returned array in my preferences table and then on re-initialization use that to re-order the table.So my question/what I need help on is this: On a change of...

 javascript                     2 answers                     33 view
 2018-10-22         Hugo

Get data from another HTML page

I am making an on-line shop for selling magazines, and I need to show the image of the magazine. For that, I would like to show the same image that is shown in the website of the company that distributes the magazines.For that, it would be easy with an absolute path, like this:<img src="http://www.remotewebsite.com/image.jpg" />But, it is not possible in my case, because the name of the image changes everytime there is a new magazine.In Javascript, it is possible to get the path of an image with this code:var strImage = document.getElementById('Image').src;But, is it...

 javascript                     3 answers                     34 view
 2018-10-22         Jack

CSS/ cut an img's width when reducing the screen/window width

I wanted to have an Image on 100% width, with a max-height. When scaling the window and you're reaching the max-height, the width should still be at a 100% but "cropping" the image bigger (provided image size is fitting). This means you can see more of the image sides (left and right) when its on a big scale window, and you can see less on a small sized window. I'll post my css try down, but i don'thave a clue how to do that at this point. Hope you're getting my issue, i'll attach a visualisation.My Code, don't get confused, I wanted to do a slider but lets focus on only on...

 javascript                     3 answers                     35 view
 2018-10-22         Doris

How to make Socket.IO serveClient option work?

I'd like to use client distrubuted with the socket.io package in client-side scripts.This is what I did:const IOserver = io.listen(server, { serveClient: true, path: "/socket.io.client.js" });But when I try to access socket.io client on that path http://localhost:1337/socket.io.client.js I get a 404 error.How to properly set up socket.io to serve client side JavaSript file? I think you are confusing what the path properties does. The path is the endpoint it should use to connect to your websocket server.You need to manage the installation of the frontend js client manual...

 javascript                     1 answers                     58 view
 2018-10-22         Rose

Retrive a field which has array of objects(ref) using nodejs

Im having mongo(mongoose) collection called "asserts" and "users".Having list of documents in "asserts" collection.Now while adding a user I need to select multiple "asserts". So need to set "ref" to asserts collection.Below is my modal asserts_list: { type: [Schema.Types.ObjectId], ref: "asserts" },POST operation is working fine (i.e) I can add multiple object IDs in Mongoose in array. But while performing list using AppComp.find({}) with populate, asserts_list is returning empty array([]).Help me to retrieve array of object ids in find({}) using nodejs. You nee...

 javascript                     1 answers                     60 view
 2018-10-22         June

Alternative solution for :focus on multiple buttons

I'm struggling to find a different solution for :focus when clicked on a button, as Safari doesn't support :focus on buttons. I have a field of 16 buttons, which should change colours when clicking on it and loose it when different button is clicked.I have created this fiddle to show the events. toggleClass is not the right solution and would like to avoid :focus.Current JS code:$(".tbl-button").on("click", function() { $(".tbl-button:focus").addClass("table-btn-color");}); You can just change your css declaration from .table-btn-color to .tbl-button:active.but if...

 javascript                     2 answers                     65 view

Page 1 of 8971  |  Show More Pages:  Top Prev Next Last