Load cryptoWriter.js and configure. index.html
<div id="container">
<div id="myElement">Some Text</div>
</div>
<script src="cryptoWriter.js"></script>
app.js
new cryptoWriter(document.querySelector("#myElement"));
That's it! You are now running cryptoWriter.js!
The library uses ".innerText" property so be sure to select the element which immediately contains the text and not its parent container.
new cryptoWriter({
randomRounds:5,
completionTime:"auto",
onVisible:true,
delayTime:0.05,
untilDelay:"random",
enabledSets:["letters","lettersCaps","numbers"],
allAtOnce:false
});
Type:Number
Determines the number of random strings of characters displayed before the actual text.
Type:Number/String
Time taken for rendering to complete in seconds
.Its default value is set to "auto", which calculates completion time at 5 characters/second.
If you want to set the speed in terms of chars/second, simply put the value as follows replacing "6" with your desired number.
new cryptoWriter({
completionTime:"6chars"
});
Type:Number
Time delayed in rendering in seconds.
Type:Boolean
Set true if you want the rendering to start once the element is in viewport
Type:String
Determines what to do until rendering begins.
Value |
What it does |
---|---|
random |
Displays a random string until rendering begins. |
same |
Displays the actual text until rendering begins. |
empty |
Displays nothing until rendering begins. |
To display text of your choice simply put that text instead of the above values |
Type:Array
Choose the source of random characters.
To disable all sets leave the array empty.
To enable all sets, set the value to 'all'.
Name |
Characters |
---|---|
letters |
abcdefghijklmnopqrstuvwxyz |
lettersCaps |
ABCDEFGHIJKLMNOPQRSTUVWXYZ |
numbers |
0123456789 |
specialChars |
!@#$%^&*(`)-=[]|\;',./~_+{}:"<>? |
-
Type:Array
-
Create and use a custom set of characters by using this option.
-
Example:
new cryptoWriter(document.querySelector("#myElement"),{ customSet:["$","@","%","5","9","3","a","j"], enabledSets:[] });
-
You can also use customSet along with enabledSets.
var emojis = "😀😃😄😁😆😅😂🤣🥲😊😇🙂🙃😉😌";
emojis = Array.from(emojis);
new cryptoWriter(document.querySelector("#myElement"),{
customSet:emojis,
enabledSets:[]
});
Type:Boolean
Controls if text appears one character at a time or all together.
Set this to true if you want all the text to appear at once.
var myElement = $("#myElement").get(0);
new cryptoWriter(myElement);
If you want to play around with the options or want to generate cryptoWriter code for yourself, head over to the
Generator.