13
votes
4answers
639 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 ...
11
votes
2answers
250 views

HTML5 / JavaScript Tic-Tac-Toe

As an exercise, I decided to create a simple Tic-Tac-Toe game. It is Ruby on Rails based, but as for now I'm not using the server side for anything (I intend to build up on it in the future, though). ...
7
votes
1answer
208 views

First HTML5 game. - Snake!

so here's my first HTML5 game. It's a really simple snake. I've never made a game before and haven't had too much experience with JavaScript. Html ...
7
votes
2answers
271 views

Optimizing the performance of html5 video manipulation

I've been working on an html5 canvas video player with a lot of fun little extras and ui toys, the main one being a chroma key (green screen) effect that allows the user to key out different colors or ...
6
votes
2answers
223 views

Data attribute text() swap on hover

This is a very basic script. If the screen width is larger than say a tablet, and a portfolio link is hovered over, it will fade out the original text and replace it with the text held in the ...
6
votes
1answer
86 views

Plan to make a small game - got a hang of canvas and made a cube fly around

I'm planning to make a small game for learning purposes. So far, I've got the hang of the canvas element and using the context to draw things on it, as well as object notation and classes in ...
5
votes
1answer
113 views

Geolocation check and error management

I've written this code that I've been using for a while now to check for browser geolocation services for Google maps applications. I have to say that I am not very happy with it as I've had to hack ...
5
votes
1answer
134 views

Expandable navigation menu

I am trying to step to the next level from student to amateur web developer, and I would like to make sure I am not making any web-development no-no's, that's all. What caused me to want to ask SO ...
5
votes
1answer
156 views

Do not select elements that contain data attributes

I have a selector that pulls in all anchor tags that start with the # symbol. I am trying to add a :not selector of some form ...
5
votes
1answer
66 views

Toggling Fullscreen

Please review this code: ...
4
votes
2answers
113 views

Validating a form without using a button and changing td class

I need to validate the form inside a table and change the class of a td-element when the value is not set. I don't have a button inside a form and I can't use the ...
4
votes
2answers
72 views

Can this localStorage login script be written more efficiently?

I understand that account details should be stored using a much more secure method, but this is only a demonstration script I've made to store login credentials and remember a user wishes to remain ...
4
votes
1answer
162 views

Function to delete oldest items out of HTML5 localStorage. Can I make it more efficient?

In a current javascript project, I'm working with the browsers localStorage, and it will pretty consistently be full. To overcome this, I wrote a wrapper to surround the localStorage object that would ...
4
votes
1answer
101 views

This blueprint has already become a mess, please suggest some restructuring

I'm particularly concerned about where I have declared the functions, can I move them around to clean up the code without breaking anything? The "conjugate" function contains a lot of stuff that has ...
4
votes
2answers
225 views

JavaScript Tic-Tac-Toe review: best practices, correctness, and any other improvements/suggestions

I just finished a little game of Tic-Tac-Toe for a class I'm in, and I think it looks alright, but I'm pretty fresh, so I would like to know how I might be able to improve it, given the situation I'm ...
4
votes
1answer
47 views

“Stack exchange page visits” alike implementation

StackExchange page views works like this: Link The objective is to increment the page visits by one. User should not be able to do this by refreshing. Number of visits can be incremented only if ...
4
votes
1answer
305 views

Better JavaScript code structure and html5 drap and drop?

This little script makes list items selectable and draggable. I'm pretty new to programming in general, and even more so to Javascript. Most of my background is in PHP and some C++. On the large, I ...
4
votes
1answer
143 views

javascript for controllers of multiple audio tags

I am trying to learn to create controllers for my own HTML5 audio tags, which I often have several of on the same page. The js.jQuery code below is a simple beginning to this; it works to apply a ...
3
votes
2answers
6k views

Using JavaScript to add and delete rows from an HTML 5 form

I am a JavaScript beginner. Here's a fictional example which isolates the functionality mentioned in the subject line. I hope to employ this functionality as part of a larger web application in the ...
3
votes
1answer
202 views

JS Beginner: Lack of clarity and structure - refactoring possible? | with code example

Hello to everyone! First of all, i have to thank everyone who contributes to this great site. It has been a source of many tipps for me while starting to code in javascript! I've read the FAQs and ...
3
votes
1answer
764 views

Creating <select> element and append data to it

I've made the following and have a few questions: Do I have some (big) mistakes in this approach? (bad practices, 'this code is trash'...) 1.1 If I do, can you suggest what to fix? Are appended ...
3
votes
1answer
252 views

JavaScript playing different audio files based on video keyframe

the general idea of function below is to load a different sound file depending on current time position of the video. I have the following information about audio files: ...
3
votes
2answers
107 views

Replacing simple jQuery methods for better use

There are a few common jQuery call I find my self calling when creating my app. I need some help and maybe a better way to do all this or rewrite it. 1) Singleton Selector If I want to select only ...
3
votes
1answer
98 views

Collision detection accuracy

How do you guys think I can improve the code for collision detection on my website asteroidfield.eu5.org? The current code is ...
3
votes
1answer
792 views

JavaScript/Canvas Pong game

This is the first time I've written JavaScript in this way (previously all I've done mostly is DOM manipulation and form validation in vanilla and jQuery). I've begun working on a basic Pong game. ...
3
votes
1answer
174 views

How to optimize this HTML5 animation?

I'm just learning the basics of animating with Javascript and HTML5. I'm trying to create this scrolling logos element for my site, and I'm pretty sure that my code is very inefficient. Can anyone ...
3
votes
1answer
185 views

Can this Drag and Drop Script be Optimized to Perform Better?

I've just finished a week long adventure of creating an HTML5 Drag and Drop scheduler. As the prototype stands it works fine, but I'm curious if some of the code can be optimized. I mostly focused on ...
3
votes
4answers
2k views

Using Javascript FileWriter with minimal use of closures

I'm currently writing a WebGL HTML5 game, and large part of the game initialization involved loading assets streamed over a websocket, and saving them to disk using the FileSystem API. As part of ...
3
votes
1answer
355 views

Structuring Simple HTML5 / CSS3 / JavaScript Math Web App

I am new to web apps and I am having a difficult time structuring my apps. I put together a very simple math web app which I wish to expand on. The app has the following pages/screens: Home screen ...
2
votes
3answers
553 views

Can I get some constructive criticism on my HTML5 / Javascript pong game?

I am nearly done developing my pong game (made in HTML5 / Javascript), and I would like some constructive criticism on my code. Please note that this is the first major coding project I have ever ...
2
votes
3answers
4k views

Playing sound on a button click

I am new to javascript and want to make sure I am on the right track when playing a sound. Is there anything I should not be doing better or not be doing at all. Below is a simple function. ...
2
votes
2answers
74 views

Having less code for the current program

I am was writing a practice program in javascript and it turned out to work quite alright, however I am not entirely happy with the code. I can't shake the feeling that there is a lot of code which ...
2
votes
1answer
525 views

Getters and Setters for localStorage

I have written the following get/set for a username which is stored in local Storage. Do you think this "buys" me anything or even perhaps has major disadvantages? I have never liked relying on ...
2
votes
1answer
145 views

Movie tickets booking system (Frontend only)

I developed this tickets booking system recently to showcase HTML5 features. I would like you to review it from the UI/UX perspective. Also if there is something more that I can add. Is it good ...
2
votes
1answer
181 views

Better way to check if Javascript Date object exists

When a button is pressed, an animation loop is triggered. At the start of the loop, I create a new time object. I also have a pause button. A problem was created when paused and then started as the ...
2
votes
2answers
583 views

Menu traversing on next and prev button click up and down

Can anyone optimize this code? I am new to jQuery. I want add class on next and previous button click. I wrote this code that works for me, but could anyone optimize it using jQuery predefined ...
2
votes
1answer
95 views

Game runs very slowly - optimization

I've made my first simple game in HTML5. Unfortunately, it runs so slowly. But there are only few rectangles! On my PC, frame rate is between 20 and 25. I expected something like 60-70 but no 20! You ...
2
votes
1answer
110 views

Edit/Details form in JavaScript

I have a Edit/Details form which has 4 user related fields. On click of Save, I save the edited fields to local storage (if supported) and display the same values in the Details view. Below is the ...
2
votes
1answer
94 views

jQuery for image swapping and some JS for text swapping

I am designing a website for a company that manages buildings/real estate. I did not have much use for a CSS library like Bootstrap or Foundation, except on one page of the website. This page ...
2
votes
1answer
58 views

Drag and normal upload code

This is a partial code of my JavaScript app. The openDoc function's task is: call newDoc if use uploads a file through ...
2
votes
1answer
221 views

Deleting a table row in JavaScript with OOP

I started learning OOP in JavaScript at school and I have to do my homework in OOP. It is a shopping list, one fills in a product and price and that is put into an array, the array its contents are ...
2
votes
2answers
169 views

Javascript canvas interactive chart - how to make my code shorter

I'm trying to teach myself javascript and HTML5, (just beginning), and for some practice with canvas I am trying to turn this chart into an interactive chart on canvas, whereby clicking on a word ...
2
votes
1answer
53 views

Web App Structure & User Adjustable Settings

I'm working on my first web app and would like some feedback on the code I have completed. I asked for a similar code review a few weeks ago but I have since improved my structure and added some user ...
2
votes
1answer
981 views

Using jQuery 1.7 .on() and event.stopPropagation to close boxes when clicking in document body

I have the following code which works but seems like it could be improved. I'm not sure if I'm using event.stopPropagation() correctly or if it is the best solution. The elements are loaded via AJAX ...
2
votes
1answer
352 views

JavaScript canvas animation slowing down and hogging memory

I'm experimenting with moving shapes in JavaScript with a canvas tag. I have one half circle (only stroked) which rotates on set intervals. I've written the code ...
1
vote
2answers
90 views

What are practical issues using this code with common JavaScript libraries?

I'm not a JavaScript programmer. I have next to no idea about "what's out there" of libraries and so on. Therefore it's not unlikely that the referred to Windows HTML Application (HTA) code here, ...
1
vote
1answer
171 views

Can this javascript with jquery be improved?

I recently started learning jquery and javascript and put this together for the site I work on here. ...
1
vote
1answer
813 views

HTML5 File API Demo

I recently wrote a small demo that allows users to send and receive files from an HTML5 Javascript application. It's all client-side. I thought this would be a good place to get feedback about what ...
1
vote
1answer
134 views

WebGL ( Three.js ) simple application ( only js without html/css )

I have done the source code for my lesson, which I shall publish later in web at my website, let's look at it: ...
1
vote
1answer
1k views

JavaScript switch statement to make an AJAX call

I have a button group that looks like this: The user selects one of the options and they can search for a person based on that criteria. I wrote a switch statement that populates the URL to make ...