Sidejar methods
Built-in functions on the global Sidejar object. Use them by name in attributes (onpaid="Sidejar.decrypt") or call them from your code. Each takes the content as a string and returns a string (or a Promise of one), so they combine.
| Method | Use | Returns |
|---|---|---|
Sidejar.decrypt(content, key?) |
unlock | Decrypts content made by Sidejar.encrypt. As a handler, uses data-key or the default key. Async. |
Sidejar.decryptWith(key) |
unlock | A decrypt function bound to your key. |
Sidejar.decodeBase64(content) |
unlock | Decodes base64 (UTF-8). |
Sidejar.json(content) |
unlock | Parses JSON, with a clear error if it's invalid. |
Sidejar.reveal(content) |
unlock | The content as-is (the default). |
Sidejar.encrypt(content, key?) |
tooling | Encrypts content: returns "sj1.…". Async. |
Sidejar.encodeBase64(content) |
tooling | Encodes as base64 (UTF-8). |
Sidejar.effects |
effects | The built-in effects by name, to call from your own effect. |
Sidejar.placeholder(content) |
stand-in | Grey skeleton lines about as long as the content. |
Sidejar.blur(content) |
stand-in | Gibberish of about the content's length, blurred. |
Sidejar.scramble(content) |
stand-in | Gibberish of about the content's length, in the same layout. |
Sidejar.teaser(content, { words }) |
stand-in | The first words words (default 40), fading out. Needs unencrypted content; an intro usually does this better. |
Combining them in your own function:
<script>
async function decryptAndSign(content) {
return (await Sidejar.decrypt(content)) + "<p>— Thanks for reading!</p>";
}
</script>
<sidejar-content for="tip" onpaid="decryptAndSign">…</sidejar-content>