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 ...

learn more… | top users | synonyms

9
votes
1answer
54 views

Script to convert Shift + Spacebar into four spaces on SE

I've posted this feature request and would like to improve the code involved to handle a few "bugs" (not that it's necessary to provide such code, just for my own practice), but I doubt I'm doing it ...
-1
votes
0answers
19 views

Optimising JS loaded in Ruby on Rails application [on hold]

I included in my RoR application some js classes from Twitter BootStrap. My application.js includes: ...
9
votes
1answer
59 views

ASCII flow chart drawer

After some free ASCII flowchart drawer started charging money, I decided to write my own. Salient features are that you can draw a box (mouse down, mouse move, mouse up), then control B it will draw a ...
1
vote
1answer
61 views

Declaring arrays knowing their maximum size

I know the maximum array size is 6. So what is the best practice to declare an array? In the following code I used it like this: ...
13
votes
4answers
614 views

Snake game with canvas element code

I created a classic snake game in the canvas element. I have not considered best practices when doing this, I just wanted to finish it first. Now it's time to improve the coding practice. You can ...
-1
votes
0answers
7 views

UIKIT style not working correctly [on hold]

Hi Guys I followed UIKIT's sample of html editor my problem is that although its working fine but the design is not... It didnt became the same as what on their docs I followed everything but still ...
3
votes
1answer
34 views

Optimize way of reading and writing file in node.js

I want to read the content of file then want to make few updates to content and then write that content to another file. I have created the code with node.js as follows. ...
-1
votes
0answers
33 views

Running code once [on hold]

I only want my JavaScript to run once, but I cannot control how many times the JavaScript file is executed. Basically I'm writing a tiny JS snippet into a CMS, and the CMS is actually calling it 5-10 ...
3
votes
1answer
34 views

Optimizing JavaScript functions

I've got a tab menu and functions that change the tabs color on click, giving the clicked tab a different color from the others. The thing is, when I click one, I give it another ...
1
vote
1answer
48 views

JavaScript eBay Listing Generator

I'm still pretty new at JS and, frankly, this is probably a little above my skill level. But here's my attempt at a script that will take user input and produce a custom interactive eBay listing. ...
-1
votes
0answers
10 views

Wondering why button is not executing code [closed]

I made a submit panel in the nav to submit files to a website I am currently working on. Dopeyemine.com For some reason the "Submit" button in the submit panel is not working. Please review the ...
4
votes
2answers
98 views

Extending Object.prototype in JavaScript

I find the default Javascript extremely poor on useful functions. There are some nice libraries, but somehow I always need something I can't find. Currently, I'd need a method removing all matching ...
1
vote
1answer
35 views

Can this code utilizing promises be written more succinctly?

I've written the following code to get all .txt files in a directory and read+delete them, repeating every 15 seconds. ...
3
votes
1answer
24 views

Is there a more efficient way of implementing this clock in Raphael JS?

Can someone let me know if this is a proper (and efficient) way of doing it? It works, but I wanted to understand if there's a way it be made better (I can use a for loop for the clones, but my ...
3
votes
1answer
31 views

Node PSP ISO Scraper

I recently bought a PSP and wanted to know the best ISO files and wrote a scraper to retrieve games ISOs titles that received a high rating and send them to a csv. Any recommendations as to ...
1
vote
1answer
49 views

Better way to write 'bulky' function in jQuery

I have this function that works fine, but it looks really ugly and repetitive... Basically I have a featured profile and underneath I have 4 smaller thumbnails, on click I want to populate the large ...
1
vote
1answer
38 views
2
votes
0answers
23 views

Activating image and video carousels

I am using this jQuery code to get two carousels working in bootstrap, and it's working for me. ...
-1
votes
0answers
34 views

if(a & b) and if(!a) means? [closed]

I am non-comp grad.I recently came across programming and knew how easily some maths puzzle can be solved in a few minutes. so I started digging up in programming and learnt javascript language myself ...
2
votes
1answer
30 views

Search for data and order by priority efficiently

I have a search-function, that searches for specific data within a huge Object. Depending on how good a found entry matches, the finding gets "matchPoints" (or "Priority") ...
15
votes
3answers
1k views

Converting an IP

I've written a DNS tool in Node and would like to know if there's a better and more efficient way of handling the conversion from an IP to a long. I'm not too good at bitwise just yet and would like ...
2
votes
1answer
44 views

Is this `img` creator decently secure from XSS?

This is being used now, seems decent to me but I'm curious. ...
0
votes
0answers
30 views

gallery.js with next/prev navigation and swipe function

This is a simple gallery script which I’m using in my website. The script is loaded in the body. (Everytime the user clicks a navigation-link to some page with a gallery, it is loaded.) I thought ...
2
votes
1answer
36 views

b10k minigame problems

I tried to recreate a mini game (not sure about its name, I call it b10k) with 2048 looks, therefore it looked better if I use html elements, and I really am not good at working with them, but I ...
5
votes
1answer
58 views

Pure JS Image Slider

I was just wanting a code review on this image slider I made. I don't have anyone else to give me their opinion on the code I write outside of work. Is this sloppy? Is it wrong? Is it ineffective? ...
6
votes
1answer
72 views

Linear algebra, reduced row echelon form - function 1

This is a derivative post from here. This is just a general review, so the question is the same: Is there something... That you would consider as a bad practice and why? That is just bad in some ...
3
votes
1answer
63 views

Can this form validation be simplified made to memory leak free for all browsers?

I am doing a validation and I believe that there are many things that can be reduced or removed. I am still re-working this. But I am looking for some experts to look at my code and offer the very ...
0
votes
1answer
40 views

Checking number of of columns in a row

I have a own made grid system and made a jQuery function for that to check if there are not too many columns in each row. If so, ...
2
votes
1answer
50 views

Simplifying AJAX success code

Please take a look at this Fiddle. Is there a better way of building a table with titles in the first cell of each row, like this: ...
5
votes
1answer
80 views

Linear algebra, reduced row echelon form

The code that I am sharing here for you to review today, is a segment of a JavaScript library that I am going to write as time goes by for fun. It is only the two functions in the following code: ...
2
votes
1answer
106 views

Checking if variable is defined before accessing its properties [closed]

I didn't write this but I noticed it in our codebase at work. ...
4
votes
1answer
131 views

DRY + principle of least knowledge + MVC in JavaScript

Is there any way of improving this code? (Here's a JSFiddle with an example and comments) Example: A Hotel greeter can greet guests and accepts tips, but it's impossible to see the total of tips a ...
2
votes
1answer
45 views

Script for adding a set of form fields on clicking an Add More button

This is a script that I use to add a set of form fields on clicking an Add More button: ...
2
votes
0answers
51 views

Basic and simple view, add, edit and delete functionality

I want to know what needs to improve with my application. Maybe there is a better way instead of what I am using currently. index.html: ...
5
votes
0answers
92 views

How can I make my website have a more modern look? [closed]

After looking at my site, I've been told by my bud: You know what this looks like? The nineties. I think it looks alright, maybe a little old fashioned but I've been staring at it so long now ...
0
votes
0answers
20 views

What would be a better way to add a table to another table?

I was coding a plugin when I've noticed that there was probably a better way of writing this. ...
5
votes
1answer
239 views

Code seems repeated, except for the callback function

I've written some JavaScript code: ...
0
votes
1answer
38 views

Getting data from the server via JSON callback and parsing the data to HTML

I'm pretty new to web development with JS and was wondering if anyone can tell me how I can improve my code. I just feel like when it comes to maintainability my code would be very difficult to ...
3
votes
2answers
50 views

Optimize jQuery selectors code

I have this fiddle http://jsfiddle.net/L7zuT/ where I'm working on a small part of a big event program. The functionality is ok, the part of the problem would be the large JavaScript lines needed with ...
2
votes
1answer
36 views

Writing my own jQuery plugin

I am trying to write a jQuery Plugin from a piece of JS code I had written. What this plugin does is it converts a select box into a map of Australia where I can select individual states. It's ...
3
votes
1answer
35 views

Personal Project for managing my Bookmarks - v2

I had asked earlier for review of parts of my JS file earlier and review of the complete JS file of my project. Now I have made changes as per the suggestions. Here are the files. I would like to get ...
10
votes
1answer
70 views

Loading the resource identified by a script element's src attribute

I have a function to load the resource identified by a <script> element's src attribute. I need it to: Be as universal ...
6
votes
1answer
143 views

Converting any PHP function toString() like in JS

In JavaScript, any function is basically an object on which you can call (function(){}).toString() to get it's underlying code as a string. I'm working on a ...
6
votes
1answer
65 views

Text Analysis web page

For a homework assignment, I made a web page that has a text area. The user inputs some text, hits the analyse button, and the output is supposed to be a list of the frequency of words of a given ...
0
votes
1answer
48 views

Class-Definition Comparison

Whenever I needed something similar like a "Class" in JavaScript, I wrote it like this: ...
2
votes
0answers
44 views

Node.js promises: save results? [closed]

I'm new to Promises and I don't know the best practises. The following code retrieves page history then search history. I want this history to be saved in variables in order to use it later. I wrote ...
7
votes
1answer
295 views

Rock Paper Scissors in JavaScript

In a few weeks I need to give a workshop about JavaScript to colleagues. They do not have much experience with JavaScript so I will explain the basics of JavaScript. At the end of the day I want them ...
2
votes
3answers
78 views

Does this function have to be nested?

Recent JavaScript student here. I ran afoul of some weirdness with event listeners that led to my code being unresponsive. After some reading and tweaking, I arrived at a version that worked in ...
1
vote
0answers
30 views

Am I correctly using MVC in my binding?

I have method in my Controller(GetAllPatients/EnrollmentQueue) which returns correct data(its array of ...
2
votes
0answers
73 views

Decoupling with a self-descriptive mediator function

I don't have a lot of experience writing libraries and just recently started thinking a lot about structure and patterns. I wrote a tiny module manager based on the facade and mediator design ...