0
First, you are usually good about naming your variables, but you still have a few single-letter variables in here, o, p, and v, to name a few. These should be more descriptive of what they are.
Second, your code would be a bit more readable if you put spaces around your operators, like for(var ...