You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Copy file name to clipboardExpand all lines: docs/webchat.md
+10-12
Original file line number
Diff line number
Diff line change
@@ -8,25 +8,23 @@ See the [reference implementation](https://github.com/alphagov/reference-webchat
8
8
9
9
## Usage
10
10
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`.
12
12
13
13
`webchat_availability_url` will be polled at an interval to check for the webchat instances' avaliability.
14
14
15
15
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.
17
17
18
18
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.
20
20
21
+
```javascript
22
+
var webchats =document.querySelectorAll('.js-webchat')
23
+
for (var i =0; i <webchats.length; i++) {
24
+
newGOVUK.Webchat(webchats[i])
25
+
}
21
26
```
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
30
28
31
29
### Note regarding response Normalisation
32
30
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
48
46
5. Finished
49
47
50
48
## 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)
0 commit comments