Tagged Questions
18
votes
5answers
8k views
Better way to generate all combinations?
I'm generating all combinations of an array, so for instance, ["a", "b", "c", "d"] will generate:
...
13
votes
5answers
799 views
Looking for a cleaner way to write a jQuery function
I've got a piece of code that takes an element, checks where it is, and if it's beyond a set place in the viewport, make the opacity increase to 1. I've made the code so that it only runs the checks ...
11
votes
2answers
16k 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 ...
10
votes
2answers
955 views
8
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
225 views
Var scope on the same line
Is there a better way I can code this? It's old code and I'm not sure makes sense today. JSLint gives me a lot of errors too. I don't have experience with JavaScript and I would like to optimize this ...
7
votes
2answers
218 views
Pulling JSON using jQuery and manipulating the Front-end
My JavaScript is fairly new and want to learn new ways to create clean, fast code. Can you have a look at this code and guide me on how to optimise this code to improve my skills? I have provided the ...
7
votes
2answers
115 views
Iterate from “0” to “ZZZZZ”
I was given an assignment, it was as follows:
Give a JS code snippet which writes to the console from:
"0" to "ZZZZZ" all the combination of the characters of a-z, 0-9 and A-Z.
Is my solution ...
7
votes
1answer
311 views
Find the word in a string that has the most repeated characters
The problem: I want to find the word in a string that has the most repeats of a single letter, each letter is independent. Does not need to be consecutive.
Currently I am jumping each character and ...
7
votes
1answer
329 views
Solving systems of linear equations
I am working on the following problem (http://www.enigmagroup.org/missions/programming/9/).
You have a 6x6 table where the first 5 columns and rows are comprised of different types of shapes, 5 ...
6
votes
3answers
1k views
Count byte length of string
I am looking for some guidance and optimization pointers for my custom JavaScript function which counts the bytes in a string rather than just chars. The website uses UTF-8 and I am looking to ...
6
votes
2answers
65 views
Three layout Gallery
I have made a gallery function, this function handles three different types of gallery, one with horizontal nav, other vertical and last one vertical with no nav.
...
6
votes
1answer
79 views
Highlight countries based on category
In the below code I should highlight countries on the map based on the category of the country in which there are 2 different type of countries (issuing office and selected countries). Based on the ...
6
votes
1answer
2k 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 ...
6
votes
1answer
179 views
DSSudokuSolver - A JavaScript Sudoku solving algorithm
I wrote DSSudokuSolver - a sudoku solving algorithm a while back. Is there any possibility that this algorithm can be improved?
Original Algorithm:
...
6
votes
1answer
183 views
AngularJs and Google Bot experiment
I have learned the question of solving Angular app optimization for search engines, and was frustrated that the most recommended option is prerendering html.
After some time spent, I suggested to ...
6
votes
1answer
71 views
Rich Text on multiple iFrames
Having so many loops running concurrently obviously can't be good, and the code seems overly complicated. There has to be a simpler, more efficient way to
Turn the designMode of all iFrames on
Find ...
6
votes
2answers
308 views
Is there a better way to write this pagination plugin?
This plugin is written in Jquery and is made to support the codeigniter framework.
It is an ajax powered table pagination plugin designed to provide only that.
You should be able to use almost any ...
5
votes
4answers
566 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
165 views
Validating HTML Form
I am trying to create a simple validation for forms. I am almost there, but there are few bugs and optimization errors that I am really struggling with. I'm looking for advice on how to make this ...
5
votes
1answer
78 views
What are your opinions on these small scripts?
I am new to JavaScript, and I was wondering if anyone can share their opinions on what I have done below:
First of all, the following functions are all placed in a file called main.js and that file ...
5
votes
2answers
111 views
A more efficient approach to existing JavaScript coding
I am now working on a Node.js project, and on my ejs view page, I'm retrieving this array of objects, like:
...
5
votes
1answer
202 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 ...
5
votes
2answers
176 views
Optimizing mouse in/out
I have this code that places a marker and on mouse-over this marker is scaled out and then back to the 'original' scale:
...
5
votes
1answer
62 views
How to speed up window leveling (brightness, contrast)?
I have to apply window leveling on Canvas Medical Image (CR). I have to get a pixel array from C# Component.lutArr, which is a lookup table array coming as a C# ...
5
votes
1answer
174 views
JavaScript Sandbox Pattern
Based on this Stack Overflow question I came up with the following code. I'd like your general thoughts about it. Code style, functional, logical, disadvantages, just anything you can come up based ...
5
votes
1answer
65 views
Can I reduce the bloat in my Google Spreadsheet form script?
Long story short I feel my code should be able to be reduced a whole lot, I just don't know how.
The form updates a spreadsheet with agents(employees) hours worked for a specific date. The form has 4 ...
5
votes
1answer
74 views
jQuery Fallback Support for the CSS Property “background-attachment: local”
I have made some jQuery Fallback Support for the CSS Property "background-attachment: local" and I am mainly a CSS developer. I do some jQuery, but I thought I would check to see if I am doing this in ...
5
votes
1answer
165 views
Optimising this simple jQuery script that vertically centers elements on pages
This is a simple jQuery script that I use to vertically center elements on pages. It's quite simple, but I would love to know if there is room for improvement.
...
4
votes
1answer
298 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:
...
4
votes
2answers
4k 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 ...
4
votes
2answers
152 views
isRTL.coffee - A JavaScript Library to determine if a text is of Right To Left direction
I just wrote this tiny library called isRTL.coffee to determine the direction of the text. Is there any better way of doing this?
original code:
...
4
votes
2answers
103 views
JavaScript Parallax Cross Platform Efficiency
I wanted to get some feedback on this js I am working on.
http://www.dapper-apps.com
It works wonderfully on my desktop, but on my and my friends laptops (expecially safari) it is very slow. I need ...
4
votes
2answers
171 views
Retrieve and load playlists from YouTube
I have this code I am using in a private project. The following is a snippet of code I use to retrieve and load playlists from YouTube:
...
4
votes
1answer
50 views
Subnetting calculator
I'm fine with any sort of answer that helps better my code -- I'm not necessarily looking for a full refactor. I have a script that converts input (IPv4 address, submask, cidr, etc.) into usable ...
4
votes
1answer
73 views
Smoothen page transition for mobile devices
I have next/previous buttons on my site and all they do is slide sections of the site from left to right and vice versa, it is smooth and looks good on a desktop but on mobile devices it is a bit slow ...
4
votes
1answer
53 views
Should I differentiate object types by calling methods via variables?
I have three JavaScript objects. The first one serves merely as a prototype. The other two are implementation of a specific type.
...
4
votes
1answer
52 views
Computationally efficient way of comparing and merging like object keys
Though I can achieve most ends via a series of conditionals and arithmetic, especially when iterating over or comparing arrays I frequently hear of much more efficient implementations.
Hailing from ...
4
votes
1answer
52 views
Matrix rotation efficiency
I am not sure if I should be using recursion or not or if it even helps in increasing the performance of my algorithm. I feel as though I am creating and replacing too many arrays by calling my inner ...
4
votes
1answer
472 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:
...
4
votes
1answer
517 views
Speed optimising JavaScript code
I've written this following rather naïve branch-and-bound based IP solver. My question is whether there are any obvious JavaScript optimisations that could speed it up? I am not looking for ...
4
votes
1answer
587 views
Price Slider using jQuery UI working in Java environment to be optimised
I am working on a price slider that is for a Java environment. It is working correctly but I would like to optimise it as much as possible. Any tips/advice?
...
4
votes
1answer
88 views
Ad page optimization?
Any suggestions on how to shorten this would be greatly appreciated. This code takes three parameters through the URL and displays a page with targeted ads. I especially need help on how to cut down ...
4
votes
1answer
93 views
Improve AJAX response handling function
This code handles a response from an RSS feed. It organizes and appends to content. If there's a video embeded then separate it from the rest of the content. I would like a review mainly on ...
4
votes
1answer
112 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
46 views
Script for dynamically-loading data onto a restaurant menu for printing
I have a script which dynamically loads data onto a restaurant menu for printing. Could the following code could be shortened at all?
...
4
votes
1answer
37 views
Hiding and revealing toggle responds very slow
I have a list of 6 items, and each one on click reveals a div that runs 100% wide under the row of list items. The code works, but the div opens very slowly and kind of choppy. Is there anything I can ...
4
votes
1answer
198 views
Refactor jQuery code to use fewer selectors
At this point I've written a fair amount of code to deal with dynamic line items. I've slowly refactored most of the code into an Order object that's created at page load which contains the methods ...
3
votes
4answers
132 views
A package for sort algorithms
I'm trying to learn basic algorithms which are typically taught in an introduction to CS course, which is usually taught in a compiled language like Java. However, I want to focus on JavaScript, so I ...
3
votes
1answer
152 views
Efficient (Virtual) Home Security
Can you help me optimize the speed and security of my homepage?
(Link now dead - 2014/04/10 - http://www.pixel-klicker.de)
...