Skip to content

Author: admin@master

Regexp javascript – url match with localhost

I’m trying to find a simple regexp for url validation, but not very good in regexing.. Currently I have such regexp: (/^https?://w/).test(url) So it’s allowing to validate urls as http://localhost:8080 etc. What I want to do is NOT to validate urls if they have some long special characters at the …

countup and countdown loop

I want to count from 3 down to 0 then back up to 3 in a loop. This is kind of “slider” implementation. Everything runs fine until reach the clearInterval from counterry. What am I missing? Answer Use a single loop:

WebAudio not playing after stop(0)

I’m writing something like a web-audio-editor, and I think I’m close to finishing the basics. I can play and stop an audiofile, but when I try to call the play method again it just won’t work, even though the parameters havn’t changed. I’d be glad to see someone look into my prob…

JavaScript set anonymous Object key to variable name

However, this yields an object with a key of “key”! How can I create a new object with a key of the value of the variable key? Answer You can do this: There’s no way to do it in JavaScript within the object literal itself; the syntax just doesn’t provide for that. edit — when this answ…

Resize ArrayBuffer

If I want to create an arraybuffer, I write: var buff = new ArrayBuffer(size) But how is it possible to resize an existing buffer? I mean, adding some more bytes at the end of the buffer. Answer I’ve done it in C++ like this. Just made a bigger array and copy the contents over and then return the larger…

Convert an array to a list using jQuery

Got a challenge to convert a two dimensional array to a html list. the array is like The structure of the nested array item is id, textOfLink, parent. parent 0 means top level, parent 3 means the item is under another list item with id of 3. the target output will a list in html like please note the array