Change function signature.

This commit is contained in:
Gunther Brunner
2014-09-29 19:43:16 +09:00
parent 9d38bced21
commit 6b1a2700bd
2 changed files with 6 additions and 4 deletions

View File

@@ -1,9 +1,9 @@
module.exports = function AdbKeysServiceFactory() {
var service = {}
service.hostNameFromKey = function (key) {
service.commentFromKey = function (key) {
if (key.match(/.+= (.+)/)) {
return key.replace(/.+= (.+)/g, '$1').replace(/(\.local)?/g, '')
return key.replace(/.+= (.+)/g, '$1')
}
return ''
}

View File

@@ -22,14 +22,16 @@ module.exports = function addAdbKeyDirective(AdbKeysService) {
scope.addForm.title = ''
scope.addForm.key = ''
console.log('scope', scope)
// TODO: cannot access to the form by name?
// TODO: cannot access to the form by name inside a directive?
//scope.adbkeyform.$setPristine()
scope.showAdd = false
}
scope.$watch('addForm.key', function (newValue) {
if (newValue && !scope.addForm.title) {
scope.addForm.title = AdbKeysService.hostNameFromKey(newValue)
// By default sets the title to the ADB key comment because
// usually it happens to be username@hostname.
scope.addForm.title = AdbKeysService.commentFromKey(newValue)
}
})