Skip to content
Advertisement

looping through arrays of arrays

I have an arrays of arrays (some thing like graph), How to iterate all arrays? Its just an example array, actual can contains any number of array and then arrays. How to print all those numbers? Its similar to html objects DOM Answer This recursive function should do the trick with any number of dimensions:

How to count active javascript timeouts?

I am using Selenium to test a web app that uses Dojo, and it uses java script to display certain elements. I want to wait until all of the elements are desplayed before I try to manipulate the page, however I am having trouble. I have started by waiting for the dojo inFlight variable to be 0, this says that

javascript – shuffle HTML list element order

I have a list: Using javascript how can I reorder the list items randomly? Answer This is based on Fisher–Yates shuffle, and exploits the fact that when you append a node, it’s moved from its old place. Performance is within 10% of shuffling a detached copy even on huge lists (100 000 elements). http://jsfiddle.net/qEM8B/

Disable button whenever a text field is empty dynamically

Here’s my code: This works but still not efficient since the user can delete the text inside the text box and click the button while he’s holding on DELETE key. Is there a more efficient way to achieve this using javascript? Answer Add a check when the button is clicked to see if there is any text. If there isn’t,

window.close() after page redirect

I am on a work intranet only having to support IE8. I am creating a page called “watch video” which (as the name suggests) serves a video to the client. A page linking to a video will open this page in a popup with the link in the url. The person accessing the video (and a datetime stamp) is then

Bind Ready Function and Resize Event

In jQuery, is it possible to somehow “bind” an action to both the ready function and a resize event? I’m trying to add/remove classes on resize and I want the initial class state to be there on ready. Answer The easiest way to do this is to trigger the resize event immediately after binding it:

Error: Can’t set headers after they are sent to the client

I’m fairly new to Node.js and I am having some issues. I am using Node.js 4.10 and Express 2.4.3. When I try to access http://127.0.0.1:8888/auth/facebook, i’ll be redirected to http://127.0.0.1:8888/auth/facebook_callback. I then received the following error: The following is my code: May I know what is wrong with my code? Answer The res object in Express is a subclass of

Split large string in n-size chunks in JavaScript

I would like to split a very large string (let’s say, 10,000 characters) into N-size chunks. What would be the best way in terms of performance to do this? For instance: “1234567890” split by 2 would become [“12”, “34”, “56”, “78”, “90”]. Would something like this be possible using String.prototype.match and if so, would that be the best way to

Blur image with JavaScript or jQuery?

Is there any way to blur images with JavaScript/jQuery so that when they are blured I can sharpen them by hovering them with the mouse? Answer Pixastic can do that for you. Here’s the relevant doc: http://www.pixastic.com/lib/docs/actions/blur/ To blur: To revert: The entire solution with jQuery:

Advertisement