From 2b01c65e50234cfa358c14db6e689444095ca9f9 Mon Sep 17 00:00:00 2001 From: Staicu Ionut Date: Fri, 30 Mar 2012 18:30:56 +0300 Subject: [PATCH] - when you add a new ssh key, the title field automatically fills with the email (if is present in the key sting) --- app/views/keys/new.html.haml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/views/keys/new.html.haml b/app/views/keys/new.html.haml index 743a3173..277936c6 100644 --- a/app/views/keys/new.html.haml +++ b/app/views/keys/new.html.haml @@ -1,3 +1,14 @@ %h3 New key %hr = render 'form' + +:javascript + $('#key_key').on('keyup', function(){ + var title = $('#key_title'), + val = $('#key_key').val(), + key_mail = val.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+|\.[a-zA-Z0-9._-]+)/gi); + + if( key_mail && key_mail.length > 0 && title.val() == '' ){ + $('#key_title').val( key_mail ); + } + }); \ No newline at end of file