Build protocal relative URLs in widget JavaScript

Addresses #741