Firebase


SUBMITTED BY: Guest

DATE: Sept. 27, 2013, 2:44 p.m.

FORMAT: HTML

SIZE: 4.3 kB

HITS: 1224

  1. <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/html4/strict.dtd'>
  2. <head>
  3. <style>
  4. #messagesDiv {
  5. background-color: white;
  6. overflow: auto;
  7. height: 230px;
  8. width: 100%;
  9. padding: 10px;
  10. border: 8px solid #424547;
  11. margin-bottom: 5px;
  12. text-align: left;
  13. }
  14. #nameInput {
  15. width: 26%;
  16. }
  17. #messageInput {
  18. width: 68%;
  19. }
  20. </style>
  21. <script src='https://cdn.firebase.com/v0/firebase.js'></script>
  22. <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js'></script>
  23. <link href='http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css' rel='stylesheet' media='screen'>
  24. <script src='http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js'></script>
  25. <!-- twitter card meta --!>
  26. <!-- <meta name='twitter:card' content='summary'>
  27. <meta name='twitter:image:src' content='http://bitcointips.tk/57x57.png'>
  28. <meta name='twitter:site' content='@1Bitcointips'>
  29. <meta name='twitter:title' content='Bitcointips.tk - your guide in the btc world.'>
  30. <meta name='twitter:description' content='Welcome to bitcointips.tk your source for free bitcoins and tips how to get started with your bitcoin buissnies. Now also with webapp! and a faucet.'>
  31. <meta name='twitter:domain' content='http://bitcointips.tk/'>
  32. <meta name='twitter:creator' content='@svbeon'>
  33. --!>
  34. <title>Chatvik - Chat</title>
  35. <meta name='viewport' content='width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;' />
  36. </head>
  37. <body>
  38. <div class='navbar navbar-inverse navbar-fixed-top' role='navigation'>
  39. <div class='container'>
  40. <div class='navbar-header'>
  41. <button type='button' class='navbar-toggle' data-toggle='collapse' data-target='.navbar-collapse'>
  42. <span class='icon-bar'></span>
  43. <span class='icon-bar'></span>
  44. <span class='icon-bar'></span>
  45. </button>
  46. <a class='navbar-brand' href='http://chatvik.tk'>Chatvik</a>
  47. </div>
  48. <div class='collapse navbar-collapse'>
  49. <ul class='nav navbar-nav'>
  50. <li><a href='http://chatvik.tk/welcome.php'>Home</a></li>
  51. <li><a href='http://firebase.com' target='_blank'>Firebase</a></li>
  52. <li class='active'><a href='#'>Chat</a></li>
  53. <li><a href='index.php?logout='><button class='btn btn-danger btn-xs'>Log out</button></a></li>
  54. </ul>
  55. </div><!-- /.nav-collapse -->
  56. </div><!-- /.container -->
  57. </div>
  58. <div class='container'></br></br></br>
  59. <div class='row row-offcanvas row-offcanvas-right'>
  60. <div class='col-xs-12 col-sm-9'>
  61. <p class='pull-right visible-xs'>
  62. <center>
  63. <div class='jumbotron'>
  64. <p>
  65. <div id='messagesDiv'></div>
  66. <input type='hidden' id='nameInput' value='<?php echo $_SESSION["sess_user"]; ?>'>
  67. <input minlength='2' type='text' id='messageInput' placeholder='Message'>
  68. </p>
  69. </div>
  70. </p>
  71. </div>
  72. </div>
  73. <script>
  74. // Get a reference to the root of the chat data.
  75. var messagesRef = new Firebase('https://chatvik.firebaseio.com/');
  76. // When the user presses enter on the message input, write the message to firebase.
  77. $('#messageInput').keypress(function (e) {
  78. if (e.keyCode == 13) {
  79. var name = $('#nameInput').val();
  80. var text = $('#messageInput').val();
  81. messagesRef.push({name:name, text:text});
  82. $('#messageInput').val('');
  83. }
  84. });
  85. // Add a callback that is triggered for each chat message.
  86. messagesRef.limit(10).on('child_added', function (snapshot) {
  87. var message = snapshot.val();
  88. $('<div/>').text(message.text).prepend($('<em/>')
  89. .text(message.name+': ')).appendTo($('#messagesDiv'));
  90. $('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight;
  91. });
  92. </script>
  93. <div class='footer'>
  94. <center>
  95. <p>â–‘copy; svbeon 2013</p></div></div><!-- /container -->
  96. </center>
  97. </div>
  98. </body>
  99. </html>

comments powered by Disqus