Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 000af6a

Browse files
feat: add line numbers to code examples
1 parent 7aaa7bd commit 000af6a

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

docs/core-concepts/api-calls-anatomy/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ A `Residence List` call returns a list of countries and 2-letter country codes,
6464

6565
The request data for this call is as below:
6666

67-
```ts
67+
```ts showLineNumbers
6868
{
6969
residence_list: 1; // Api Call Method Name
7070
passthrough?: object; // Optional
@@ -96,7 +96,7 @@ When you get the response for the call, there will be a `Field` with the same na
9696

9797
The response for the `Residence List` call:
9898

99-
```js
99+
```js showLineNumbers
100100
{
101101
echo_req: {
102102
req_id: 1,
@@ -173,7 +173,7 @@ This `Field` contains the exact `Request Data` you sent to the server.
173173

174174
This `Field` helps you determine which `message` data you're getting on the message event of the WebSocket connection. For example, your `onmessage` event handler for your WebSocket connection in `JavaScript` would be:
175175

176-
```js
176+
```js showLineNumbers
177177
socket.onmessage = (event) => {
178178
const receivedMessage = JSON.parse(event.data);
179179

docs/core-concepts/authorization-authentication/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Once a user signs up/logs in, they will be redirected to the URL that you entere
7171

7272
The query parameters in the redirect URL are the user's accounts and their related session tokens. You can map the query parameters to an array using the following approach:
7373

74-
```js
74+
```js showLineNumbers
7575
const user_accounts = [
7676
{
7777
account: 'cr799393',
@@ -88,15 +88,15 @@ const user_accounts = [
8888

8989
To authorise the user based on the user's **selected** account, call the [authorize](https://api.deriv.com/api-explorer#authorize) API call with the user's **selected** account **session token**:
9090

91-
```js
91+
```js showLineNumbers
9292
{
9393
"authorize": "a1-f7pnteezo4jzhpxclctizt27hyeot"
9494
}
9595
```
9696

9797
The response for the `authorize` call would be an object as below:
9898

99-
```js
99+
```js showLineNumbers
100100
{
101101
"account_list": [
102102
{

docs/core-concepts/websocket/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Sending a message can be done via socket.send(data).
4747

4848
Here’s an example in `JavaScript`:
4949

50-
```js
50+
```js showLineNumbers
5151
const app_id = 1089; // Replace with your app_id or leave as 1089 for testing.
5252
const socket = new WebSocket(`wss://ws.binaryws.com/websockets/v3?app_id=${app_id}`);
5353

docs/languages/javascript/get-country-list/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ You can learn more about countries [here](/docs/terminology/trading/residence-li
1717

1818
To get a list of countries, update the open event listener using the following approach:
1919

20-
```js title="index.js"
20+
```js title="index.js" showLineNumbers
2121
const ping_interval = 12000; // it's in milliseconds, which equals to 120 seconds
2222
let interval;
2323
// subscribe to `open` event
@@ -38,7 +38,7 @@ websocket.addEventListener('open', (event) => {
3838

3939
Now, update the `message` event listener to render the data:
4040

41-
```js title="index.js"
41+
```js title="index.js" showLineNumbers
4242
// subscribe to `message` event
4343
websocket.addEventListener('message', (event) => {
4444
const receivedMessage = JSON.parse(event.data);
@@ -58,7 +58,7 @@ websocket.addEventListener('message', (event) => {
5858

5959
The response should be an object:
6060

61-
```json
61+
```json showLineNumbers
6262
{
6363
"echo_req": {
6464
"req_id": 1,
@@ -143,7 +143,7 @@ You will need detailed content about `IDV` and `ONFIDO` identity services, their
143143

144144
Your final code will be:
145145

146-
```js title="index.js"
146+
```js title="index.js" showLineNumbers
147147
const app_id = 1089; // Replace with your app_id or leave as 1089 for testing.
148148
const websocket = new WebSocket(`wss://ws.binaryws.com/websockets/v3?app_id=${app_id}`);
149149
const ping_interval = 12000; // it's in milliseconds, which equals to 120 seconds

docs/languages/javascript/project-setup/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ Now, open the `index.html` file or use the [Live Server Extension](https://marke
3838

3939
Now, change the content of the files using the following approach:
4040

41-
```js title="index.js"
42-
console.log("we will create our websocket connection here");
41+
```js title="index.js" showLineNumbers
42+
console.log('we will create our websocket connection here');
4343
```
4444

45-
```html title="index.html"
45+
```html title="index.html" showLineNumbers
4646
<!DOCTYPE html>
4747
<html lang="en">
4848
<head>

docs/languages/javascript/websocket-connection/index.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ If you're not familiar with WebSockets, please check out [our documentation](/do
2222

2323
Next, we'll create a WebSocket connection to Deriv WebSocket Server as seen below:
2424

25-
```js title="index.js"
25+
```js title="index.js" showLineNumbers
2626
const app_id = 1089; // Replace with your app_id or leave as 1089 for testing.
2727
const websocket = new WebSocket(`wss://ws.binaryws.com/websockets/v3?app_id=${app_id}`);
2828
```
@@ -46,7 +46,7 @@ Generally, we have 4 events on `WebSocket connections`:
4646

4747
Let's add an event listener for these events on our WebSocket connection.
4848

49-
```js title="index.js"
49+
```js title="index.js" showLineNumbers
5050
// subscribe to `open` event
5151
websocket.addEventListener('open', (event) => {
5252
console.log('websocket connection established: ', event);
@@ -78,7 +78,7 @@ Our WebSocket server provides [ping/pong](/api-explorer#ping) functionality. Let
7878
The `send` function on the WebSocket connection, only receives `string`, `ArrayBuffer`, `Blob`, `TypedArray` and `DataView`. You can read more about them on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send). This means, if we want to send an `object`, we have to stringify it with `JSON.stringify` first.
7979
:::
8080

81-
```js title="index.js"
81+
```js title="index.js" showLineNumbers
8282
// subscribe to `open` event
8383
websocket.addEventListener('open', (event) => {
8484
console.log('websocket connection established: ', event);
@@ -95,7 +95,7 @@ websocket.addEventListener('message', (event) => {
9595

9696
The `receivedMessage` would be an object like so:
9797

98-
```js
98+
```js showLineNumbers
9999
{
100100
echo_req: {
101101
ping: 1
@@ -119,7 +119,7 @@ By default, `WebSocket connections` will be closed when no traffic is sent betwe
119119

120120
A simple setup example would be the following:
121121

122-
```js title="index.js"
122+
```js title="index.js" showLineNumbers
123123
const ping_interval = 12000; // it's in milliseconds, which equals to 120 seconds
124124
let interval;
125125
websocket.addEventListener('open', (event) => {
@@ -145,7 +145,7 @@ Now, when the connection is `established`, we start sending `ping` requests with
145145

146146
Your final code should be:
147147

148-
```js title="index.js"
148+
```js title="index.js" showLineNumbers
149149
const app_id = 1089; // Replace with your app_id or leave as 1089 for testing.
150150
const websocket = new WebSocket(`wss://ws.binaryws.com/websockets/v3?app_id=${app_id}`);
151151
const ping_interval = 12000; // it's in milliseconds, which equals to 120 seconds

0 commit comments

Comments
 (0)