Skip to content

Instantly share code, notes, and snippets.

@davidmaogomezz
Created September 16, 2015 18:42
Show Gist options
  • Save davidmaogomezz/48bee0082abb56d3f960 to your computer and use it in GitHub Desktop.
Save davidmaogomezz/48bee0082abb56d3f960 to your computer and use it in GitHub Desktop.
HyFio
<html ng-app="myApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js"></script>
<script src="https://cdn.firebase.com/js/client/1.1.1/firebase.js"></script>
<script src="https://cdn.firebase.com/libs/angularfire/0.8.0/angularfire.min.js"></script>
<link rel='stylesheet' href='/resources/tutorial/css/example.css'/>
</head>
<body ng-controller="MyController">
<!-- CHAT MARKUP -->
<div class='example-chat l-demo-container'>
<header>Firebase Chat Demo</header>
<div class='example-chat-toolbar'>
<label for='nameInput'>Username:</label>
<input ng-model='name' type='text' id='nameInput' placeholder='enter a username...'>
</div>
<ul id='example-messages' class='example-chat-messages'>
<li ng-repeat='msg in messages'>
<strong class='example-chat-username'>{{msg.from}}</strong>
{{msg.body}}
</li>
</ul>
<footer>
<input ng-model='msg' ng-keydown="addMessage($event)" type='text' id='messageInput' placeholder='Type a message...'>
</footer>
</div>
<script>
</script>
</body>
</html>
var myApp = angular.module("myApp", ["firebase"]);
myApp.controller('MyController', ['$scope', '$firebase',
function($scope, $firebase) {
//CREATE A FIREBASE REFERENCE
var ref = new Firebase("https://y0beb2b8zxl.firebaseio-demo.com/");
// GET MESSAGES AS AN ARRAY
$scope.messages = $firebase(ref).$asArray();
//ADD MESSAGE METHOD
$scope.addMessage = function(e) {
//LISTEN FOR RETURN KEY
if (e.keyCode === 13 && $scope.msg) {
//ALLOW CUSTOM OR ANONYMOUS USER NAMES
var name = $scope.name || 'anonymous';
//ADD TO FIREBASE
$scope.messages.$add({
from: name,
body: $scope.msg
});
//RESET MESSAGE
$scope.msg = "";
}
}
}
]);
.example-base {
font-family: "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
color: #333; }
.hide {
display: none; }
.l-demo-container {
width: 500px;
margin: 40px auto 0px auto; }
.l-popout {
margin: 0;
padding: 0;
border: 0; }
.l-popout iframe {
width: 100%;
height: 100%;
min-height: 100%;
margin: 0;
padding: 0;
border: 0; }
.example-chat {
font-family: "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
border-radius: 3px;
-webkit-box-shadow: 0px 8px 20px rgba(0, 0, 0, 0.2);
box-shadow: 0px 8px 20px rgba(0, 0, 0, 0.2);
background-color: #dfe3ea;
border: 1px solid #CCC;
overflow: auto;
padding: 0px;
font-size: 18px;
line-height: 22px;
color: #666; }
.example-chat header {
background-color: #EEE;
background: -webkit-gradient(linear, left top, left bottom, from(#EEEEEE), to(#DDDDDD));
background: -webkit-linear-gradient(top, #EEEEEE, #DDDDDD);
background: linear-gradient(top, #EEEEEE, #DDDDDD);
-webkit-box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.9), 0px 1px 2px rgba(0, 0, 0, 0.1);
box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.9), 0px 1px 2px rgba(0, 0, 0, 0.1);
border-radius: 3px 3px 0px 0px;
border-bottom: 1px solid #CCC;
line-height: 24px;
font-size: 12px;
text-align: center;
color: #999; }
.example-chat input {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-box-shadow: inset 0px 1px 3px rgba(0, 0, 0, 0.2);
box-shadow: inset 0px 1px 3px rgba(0, 0, 0, 0.2);
border-radius: 3px;
padding: 0px 10px;
height: 30px;
font-size: 18px;
width: 100%;
font-weight: normal;
outline: none; }
.example-chat .example-chat-toolbar {
background-color: #FFF;
padding: 10px;
position: relative;
border-bottom: 1px solid #CCC; }
.example-chat .example-chat-toolbar label {
text-transform: uppercase;
line-height: 32px;
font-size: 14px;
color: #999;
position: absolute;
top: 10px;
left: 20px;
z-index: 1; }
.example-chat .example-chat-toolbar input {
-webkit-box-shadow: none;
box-shadow: none;
border: 1px solid #FFF;
padding-left: 100px;
color: #999; }
.example-chat .example-chat-toolbar input:active, .example-chat .example-chat-toolbar input:focus {
color: #1d9dff;
border: 1px solid #FFF; }
.example-chat ul {
list-style: none;
margin: 0px;
padding: 20px;
height: 200px;
overflow: auto; }
.example-chat ul li {
margin-bottom: 10px;
line-height: 24px; }
.example-chat ul li:last-child {
margin: 0px; }
.example-chat ul .example-chat-username {
margin-right: 10px; }
.example-chat footer {
display: block;
padding: 10px; }
.example-chat footer input {
border: 1px solid #ced3db;
height: 40px; }
#colorholder {
width: 480px;
height: 30px;
border: 2px solid #424547;
margin: 5px auto 0px auto; }
#drawing-canvas {
border: 3px solid #999; }
.colorbox {
width: 22px;
height: 22px;
margin: 1px;
display: inline-block;
border: 3px solid black; }
.example-leaderboard {
-webkit-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.3);
box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.3);
padding: 20px;
border-radius: 5px;
background-color: white;
overflow: auto;
color: #666; }
.example-leaderboard table {
border-radius: 3px;
margin-bottom: 20px;
width: 100%;
border-collapse: collapse; }
.example-leaderboard table th {
background: #EEE;
border-bottom: 1px solid #CCC;
font-size: 12px;
color: #999;
padding: 5px 10px;
text-align: left; }
.example-leaderboard table td {
border-bottom: 1px solid #EEE;
padding: 10px;
color: #28a562; }
.example-leaderboard table td em {
font-style: normal;
font-weight: bold;
color: #666; }
.example-leaderboard table tr:first-child td {
background: green; }
.example-leaderboard input {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-box-shadow: inset 0px 1px 3px rgba(0, 0, 0, 0.2);
box-shadow: inset 0px 1px 3px rgba(0, 0, 0, 0.2);
border-radius: 3px;
padding: 0px 10px;
height: 30px;
font-size: 18px;
font-weight: normal;
outline: none;
border: 1px solid #CCC; }
.example-leaderboard input.example-leaderboard-name {
width: 186px;
margin-right: 10px; }
.example-leaderboard input.example-leaderboard-score {
width: 300px; }
#highestscore {
margin-top: 20px;
font-size: 14px; }
/* Presence */
#presenceDiv {
text-align: center; }
/* Tetris */
.tetris-body {
width: 600px; }
#canvas0, #canvas1 {
display: inline-block;
border: 4px solid #424547; }
#restartButton {
margin-top: 5px; }
#gameInProgress {
font-size: 14px; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment