Circuit simulator in JavaScript