javascript for oscillation