diff --git a/Samples/PubNub/.DS_Store b/Samples/PubNub/.DS_Store new file mode 100644 index 0000000..7a8f5d9 Binary files /dev/null and b/Samples/PubNub/.DS_Store differ diff --git a/Samples/PubNub/LICENSE b/Samples/PubNub/LICENSE new file mode 100644 index 0000000..18019ef --- /dev/null +++ b/Samples/PubNub/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 PubNub + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Samples/PubNub/README.md b/Samples/PubNub/README.md new file mode 100644 index 0000000..2a68572 --- /dev/null +++ b/Samples/PubNub/README.md @@ -0,0 +1,36 @@ +# PubNub JavaScript APIs Example: Super Simple Chat Demo + +This is a super simple chat web app, built with using [PubNub JavaScript APIs][pubnub]. + +## Live Demo + +Try this [chat room demo][demo] on multiple browser windows. + +## Send and Receive Messages with PubNub APIs + +Tasks like sending and receiving data through PubNub take a single function call. The basic *send* functionality happens through a `publish()` call. And to *receive* all of the sent messages on a specific channel, simply make a `subscribe()` call. All of the network infrastructure and scaling is taken care of for you, so you spend time building your app, not the infrastructure. + +``` +// Send a message +PUBNUB.publish({ channel: 'chat', message: "hello!" }); +``` + +``` +// Receive messages +PUBNUB.subscribe({ channel: 'chat', callback: function(m){console.log(m)}}); +``` + +Super easy! + +## So, What is PubNub? + +PubNub is a globally distributed *data stream* network, a cloud service that developers use to build and scale real-time applications. We connect to over 250 million devices with billions of monthly real-time transactions for financial services, social apps, online auctions, multi-player games, telecom infrastructure, retail apps etc. PubNub also enables many Internet of Things (IoT) solutions for home automation, connected cars, retail, transportation and many others. + +Are you looking for the SDKs in different languages? visit our [developers page]! +PubNub creates and supports over 50 languages and development platforms with our SDKs, inluding node.js, ruby, python, Objective-C, etc, etc! + +Happy hacking :-) + +[Demo]: http://pubnub.github.io/super-simple-chat/index.html +[pubnub]: http://www.pubnub.com/docs/javascript/javascript-sdk.html +[dev]: http://www.pubnub.com/developers/ diff --git a/Samples/PubNub/assets/.DS_Store b/Samples/PubNub/assets/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/Samples/PubNub/assets/.DS_Store differ diff --git a/Samples/PubNub/assets/skipop.ttf b/Samples/PubNub/assets/skipop.ttf new file mode 100755 index 0000000..fa0d6cb Binary files /dev/null and b/Samples/PubNub/assets/skipop.ttf differ diff --git a/Samples/PubNub/css/.DS_Store b/Samples/PubNub/css/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/Samples/PubNub/css/.DS_Store differ diff --git a/Samples/PubNub/css/style.css b/Samples/PubNub/css/style.css new file mode 100644 index 0000000..718f7b8 --- /dev/null +++ b/Samples/PubNub/css/style.css @@ -0,0 +1,173 @@ +* { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; } + +html { + height: 100%; +} +body { + padding: 0; + margin: 0; + font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", "Roboto Light", "Segoe UI Web Light", "Segoe UI Light", "Segoe UI Web Regular", "Segoe UI", Helvetica, Arial, sans-serif; + background: #f9f9f9; + color: #333; +} +header { + height: 58px; + background: #fff; + border-top: 4px solid #ce1126; + border-bottom-color: #eee; +} +h1, h2, h3 { + margin: 0; + text-rendering: optimizeLegibility; +} +h1 { + font-size: 2em; + line-height: 58px; + text-align: center; + font-weight: normal; +} +input[type=text], button { + -webkit-appearance: none; + -moz-appearance: none; + border: 1px solid #ddd; + color: #333; + font-size: 1em; + padding: .7em 1em; + margin-bottom: 1em; + display: block; +} +button { + background: #e6e6e6; + text-shadow: 0 1px 0 #f3f3f3; + margin: .5em 0 2em 0; + width: 100%; +} +#chat { + height: 75px; + position: relative; +} +#chat i { + font-size: 75px; + position: absolute; + +} +#chat input { + margin-left: 75px; + position: relative; + top: 15px; + width: calc(100% - 75px); +} +#main { + margin: 2em 1em 1em; +} +#main > p { + color: #ce1126; +} +#output p { + font-size: 1.2em; + margin: 0.6em; + position: relative; +} +#output i { + font-size: 40px; + position: absolute; + top: -5px; +} +#output span { + position: relative; + margin-left: 40px; +} + +/* Font Icons */ + +@font-face { + font-family: 'skipop'; + src:url('../assets/skipop.ttf') format('opentype'); + font-weight: normal; + font-style: normal; +} + +[class^="face"], [class*=" face"] { + font-family: 'skipop'; + speak: none; + font-style: normal; + font-weight: normal; + font-variant: normal; + text-transform: none; + line-height: 1; + + /* Better Font Rendering =========== */ + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.face-1:before { + content: "\2a"; +} +.face-2:before { + content: "\34"; +} +.face-3:before { + content: "\36"; +} +.face-4:before { + content: "\3b"; +} +.face-5:before { + content: "\3e"; +} +.face-6:before { + content: "\45"; +} +.face-7:before { + content: "\47"; +} +.face-8:before { + content: "\4d"; +} +.face-9:before { + content: "\52"; +} +.face-10:before { + content: "\59"; +} +.face-11:before { + content: "\63"; +} +.face-12:before { + content: "\6f"; +} +.face-13:before { + content: "\7a"; +} + +.color-1 { + color: #393b79; +} +.color-2 { + color: #6b6ecf; +} +.color-3 { + color: #637939; +} +.color-4 { + color: #b5cf6b; +} +.color-5 { + color: #8c6d31; +} +.color-6 { + color: #e7ba52; +} +.color-7 { + color: #843c39; +} +.color-8 { + color: #d6616b; +} +.color-9 { + color: #7b4173; +} +.color-10 { + color: #ce6dbd; +} diff --git a/Samples/PubNub/index.html b/Samples/PubNub/index.html new file mode 100644 index 0000000..3732442 --- /dev/null +++ b/Samples/PubNub/index.html @@ -0,0 +1,35 @@ + + +
+ + + +' + m.text.replace( /[<>]/ig, '' ) + '
' + output.innerHTML; + } + }); + + /* * + * Sending a message with PubNub Publish API + */ + function publish() { + p.publish({ + channel : channel, + message : { + avatar: avatar.className, + text: input.value + }, + callback : function() { + input.value = ''; + } + }); + } + + // Press Return or click the Send button to submit + input.addEventListener('keyup', function(e) { + (e.keyCode || e.charCode) === 13 && publish(); + }, false); + + button.addEventListener('click', publish, false); + +})(); \ No newline at end of file