9
votes
5answers
2k views

Better way to generate all combinations?

I'm generating all combinations of an array, so for instance, ["a", "b", "c", "d"] will generate: [ "a", "b", "ab", "c", "ac", "bc", "abc", "d", "ad", "bd", "abd", "cd", ...
7
votes
1answer
2k views

Looking for improvements on my jQuery-UI tagging widget

I am looking for any possible improvements on this tagging widget. I ask for special attention to be paid to my blur handler in the event of a autocomplete option being specified but any ...
7
votes
2answers
377 views

Optimize/Refactor Javascript Unique Array function

This is one idea of implementation: Array.prototype.unique = function () { unique_array = []; for (var i = 0, l = this.length; i < l; i++) { if(unique_array.indexOf(this[i]) == -1){ ...
6
votes
2answers
6k views

Pack and unpack bytes to strings

I need to write a function that "packs" an array of bytes (integers between 0 and 255) into a string. I also need to be able to perform the reverse operation, to get my byte array from the string that ...
5
votes
4answers
255 views

Improve speed for looping through 1,000's of items in javascript?

This is a script I use to count how many items are selected in a form. Currently it loops through the entire form to count how many check boxes are selected, each time a checkbox is clicked. The form ...
5
votes
1answer
113 views

Optimize iterative pixel blending function

Summary I've created a function that blends tiles on a 2D hexagonal grid with their neighboring tiles based on an image that serves as a "blend mask". It runs, and isn't too intensive, but I feel it ...
4
votes
1answer
53 views

Looping through Radgrid in JS is slow, can this be faster?

I do a single select in one radgrid, and based upon that selection I want to select multiple rows in a different radgrid: <telerik:RadGrid ID="rgPaymentLines"> <ClientEvents ...
4
votes
1answer
60 views

Code review for a collection manipulation tool in Javascript

As I was working with .NET, I started wondering how I would implement the LINQ methods syntax in Javascript. So here is my first try; is there a more elegant, or more performant, way to write this ...
4
votes
1answer
553 views

How can I optimize my d3 graph visualization?

I've been learning Python for about a year and now I'm trying to improve my Javascript. I wrote this simple d3 visualization that shows your Facebook friends as a force-directed graph. Here's a live ...
3
votes
1answer
259 views

Which is better: the short, clever way, or the long, ctrl+c way?

The code below is equivalent. I can see pros and cons for both versions. Which one is better? Short version: character.on("key",function(key){ var action = ({ ...
3
votes
2answers
1k views

.hasScroll function, checking if a scrollbar is visible in an element

I have constructed a function that checks whether an element has a scrollbar or not, and can also check individual axes. I don't know if this works in all major browsers and am unsure about the ...
3
votes
2answers
149 views

More concise way to create a board out of an array?

I have been doing some personal projects for fun and most of them have visual representation of boards (ej: sudoku solvers, chess PGN viewer, etc) and I always end up doing something like this: var ...
3
votes
2answers
112 views

Javascript function optimization

I created a function that rewrites file names according to the available space on screen: @{ var index = 0; foreach (var item in Model) { <div class="gallery-item"> <a ...
3
votes
2answers
117 views

Javascript Coding Wager

I have two scripts written by my co-workers for auto-filling a form with information from the facebook graph-api. I am trying to figure out which has been coded in a more efficient style? This is the ...
3
votes
3answers
162 views

hand optimising javascript selector function

I personally want a small selector function that covers the three common cases getElementById getElementsByClassName getElementsByTagName It should support contexts and should not support ...

1 2 3 4 5
15 30 50 per page