How to implement a JavaScript-based optical character recognition (OCR) system?