API: fixed coordinates for situations when the page has been scrolled. Also, use the same code for the API as in the pull request #93 in isitchristmas/web.