Refactor fidohtml.js