How to find an element outside its parent with jQuery

I have this markup:    <div>     <div>       <button class="button"></button>     </div>     <div class="panel">     </div>   </div>   Now i need to find next panel just right for button...

React - What's the great benefit of having immutable props?

After occupying myself a bit with learning React I still consider many of the concepts as hard to get.  Among other: The immutability of props.  If I get it right then components are, more or less, the equivalent to objects in object-oriented program...

Is it secure to call a PHP file from JavaScript?

I have a simple HTML5 Canvas game and at the end of a part I want to store variables in MySQL. Is it secure to do this with XMLHttpRequest, Ajax or anything? This is how I started to write it:  var request = new XMLHttpRequest(); request.onreadystate...

How to redirect user to different page?

I need to make to redirect the user to another page, in accordance to the language of the browser. For example: if the language of the browser english redirect to site.com/en/.  I try to do like this:  $(document).ready(function () {     var userLang...

KineticJS - Drawing Lines with Mouse

I'm using KinectJS to draw lines based on mouse movement.  When a user holds down the mouse button, I want it to be the 'start' point of the line, and when the user release, it will be the 'end' of the line, but as they are holdin...

JQuery find data attribute value onclick

I am trying to retrieve a data value which contains an image url when the user clicks on a thumbnail image. HTML is as follows:  <div class="port_image_holder"> <a class="port_enlarge" href="javascript:void(0)">...

Unit testing angular/Ionic project

I have a very simple controller that looks like this.  timeInOut.controller('timeInOutController', function($scope, $filter, $ionicScrollDelegate){      ...   });   Whenever I try to create a unit test for it like so...  (function() { 'us...

How to unserialize PHP session in node.js?

I am storing the PHP $_SESSION data in a database.  Then from a Node.js server I want to take that data and unserialize it.  I tried to use js-php-unserialize like this:  con.query('SELECT user_id, data ' +              'FROM sessions ...

Dynamically changing url in Backbone

I was trying to dynamically change the url inside the router but couldn't manage to do it, it keeps returning to the base Collection URL. Here i posted the code with the 3 different collections which apart from pointing to three different urls th...

Convert milliseconds to years

I have a validator that checks if an user is at least 18 years old.  This is the check:  var res = /^([1-2]\d{3})\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])\-([0-9]{4})$/.exec(str); var todays_date = new Date(); var birth_date = null;  if (res != nul...

Scroll function doesn't produce a smooth transition

I have 1 fixed DIV #scroll-up that is 100% height of the browser window. I have another DIV #next-prev that sits underneath it. As soon as #next-prev comes into view I want the #scroll-up DIV to begin scrolling up. My code blow does this, however as...

Is there a way to restrict params to certain values while using react-router?

I'm building a site with react and react-router and I have two different type of routes, like in the example bellow:    <Route name="products" path="/:type/*" handler={ ProductList } /> <Route name="generic-template&#...

A way to minify or uglify ES6 Template Strings

Something like  var tpl = ` <div>     template    <span>string</span> </div> `   Will produce:  var tpl = "\n<div> \n  template\n  <span>string</span>\n</div>\n";   What I need is to get rid of...

How to set manual default image, if image is not available on my site using js?

I want to set manual dummy image if particular image is not available on website. Also how to set if that image is deleted on server or not available, in that case also i need to display default image using JS....

Dynamically change background image using javascript

I'm looking into being able to change the background of a webpage to a dynamically generated image at runtime. I'm using javascript and the canvas element to create the backgrounds, which I'm storing in an array so that the user can toggl...

Wait until callback

I've got an array with audio-files, to play all one by one. I'm using a javascript player, that will play the audio and provides a callback when finished.  for (i = 0; i < audioFiles.length; i++) {     PlayAudio(audioFiles[i], function(){...

Make an HTML input field appear as just the text in the field

I have an HTML form with a number of input fields that are added dynamically with content in each field using jQuery.    Is it possible to hide the fact that these fields are input fields and only display them as the content in the field?  I don'...

How to make HTML5 video fade in when it has finished loading?

I'm trying to have my HTML5 video element fade in when it loads, (I'm currently having it appear using Javascript canplaythrough as you can see in the code you see below, but it's a little harsh.) How can I get the HTML5 video element to...

Multiple Min and Max value for textbox

I have a working code for entering valid minimum and maximum value in text box by using below code:  <input type="number" name="quantity" min="1" max="5">   But how about if I have multiple ranges allowed? For ex...

keycode 13 and keycode 10 not working

Event keypress 13 and 10 not working on iPhone safari, android firefox but working with android default browser.  I have a jsp page which has a form which that takes a number as input and changes values of other div elements in the same page by divid...

How to pass variable from back-end to front-end in node.js ejs template

I render my page like this:  response.render('index', {     data: list // the `list` is an array variable });   And in the front page, I want store the data as globe variable, so I tried:  <script>    window.app = <%= data %> <...

If Deeplink url not work send him to download page

I need to implement a javascript where I can detect if my deep link is worked or not, If it works then it should remain same but if it does not work then it must start download file.  For that, i use timeout function to do it. Here is sample code I u...

JVector Map onRegionClick Event

So in JVector map I need a function that has each region linked to a URL. So if you click on South Africa it will take you to a page with information about South Africa. I know to start with onRegionClick: function () but where to go from there is a...

Disable input, allow click textbox

I'm building a .net web app using Bootstrap styling. I have a datepicker equipped textbox scenario where I would like to avoid the hassle of date string validation. I'm thinking I can simply check for empty string values (no input) as the onl...

prettyPhoto multiple galleries on one page

I am building a worpdress site and have multiple galleries on a page built using the shortcode. At the moment all the image are given the rel attribute 'prettyPhoto[1]' but I need each gallery to be separate.  I have 56 images in total on the...

Parameter passing vs local storage

I have a lobby written in HTML5 / javascript.  A .json file provides a few config parameters for the lobby and for the various other HTML5 games that can be launched from it.  These parameters can either be passed to the games in the window.open stri...

Three.js disable depth test

I use an EffectComposer :  renderer = new THREE.WebGLRenderer(); renderer.setDepthTest(false); ... composer = new THREE.EffectComposer( renderer);   So I want to disable the depth test but when I do :  composer.render(); var gl = renderer.context; al...

Twitter Bootstrap, show all popovers at one div

I tried to achieve the following using Twitter Bootstrap 2.0 and it's popover-plugin, but after a few hours, I still can't figure it out.  Let's just say, on the down-left corner of my page I got a picture showing a bird. This bird should...

Replace parent element with its contents

I'm trying to do something similar/same as in this question: How to remove only the parent element and not its child elements in JavaScript?  <div>     This is some text here     <h2>This is more text</h2> </div>   All I w...

How to upload multiple file under 1 http request

Using HTML5 chunking, I could do file upload with smaller piece. But the problem starts when it started using multiple http POST request which will cause the computer slowing down, or probably crash. Is there anyway to have the splitted file under on...