Created
March 15, 2017 21:59
-
-
Save craigthomasfrost/85170ec18ae5f935b5dc04fa01186da7 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-container { | |
| position: relative; | |
| } | |
| pre { | |
| padding: 24px 12px; | |
| background-color: black; | |
| color: white; | |
| overflow: scroll; | |
| } | |
| button { | |
| position: absolute; | |
| bottom: 0; | |
| right: 24px; | |
| -webkit-appearance: none; | |
| padding: 6px 12px; | |
| font-size: inherit; | |
| font-family: inherit; | |
| border: none; | |
| background-color: #333; | |
| color: white; | |
| margin-bottom: 24px; | |
| } | |
| button:hover { | |
| cursor: pointer; | |
| } | |
| button:focus { | |
| outline: none; | |
| } | |
| #value { | |
| border-bottom: 1px dashed white; | |
| color: lightgreen; | |
| } | |
| #value:focus { | |
| border-bottom: none; | |
| outline: none; | |
| } | |
| ul { | |
| height: 150px; | |
| overflow: auto; | |
| background-color: black; | |
| list-style: none; | |
| margin: 0; | |
| padding: 48px; | |
| } | |
| li { | |
| margin-bottom: 24px; | |
| padding: 24px; | |
| background-color: #333; | |
| color: white; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <ul class="list"></ul> | |
| <div id="demo-code"> | |
| <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> | |
| <div class="pre-container"> | |
| <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> | |
| <button onclick="appendToFeed();">Append</button> | |
| </div> | |
| </div> | |
| <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-container { | |
| position: relative; | |
| } | |
| pre { | |
| padding: 24px 12px; | |
| background-color: black; | |
| color: white; | |
| overflow: scroll; | |
| } | |
| button { | |
| position: absolute; | |
| bottom: 0; | |
| right: 24px; | |
| -webkit-appearance: none; | |
| padding: 6px 12px; | |
| font-size: inherit; | |
| font-family: inherit; | |
| border: none; | |
| background-color: #333; | |
| color: white; | |
| margin-bottom: 24px; | |
| } | |
| button:hover { | |
| cursor: pointer; | |
| } | |
| button:focus { | |
| outline: none; | |
| } | |
| #value { | |
| border-bottom: 1px dashed white; | |
| color: lightgreen; | |
| } | |
| #value:focus { | |
| border-bottom: none; | |
| outline: none; | |
| } | |
| ul { | |
| height: 150px; | |
| overflow: auto; | |
| background-color: black; | |
| list-style: none; | |
| margin: 0; | |
| padding: 48px; | |
| } | |
| li { | |
| margin-bottom: 24px; | |
| padding: 24px; | |
| background-color: #333; | |
| color: white; | |
| }</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-container { | |
| position: relative; | |
| } | |
| pre { | |
| padding: 24px 12px; | |
| background-color: black; | |
| color: white; | |
| overflow: scroll; | |
| } | |
| button { | |
| position: absolute; | |
| bottom: 0; | |
| right: 24px; | |
| -webkit-appearance: none; | |
| padding: 6px 12px; | |
| font-size: inherit; | |
| font-family: inherit; | |
| border: none; | |
| background-color: #333; | |
| color: white; | |
| margin-bottom: 24px; | |
| } | |
| button:hover { | |
| cursor: pointer; | |
| } | |
| button:focus { | |
| outline: none; | |
| } | |
| #value { | |
| border-bottom: 1px dashed white; | |
| color: lightgreen; | |
| } | |
| #value:focus { | |
| border-bottom: none; | |
| outline: none; | |
| } | |
| ul { | |
| height: 150px; | |
| overflow: auto; | |
| background-color: black; | |
| list-style: none; | |
| margin: 0; | |
| padding: 48px; | |
| } | |
| li { | |
| margin-bottom: 24px; | |
| padding: 24px; | |
| background-color: #333; | |
| color: white; | |
| } |
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