I've completed writing a purpose-specific plugin and there are a few spots where I have duplicate code and due to the structure of the function, I'm not quite sure how to cleanly get rid of repetitious code.
You can see the code here:
http://jsbin.com/aboca3/8/edit
I am specifically referring to the 4 switch statements and wondering how I can consolidate them in to a function in a way that makes sense, and more importantly, actually works.
Last but certainly not least, there may be more efficient ways to go about performing the functions I'm performing so if anyone has any input on that, I'd be very grateful.