The Viewer SDK Reference documentation and JS source code of the Viewer Plugin for ArcGIS Online are available on the Developer Zone: https://orbitgt.com/developer-zone/
Here some basic examples.
Review the source code of the web-page to see and copy the JS code between the <script> tag.