Getting the pattern as a prototype inside class and modifying windows.onload function