Does jade's syntax support a switch statement?

I tried this in jade served by express but got "unexpected identifier" as an error.  - switch(myvar)     - case: "0"         span First Case             break     - case: "2"         span Second Case             break     - ca...

Dynamically delete object property JavaScript

I have the following code to get a key for a given object. So for the object {"hello": {"data": {"a": "world", "b": "random"}}} if the key passed in was hello.data.a, the output would be world.  (object...

Trigger Keypress with jQuery

On the Definitive Trigger Keypress jQuery thread there is no working JSFiddle for the answer, and the code that is there doesn't work for me.   $("button").click(function () {     $("input").focus();     var e = jQuery.Event("...

How to make the Button and TextField pitch perfect?

I'm trying to make a form using Material UI and React. This is what I have so far:  import React from 'react' import {Button, TextField} from '@material-ui/core' import AddIcon from '@material-ui/icons/Add' import PropType...

Can't access refs on ComponentDidMount

I am trying to select all the text in a textarea when a component loads using React v16.3.1  Following the Refs docs I have a basic sample but this.textarea is always undefined, if I change this sample to execute the same code on a button click it wo...

Getting iframe current src url in cross domain [duplicate]

This question already has answers here:...

How do I get information about the type of connection of a WebRTC PeerConnection?

Is there any way to get information about the type of connection used in WebRTC in a programmatic way?  For example in my app I use local connections as well as STUN and TURN. From the ICE candidates I can gather if the type of the candidates is host...

Why use Number.parseInt instead of parseInt()?

From documentation:     This method behaves identically to the global function parseInt()   But, as it's experimental, the compatibility is worst. For example, is not available in IE or Safari.  So, why should a developer use Number.parseInt()?...

Get plain text from contenteditable div

Is it possible to extract the plaintext from a contenteditable div, including newlines? The jQuery $.text() method strips out newlines, which I need.  The solution can use jQuery....

If image 'src' is '(unknown)' replace with 'missing.png'

My CMS produces an img src="(unknown)" if an image isn't provided in the database. I would like to use javascript when this occurs to change it to img src="/images/missing.png" As a complete JS noob I have tried several hacks but...

Return the Array of Bytes from FileReader()

I need some help returning the "bytes" variable from this function below to be used as input in another function.  function openfile() { var input = document.getElementById("files").files; var fileData = new Blob([input[0]]);  var rea...

How to test class constructor in Jest

Let's say I have a class like following:  class SomeClass {   constructor(a, b) {     this.a = a;     this.b = b;   } }   How can I test through Jest that constructor was initialized the right way? Say... this.a = a and this.b = b and not vice ve...

Knockout + Select2 — setting default values?

TL;DR: I need to set a default value for display on a select2 field, bound via knockout, but the select2 binding keeps overriding my viewmodel value to "" instead of accepting the value.  The Ingredients  I am utilizing the following:   Knock...

Modern way to create static or Class variable for Javascript class

I've been hunting around for a clear answer to this, and most of what pops up still relates to the old (or should I say "traditional") way of defining classes using function.  According to this SO answer,     Class properties are not supp...

Copy to clipboard in bootstrap 3

I want to add a "copy to clipboard" button on my website. The site uses the Bootstrap 3 framework. I want my button to work similarly to the "Copy to Clipboard" button used here: http://twitterbootstrapbuttons.w3masters.nl/  I tried t...

How do I implement ReCaptcha in a Single Page Application (SPA)

I have a Single Page Application (SPA) I would like to add ReCaptcha to.  This application is hosted using IIS as flat Html, Css & Javascript, this SPA in turn talks to a separate REST server (using CORS) for all dynamic content.   The REST serve...

Cordova/UWP Windows Mobile 10 Access Violation on HTML select element

In Visual Studio 2015 Update 3, I have created a JavaScript -> Windows -> Windows 8 -> Windows Phone -> Blank App (Windows Phone) project. I then changed the default.html to include a <select> element like this:  <!DOCTYPE html&g...

How to pass Django template variables to a WebPack module

I am just learning about WebPack module, and I am thinking of moving the entire JS infrastructure of my Django app to modules. It seems that a straightforward way of doing this is to create a webpack module for each Django template (or view), and hav...

Get rid of blank entry in select tag

I have a number of items that get their data from a Json object and populate it using angular.  <select ng-model="MyCtrl.cargoList">     <option ng-repeat="cargo in MyCtrl.cargoList">{{ cargo.name }}</option> </se...

Backbone: Why are events syntax quite different between model and view?

define events in Backbone.Model  var Todo = Backbone.Model.extend({   initialize: function(){     this.on('change', function(){         console.log('- Values for this model have changed.');     });   } })   define events in Backbone.V...

browserify and babelify very slow due to large data js files

I have a nodejs project which uses large dictionary lists (millions of entries), stored in js files, that look like this:  module.exports = ["entry1", "entry2", "entry3", "entry4", "entry5", etc.];  and then I...

How to (locally) call a JavaScript function from PHP (on Raspberry Pi)

I'm in a slight predicament where I can't really understand how to proceed. I've got a set-up where I'm hosting a website locally, on a Raspberry Pi which is used to send commands to a LED-donut + speaker. The website also contains a...

Moving line items from one table to another table and validating data entered on the first table before adding selected line items to second table

I have a wizard form with four steps which is for ordering Parts, the first step user provide details(Stock Type and Approver who will approve the order) which are validated correctly. Second step user will select which parts to order from the table....

Why does clicking and dragging cause the parent element to be the `event.target`?

On a regular click of the child div, the following code will print the ID of that specific child div that was clicked.  <div id="parent">   <div id="A" class="child"></div>   <div id="B" class="...

Unit testing Vue components that rely on a global event bus

I declare an event bus in my global app.js like so:  window.Event = new Vue();   The component looks like  export default {     data() {         return {             hasError: false,             zip: '',         };     },      methods: {...

DoubleClick for publishers: Specify browser and ad dimensions

I'm trying to get banners to load according to the browser size. So in a location where i have a 728x90 banner, a 300x250 will show if its on mobile.  Problem is, the 728x90 loads on desktop. but on mobile the 300x250 doesn't show.  I tried f...

Firebase cloud function returns 304 error and then restarts

I've been stuck on this for months. I have removed some minor details from the function but nothing major. I have this https cloud function that ends a session and then uses endTime and startTime to calculate bill which is then returned to the cl...

Nexus-prisma: order nested connections

What is the best way to keep order of nested objects in the schema.  My schema:  type Article {   id: ID! @id   pages: [Page!]! }  type Page {   id: ID! @id }   This is how I'm trying to sort the pages(unsuccessfully):    updateArticle({     vari...

React Router doesn`t load external html files

I am building a React App with react + react-router, but I have a problem about the redirections.  I have the next folder structure:  ...     /public       /index.html (react index)       /tos/         /terms.html         /privacy.html       ......

Typescript mind the order of instantiation in an Object literal?

I'm using the latest Typescript version :2.6.2.  I'm encountering a bizarre situation where if I do foo({a:1,b:2}) - things don't work whereas if I do :  foo({b:2,a:1}) - they do work.  I have a generic class  , an interface which has 2 p...