changed js code for web to event-based style