stoplights converted to javascript