Skip to content

Commit bb33f68

Browse files
author
Ethan Mick
committed
Laid waste to these js files and made them some coffee.
1 parent cd1a6f7 commit bb33f68

16 files changed

+159
-401
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#
2+
#
3+
#
4+
#
5+
6+
run:
7+
./node_modules/http-server/bin/http-server _app

app/header.jade

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
head
2+
meta(charset="utf-8")
3+
meta(http-equiv="X-UA-Compatible" content="IE=edge")
4+
meta(name="viewport" content="width=device-width, initial-scale=1")
5+
link(rel="icon" href="/favicon.png")
6+
title FastChat
7+
link(rel="stylesheet" href="css/compiled.css")

app/index.jade

Lines changed: 36 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,37 @@
11
doctype html
2-
html(lang='en', ng-app='fastchat')
3-
head
4-
meta(name='viewport', content='width=device-width, initial-scale=1.0')
5-
title FastChat
6-
link(rel='stylesheet', type='text/css', href='css/bootstrap.min.css')
7-
link(rel='stylesheet', type='text/css', href='css/flat-ui.css')
8-
link(rel='stylesheet', type='text/css', href='css/hotkeys.min.css')
9-
link(rel='stylesheet', type='text/css', href='css/style.css')
10-
link(rel='stylesheet', type='text/css', href='css/sidebar.css')
11-
link(rel='stylesheet', type='text/css', href='css/chat.css')
12-
script(src='js/scripts/jquery-2.1.1.min.js')
13-
script(src='js/scripts/bootstrap.min.js')
14-
script(src='js/scripts/angular.min.js')
15-
script(src='js/scripts/angular-route.min.js')
16-
script(src='js/scripts/angular-sanitize.min.js')
17-
script(src='/socket.io/socket.io.js')
18-
script(src='js/scripts/notify.js')
19-
script(src='js/scripts/scrollglue.js')
20-
script(src='js/scripts/hotkeys.min.js')
21-
script(src='js/scripts/ui-bootstrap-tpls-0.11.0.min.js')
22-
script(src='js/scripts/async.js')
23-
script(src='js/scripts/Autolinker.min.js')
24-
script(src='js/models/group.js')
25-
script(src='js/models/message.js')
26-
script(src='js/app.js')
27-
script(src='js/services/authService.js')
28-
script(src='js/services/api.js')
29-
script(src='js/services/socket.js')
30-
script(src='js/services/notification.js')
31-
script(src='js/controllers/NavbarController.js')
32-
script(src='js/controllers/LoginController.js')
33-
script(src='js/controllers/RegisterController.js')
34-
script(src='js/controllers/ChatController.js')
35-
script(src='js/controllers/ProfileController.js')
36-
script.
37-
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
38-
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
39-
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
40-
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
41-
ga('create', 'UA-54229110-1', 'auto');
42-
ga('send', 'pageview');
43-
44-
body
45-
header.header-10.navbar-fixed-top(ng-controller='NavbarController')
46-
.container
47-
.navbar.col-sm-12(role='navigation')
48-
.navbar-header
49-
button.navbar-toggle(type='button')
50-
a.brand.purple-color(href='/') FastChat
51-
.collapse.navbar-collapse.pull-right(ng-if='isLoggedIn() == true')
52-
ul.nav.pull-left
53-
li
54-
a(href='#/chat') Chat
55-
div(ng-if='show == true')
56-
form.navbar-form.pull-left
57-
button.btn.btn-info(rel='popover', type='button', data-container='body', data-toggle='popover', data-placement='bottom', data-title='{{title}}', data-content='{{content}}') Whats new?
58-
form.navbar-form.pull-left
59-
a.btn.btn-info(href='/', ng-click='logout()') Logout
60-
.collapse.navbar-collapse.pull-right(ng-if='isLoggedIn() == false')
61-
ul.nav.pull-left
62-
li.active
63-
a(href='/index.html') Home
64-
li
65-
a(href='#') Blog
66-
li
67-
a(href='#') Contact
68-
form.navbar-form.pull-left
69-
a.btn.btn-info(href='#/login') Login
70-
a.btn.btn-info(href='#/register') Register
71-
ng-view
2+
include header.jade
3+
4+
body(ng-app="fastchat" layout='row' ng-controller="SidebarController")
5+
md-sidenav(layout='column'
6+
style={'overflow': 'hidden', 'display': 'flex'}
7+
class='site-sidenav md-sidenav-left md-whiteframe-z2'
8+
md-component-id='left'
9+
md-is-locked-open="$media('gt-sm')")
10+
md-toolbar
11+
h1.md-toolbar-tools
12+
a(ng-href='/' layout='row' flex)
13+
img#hero-image(src='img/fastchat.png')
14+
div(style={'line-height':'40px', 'text-indent':'15px'}) Documentation
15+
16+
md-content(style={'overflow': 'auto'})
17+
ul.docs-menu
18+
li.parent-list-item(ng-repeat="section in menu.sections" ng-class="{'parentActive' : isSectionSelected(section)}")
19+
h2(class="menu-heading" ng-if="section.type === 'heading'" id="heading_{{ section.name }}") {{section.name}}
20+
menu-link.sidebar-link(section="section" ng-if="section.type === 'link'")
21+
menu-toggle(section="section" ng-if="section.type === 'toggle'")
22+
ul.menu-nested-list(ng-if="section.children")
23+
li(ng-repeat="page in section.pages" ng-class="{'childActive' : isSectionSelected(child)}")
24+
menu-toggle(section="child")
25+
26+
div(layout="column" layout-fill tabIndex="-1" role="main")
27+
md-toolbar
28+
div.md-toolbar-tools(ng-click="openMenu()")
29+
button.menu-icon(hide-gt-sm aria-label="Toggle Menu")
30+
img(src= root + 'img/menu.png')
31+
32+
md-content#main-content.md-padding(ng-view md-scroll-y flex)
33+
34+
35+
script(src='//localhost:35729/livereload.js')
36+
script(src='js/scripts/compiled.js')
37+
script(src='js/app.js')

app/js/app.coffee

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@ fastchat.filter 'reverse', ->
88
# Directive
99
#
1010
fastchat.directive 'fileread', [->
11-
return
12-
scope:
13-
fileread: "="
14-
link: (scope, element, attributes)->
15-
element.bind 'change', (changeEvent)->
16-
reader = new FileReader()
17-
reader.onload = (loadEvent)->
18-
scope.$apply ->
19-
scope.fileread = loadEvent.target.result
20-
reader.readAsDataURL(changeEvent.target.files[0])
11+
scope:
12+
fileread: "="
13+
link: (scope, element, attributes)->
14+
element.bind 'change', (changeEvent)->
15+
reader = new FileReader()
16+
reader.onload = (loadEvent)->
17+
scope.$apply ->
18+
scope.fileread = loadEvent.target.result
19+
reader.readAsDataURL(changeEvent.target.files[0])
2120
]
2221

2322
#
@@ -28,19 +27,20 @@ fastchat.config ($routeProvider, $locationProvider)->
2827
.when '/',
2928
templateUrl: 'views/index.html'
3029
.when '/login',
31-
templateUrl:'views/login.html'
32-
.when('/register', {
33-
templateUrl:'views/register.html'
30+
templateUrl: 'views/login.html'
31+
.when '/register',
32+
templateUrl: 'views/register.html'
3433
.when '/chat/:group',
35-
templateUrl:'views/chat.html'
34+
templateUrl: 'views/chat.html'
3635
.when '/chat',
3736
redirectTo: '/chat/0'
3837
.when '/profile',
39-
templateUrl:'views/profile.html'
38+
templateUrl: 'views/profile.html'
4039
.when '/privacy',
41-
templateUrl:'views/privacy.html'
42-
.otherwise
40+
templateUrl: 'views/privacy.html'
41+
.otherwise {
4342
redirectTo: '/'
43+
}
4444

4545
fastchat.run (api, authService)->
4646
console.log('Root Running')

app/js/controllers/ChatController.coffee

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fastchat.controller 'ChatController', ($scope, $routeParams, $location, $sce, $t
99
$scope.groups = []
1010
$scope.avatars = {}
1111
$scope.media = {}
12-
12+
1313
#
1414
# Really wanted this to just be in the group, but it's not really
1515
# easy or good to modify it as a group property.
@@ -26,7 +26,7 @@ fastchat.controller 'ChatController', ($scope, $routeParams, $location, $sce, $t
2626
group: $scope.currentGroup._id
2727
hasMedia: false
2828
});
29-
29+
3030
#
3131
# has media?
3232
#
@@ -35,7 +35,7 @@ fastchat.controller 'ChatController', ($scope, $routeParams, $location, $sce, $t
3535
$scope.messages.unshift(message)
3636
$scope.messageText = ''
3737
$scope.currentGroup.lastMessage = message
38-
38+
3939
#send to socket io
4040
console.log('text?', text)
4141

@@ -49,7 +49,7 @@ fastchat.controller 'ChatController', ($scope, $routeParams, $location, $sce, $t
4949

5050

5151
$scope.mediaLoaded = (message)->
52-
typeof $scope.media[message._id] !== 'undefined'
52+
typeof($scope.media[message._id]) isnt 'undefined'
5353

5454
#
5555
# Scrolls to the bottom of the Chat.
@@ -63,7 +63,7 @@ fastchat.controller 'ChatController', ($scope, $routeParams, $location, $sce, $t
6363
onMessage = (data)->
6464
message = new Message(data)
6565
console.log('GOT MESSAGE', message)
66-
if message.group === $scope.currentGroup._id
66+
if message.group is $scope.currentGroup._id
6767
console.log('Current Group:', $scope.currentGroup)
6868
$scope.messages.unshift(message)
6969
if message.hasMedia
@@ -109,23 +109,23 @@ fastchat.controller 'ChatController', ($scope, $routeParams, $location, $sce, $t
109109
$scope.groups = groups
110110
if groups.length - 1 >= $scope.currentGroup
111111
$scope.currentGroup = groups[$routeParams.group]
112-
112+
113113
# Get all users avatars
114114
async.each $scope.currentGroup.members, (member, callback)->
115115
api.profileImage(member._id)
116-
.then (url)->
117-
console.log('Got avatar: ', url)
118-
$scope.avatars[member._id] = url
119-
img = $(".avatar")
120-
img.src = url
121-
callback()
116+
.then (url)->
117+
console.log('Got avatar: ', url)
118+
$scope.avatars[member._id] = url
119+
img = $(".avatar")
120+
img.src = url
121+
callback()
122122
.catch (err)->
123-
console.log('Failed to find Avatar!', err)
124-
$scope.avatars[member._id] = '/img/default_avatar.png'
125-
callback()
123+
console.log('Failed to find Avatar!', err)
124+
$scope.avatars[member._id] = '/img/default_avatar.png'
125+
callback()
126126
, (err)->
127127
console.log('Finished getting Avatars. Error? ', err)
128-
128+
129129
# Now get the messages
130130
api.messages($scope.currentGroup._id).then (messages)->
131131
console.log('Messages', messages);

app/js/controllers/LoginController.coffee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ fastchat.controller 'LoginController', ($scope, $location, api)->
44

55
$scope.login = ->
66
console.log($scope.username, $scope.password)
7-
api.login($scope.username, $scope.password).then (data)->n
7+
api.login($scope.username, $scope.password).then (data)->
88
console.log(data)
9-
if data === true
9+
if data is true
1010
$location.path('chat')
1111
else
1212
$('#login_errors').text(data.data.error)

app/js/controllers/RegisterController.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ fastchat.controller 'RegisterController', ($scope, api)->
44

55
$scope.register = ->
66
console.log($scope.username, $scope.password, $scope.passwordConfirm)
7-
api.register($scope.username, $scope.password)
7+
api.register($scope.username, $scope.password)

app/js/models/group.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
memberLookup = {}
22

33
Group = (properties)->
4-
for var key of properties
4+
for key of properties
55
if properties.hasOwnProperty(key)
66
this[key] = properties[key]
77

app/js/models/message.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44

55
Message = (properties)->
6-
for var key of properties
6+
for key of properties
77
if properties.hasOwnProperty(key)
88
this[key] = properties[key]
99
this

0 commit comments

Comments
 (0)