Skip to content

Commit

Permalink
chore(examples.md): fixup formatting (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeD123 committed Apr 2, 2020
1 parent d507d13 commit 274bcf6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions proposals/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ For each use case we should see code that demonstrates the following, with descr
## Code Samples

<h3 id="example2">Getting permission to "handle payments"</h3>

```javascript
navigator.serviceWorker
.register('/app.js', 'https://apps.domain.net/')
Expand All @@ -44,6 +45,7 @@ navigator.serviceWorker
```

<h3 id="example31">Adding payment methods</h3>

```javascript
navigator.serviceWorker
.getRegistration('https://apps.domain.net/')
Expand All @@ -59,6 +61,7 @@ navigator.serviceWorker
```

<h3 id="example33">Updating payment methods</h3>

```javascript
navigator.serviceWorker
.getRegistration('https://apps.domain.net/')
Expand All @@ -74,7 +77,9 @@ navigator.serviceWorker
```

<h3 id="example32">Removing payment methods</h3>
```javascript

```
javascript
navigator.serviceWorker
.getRegistration('https://apps.domain.net/')
.then(function(registration) {
Expand All @@ -83,13 +88,15 @@ navigator.serviceWorker
```

<h3 id="example1">A service worker that has an event listener for the `onpaymentrequest` event</h3>

```javascript
self.addEventListener('paymentrequest', function (paymentrequestEvent) {
console.log("got it! " + JSON.stringify(paymentrequestEvent.data));
});
```

<h3 id="example4">Returning a response to the `onpaymentrequest` event</h3>

```javascript
self.addEventListener('paymentrequest', function (paymentrequestEvent) {
var accepted = true;
Expand All @@ -103,7 +110,9 @@ self.addEventListener('paymentrequest', function (paymentrequestEvent) {
## App Samples
<h3 id="app1">`basic-card` payment</h3>
Actual running full project [here](https://github.com/pjbazin/wapp-examples)

#### registration

```javascript
navigator.serviceWorker
.register('/app-bc.js')
Expand Down Expand Up @@ -132,6 +141,7 @@ navigator.serviceWorker
```

#### execution (app-bc.js)

```javascript
self.addEventListener('install', function(event) {
// 'install' event is fired when the SW registration is successfully completed.
Expand Down Expand Up @@ -175,6 +185,4 @@ self.addEventListener('paymentrequest', function(paymentrequestEvent) {

}));

});

```
});```

0 comments on commit 274bcf6

Please sign in to comment.