complete rewrite

partially tested, done in pure js aside from plugin def for speed, uses bounding rect to minimize number of guesses required and allow edit in place.