implement alt-a and ctrl-g keybindings

This commit is contained in:
Tor Hveem 2013-10-11 15:59:55 +02:00
parent f1582b463b
commit a686d7e398
2 changed files with 34 additions and 3 deletions

View File

@ -8,7 +8,7 @@
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" media="screen"> <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link rel="shortcut icon" type="image/png" href="img/favicon.png" > <link rel="shortcut icon" type="image/png" href="img/favicon.png" >
<link href="css/glowingbear.css" rel="stylesheet" media="screen"> <link href="css/glowingbear.css" rel="stylesheet" media="screen">
<script type="text/javascript" src="js/angular.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular.min.js"></script>
<script type="text/javascript" src="js/underscore.js"></script> <script type="text/javascript" src="js/underscore.js"></script>
<script type="text/javascript" src="js/localstorage.js"></script> <script type="text/javascript" src="js/localstorage.js"></script>
<script type="text/javascript" src="js/weechat-protocol.js"></script> <script type="text/javascript" src="js/weechat-protocol.js"></script>
@ -18,7 +18,7 @@
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
</head> </head>
<body ng-controller="WeechatCtrl"> <body ng-controller="WeechatCtrl" ng-keypress="handleKeyPress($event)">
<div ng-hide="connected" class="container"> <div ng-hide="connected" class="container">
<h2> <h2>
<img src="img/favicon.png"> <img src="img/favicon.png">
@ -121,7 +121,7 @@ $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out rel
<div class="navbar navbar-inverse navbar-fixed-bottom"> <div class="navbar navbar-inverse navbar-fixed-bottom">
<form class="form form-horizontal" ng-submit="sendMessage()"> <form class="form form-horizontal" ng-submit="sendMessage()">
<div class="input-group"> <div class="input-group">
<input id="sendMessage" type="text" class="form-control" ng-model="command"> <input id="sendMessage" type="text" class="form-control" ng-model="command" autofocus>
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-default btn-primary">Send</button> <button class="btn btn-default btn-primary">Send</button>
</span> </span>

View File

@ -488,5 +488,36 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
} }
return true; return true;
}; };
$rootScope.switchToActivityBuffer = function() {
// Find next buffer with activity and switch to it
angular.forEach($scope.buffers, function(buffer) {
if(buffer.notification) {
console.log('a', buffer.id);
$scope.setActiveBuffer(buffer.id);
return false;
}else if((parseInt(buffer.unread) || 0) > 0) {
console.log('b',buffer.id);
$scope.setActiveBuffer(buffer.id);
return false;
}
return true;
});
}
$scope.handleKeyPress = function($event) {
//console.log('keypress', $event.charCode, $event.altKey);
// Handle alt-a
if($event.altKey && $event.charCode == '97') {
$event.preventDefault();
$rootScope.switchToActivityBuffer();
return true;
}
// Handle ctrl-g
if($event.ctrlKey && $event.charCode == '103') {
document.querySelector('#bufferFilter').focus();
return true;
}
};
}] }]
); );