Tagged Questions
ECMAScript (commonly referred to as JavaScript) is primarily used for scripting web-pages but also has several embedded forms and stand-alone interpreters / JIT engines. Use this tag for questions regarding ECMAScript 5 or 6 and its dialects / implementations: JavaScript, JScript, etc., excluding ...
2
votes
0answers
25 views
Implementing Python-like slice in JavaScript
Python has by far the best slice implementation I've ever used. As a quick evening project I felt like trying to implement Python's slice construct in a JavaScript function (thinking about sending a ...
0
votes
0answers
14 views
Variable value Comparisons (Javascript) [on hold]
I wanted to know if there's any way to simplify the if statement. The function may change the value or return the same value. I also have an option to just overwrite the variable if that helps ...
3
votes
1answer
34 views
Idea of 'parser' to make the writing of asynchronous functions chains easier
Why this thing :
I work on a project where I need to call many asynchronous functions to get data, chain them, execute them if conditions are met,.. and I ended up having unreadable code.
At some ...
1
vote
1answer
25 views
How can I organize polymer-element structure in order to embrace the Polymer way of developing custom elements?
My goal has been to learn Polymer so I started developing a complex combo-box element.
I did my development on Plunker. Here is link to my plunk.
I'm happy with ...
2
votes
0answers
38 views
JavaScript function that returns all possible combinations of letters in a word
This is a JavaScript function that returns ALL the possible combinations of whatever word the user enters. I am looking to clean this code up a bit...any and all suggestions are welcome!
...
1
vote
0answers
15 views
Feed API to display RSS feeds Ted talk
I am trying to create a webpage that will read RSS feeds from the TED talk website and display it on a page. I am using Google's Feed API for this.
Here is the link to view the code online.
Could ...
3
votes
0answers
38 views
User-logging authentication
I'm little frustrated because I don't know how well I can refactor this script. I wrote the authentication function but it's too complicated, maybe too large in one function, and seems like spaghetti ...
1
vote
2answers
34 views
Menu selector code that changes the background of a selected div
i made this code to change the background color for a div in set of divs while disable the rest divs background it work fine as it look but i wanted to review the code for more improvement since I am ...
3
votes
0answers
67 views
Strategy Game in Javascript with Three.JS
I've been playing around with porting a simple strategy game over to Javascript, the idea being to run it in a browser for testing. I've done some simple Javascript code in the past, but this is my ...
3
votes
1answer
36 views
Load images, manipulate DOM, store/retrieve data using localStorage
I wrote a little code sample which:
load images
manipulate DOM (replace images)
store/retrieve related data using
localStorage
...
3
votes
1answer
12 views
Bit compressing in JavaScript
I have an bit array var data = []; ... and I have the following function:
jsPerf
...
2
votes
1answer
50 views
Improved lightbox2-fork
I found a nice lightbox2-fork, which I tried to improve. After about six hours of work the code passes jslint. I also tried to change variable names for better understanding of what they are for.
...
1
vote
2answers
46 views
Looking for matching names among two text files
I'm trying to enhance the execution speed of my below code. I am using only vanilla JavaScript. I would be willing to bring in additional libraries and plugins as long as they will enhance the overall ...
0
votes
0answers
22 views
Return all string values in nexted array recursively [on hold]
I would like to recursively check and return all the 'name' strings in the data object.
This code works fine. But it worries me that i am using a lot of loops and conditionals.
Would greatly ...
2
votes
2answers
26 views
Promise.jsm demo of Promise.all and Promise.defer
I created this demo example for MDN documentation to show how to use Promise.all and Promise.defer in user created promise. I ...
4
votes
1answer
42 views
Improvements to nsiZipReader and nsIScriptableInputStream
I wrote this code to list contents of an XPI file and then read the contents in it.
I was thinking areas of improvment:
I put the zr.open in the ...
2
votes
1answer
56 views
URL Conditional in JavaScript
I'd appreciate any help just refining this working code. It has a bit of a weird context, but basically it's for a gallery style site that has hundreds of pages, but needs new navigation buttons. ...
1
vote
2answers
34 views
Making the save and cancel buttons editable
The following code makes a div tag editable and handles the save and cancel buttons. But there is a lot of duplication. How could I remove the duplication on this?
...
0
votes
1answer
31 views
Show <div> on <li> click
Simple task, I am just trying to have the data that correlates to a menu item hidden until it is clicked. However, I feel like this can be optimized. There are 2 ...
4
votes
1answer
43 views
backbone.js boilerplate
I am currently experimenting with a backbone boilerplate application and would really appreciate some feedback or thoughts on its structure.
I come from a PHP background so am used to frameworks ...
3
votes
2answers
76 views
+50
Increase performance on canvas repainting
I'm working on a little project where I have to create sort of an image mask.
Overall my code works quite good in all browsers but sporadically the animations "flickr" on Chrome (Windows). So I was ...
4
votes
4answers
922 views
5
votes
1answer
54 views
JavaScript Weather App
I am pretty new to JavaScript, and put together a weather application. I'd like to get some feedback on improvements I could make to the code itself and also possible ways to speed up weather data ...
2
votes
1answer
42 views
Simple text toggling
I made a simple AngularJS text function. The purpose is to provide an array of content to display. A 'slider' will be made with next and previous buttons that hide on the last and first slide, ...
7
votes
1answer
77 views
+100
Managing Google Calendar from Spreadsheet
Overview:
I have a need to manage a Google Calendar from a spreadsheet, so I developed a Calendar Manager program with Google Apps Script. I found some inspiration over on Stack Overflow, but my ...
2
votes
0answers
24 views
Homemade Lightbox and Image Gallery
I'm new to JavaScript, and I've built a lightbox for an image gallery. There's a button to open the gallery, plus forwards, backwards, and close buttons, and keyboard controls. Currently, everything ...
0
votes
0answers
21 views
Only able to zoom the first or the last image on the slideshow [closed]
First of all, I am sorry if I have to move this question here, considering that in stackoverflow it still dons't have any answer yet since yesterday.
HERE IS THE DEMO
I have an images slideshow ...
8
votes
1answer
69 views
Calculate torque of a bolt based on grade, size, and lubricant
To calculate torque I need to look up a value from a table which I've hardcoded based on three conditions: grade, size, and thread. Then I need to multiply it by coefficients associated with the ...
4
votes
2answers
53 views
Conditional Branching Using Filter
I'm using multiple jQuery filter functions to affect the background color of select objects based on the selected option and it works, but it seems bulky/redundant. Does anyone know how these filter ...
0
votes
3answers
41 views
Should I declare all of the outer functions inside the object literal?
I am working on an HTML5/jQuery todo list app and here is my code so far: http://jsfiddle.net/rdesai/csTS7/19/
As you might notice, there are some functions called at the beginning of the JS code. ...
0
votes
0answers
26 views
JavaScript Classes [closed]
Why can't I call myCar.engine or any of it's properties in the following code?
...
3
votes
2answers
114 views
Create an array of objects from array of arrays
I have the following function that creates an array of JSON objects with properties from an array of arrays, where the first 'row' in the array contains the keys.
It works, but could it be improved?
...
0
votes
0answers
7 views
D.js ( A+ ) promises lib, performance improvement [closed]
got question at work about improving the D.js library performance-wise.
I m a FE dev for a year, but i mostly do stuff like dom manipulation and simple ajax. I know what promise is, no xp on the topic ...
10
votes
3answers
664 views
Basic timer from one minute to 0
I'm a beginner in JavaScript and I am sure that there is a better way to do it (basic one minute timer from 01:00 to 00:00 running from pageload):
JSFiddle
...
9
votes
2answers
301 views
OO design for Tic Tac Toe program
I am practicing object oriented design and have taken Tic Tac Toe as an example. I have written first all the requirements and then started writing code. I would like to get it reviewed so that I can ...
4
votes
1answer
32 views
Catch-style unit testing in JavaScript (phase 2)
Continued from phase 1; please read it first for background.
Overview
This phase focuses on assertions. Here's where things get ugly. Catch uses macro expansions to decompose assertion ...
4
votes
1answer
50 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?
...
7
votes
2answers
235 views
+100
HTML Pencil: an online HTML editor with real-time preview
HTML Pencil is an online HTML editor created for modern browsers.
Please review the source code and provide feedback:
...
7
votes
1answer
44 views
Catch-style unit testing in JavaScript (phase 1)
I decided to port my favorite unit testing framework, Catch, to JavaScript. So far I'm focusing on test cases and sections. I'll add assertions in phase 2, and output in phase 3.
The goal for this ...
5
votes
4answers
521 views
Reducing code with two identical objects
I have two identical objects on the page, so I get more of the same lines of code. Can anything be made simpler, perhaps with merging?
...
1
vote
0answers
20 views
Angular ui.route
I'm new to ui.router in Angular and have to build an app, which contains a header, sidebar (off-canvas), feedback area (save successful and warnings area) and a content area.
I thought it would be ...
5
votes
3answers
69 views
DRYing out a basic image slider
I built a very basic image slider, but I'm still having trouble refactoring.
I caught myself reusing same code for clicking the previous/next buttons, selecting a slider dot, and the automated ...
6
votes
1answer
60 views
2
votes
0answers
37 views
Refactoring JavaScript functions that differentiate only by condition and return value [closed]
Currently I have 3 functions which are really similar. They differentiate only in input parameter name, condition and return value.
I'm going to refactor them, and I thought you guys might tell me ...
3
votes
1answer
42 views
Can this date-validation function can be simplified further or is it the correct approach?
I am doing a date validation. I have no. of pages, which have the date field. User can input the date like "220875" or "22AUG75" - I need to test both and check the length as well.
...
0
votes
1answer
49 views
Use of getters and setters with a car information example
I have very quickly mocked this up as an example model in Angular JS:
...
5
votes
2answers
75 views
Small jQuery mobile plugin to handle touch events
Why this plugin:
I am developing a mobile app - at some point, I felt like this would be a good idea to give the users the possibility to control everything in the app with touch gestures, hence the ...
4
votes
1answer
39 views
Multiple drop down validation
I have written some jQuery which validates a group of drop downs. It checks the text value selected in all the drop downs (first three characters), and if there is a duplicate, it warns the user.
...
4
votes
3answers
52 views
Building SQL from multiple combinations of query parameters
I have a node.js/express.js based REST application. In one GET service I am querying data based on different set of request parameters. I am looking for a better way to implement it.
...
5
votes
0answers
58 views
Reduce duplicate sequences
I am writing a copy paste detector using esprima.js and Hmm.
This particular function checks a number of sequences and reduces them.
Due to the parsing I might have 2 sequences with the same piece of ...