Skip to content

Commit

Permalink
Laid waste to these js files and made them some coffee.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethan Mick committed Apr 15, 2015
1 parent cd1a6f7 commit bb33f68
Show file tree
Hide file tree
Showing 16 changed files with 159 additions and 401 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#
#
#
#

run:
./node_modules/http-server/bin/http-server _app
7 changes: 7 additions & 0 deletions app/header.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
head
meta(charset="utf-8")
meta(http-equiv="X-UA-Compatible" content="IE=edge")
meta(name="viewport" content="width=device-width, initial-scale=1")
link(rel="icon" href="/favicon.png")
title FastChat
link(rel="stylesheet" href="css/compiled.css")
106 changes: 36 additions & 70 deletions app/index.jade
Original file line number Diff line number Diff line change
@@ -1,71 +1,37 @@
doctype html
html(lang='en', ng-app='fastchat')
head
meta(name='viewport', content='width=device-width, initial-scale=1.0')
title FastChat
link(rel='stylesheet', type='text/css', href='css/bootstrap.min.css')
link(rel='stylesheet', type='text/css', href='css/flat-ui.css')
link(rel='stylesheet', type='text/css', href='css/hotkeys.min.css')
link(rel='stylesheet', type='text/css', href='css/style.css')
link(rel='stylesheet', type='text/css', href='css/sidebar.css')
link(rel='stylesheet', type='text/css', href='css/chat.css')
script(src='js/scripts/jquery-2.1.1.min.js')
script(src='js/scripts/bootstrap.min.js')
script(src='js/scripts/angular.min.js')
script(src='js/scripts/angular-route.min.js')
script(src='js/scripts/angular-sanitize.min.js')
script(src='/socket.io/socket.io.js')
script(src='js/scripts/notify.js')
script(src='js/scripts/scrollglue.js')
script(src='js/scripts/hotkeys.min.js')
script(src='js/scripts/ui-bootstrap-tpls-0.11.0.min.js')
script(src='js/scripts/async.js')
script(src='js/scripts/Autolinker.min.js')
script(src='js/models/group.js')
script(src='js/models/message.js')
script(src='js/app.js')
script(src='js/services/authService.js')
script(src='js/services/api.js')
script(src='js/services/socket.js')
script(src='js/services/notification.js')
script(src='js/controllers/NavbarController.js')
script(src='js/controllers/LoginController.js')
script(src='js/controllers/RegisterController.js')
script(src='js/controllers/ChatController.js')
script(src='js/controllers/ProfileController.js')
script.
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-54229110-1', 'auto');
ga('send', 'pageview');

body
header.header-10.navbar-fixed-top(ng-controller='NavbarController')
.container
.navbar.col-sm-12(role='navigation')
.navbar-header
button.navbar-toggle(type='button')
a.brand.purple-color(href='/') FastChat
.collapse.navbar-collapse.pull-right(ng-if='isLoggedIn() == true')
ul.nav.pull-left
li
a(href='#/chat') Chat
div(ng-if='show == true')
form.navbar-form.pull-left
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?
form.navbar-form.pull-left
a.btn.btn-info(href='/', ng-click='logout()') Logout
.collapse.navbar-collapse.pull-right(ng-if='isLoggedIn() == false')
ul.nav.pull-left
li.active
a(href='/index.html') Home
li
a(href='#') Blog
li
a(href='#') Contact
form.navbar-form.pull-left
a.btn.btn-info(href='#/login') Login
a.btn.btn-info(href='#/register') Register
ng-view
include header.jade

body(ng-app="fastchat" layout='row' ng-controller="SidebarController")
md-sidenav(layout='column'
style={'overflow': 'hidden', 'display': 'flex'}
class='site-sidenav md-sidenav-left md-whiteframe-z2'
md-component-id='left'
md-is-locked-open="$media('gt-sm')")
md-toolbar
h1.md-toolbar-tools
a(ng-href='/' layout='row' flex)
img#hero-image(src='img/fastchat.png')
div(style={'line-height':'40px', 'text-indent':'15px'}) Documentation

md-content(style={'overflow': 'auto'})
ul.docs-menu
li.parent-list-item(ng-repeat="section in menu.sections" ng-class="{'parentActive' : isSectionSelected(section)}")
h2(class="menu-heading" ng-if="section.type === 'heading'" id="heading_{{ section.name }}") {{section.name}}
menu-link.sidebar-link(section="section" ng-if="section.type === 'link'")
menu-toggle(section="section" ng-if="section.type === 'toggle'")
ul.menu-nested-list(ng-if="section.children")
li(ng-repeat="page in section.pages" ng-class="{'childActive' : isSectionSelected(child)}")
menu-toggle(section="child")

div(layout="column" layout-fill tabIndex="-1" role="main")
md-toolbar
div.md-toolbar-tools(ng-click="openMenu()")
button.menu-icon(hide-gt-sm aria-label="Toggle Menu")
img(src= root + 'img/menu.png')

md-content#main-content.md-padding(ng-view md-scroll-y flex)


script(src='//localhost:35729/livereload.js')
script(src='js/scripts/compiled.js')
script(src='js/app.js')
34 changes: 17 additions & 17 deletions app/js/app.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ fastchat.filter 'reverse', ->
# Directive
#
fastchat.directive 'fileread', [->
return
scope:
fileread: "="
link: (scope, element, attributes)->
element.bind 'change', (changeEvent)->
reader = new FileReader()
reader.onload = (loadEvent)->
scope.$apply ->
scope.fileread = loadEvent.target.result
reader.readAsDataURL(changeEvent.target.files[0])
scope:
fileread: "="
link: (scope, element, attributes)->
element.bind 'change', (changeEvent)->
reader = new FileReader()
reader.onload = (loadEvent)->
scope.$apply ->
scope.fileread = loadEvent.target.result
reader.readAsDataURL(changeEvent.target.files[0])
]

#
Expand All @@ -28,19 +27,20 @@ fastchat.config ($routeProvider, $locationProvider)->
.when '/',
templateUrl: 'views/index.html'
.when '/login',
templateUrl:'views/login.html'
.when('/register', {
templateUrl:'views/register.html'
templateUrl: 'views/login.html'
.when '/register',
templateUrl: 'views/register.html'
.when '/chat/:group',
templateUrl:'views/chat.html'
templateUrl: 'views/chat.html'
.when '/chat',
redirectTo: '/chat/0'
.when '/profile',
templateUrl:'views/profile.html'
templateUrl: 'views/profile.html'
.when '/privacy',
templateUrl:'views/privacy.html'
.otherwise
templateUrl: 'views/privacy.html'
.otherwise {
redirectTo: '/'
}

fastchat.run (api, authService)->
console.log('Root Running')
Expand Down
32 changes: 16 additions & 16 deletions app/js/controllers/ChatController.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fastchat.controller 'ChatController', ($scope, $routeParams, $location, $sce, $t
$scope.groups = []
$scope.avatars = {}
$scope.media = {}

#
# Really wanted this to just be in the group, but it's not really
# easy or good to modify it as a group property.
Expand All @@ -26,7 +26,7 @@ fastchat.controller 'ChatController', ($scope, $routeParams, $location, $sce, $t
group: $scope.currentGroup._id
hasMedia: false
});

#
# has media?
#
Expand All @@ -35,7 +35,7 @@ fastchat.controller 'ChatController', ($scope, $routeParams, $location, $sce, $t
$scope.messages.unshift(message)
$scope.messageText = ''
$scope.currentGroup.lastMessage = message

#send to socket io
console.log('text?', text)

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


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

#
# Scrolls to the bottom of the Chat.
Expand All @@ -63,7 +63,7 @@ fastchat.controller 'ChatController', ($scope, $routeParams, $location, $sce, $t
onMessage = (data)->
message = new Message(data)
console.log('GOT MESSAGE', message)
if message.group === $scope.currentGroup._id
if message.group is $scope.currentGroup._id
console.log('Current Group:', $scope.currentGroup)
$scope.messages.unshift(message)
if message.hasMedia
Expand Down Expand Up @@ -109,23 +109,23 @@ fastchat.controller 'ChatController', ($scope, $routeParams, $location, $sce, $t
$scope.groups = groups
if groups.length - 1 >= $scope.currentGroup
$scope.currentGroup = groups[$routeParams.group]

# Get all users avatars
async.each $scope.currentGroup.members, (member, callback)->
api.profileImage(member._id)
.then (url)->
console.log('Got avatar: ', url)
$scope.avatars[member._id] = url
img = $(".avatar")
img.src = url
callback()
.then (url)->
console.log('Got avatar: ', url)
$scope.avatars[member._id] = url
img = $(".avatar")
img.src = url
callback()
.catch (err)->
console.log('Failed to find Avatar!', err)
$scope.avatars[member._id] = '/img/default_avatar.png'
callback()
console.log('Failed to find Avatar!', err)
$scope.avatars[member._id] = '/img/default_avatar.png'
callback()
, (err)->
console.log('Finished getting Avatars. Error? ', err)

# Now get the messages
api.messages($scope.currentGroup._id).then (messages)->
console.log('Messages', messages);
Expand Down
4 changes: 2 additions & 2 deletions app/js/controllers/LoginController.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ fastchat.controller 'LoginController', ($scope, $location, api)->

$scope.login = ->
console.log($scope.username, $scope.password)
api.login($scope.username, $scope.password).then (data)->n
api.login($scope.username, $scope.password).then (data)->
console.log(data)
if data === true
if data is true
$location.path('chat')
else
$('#login_errors').text(data.data.error)
Expand Down
2 changes: 1 addition & 1 deletion app/js/controllers/RegisterController.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ fastchat.controller 'RegisterController', ($scope, api)->

$scope.register = ->
console.log($scope.username, $scope.password, $scope.passwordConfirm)
api.register($scope.username, $scope.password)
api.register($scope.username, $scope.password)
2 changes: 1 addition & 1 deletion app/js/models/group.coffee
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
memberLookup = {}

Group = (properties)->
for var key of properties
for key of properties
if properties.hasOwnProperty(key)
this[key] = properties[key]

Expand Down
2 changes: 1 addition & 1 deletion app/js/models/message.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#

Message = (properties)->
for var key of properties
for key of properties
if properties.hasOwnProperty(key)
this[key] = properties[key]
this
Expand Down
Loading

0 comments on commit bb33f68

Please sign in to comment.