Modal generator in pure JavaScript