Move index to it's own controller

with-route-provider
David Cormier 12 years ago
parent 3a5dfd5e94
commit 3c116b437e
  1. 6
      index.html
  2. 50
      js/glowingbear.js

@ -30,8 +30,8 @@
<script type="text/javascript" src="3rdparty/favico-0.3.4-mod.min.js"></script> <script type="text/javascript" src="3rdparty/favico-0.3.4-mod.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
</head> </head>
<body ng-controller="WeechatCtrl" ng-keydown="handleKeyPress($event)"> <body>
<div ng-hide="connected" class="container"> <div ng-controller="indexCtrl" ng-hide="connected" class="container">
<h2> <h2>
<img alt="logo" src="img/favicon.png"> <img alt="logo" src="img/favicon.png">
glowing bear glowing bear
@ -178,7 +178,7 @@ $ openssl req -nodes -newkey rsa:4096 -keyout relay.pem -x509 -days 365 -out rel
</div> </div>
</div> </div>
</div> </div>
<div class="content" ng-show="connected"> <div ng-controller="WeechatCtrl" ng-keydown="handleKeyPress($event)" class="content" ng-show="connected">
<div id="topbar"> <div id="topbar">
<div class="brand"> <div class="brand">
<a href="#" data-target="#sidebar" data-toggle="collapse"> <a href="#" data-target="#sidebar" data-toggle="collapse">

@ -84,6 +84,7 @@ weechat.factory('handlers', ['$rootScope', 'models', 'plugins', function($rootSc
}; };
var handleBufferOpened = function(message) { var handleBufferOpened = function(message) {
console.log(message);
var bufferMessage = message.objects[0].content[0]; var bufferMessage = message.objects[0].content[0];
var buffer = new models.Buffer(bufferMessage); var buffer = new models.Buffer(bufferMessage);
models.addBuffer(buffer); models.addBuffer(buffer);
@ -446,6 +447,39 @@ function($rootScope,
}; };
}]); }]);
weechat.controller('indexCtrl',
['$rootScope',
'$scope',
'$store',
'connection',
function($rootScope,
$scope,
$store,
connection) {
$store.bind($scope, "host", "localhost");
$store.bind($scope, "port", "9001");
$store.bind($scope, "proto", "weechat");
$store.bind($scope, "ssl", false);
$store.bind($scope, "savepassword", false);
if ($scope.savepassword) {
$store.bind($scope, "password", "");
}
$scope.connect = function() {
connection.connect($scope.host, $scope.port, $scope.password, $scope.ssl);
};
$scope.disconnect = function() {
connection.disconnect();
};
}
]);
weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', '$log', 'models', 'connection', function ($rootScope, $scope, $store, $timeout, $log, models, connection) { weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', '$log', 'models', 'connection', function ($rootScope, $scope, $store, $timeout, $log, models, connection) {
if (window.Notification) { if (window.Notification) {
// Request notification permission // Request notification permission
@ -558,15 +592,6 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$rootScope.iterCandidate = null; $rootScope.iterCandidate = null;
$store.bind($scope, "host", "localhost");
$store.bind($scope, "port", "9001");
$store.bind($scope, "proto", "weechat");
$store.bind($scope, "ssl", false);
$store.bind($scope, "savepassword", false);
if ($scope.savepassword) {
$store.bind($scope, "password", "");
}
// Save setting for displaying only buffers with unread messages // Save setting for displaying only buffers with unread messages
$store.bind($scope, "onlyUnread", false); $store.bind($scope, "onlyUnread", false);
// Save setting for not showing timestamp // Save setting for not showing timestamp
@ -663,12 +688,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
}; };
$scope.connect = function() {
connection.connect($scope.host, $scope.port, $scope.password, $scope.ssl);
};
$scope.disconnect = function() {
connection.disconnect();
};
$scope.install = function() { $scope.install = function() {
if (navigator.mozApps !== undefined) { if (navigator.mozApps !== undefined) {
var request = navigator.mozApps.install('http://torhve.github.io/glowing-bear/manifest.webapp'); var request = navigator.mozApps.install('http://torhve.github.io/glowing-bear/manifest.webapp');

Loading…
Cancel
Save