create encrypted button

This commit is contained in:
Claude 2014-09-06 16:14:13 +02:00
parent e4c0b178a9
commit 3ea8800db8
2 changed files with 7 additions and 2 deletions

View File

@ -242,7 +242,6 @@ h4 {
} }
.form_wrapper button { .form_wrapper button {
clear: both;
float: left; float: left;
margin-left: 150px; margin-left: 150px;
width: 125px; width: 125px;
@ -260,6 +259,10 @@ h4 {
margin-top: 20px; margin-top: 20px;
} }
#create_encrypted {
margin-left: 10px;
}
.form_wrapper .dangerbutton:hover { .form_wrapper .dangerbutton:hover {
background: #f00; background: #f00;
} }

View File

@ -108,12 +108,14 @@ ST.highlight_lines = function() {
} }
ST.crypto = function() { ST.crypto = function() {
$('button[name=submit]').on('mouseenter', function() { $('button[name=submit]').after('<button id="create_encrypted">Create encrypted</button>');
$('#create_encrypted').on('click', function() {
var $code = $('#code'); var $code = $('#code');
var key = ST.crypto_generate_key(); var key = ST.crypto_generate_key();
var encrypted = CryptoJS.AES.encrypt($code.val(), key) + ''; var encrypted = CryptoJS.AES.encrypt($code.val(), key) + '';
encrypted = encrypted.replace(/(.{100})/g, "$1\n"); encrypted = encrypted.replace(/(.{100})/g, "$1\n");
$code.val(encrypted + '\n\n' + '#' + key); $code.val(encrypted + '\n\n' + '#' + key);
return false;
}); });
} }