Skip to content

Commit 70998ab

Browse files
committed
Updating to arrow functions
1 parent 359ad05 commit 70998ab

File tree

6 files changed

+50
-50
lines changed

6 files changed

+50
-50
lines changed

source/includes/_debugging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
```javascript
66
(WIAPI => {
77
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
8-
API.subscribe('page-load-v1', function (ev) {
8+
API.subscribe('page-load-v1', ev => {
99
if (ev.payload.searchPage) {
1010
API.log('My integration has loaded and this is a search results page.');
1111
}

source/includes/_events.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ To receive data for events, you must opt-in to event subscriptions. Each event i
212212
```javascript
213213
(WIAPI => {
214214
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
215-
API.subscribe('page-load-v1', function(ev) {
215+
API.subscribe('page-load-v1', ev => {
216216
API.log(ev);
217217
});
218218
})(window.DDC.API);
@@ -222,7 +222,7 @@ To receive data for events, you must opt-in to event subscriptions. Each event i
222222
Parameter Name | Example Value | Parameter Type
223223
-------------- | -------------- | --------------
224224
`event-id` | `page-load-v1` | `String`
225-
`callback` | `function(ev) { API.log(ev); }` | `function`
225+
`callback` | `ev => { API.log(ev); }` | `function`
226226

227227
> This event passes the standard <a href="#page-event">Page Event</a> object to your callback function.
228228
@@ -235,7 +235,7 @@ The page load event is useful to determine the context of the current page. By m
235235
```javascript
236236
(WIAPI => {
237237
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
238-
API.subscribe('dealership-info-v1', function(ev) {
238+
API.subscribe('dealership-info-v1', ev => {
239239
API.log(ev);
240240
});
241241
})(window.DDC.API);
@@ -245,7 +245,7 @@ The page load event is useful to determine the context of the current page. By m
245245
Parameter Name | Example Value | Parameter Type
246246
-------------- | -------------- | --------------
247247
`event-id` | `dealership-info-v1` | `String`
248-
`callback` | `function(ev) { API.log(ev); }` | `function`
248+
`callback` | `ev => { API.log(ev); }` | `function`
249249

250250
> This event passes the standard <a href="#dealership-info-event">Dealership Info Event</a> object to your callback function.
251251
@@ -258,7 +258,7 @@ The dealership info event is useful if you need to know the name and address of
258258
```javascript
259259
(WIAPI => {
260260
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
261-
API.subscribe('vehicle-shown-v1', function(ev) {
261+
API.subscribe('vehicle-shown-v1', ev => {
262262
API.log(ev);
263263
});
264264
})(window.DDC.API);
@@ -267,7 +267,7 @@ The dealership info event is useful if you need to know the name and address of
267267
Parameter Name | Example Value | Parameter Type
268268
-------------- | -------------- | --------------
269269
`event-id` | `vehicle-shown-v1` | `String`
270-
`callback` | `function(ev) { API.log(ev); }` | `function`
270+
`callback` | `ev => { API.log(ev); }` | `function`
271271

272272
> This event passes the standard <a href="#vehicle-event">Vehicle Event</a> object to your callback function.
273273
@@ -282,7 +282,7 @@ On a vehicle deals page, a single event is fired because you are viewing a singl
282282
```javascript
283283
(WIAPI => {
284284
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
285-
API.subscribe('vehicle-data-updated-v1', function(data) {
285+
API.subscribe('vehicle-data-updated-v1', data => {
286286
API.log(data.payload.pageData); // Outputs the Page Data object to the console.
287287
API.log(data.payload.vehicleData); // Outputs the updated Vehicle Data object to the console.
288288
});
@@ -292,7 +292,7 @@ On a vehicle deals page, a single event is fired because you are viewing a singl
292292
Parameter Name | Example Value | Parameter Type
293293
-------------- | -------------- | --------------
294294
`event-id` | `vehicle-data-updated-v1` | `String`
295-
`callback` | `function(ev) { API.log(ev); }` | `function`
295+
`callback` | `ev => { API.log(ev); }` | `function`
296296

297297
> This event passes the standard <a href="#page-event">Page Event</a> object to your callback function as well as the full array of <a href="#vehicle-event">Vehicle Event</a> data objects.
298298

source/includes/_locations.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ See the <a href="#api-insert-name-callback-elem-meta">insert documentation</a> f
1111
```javascript
1212
(WIAPI => {
1313
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
14-
API.insert('vehicle-media', function(elem, meta) {
14+
API.insert('vehicle-media', (elem, meta) => {
1515
// This element is positioned below the vehicle image area on vehicle search pages.
1616
});
1717
})(window.DDC.API);
@@ -22,9 +22,9 @@ See the <a href="#api-insert-name-callback-elem-meta">insert documentation</a> f
2222
```javascript
2323
(WIAPI => {
2424
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
25-
API.subscribe('page-load-v1', function(ev) {
25+
API.subscribe('page-load-v1', ev => {
2626
if (ev.payload.searchPage) {
27-
API.insert('vehicle-media', function(elem, meta) {
27+
API.insert('vehicle-media', (elem, meta) => {
2828
const button = API.create('button', {
2929
text: 'Watch Video',
3030
href: 'https://www.providerdomain.com/path/video-player.html?vin=' + meta.vin,
@@ -50,7 +50,7 @@ This element is positioned below the vehicle image area on vehicle search pages.
5050
```javascript
5151
(WIAPI => {
5252
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
53-
API.insert('vehicle-badge', function(elem, meta) {
53+
API.insert('vehicle-badge', (elem, meta) => {
5454
// This element is positioned below the vehicle tech specs area on vehicle search and detail pages.
5555
});
5656
})(window.DDC.API);
@@ -61,9 +61,9 @@ This element is positioned below the vehicle image area on vehicle search pages.
6161
```javascript
6262
(WIAPI => {
6363
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
64-
API.subscribe('page-load-v1', function(ev) {
64+
API.subscribe('page-load-v1', ev => {
6565
if (ev.payload.searchPage || ev.payload.detailPage) {
66-
API.insert('vehicle-badge', function(elem, meta) {
66+
API.insert('vehicle-badge', (elem, meta) => {
6767
if (meta.inventoryType !== 'used') {
6868
return;
6969
}
@@ -95,7 +95,7 @@ This element is positioned below the vehicle tech specs area on vehicle search a
9595
```javascript
9696
(WIAPI => {
9797
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
98-
API.insert('vehicle-pricing', function(elem, meta) {
98+
API.insert('vehicle-pricing', (elem, meta) => {
9999
// This element is positioned below the vehicle pricing area on vehicle search and detail pages.
100100
});
101101
})(window.DDC.API);
@@ -106,7 +106,7 @@ This element is positioned below the vehicle tech specs area on vehicle search a
106106
```javascript
107107
(WIAPI => {
108108
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
109-
API.subscribe('page-load-v1', function(ev) {
109+
API.subscribe('page-load-v1', ev => {
110110
// Only execute the code on search results and vehicle details pages.
111111
if (ev.payload.searchPage || ev.payload.detailPage) {
112112
API.insert('vehicle-pricing', function (elem, meta) {
@@ -134,7 +134,7 @@ This element is positioned below the vehicle pricing area on vehicle search and
134134
```javascript
135135
(WIAPI => {
136136
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
137-
API.insert('vehicle-media-container', function(elem, meta) {
137+
API.insert('vehicle-media-container', (elem, meta) => {
138138
// This element is the media gallery container on vehicle deals pages.
139139
// Injecting into this location will replace the media gallery with the elements you insert.
140140
});
@@ -146,9 +146,9 @@ This element is positioned below the vehicle pricing area on vehicle search and
146146
```javascript
147147
(WIAPI => {
148148
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
149-
API.subscribe('page-load-v1', function(ev) {
149+
API.subscribe('page-load-v1', ev => {
150150
if (ev.payload.detailPage) {
151-
API.insert('vehicle-media-container', function(elem, meta) {
151+
API.insert('vehicle-media-container', (elem, meta) => {
152152
const containerEl = document.createElement('div');
153153
containerEl.style = 'background-color: #ff0000; font-size: 30px; width: 100%; height: 540px; margin: 0 auto; padding: 100px; text-align: center;';
154154
containerEl.innerHTML = 'Your media container goes here.';
@@ -168,7 +168,7 @@ This element is the media gallery container on vehicle deals pages. Injecting in
168168
```javascript
169169
(WIAPI => {
170170
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
171-
API.insert('primary-banner', function(elem, meta) {
171+
API.insert('primary-banner', (elem, meta) => {
172172
// This element is typically positioned in a prominent location above the vehicle listings on the Search Results Page.
173173
// On the Details page, it is near the top of the vehicle information, below the media gallery.
174174
});
@@ -180,9 +180,9 @@ This element is the media gallery container on vehicle deals pages. Injecting in
180180
```javascript
181181
(WIAPI => {
182182
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
183-
API.subscribe('page-load-v1', function(ev) {
183+
API.subscribe('page-load-v1', ev => {
184184
if (ev.payload.searchPage || ev.payload.detailPage) {
185-
API.insert('primary-banner', function(elem, meta) {
185+
API.insert('primary-banner', (elem, meta) => {
186186
const img = document.createElement('img'),
187187
a = document.createElement('a');
188188

source/includes/_methods.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
```javascript
88
(WIAPI => {
99
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
10-
API.subscribe('event-name-and-version', function(event) {
10+
API.subscribe('event-name-and-version', event => {
1111
API.log(event);
1212
});
1313
})(window.DDC.API);
@@ -21,7 +21,7 @@ Please see the <a href="#event-subscriptions">specific event documentation</a> f
2121
```javascript
2222
(WIAPI => {
2323
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
24-
API.insertCallToAction('button', 'value-a-trade', function(meta) {
24+
API.insertCallToAction('button', 'value-a-trade', meta => {
2525
return {
2626
"type": "default",
2727
"href": "https://www.yourdomain.com/value-a-trade/?vin=" + meta.vin,
@@ -116,20 +116,20 @@ After creating the callback object, you must then return it for the API to creat
116116
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
117117

118118
// Receive a notification each time vehicle data is updated on the page (or a new page is loaded).
119-
API.subscribe('vehicle-data-updated-v1', function(ev) {
119+
API.subscribe('vehicle-data-updated-v1', ev => {
120120

121121
// Collect the VIN for each vehicle on the page in an array.
122-
API.utils.getAttributeForVehicles('vin').then(function(vins) {
122+
API.utils.getAttributeForVehicles('vin').then(vins => {
123123
API.log("Calling service with these VINs: " + vins.join(','));
124124

125125
// Fetch data from your endpoint by supplying the list of VINs.
126126
fetch('https://www.yourdomain.com/api/endpoint-that-returns-json?vins=' + vins.join(','))
127-
.then(function(response) {
127+
.then(response => {
128128
return response.json();
129129
})
130-
.then(function(serviceData) {
130+
.then(serviceData => {
131131
// Now that you have your service data, you can determine whether or not to place a CTA for this vehicle on the page.
132-
API.insertCallToActionOnce('button', 'value-a-trade', function(meta) {
132+
API.insertCallToActionOnce('button', 'value-a-trade', meta => {
133133
if (serviceData.hasOwnProperty(meta.vin)) {
134134
return {
135135
"type": "default",
@@ -208,7 +208,7 @@ Name | Description
208208
```javascript
209209
(WIAPI => {
210210
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
211-
API.insert('location-name', function(elem, meta) {
211+
API.insert('location-name', (elem, meta) => {
212212
API.log(elem); // The DOM element where markup may be inserted.
213213
API.log(meta); // The payload object for the current insertion point.
214214
});
@@ -231,9 +231,9 @@ If you need to execute additional code before determining if you wish to insert
231231
(WIAPI => {
232232
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
233233
// Receive a notification each time vehicle data is updated on the page (or a new page is loaded).
234-
API.subscribe('vehicle-data-updated-v1', function(ev) {
234+
API.subscribe('vehicle-data-updated-v1', ev => {
235235
// Insert content into each vehicle location now present on the page.
236-
API.insertOnce('location-name', function(elem, meta) {
236+
API.insertOnce('location-name', (elem, meta) => {
237237
API.log(elem); // The DOM element where markup may be inserted.
238238
API.log(meta); // The payload object for the current insertion point.
239239
});
@@ -250,18 +250,18 @@ If you need to execute additional code before determining if you wish to insert
250250
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
251251

252252
// Receive a notification each time vehicle data is updated on the page (or a new page is loaded).
253-
API.subscribe('vehicle-data-updated-v1', function(ev) {
253+
API.subscribe('vehicle-data-updated-v1', ev => {
254254

255255
// Collect the VIN for each vehicle on the page in an array.
256-
API.utils.getAttributeForVehicles('vin').then(function(vins) {
256+
API.utils.getAttributeForVehicles('vin').then(vins => {
257257
API.log("Calling service with these VINs: " + vins.join(','));
258258

259259
// Fetch data from your endpoint by supplying the list of VINs.
260260
fetch('https://www.yourdomain.com/api/endpoint-that-returns-json?vins=' + vins.join(','))
261-
.then(function(response) {
261+
.then(response => {
262262
return response.json();
263263
})
264-
.then(function(serviceData) {
264+
.then(serviceData => {
265265
// Now that you have your service data, you can determine whether or not to place content for this location on to the page.
266266
API.insertOnce('vehicle-badge', function (elem, meta) {
267267
// Verify my service has data for this vehicle
@@ -322,7 +322,7 @@ Field Name | Purpose | Field Format
322322
imgAttributes: {
323323
'data-image-attribute': 'image-attribute-value'
324324
},
325-
onclick: function() {
325+
onclick: () => {
326326
window.MyIntegration.activateModalOverlay();
327327
}
328328
});
@@ -374,7 +374,7 @@ Field Key | Example Value | Field Format | Purpose
374374
```javascript
375375
(WIAPI => {
376376
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
377-
API.insert('target-location-name', function(elem, meta) {
377+
API.insert('target-location-name', (elem, meta) => {
378378
let lowPrice = Math.round(meta.finalPrice - 1000);
379379
let highPrice = Math.round(meta.finalPrice + 1000);
380380
const button = API.create('button', {
@@ -402,7 +402,7 @@ When calling the insert method, the goal is to insert some markup into a locatio
402402
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
403403
// Loads a JavaScript file
404404
API.loadJS('https://www.company.com/script.js')
405-
.then(function() {
405+
.then(() => {
406406
// Code to execute after your JavaScript file has loaded.
407407
});
408408
})(window.DDC.API);
@@ -419,7 +419,7 @@ The loadJS method is a simple way to include additional JavaScript files require
419419
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
420420
// Loads a CSS stylesheet
421421
API.loadCSS('https://www.company.com/integration.css')
422-
.then(function() {
422+
.then(() => {
423423
// Code to execute after your stylesheet has loaded.
424424
});
425425
})(window.DDC.API);

source/includes/_samples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function sendResizeMessage() {
1818
}
1919

2020
if (window.ResizeObserver) {
21-
const heightObserver = new ResizeObserver(function() {
21+
const heightObserver = new ResizeObserver(() => {
2222
sendResizeMessage();
2323
});
2424
heightObserver.observe(document.body);

source/includes/_utilities.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ In addition to the event based system for working with sites, some utility metho
99
```javascript
1010
(WIAPI => {
1111
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
12-
API.subscribe('vehicle-data-updated-v1', function(data) {
12+
API.subscribe('vehicle-data-updated-v1', data => {
1313

1414
API.log(data.payload.pageData); // Logs the Page Data object
1515
API.log(data.payload.vehicleData); // Logs the updated Vehicle Data object
1616

17-
API.utils.getAttributeForVehicles('vin').then(function(vins) {
17+
API.utils.getAttributeForVehicles('vin').then(vins => {
1818
// With the updated list of VINs, you could query your service
1919
// to determine which VINs are supported by your service before
2020
// placing relevant content such as buttons or iframes.
@@ -43,7 +43,7 @@ This can be used to obtain an array of attributes for the currently displayed ve
4343
showOnVDP: false,
4444
apiKey: "abcd12349876zyxw"
4545
}
46-
API.utils.getConfig(testConfig).then(function(config) {
46+
API.utils.getConfig(testConfig).then(config => {
4747
// Output the configuration object for your integration (if defined).
4848
API.log(config);
4949
});
@@ -61,7 +61,7 @@ This fetches a JavaScript object of your integration's configuration for the cur
6161
```javascript
6262
(WIAPI => {
6363
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
64-
API.utils.getDealerData().then(function(dealerData) {
64+
API.utils.getDealerData().then(dealerData => {
6565
// Logs the Dealership Info Event object for the current website.
6666
API.log(dealerData);
6767
});
@@ -77,7 +77,7 @@ This fetches the <a href="#dealership-info-event">Dealership Info Event object</
7777
```javascript
7878
(WIAPI => {
7979
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
80-
API.utils.getJwtForSite().then(function(jwtObject) {
80+
API.utils.getJwtForSite().then(jwtObject => {
8181
API.log(jwtObject);
8282
// Returns a data structure like this:
8383
// {
@@ -97,7 +97,7 @@ This fetches an object containing a Java Web Token which can be used to secure/v
9797
```javascript
9898
(WIAPI => {
9999
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
100-
API.utils.getJwtForVehicles().then(function(jwtObject) {
100+
API.utils.getJwtForVehicles().then(jwtObject => {
101101
API.log(jwtObject);
102102
// Returns a data structure like this:
103103
// {
@@ -117,7 +117,7 @@ This fetches an object containing the array of VINs on the current page and a co
117117
```javascript
118118
(WIAPI => {
119119
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
120-
API.utils.getPageData().then(function(pageData) {
120+
API.utils.getPageData().then(pageData => {
121121
// Outputs the Page Data Object for the current page.
122122
API.log(pageData);
123123
});
@@ -162,7 +162,7 @@ Will return the following object:
162162
```javascript
163163
(WIAPI => {
164164
const API = new WIAPI('test-integration'); // Note: Replace 'test-integration' with your actual integration identifier.
165-
const config = API.utils.getVehicleData().then(function(vehicleData) {
165+
const config = API.utils.getVehicleData().then(vehicleData => {
166166
// Outputs the current set of vehicle data.
167167
API.log(vehicleData);
168168
});

0 commit comments

Comments
 (0)