From f0541be900e37f9c65f920ea1de48d7f927a30ab Mon Sep 17 00:00:00 2001 From: Andrew Buss Date: Mon, 25 May 2015 00:13:49 -0700 Subject: [PATCH] navbar icons! --- config.js | 2 +- home.html | 48 +++++++++++++------------------------------ scripts/FeedController.js | 52 +++++++++++++++++++++++------------------------ scripts/RootController.js | 13 ++++-------- templates/cardlist.html | 4 ---- templates/deck.html | 6 +----- templates/feed.html | 4 ---- 7 files changed, 45 insertions(+), 84 deletions(-) diff --git a/config.js b/config.js index b0b02b9..10cd1ca 100644 --- a/config.js +++ b/config.js @@ -65,7 +65,7 @@ angular.module('flashy', [ }). state('root', { resolve: auth_resolve, - url: '/', + url: '', templateUrl: 'templates/root.html', controller: 'RootController' }). diff --git a/home.html b/home.html index b0153fc..7b1f4d4 100644 --- a/home.html +++ b/home.html @@ -14,54 +14,35 @@
- - -
-
diff --git a/scripts/FeedController.js b/scripts/FeedController.js index a9b0689..de73c84 100644 --- a/scripts/FeedController.js +++ b/scripts/FeedController.js @@ -1,10 +1,8 @@ angular.module('flashy.FeedController', ['ui.router']). - - controller('FeedController', ['$scope', '$stateParams', '$state', '$http', function($scope, $stateParams, $state, $http) { - - + controller('FeedController', function ($scope, $rootScope, $stateParams, $state, $http) { console.log('Hello from feed'); sectionId = $stateParams.sectionId; + $rootScope.sectionId = sectionId; $scope.cards = []; var loc = window.location, new_uri; @@ -16,39 +14,39 @@ angular.module('flashy.FeedController', ['ui.router']). new_uri += '//' + loc.host; var ws = new WebSocket(new_uri + '/ws/feed/' + sectionId + '?subscribe-broadcast'); - ws.onopen = function() { + ws.onopen = function () { console.log('websocket connected'); }; - ws.onmessage = function(e) { + ws.onmessage = function (e) { console.log('got websocket message ' + e.data); $scope.refreshCards(); }; - ws.onerror = function(e) { + ws.onerror = function (e) { console.error(e); }; - ws.onclose = function(e) { + ws.onclose = function (e) { console.log('connection closed'); }; $http.get('/api/sections/' + sectionId + '/feed/'). - success(function(data) { + success(function (data) { console.log(data); $scope.cards = data; }). - error(function(err) { + error(function (err) { console.log('pulling feed failed'); }); - $scope.viewDeck = function() { + $scope.viewDeck = function () { $state.go('deck', {sectionId: sectionId}); console.log('go to deck'); }; - $scope.pushCard = function() { + $scope.pushCard = function () { var pushed = new Date(Date.now()); var i = 0; var blanks = []; - $('#new-card-input')[0].childNodes.forEach(function(node) { + $('#new-card-input')[0].childNodes.forEach(function (node) { node = $(node)[0]; console.log(node); if (node.tagName == 'B') { @@ -68,25 +66,25 @@ angular.module('flashy.FeedController', ['ui.router']). section: sectionId }; $http.post('/api/flashcards/', myCard). - success(function(data) { + success(function (data) { console.log('pushed a card!'); listenForC = true; }). - error(function(error) { + error(function (error) { console.log('something went wrong pushing a card!'); }); $('#new-card-input').html(''); }; - $scope.refreshCards = function() { + $scope.refreshCards = function () { $http.get('/api/sections/' + sectionId + '/feed/'). - success(function(data) { + success(function (data) { console.log(data); $scope.cards = data; console.log('success in refresh cards...'); }). - error(function(err) { + error(function (err) { console.log('refresh fail'); }); }; @@ -102,19 +100,19 @@ angular.module('flashy.FeedController', ['ui.router']). opacity: 0, // Opacity of modal background in_duration: 300, // Transition in duration out_duration: 200, // Transition out duration - ready: function() { + ready: function () { listenForC = false; console.log('modal OPENING'); $('#new-card-input').focus(); }, - complete: function() { + complete: function () { listenForC = true; console.log('modal done, closing'); $('#new-card-input').blur(); } }; - $(document).keydown(function(e) { + $(document).keydown(function (e) { var keyed = e.which; if (keyed == 67 && listenForC) { // "c" or "C" for compose $('#newCard').openModal(modal_options); @@ -130,10 +128,10 @@ angular.module('flashy.FeedController', ['ui.router']). $scope.text = ''; var selected_start = 0; var selected_end = 0; - $(document).ready(function() { + $(document).ready(function () { // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered $('.modal-trigger').leanModal(modal_options); - $('#new-card-input').on('keydown', function(e) { + $('#new-card-input').on('keydown', function (e) { if (e.which == 13) { e.preventDefault(); $scope.pushCard(); @@ -141,18 +139,18 @@ angular.module('flashy.FeedController', ['ui.router']). return false; } }); - $('#new-card-input').on('mouseup', function() { + $('#new-card-input').on('mouseup', function () { console.log('got selection: ' + selected_start); }); - $('button#blank-selected').click(function() { + $('button#blank-selected').click(function () { console.log(window.getSelection()); document.execCommand('bold'); }); }); - $scope.$on('$destroy', function() { + $scope.$on('$destroy', function () { ws.close(); $(document).off('keydown'); }); - }]); + }); diff --git a/scripts/RootController.js b/scripts/RootController.js index 9f73282..7c05e13 100644 --- a/scripts/RootController.js +++ b/scripts/RootController.js @@ -1,14 +1,9 @@ angular.module('flashy.RootController', ['ui.router']). - controller('RootController', ['$rootScope', '$scope', '$state', 'UserService', function($rootScope, $scope, $state, UserService) { - //UserService.getUserData(); - //$('#top').collapsible('accordion'); - //$('.button-collapse').sideNav(); - if (UserService.isLoggedIn()) $state.go('login'); - else $state.go('addclass'); + controller('RootController', function ($rootScope, $scope, $state, UserService) { $rootScope.isLoggedIn = false; - console.log(UserService._user); - UserService.getUserData().then(function(data) { + $rootScope.sectionId = 0; + UserService.getUserData().then(function (data) { console.log(data); $rootScope.user = data; }); @@ -18,4 +13,4 @@ angular.module('flashy.RootController', ['ui.router']). closeOnClick: true // Closes side-nav on clicks, useful for Angular/Meteor } ); - }]); + }); diff --git a/templates/cardlist.html b/templates/cardlist.html index 8b03b97..7a55250 100644 --- a/templates/cardlist.html +++ b/templates/cardlist.html @@ -1,7 +1,3 @@ -
- View Feed -
-
diff --git a/templates/deck.html b/templates/deck.html index 891c0ca..4adc333 100644 --- a/templates/deck.html +++ b/templates/deck.html @@ -1,8 +1,4 @@ - - - +
diff --git a/templates/feed.html b/templates/feed.html index 102790f..fa043dc 100644 --- a/templates/feed.html +++ b/templates/feed.html @@ -1,8 +1,4 @@ - -
-- 1.9.1