Ported elevation to javascript