Converted javascript to AMD.