'use strict';

/* Controllers */

var twitterplusControllers = angular.module('twitterplus.controllers', ['twitterplus.services']);

twitterplusControllers.controller('SelectAccountsCtrl', ['$scope', '$rootScope', '$location',
          function($scope, $rootScope, $location) {
            $scope.twitter = $scope.googleplus = '';
            $scope.showStreams = function() {
                  $rootScope.accounts = {
                      twitter: $scope.twitter,
                      googleplus: $scope.googleplus,
                    };
                  $location.path('show');
              };
              
              $scope.isShowEnabled = function() {
                return $scope.twitter.length > 0 && $scope.googleplus.length > 0;
              };
          }]);

twitterplusControllers.controller('ShowStreamsCtrl', ['$scope', '$rootScope', '$location', 'Twitter', 'GooglePlus',
        function($scope, $rootScope, $location, Twitter, GooglePlus) {
                $scope.viewMode = 'unified';
                $scope.newestFirst = true;
        
                $scope.twitter = $rootScope.accounts !== undefined ? $rootScope.accounts.twitter : 'Twitter Demo';
                $scope.googleplus = $rootScope.accounts !== undefined ? $rootScope.accounts.googleplus : 'Google+ Demo';
                
                $scope.hasTweet = function(item) {
                    return item.tweet !== undefined;
                };
                
                $scope.hasGoogleplus = function(item) {
                    return item.googleplus !== undefined;
                };
                
                $scope.showSelect = function() {
                   $location.path('select');
                } 

                var reload = function() {
                      $scope.stream = [];
                      Twitter.get(false, $scope.twitter, function(tweets) { 
                          $scope.stream = $scope.stream.concat(tweets);
                      });
                      GooglePlus.get($scope.googleplus, function(tweets) { 
                          $scope.stream = $scope.stream.concat(tweets);
                      });
                  };
                      
                $scope.reload = reload;
                reload();
           }]);

twitterplusControllers.directive('streamitem', 
        function() {
            return {
                restrict: 'E',
                scope: { item : '=' },
                templateUrl: 'partials/streamitem.html'
            };
        });

@@ -27,16 +27,38 @@
 ers */%0A%0A
+var demoMode = true;%0A%0A
 var twit
@@ -1185,20 +1185,18 @@
  : '
-Twitter Demo
+_tensberg_
 ';%0A 
@@ -1304,20 +1304,26 @@
  : '
-Google+ Demo
+tensberg@gmail.com
 ';%0A 
@@ -1864,12 +1864,15 @@
 get(
-fals
+demoMod
 e, $

use demo mode per default