PageRenderTime 57ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/dist/index.html

https://github.com/colincarr/pubnub-backbone
HTML | 265 lines | 210 code | 46 blank | 9 comment | 0 complexity | 2c29da58d3af03c9af60d751a2d35e24 MD5 | raw file
  1. <!doctype html>
  2. <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
  3. <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
  4. <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
  5. <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
  6. <head>
  7. <meta charset="utf-8">
  8. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  9. <title>Backbone.js and PubNub Integration - Real Time Backbone Collections and Models</title>
  10. <meta name="description" content="">
  11. <meta name="viewport" content="width=device-width">
  12. <link href="favicon.ico" rel="shortcut icon" type="image/x-icon">
  13. <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,300" rel="stylesheet" type="text/css">
  14. <link rel="stylesheet" href="bower_components/google-code-prettify/src/prettify.css">
  15. <!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
  16. <link rel="stylesheet" href="styles/53b0198e.main.css">
  17. <script src="scripts/vendor/f7f27360.modernizr.js"></script>
  18. </head>
  19. <body>
  20. <a href="https://github.com/pubnub" id="github"><img style="position: absolute; top: 0; right: 0; border: 0" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
  21. <div class="title">
  22. <div class="container">
  23. <div class="row-fluid">
  24. <div class="span12">
  25. <h1>Backbone.js + PubNub</h1>
  26. <h3>Real-Time Multi-User Backbone Collections and Models</h3>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. <div class="main">
  32. <div class="container">
  33. <div class="row-fluid border-row">
  34. <div class="span6">
  35. <div id="todoapp">
  36. <header>
  37. <h3>Todos</h3>
  38. <input id="new-todo" type="text" placeholder="What needs to be done?">
  39. <br>
  40. <input id="toggle-all" type="checkbox">
  41. <label for="toggle-all">Mark all as complete</label>
  42. </header>
  43. <section id="main">
  44. <div class="row-fluid">
  45. <ul id="todo-list"></ul>
  46. </div>
  47. </section>
  48. <footer>
  49. <a id="clear-completed">Clear completed</a>
  50. <div id="todo-count"></div>
  51. <div id="instructions">
  52. Double-click to edit a todo.
  53. </div>
  54. </footer>
  55. </div>
  56. </div>
  57. <div class="span6 what-is-happening">
  58. <div>
  59. <h2>How It Works</h2>
  60. <p>This is an example of the <a href="http://backbonejs.org/examples/todos/index.html" target="_blank">Backbone Todo List</a> extended with the real-time power of <a href="http://pubnub.com" target="_blank">PubNub</a>. Every time a change is detected in the collection of todos, that change is propagated to all other clients running the same demo in their browser. <a href="http://pubnub.github.io/backbone" target="_blank">Open this page in another browser window</a> to see it in action!</p>
  61. <a href="http://github.com/pubnub/backbone" id="github" class="btn btn-large"><i class="icon-github-sign"></i>View on GitHub</a>
  62. <br>
  63. <br>
  64. <iframe src="http://ghbtns.com/github-btn.html?user=pubnub&repo=backbone&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110" height="20"></iframe>
  65. <a href="https://twitter.com/share" class="twitter-share-button" data-via="pubnub">Tweet</a>
  66. <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
  67. <div class="fb-like" data-href="https://www.facebook.com/PubNub" data-width="450" data-layout="button_count" data-show-faces="false" data-send="false"></div>
  68. </div>
  69. </div>
  70. </div>
  71. <div class="row-fluid">
  72. <div class="span12">
  73. <h3>Getting Started</h3>
  74. <p>You can install the package using bower and <code>bower install pubnub-backbone</code> or by cloning this repository. Install the PubNub library along with this one in your html file like so, replacing the *&#39;s with the PubNub version you want to use:</p>
  75. <p><pre class="prettyprint linenums">&lt;script src=&quot;http://cdn.pubnub.com/pubnub.min.js&quot;&gt;&lt;/script&gt;
  76. &lt;script src=&quot;/path/to/backbone-pubnub.min.js&quot;&gt;&lt;/script&gt;</pre></p>
  77. <p>From here the framework gives you three ways to integrate:</p>
  78. </div>
  79. </div>
  80. <div class="row-fluid">
  81. <div class="span12">
  82. <h3>Backbone.PubNub.Collection</h3>
  83. <p>This collection takes the pubnub instance and a name and then publishes all create, update, and delete methods across clients using PubNub. The <code>name</code> property is used to generate a unique channel name so collections do not collide with each other. As a warning, with the same name will update each other regardless of what class they come from.</p>
  84. <p><pre class="prettyprint linenums">
  85. var MyCollection = Backbone.PubNub.Collection.extend({
  86. name: &#39;MyCollection&#39;, // Used to namespace the updates to this collection
  87. pubnub: pubnub // A global instance of PubNub
  88. });
  89. var myCollection = new MyCollection();</pre></p>
  90. </div>
  91. </div>
  92. <div class="row-fluid">
  93. <div class="span12">
  94. <h3>Backbone.sync</h3>
  95. <p>The Backbone.sync method allows you to have a collection with a remote store, much like the LocalStorage module from the original Backbone Todos demo. This allows you to take updates from other clients when you want them and not automatically.</p>
  96. <p><pre class="prettyprint linenums">
  97. var MyCollection = Backbone.Collection.extend({
  98. pubnub: new Backbone.PubNub(pubnub, "MyCollection") // A PubNub plugin to make the collection real-time
  99. });
  100. var myCollection = new MyCollection();</pre></p>
  101. </div>
  102. </div>
  103. <div class="row-fluid">
  104. <div class="span12">
  105. <h3>Backbone.PubNub.Model</h3>
  106. <p>This will create a model that is updated in real-time across all instances. This works very similarly to the collection in that it publishes all changes across the PubNub network.</p>
  107. </div>
  108. </div>
  109. <div class="row-fluid border-row">
  110. <div class="span6">
  111. <p><pre class="prettyprint linenums">
  112. var MyModel = Backbone.PubNub.Model.extend({
  113. name: &#39;MyModel&#39;,
  114. pubnub: pubnub
  115. });
  116. var myModel = new MyModel();</pre></p>
  117. </div>
  118. <div class="span6">
  119. <div id="mymodel"></div>
  120. </div>
  121. </div>
  122. <div class="row-fluid">
  123. <div class="span4">
  124. <h3>What is PubNub?</h3>
  125. <p>Todays users expect to interact in real-time. PubNub makes it easy for you to add real-time capabilities to your apps, without worrying about the infrastructure. Build apps that allow your users to engage in real-time across mobile, browser, desktop and server.</p>
  126. </div>
  127. <div class="span8">
  128. <h3>What Can I Build With PubNub?</h3>
  129. <p>The PubNub Real-Time Network takes care of the connections, global infrastructure and key building blocks for real-time interactivity, so you can focus creating killer apps</p>
  130. <ul style="float: left; width: 50%">
  131. <li>Real-Time Collaboration</li>
  132. <li>Machine-to-Machine</li>
  133. <li>Real-Time Financial Streams</li>
  134. <li>Real-Time Location Tracking</li>
  135. <li>Call Triggering</li>
  136. </ul>
  137. <ul>
  138. <li>2nd Screen Sync</li>
  139. <li>Live Dashboards</li>
  140. <li>Multi-Player Games</li>
  141. <li>Group Chat Rooms</li>
  142. <li>Thousands more</li>
  143. </ul>
  144. </div>
  145. </div>
  146. </div>
  147. </div>
  148. <div class="highlight">
  149. <div class="container">
  150. <div class="row-fluid">
  151. <div class="span8">
  152. <h3 class="call-to-action">Start Building Real-Time Apps Now!</h3>
  153. </div>
  154. <div class="span2 offset2">
  155. <a href="http://pubnub.com/free-trial" class="btn btn-large" id="get-started">Get Started</a>
  156. </div>
  157. </div>
  158. </div>
  159. </div>
  160. <footer class="text-center">
  161. &copy; 2013 PubNub
  162. </footer>
  163. <script type="text/template" id="mymodel-template">
  164. <h3>Real-Time Model</h3>
  165. <p>Open this page in another window to see me update in real-time!</p>
  166. <p>Rand: <%= rand %></p>
  167. <button id="update">Set Random Number</button>
  168. </script>
  169. <!-- Templates -->
  170. <script type="text/template" id="item-template">
  171. <div class="view">
  172. <input class="toggle" type="checkbox" <%= done ? 'checked="checked"' : '' %> />
  173. <label><%- title %></label>
  174. <a class="destroy"><i class="icon-remove-circle"></i></a>
  175. </div>
  176. <input class="edit" type="text" value="<%- title %>" />
  177. </script>
  178. <script type="text/template" id="stats-template">
  179. <% if (done) { %>
  180. <a id="clear-completed">Clear <%= done %> completed <%= done == 1 ? 'item' : 'items' %></a>
  181. <% } %>
  182. <div class="todo-count"><b><%= remaining %></b> <%= remaining == 1 ? 'item' : 'items' %> left</div>
  183. </script>
  184. <!--[if lt IE 7]>
  185. <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
  186. <![endif]-->
  187. <!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
  188. <script>
  189. (function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
  190. function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
  191. e=o.createElement(i);r=o.getElementsByTagName(i)[0];
  192. e.src='//www.google-analytics.com/analytics.js';
  193. r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
  194. ga('create','UA-41019038-2');ga('send','pageview');
  195. </script>
  196. <script type="text/javascript">
  197. (function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src=("https:"===e.location.protocol?"https:":"http:")+'//cdn.mxpnl.com/libs/mixpanel-2.2.min.js';f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f);b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==
  198. typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.append people.track_charge people.clear_charges people.delete_user".split(" ");for(g=0;g<i.length;g++)f(c,i[g]);
  199. b._i.push([a,e,d])};b.__SV=1.2}})(document,window.mixpanel||[]);
  200. mixpanel.init("778311a72655af3d2eaebacbccf26122");
  201. </script>
  202. <div id="fb-root"></div>
  203. <script>(function(d, s, id) {
  204. var js, fjs = d.getElementsByTagName(s)[0];
  205. if (d.getElementById(id)) return;
  206. js = d.createElement(s); js.id = id;
  207. js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  208. fjs.parentNode.insertBefore(js, fjs);
  209. }(document, 'script', 'facebook-jssdk'));</script>
  210. <script src="http://cdn.pubnub.com/pubnub-3.5.3.min.js"></script>
  211. <script src="scripts/4c8e1eec.plugins.js"></script>
  212. <script>
  213. (function(){
  214. prettyPrint();
  215. })();
  216. </script>
  217. <script src="scripts/ea4bda14.main.js"></script>
  218. </body>
  219. </html>