mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-26 19:47:20 +00:00
Add support for custom password prompts
This commit is contained in:
parent
67db9d57a2
commit
0c8e538077
@ -1244,10 +1244,14 @@ Decrypt any tiddlers stored within the element with the ID "encryptedArea". The
|
||||
$tw.boot.decryptEncryptedTiddlers = function(callback) {
|
||||
var encryptedArea = document.getElementById("encryptedStoreArea");
|
||||
if(encryptedArea) {
|
||||
var encryptedText = encryptedArea.innerHTML;
|
||||
var encryptedText = encryptedArea.innerHTML,
|
||||
prompt = "Enter a password to decrypt this TiddlyWiki";
|
||||
// Prompt for the password
|
||||
if($tw.utils.hop($tw.boot,"encryptionPrompts")) {
|
||||
prompt = $tw.boot.encryptionPrompts.decrypt;
|
||||
}
|
||||
$tw.passwordPrompt.createPrompt({
|
||||
serviceName: "Enter a password to decrypt this TiddlyWiki",
|
||||
serviceName: prompt,
|
||||
noUserName: true,
|
||||
submitText: "Decrypt",
|
||||
callback: function(data) {
|
||||
|
@ -0,0 +1,15 @@
|
||||
title: How to customise the password prompt
|
||||
tags: howto
|
||||
created: 20141006085526118
|
||||
modified: 20141006085526118
|
||||
|
||||
You can customise the text and appearance of the password prompt that is displayed when encrypted TiddlyWiki files are first opened.
|
||||
|
||||
To do so, create a tiddler tagged {{$:/core/wiki/rawmarkup|$:/core/ui/TagTemplate}} containing:
|
||||
|
||||
# A JavaScript `<script>` tag containing code to override the configuration variable `$tw.boot.encryptionPrompts.decrypt`
|
||||
# CSS `<style>` definitions targeting the `tc-password-wrapper` class to apply styles to the form
|
||||
|
||||
Raw markup tiddlers are spliced into the top of the standalone HTML file, and are executed before the boot prefix and boot kernel.
|
||||
|
||||
See $:/PathEncryptionPrompt for an example.
|
33
editions/dev/tiddlers/system/PatchEncryptionPrompt.tid
Normal file
33
editions/dev/tiddlers/system/PatchEncryptionPrompt.tid
Normal file
@ -0,0 +1,33 @@
|
||||
title: $:/PatchEncryptionPrompt
|
||||
tags: $:/core/wiki/rawmarkup
|
||||
|
||||
<script>
|
||||
|
||||
window.$tw = window.$tw || Object.create(null);
|
||||
$tw.boot = $tw.boot || Object.create(null);
|
||||
|
||||
$tw.boot.encryptionPrompts = {
|
||||
decrypt: "Decrypt this TiddlyWiki by entering the password"
|
||||
};
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body .tc-password-wrapper {
|
||||
background-color: rgb(183, 197, 235);
|
||||
border: 8px solid rgb(152, 164, 197);
|
||||
}
|
||||
|
||||
body .tc-password-wrapper form {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
body .tc-password-wrapper h1 {
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
body .tc-password-wrapper input {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user