The protocol property sets or returns the protocol of the current URL, including the colon (:).
This means that if you want to get only the HTTP/HTTPS part you can do something like this:
var protocol = window.location.protocol.replace(/:/g,'')
For the domain you can use:
var domain = window.location.hostname;
For the port you can use:
var port = window.location.port;
Keep in mind that the port will be an empty string if it is not visible in the URL. For example:
If you need to show 80/443 when you have no port use
var port = window.location.port || (protocol === 'https' ? '443' : '80');