js view logic