10
votes
3answers
551 views

Is this code good enough? (jQuery)

I'm working on a simple star rating system, and before I move on to actually "tallying" the votes, which I figure I'll just do with $.ajax, I wanted to make sure what I've done so far has been done as ...
10
votes
1answer
339 views

Unit-testing function

I've got this javascript function which was written a bit ad-hoc and I'm not really sure how to go about refactoring and improving it. It's basically an implementation of draft Unit-Testing/1.1 ...
8
votes
4answers
844 views

Any tips on making this JS better?

Working on a personal project to keep different snippets/examples/small projects of mine organized. I want to make the most of my page width, so I decided to write a navigation menu that slides out. ...
5
votes
2answers
165 views

shorthand methods

Is it good or bad practice (or, when is it appropriate) to use shorthand methods? Lets pretend we're using jQuery here, because it has a lot of them.: jQuery.ajax() jQuery.get() jQuery.getJSON() ...
4
votes
4answers
202 views

poh-tay-toh poh-tah-toh, does writing the same code a different way affect readability?

I have a particular if statement that could be written in different ways, and I'm curious as to whether there's any significant difference in readability that I should prefer one over the other: The ...
4
votes
2answers
248 views

Feedback welcomed on this regexp tester javascript code

I'm quite new to JavaScript, and any feedback of the following code structure and syntax is warmly welcomed. It serves this little online regexp test (still a work in progress): ...
4
votes
1answer
139 views

Loading Javascript Libraries with PHP API

First question on this site so please take it easy on me and let me know if I infringe the common etiquette :-) I have written the following script which simply: Loops through javascript files ...
4
votes
1answer
2k views

Pie Chart jQuery-UI plugin

I would greatly appreciate the input of any gurus out there. I have recently begun learning JavaScript and then jQuery and jQuery-UI and have thought I would take a stab at writing my own jQuery-UI ...
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
77 views

If statement, is the shortened version readable enough?

I have to perform an IF statement in my Javascript code. I utilised the first method shown below: (someVar1 !== "someString") && (someVar2[i].disabled = (someVar3.find("." + someVar4).length ...
3
votes
1answer
764 views

jquery/css/html sliding panels - Please review

Is there a better way to to do what I'm doing? If not just a general review of how I did it and the usability of it (how it works and function not artistically how it looks). Working jsfiddle. ...
2
votes
3answers
446 views

Building an HTML table using JavaScript

More readable way to do this? renderHtmlTable(function(tableItems) { var tableArray,_i,item,_len; tableArray = ['<table id = sampleTable ><thead><tr>' + ...
2
votes
1answer
597 views

How can I improve function definition and manage scope better in javascript?

I often use jQuery plugins for front-end functionality in web applications. This requires me to write code like this, where I am assigning a function to a an object property: var trainingDiary = ...
2
votes
1answer
155 views

New at jQuery, lack of structure

My job required me to learn jQuery the last couple of weeks, but it's a mess and I do not know how to structure my code in an acceptable manner. I come from a Java and PHP background and have never ...
2
votes
4answers
127 views

How would I format this JavaScript code so it's more readable

How can I format this code so it's more readable? $(".card").click(function(){ $(this).stop().animate({ width:'0px', marginLeft: margin+'px', opacity: ...

1 2
15 30 50 per page