function EncryptDialog(textArea) { this.visible = true; this.textArea = textArea; this.sack = new sack(DOKU_BASE + "lib/exe/ajax.php"); // read cached password if ((JSINFO['crypto_cache_password'] == 1) && (JSINFO['crypto_password'] != undefined)) { this.password = ' value="' + JSINFO['crypto_password'] + '"'; } else { this.password = ""; } // create HTML Structure this.dialog = document.createElement('div'); this.dialog.id = 'encrypt_dialog'; this.dialog.className = 'picker cryptodialog'; this.dialog.style.top = (findPosY(textArea)+20)+'px'; this.dialog.style.left = (findPosX(textArea)+80)+'px'; this.textArea.form.parentNode.appendChild(this.dialog); this.dialog.innerHTML = '
'+ ' ' + LANG.plugins.crypto['encrypt_dialog_title'] + '
' + '
' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + '
' + LANG.plugins.crypto['input_secret'] + ':
' + LANG.plugins.crypto['repeat_secret'] + ':
' + '
'; // attach event handlers drag.attach(this.dialog, $('encrypt_dialog_header')); var dialog = this; $('encrypt_dialog_password1').focus(); $('encrypt_dialog_password1').onkeypress = function(event) { if (event.keyCode==9) { $('encrypt_dialog_password2').focus(); return false; } if (event.keyCode==13) { $('encrypt_dialog_button_encrypt').onclick(); } return true; }; $('encrypt_dialog_password2').onkeypress = function(event) { if (event.keyCode==9) { $('encrypt_dialog_button_encrypt').focus(); return false; } if (event.keyCode==13) { $('encrypt_dialog_button_encrypt').onclick(); } return true; }; $('encrypt_dialog_button_encrypt').onkeypress = function(event) { if (event.keyCode==9) { $('encrypt_dialog_password1').focus(); return false; } return true; }; // register destructor $('encrypt_dialog_close').onclick = function() { dialog.textArea.focus(); dialog.textArea.form.parentNode.removeChild(dialog.dialog); dialog.visible = false; dialog.dialog = null; dialog.textArea = null; }; $('encrypt_dialog_button_encrypt').onclick = function() { var selection = getSelection(dialog.textArea); var text = selection.getText(); if ($('encrypt_dialog_password1').value == $('encrypt_dialog_password2').value) { dialog.sack.setVar("call", "crypto_encrypt"); dialog.sack.setVar("secret", escape($('encrypt_dialog_password1').value)); dialog.sack.setVar("data", escape(selection.getText())); dialog.sack.onCompletion = function() { pasteText(selection, dialog.sack.response); $('encrypt_dialog_close').onclick(); }; // cache the password if (JSINFO['crypto_cache_password'] == 1) { JSINFO['crypto_password'] = $('encrypt_dialog_password1').value; } else { JSINFO['crypto_password'] = ""; } dialog.sack.runAJAX(); } else { alert(LANG.plugins.crypto['encrypt_secrets_dont_match']); } }; };