Created
March 15, 2017 17:45
-
-
Save craigthomasfrost/dd74a84e826c5fff00b7cd677f311782 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/gumibi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| <style id="jsbin-css"> | |
| html { | |
| font-family: sans-serif; | |
| } | |
| body { | |
| padding: 24px; | |
| } | |
| pre { | |
| padding: 24px; | |
| background-color: black; | |
| color: white; | |
| overflow: scroll; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class=""> | |
| <pre> | |
| <code> | |
| # Copy and paste this into your terminal | |
| curl -k -v -X POST https://api.private-beta-1.pusherplatform.com:443/apps/a9d42303-65fc-490d-b8ab-0521971d5dcc/feeds/feedsLandingPage -d '{ "items": [ { "yourKey": "This is from curl!" } ] }' | |
| </code> | |
| </pre> | |
| <pre> | |
| <code> | |
| // You can edit the below and click | |
| // ‘Run code’ to append to your feed | |
| // in realtime - open some tabs to | |
| // check it out! | |
| myFeed.append({ | |
| yourKey: '<span id="value" contenteditable="true">Default value!</span>' | |
| }) | |
| .then(response => { | |
| console.log('Success:', response) | |
| }) | |
| .catch(err => { | |
| console.error('Error:', err) | |
| }); | |
| </code> | |
| </pre> | |
| </div> | |
| <button onclick="appendToFeed();">Append</button> | |
| <ul class="list"></ul> | |
| <script src="https://code.jquery.com/jquery-3.1.0.js"></script> | |
| <script src="https://js.pusher.com/platform/latest/pusher-platform.js"></script> | |
| <script id="jsbin-javascript"> | |
| var app = new PusherPlatform.App({ | |
| appId: 'a9d42303-65fc-490d-b8ab-0521971d5dcc', | |
| }); | |
| var myFeed = app.feed('feedsLandingPage'); | |
| myFeed.subscribe({ | |
| lastEventId: "0", | |
| onOpen: () => console.log('Connection established'), | |
| onItem: item => { | |
| $('.list').prepend('<li>'+item.body.data.yourKey+'</li>'); | |
| }, | |
| onError: error => console.error('Error:', error), | |
| }); | |
| $.ajax({ | |
| url: '//freegeoip.net/json/', | |
| type: 'POST', | |
| dataType: 'jsonp', | |
| success: function(location) { | |
| myFeed.append({ yourKey: 'You opened this page in '+location.city }) | |
| .then(response => console.log('Success:', response)) | |
| .catch(err => console.error('Error:', err)); | |
| } | |
| }); | |
| function appendToFeed() { | |
| var contentValue = $('#value').html(); | |
| myFeed.append({ | |
| yourKey: '"'+contentValue+'" was appended!' | |
| }) | |
| .catch(err => { | |
| console.error('Error:', err) | |
| }); | |
| } | |
| </script> | |
| <script id="jsbin-source-css" type="text/css">html { | |
| font-family: sans-serif; | |
| } | |
| body { | |
| padding: 24px; | |
| } | |
| pre { | |
| padding: 24px; | |
| background-color: black; | |
| color: white; | |
| overflow: scroll; | |
| }</script> | |
| <script id="jsbin-source-javascript" type="text/javascript">var app = new PusherPlatform.App({ | |
| appId: 'a9d42303-65fc-490d-b8ab-0521971d5dcc', | |
| }); | |
| var myFeed = app.feed('feedsLandingPage'); | |
| myFeed.subscribe({ | |
| lastEventId: "0", | |
| onOpen: () => console.log('Connection established'), | |
| onItem: item => { | |
| $('.list').prepend('<li>'+item.body.data.yourKey+'</li>'); | |
| }, | |
| onError: error => console.error('Error:', error), | |
| }); | |
| $.ajax({ | |
| url: '//freegeoip.net/json/', | |
| type: 'POST', | |
| dataType: 'jsonp', | |
| success: function(location) { | |
| myFeed.append({ yourKey: 'You opened this page in '+location.city }) | |
| .then(response => console.log('Success:', response)) | |
| .catch(err => console.error('Error:', err)); | |
| } | |
| }); | |
| function appendToFeed() { | |
| var contentValue = $('#value').html(); | |
| myFeed.append({ | |
| yourKey: '"'+contentValue+'" was appended!' | |
| }) | |
| .catch(err => { | |
| console.error('Error:', err) | |
| }); | |
| } | |
| </script></body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| html { | |
| font-family: sans-serif; | |
| } | |
| body { | |
| padding: 24px; | |
| } | |
| pre { | |
| padding: 24px; | |
| background-color: black; | |
| color: white; | |
| overflow: scroll; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var app = new PusherPlatform.App({ | |
| appId: 'a9d42303-65fc-490d-b8ab-0521971d5dcc', | |
| }); | |
| var myFeed = app.feed('feedsLandingPage'); | |
| myFeed.subscribe({ | |
| lastEventId: "0", | |
| onOpen: () => console.log('Connection established'), | |
| onItem: item => { | |
| $('.list').prepend('<li>'+item.body.data.yourKey+'</li>'); | |
| }, | |
| onError: error => console.error('Error:', error), | |
| }); | |
| $.ajax({ | |
| url: '//freegeoip.net/json/', | |
| type: 'POST', | |
| dataType: 'jsonp', | |
| success: function(location) { | |
| myFeed.append({ yourKey: 'You opened this page in '+location.city }) | |
| .then(response => console.log('Success:', response)) | |
| .catch(err => console.error('Error:', err)); | |
| } | |
| }); | |
| function appendToFeed() { | |
| var contentValue = $('#value').html(); | |
| myFeed.append({ | |
| yourKey: '"'+contentValue+'" was appended!' | |
| }) | |
| .catch(err => { | |
| console.error('Error:', err) | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment