1
vote
0answers
42 views

Optimize jQuery plugin according to DRY-principle [duplicate]

Possible Duplicate: Optimize jQuery plugin according to DRY-principle According to the DRY-principle, any ideas how to write this a bit shorter? jQuery.konami = function(fn, code) { // ...
3
votes
2answers
45 views

Optimize jQuery plugin according to DRY-principle

According to the DRY-principle, any ideas how to write this a bit shorter? jQuery.konami = function(fn, code) { // ↑ ↑ ↓ ↓ ← → ← → B A code = code || [38, 38, 40, 40, 37, 39, 37, 39, 66, 65]; ...
2
votes
2answers
111 views

Can someone help me DRY up these jQuery each loops?

I just posted this on the Stack Exchange, but was told I should post it here: function redundantSee() { var optionSet1 = $('.wrapper:eq(0)'), optionSet2 = $('.wrapper:eq(1)'); ...
2
votes
2answers
314 views

How can I make my Jquery code less repetitive?

I'm making an avatar creator with Jquery where users can select and change hair, eye and skin colour. The page is a form with different values and when the user clicks on the form options the values ...
2
votes
1answer
285 views

How to load content without repeating code using jQuery load method

A while ago I used this code to load content into a div using jQuery load. I repeated the code for all the clicks to load different pages in the same div. $("#button1").click(function(){ ...
1
vote
1answer
79 views

Shortening a webshop page

I am making a simple webshop page where I need to add a couple of products (and their prices). The shop consists of less than 10 products so therefore I decided to build my own solution since it is ...
2
votes
1answer
157 views

Is there a better way to do a Luhn check?

I feel like I should not be duplicating the code to gather the credit card number, but I am not sure how best to do it. Any suggestions? $('input[name="payment\[cc_number\]"]').keyup(function() { ...
1
vote
2answers
1k views

Get device orientation

Here is my code: // get orientation of device getOrientation(); // animate var num = 400; if( $('body').hasClass("landscape") ) { $('.example').animate({'bottom', 0}); } else { ...
2
votes
3answers
1k views

Simple jQuery validation script works but it uses a ton of if/else statements

I've a jQuery validation script to check all form fields for a valid value and prevent form submission and display an error message if any fields fail. It was requested that the validation script not ...
5
votes
3answers
249 views

How can I make this code more DRY?

This code is for a simple language quiz. It fetches two words and related audio files via a JSON call, presents the user with an image that matches one of the words, and challenges the user to make ...