mirror of
https://github.com/arnaucube/socketioMEANseed.git
synced 2026-02-07 03:36:47 +01:00
update
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
angular.module('app', [
|
||||
'ngRoute',
|
||||
'btford.socket-io',
|
||||
'ngMaterial',
|
||||
'app.chat'
|
||||
])
|
||||
.factory('socket', function(socketFactory) {
|
||||
|
||||
21
www/css/chat.css
Normal file
21
www/css/chat.css
Normal file
@@ -0,0 +1,21 @@
|
||||
.chat_backgroundImg{
|
||||
width: auto;
|
||||
height: 100%;
|
||||
min-height: auto;
|
||||
-webkit-background-size: cover;
|
||||
-moz-background-size: cover;
|
||||
background-size: cover;
|
||||
-o-background-size: cover;
|
||||
background-position: center;
|
||||
background-image: url('https://images3.alphacoders.com/106/106327.jpg');
|
||||
text-align: center;
|
||||
/*color: white;*/
|
||||
|
||||
/* Create the parallax scrolling effect */
|
||||
background-attachment: fixed;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
|
||||
color: #ffffff;
|
||||
}
|
||||
@@ -5,11 +5,11 @@
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
|
||||
|
||||
<!-- Angular-Material -->
|
||||
<link rel="stylesheet" href="./bower_components/angular-material/angular-material.css">
|
||||
<link rel="stylesheet" href="bower_components/angular-material/angular-material.css">
|
||||
|
||||
<!-- own styles -->
|
||||
<link rel="stylesheet" href="css/colors.css">
|
||||
<link rel="stylesheet" href="css/main.css">
|
||||
<link rel="stylesheet" href="css/chat.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@@ -1,18 +1,23 @@
|
||||
<md-content class="md-padding">
|
||||
<md-toolbar layout="row" class="o_purple300">
|
||||
<md-toolbar layout="row" class="o_bBlueDark" style="top:0; position:fixed;">
|
||||
<div class="md-toolbar-tools">
|
||||
<span>chat</span>
|
||||
</div>
|
||||
</md-toolbar>
|
||||
<form>
|
||||
<input id="m" ng-model="msg.text" /><button ng-click="send()">Send</button>
|
||||
</form>
|
||||
|
||||
<md-list flex>
|
||||
<md-subheader class="md-no-sticky">3 line item (with hover)</md-subheader>
|
||||
|
||||
<md-list-item ng-repeat="msg in msgs" ng-click="null">
|
||||
<p>{{msg.text}}</p>
|
||||
</md-list-item>
|
||||
</md-list>
|
||||
<md-content class="md-padding chat_backgroundImg" style="margin-top: 50px;">
|
||||
<md-list flex>
|
||||
<md-list-item ng-repeat="msg in msgs" ng-click="null">
|
||||
<p>{{msg.text}}</p>
|
||||
<div class="md-secondary">{{msg.date | date:"HH:mm"}}h</div>
|
||||
</md-list-item>
|
||||
</md-list>
|
||||
</md-content>
|
||||
|
||||
<md-toolbar layout="row" class="o_grey300" style="bottom:0; position:fixed;">
|
||||
<div class="md-toolbar-tools">
|
||||
<md-input-container md-no-float class="md-block" flex>
|
||||
<input ng-model="msg.text" placeholder="Write a message..."
|
||||
ng-keyup="$event.keyCode == 13 ? send() : null">
|
||||
</md-input-container>
|
||||
<md-button class="md-raised" ng-click="send()">Send</md-button>
|
||||
</div>
|
||||
</md-toolbar>
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('app.chat', [
|
||||
'btford.socket-io', 'ngRoute'
|
||||
'btford.socket-io', 'ngRoute', 'ngAnimate'
|
||||
])
|
||||
.controller('ChatCtrl', function ($scope, socket) {
|
||||
.controller('ChatCtrl', function ($scope, socket,
|
||||
$filter) {
|
||||
$scope.msgs=[];
|
||||
|
||||
socket.on('newmsg', function (data) {
|
||||
console.log(data);
|
||||
$scope.msgs.push(data);
|
||||
});
|
||||
$scope.msg={
|
||||
text: ""
|
||||
};
|
||||
$scope.msg={};
|
||||
$scope.send = function(){
|
||||
console.log("emitting");
|
||||
socket.emit("msg", $scope.msg, function(data){
|
||||
if($scope.msg.text)
|
||||
{
|
||||
console.log("emitting");
|
||||
socket.emit("msg", $scope.msg, function(data){
|
||||
|
||||
});
|
||||
});
|
||||
$scope.msg={};
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user