hacktyler / hacktyler-artmap

A guide to public art in Tyler, TX.
http://hacktyler.com
4 stars 2 forks source link

DRYed up goto functions #43

Closed joequery closed 12 years ago

joequery commented 12 years ago

The goto functions were looking a bit repetitive, I attempted to DRY them up a bit. Feel free to disregard if you don't agree with it.

onyxfish commented 12 years ago

I think this is good too, though it you really want to make it super generic I would suggest making switch_page take any number of arguments and then passing the list into reset. That way we don't have to count on reset only ever accepting slug or nothing. (Otherwise we'll end up de-DRYing this later on with a bunch of if/else blocks.

This key to accomplishing this is the arguments variable which always contains the list passed to the function and the apply method which allows you call a function with a list of arguments, documented here:

https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/apply

Up for making the changes?

joequery commented 12 years ago

Yeah, I try to get to this tonight or tomorrow.