Skip to content

Commit 6601a34

Browse files
committed
Update links in Webchat README
After talking to HMPO and their new service provider, it became clear that they were looking at an old version of the code for the Webchat implementation and quoting incorrect polling times etc. Removing the link to a specific commit means that we are always linking to the current version of the code. There is a risk that the file could move and the link could break, but if that seems a more acceptable than having to also update these docs if any of the hardcoded values change. Also removes the jQuery example code and replaces it with vanilla Javascript as jQuery has been removed from all of the frontend GOV.UK applications and we don't want to encourage its return.
1 parent 796061a commit 6601a34

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

docs/webchat.md

+10-12
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,23 @@ See the [reference implementation](https://github.com/alphagov/reference-webchat
88

99
## Usage
1010

11-
The Webchat should be accessed through a shared [shared partial](https://github.com/alphagov/government-frontend/blob/957e3fb325eb3ff78b277ceb7054417849009756/app/views/shared/_webchat.html.erb) in which you need to pass the locals `webchat_availability_url` and `webchat_open_url`.
11+
The Webchat should be accessed through a shared [shared partial](https://github.com/alphagov/government-frontend/blob/main/app/views/shared/_webchat.html.erb) in which you need to pass the locals `webchat_availability_url` and `webchat_open_url`.
1212

1313
`webchat_availability_url` will be polled at an interval to check for the webchat instances' avaliability.
1414

1515

16-
`webchat_open_url` is the page that will be opened when a user clicks the webchat call-to-action showm in the 'avaliable' state.
16+
`webchat_open_url` is the page that will be opened when a user clicks the webchat call-to-action shown in the 'avaliable' state.
1717

1818

19-
Finally once you have your partial rendering on the page, you will need to make sure the [library](https://github.com/alphagov/government-frontend/blob/957e3fb325eb3ff78b277ceb7054417849009756/app/assets/javascripts/webchat/library.js) is included on your page and this in your initialisation code.
19+
Finally once you have your partial rendering on the page, you will need to make sure the [library](https://github.com/alphagov/government-frontend/blob/main/app/assets/javascripts/webchat/library.js) is included on your page and this in your initialisation code.
2020

21+
```javascript
22+
var webchats = document.querySelectorAll('.js-webchat')
23+
for (var i = 0; i < webchats.length; i++) {
24+
new GOVUK.Webchat(webchats[i])
25+
}
2126
```
22-
$('.js-webchat').map(function () {
23-
return new GOVUK.Webchat({
24-
$el: $(this),
25-
})
26-
})
27-
28-
```
29-
a fuller example can be seen [here](https://github.com/alphagov/government-frontend/blob/957e3fb325eb3ff78b277ceb7054417849009756/app/assets/javascripts/webchat.js#L31-L41) that has an implementation of the normalisation as noted below
27+
a fuller example can be seen [here](https://github.com/alphagov/government-frontend/blob/main/app/assets/javascripts/webchat.js) that has an implementation of the normalisation as noted below
3028

3129
### Note regarding response Normalisation
3230
As can be seen in the fuller example above, we currently have the option to do the normalisation in JavaScript, this is deprecated, and is shim code until all current users of Wbchat have their own proxies up and running.
@@ -48,7 +46,7 @@ Once this shim is removed we can move this component into Static as a GOV.UK Pub
4846
5. Finished
4947
5048
## CORS considerations
51-
To avoid CORS and CSP issues a new provider would need to be added to the Content Security Policy
49+
To avoid CORS and CSP issues a new provider would need to be added to the [Content Security Policy](https://docs.publishing.service.gov.uk/manual/content-security-policy.html)
5250
5351
## Required configuration
5452

0 commit comments

Comments
 (0)