adding javascript function to TW5

207 views
Skip to first unread message

RunningUtes

unread,
Jul 9, 2017, 4:21:40 AM7/9/17
to TiddlyWiki
I would like to add a javascript function to TW5 but am not sure how to accomplish it.


Specifically, I would like to add the JavaScript library steganography.js. This library uses two functions:
  • encode takes a message as String and a image as Image, HTMLImageElement or String representing the data-URL of the cover image. Returns the data-URL of the image with the encoded message inside.
  • decode takes a image as Image, HTMLImageElement or String representing the data-URL of the image and returns the message which was found in the image.
Can this be accomplished in TW5 using macros?
\define StegEncode(text, image)

function hide() {
 
var stego = document.getElementById("stego"),
 img
= document.getElementById("img"),
 cover
= document.getElementById("cover"),
 message
= document.getElementById("message"),
 textarea
= document.getElementById("text"),
 download
= document.getElementById("download");
 
if(img && textarea) {
 cover
.src = steg.encode(textarea.value, img, {"width": img.width, "height": img.height});
 stego
.className = "half";
 message
.innerHTML="";
 message
.parentNode.className="invisible";
 download
.href=cover.src.replace("image/png", "image/octet-stream");
 
}
 
}
\end

I'm just not sure how to mix the javascript with the macro variables from tiddlywiki.

Thomas Elmiger

unread,
Jul 9, 2017, 4:45:59 AM7/9/17
to TiddlyWiki
Take a look at this: http://tiddlywiki.com/dev/index.html#JavaScript%20Macros

You will notice that there is no direct access to DOM-objects …

Maybe you would profit from inspecting Jed’s existing solution here: http://ooktech.com/jed/ExampleWikis/TiddlySteganography/#%24%3A%2Fplugins%2FOokTech%2FTiddlySteganography

Good luck!
Thomas

Jan

unread,
Jul 9, 2017, 4:53:09 PM7/9/17
to tiddl...@googlegroups.com
Hi again Thomas,
you once posted a kind of instrucional experiment on integrating a
va-script ( It must be about one and a half years ago... )
I already looked for it in the some time ago and was not able to locate
it, could you post it again.

Best Wishes, Jan

Thomas Elmiger

unread,
Jul 10, 2017, 2:26:57 AM7/10/17
to TiddlyWiki
Hi Jan

Sorry I have no idea what a va-script is … maybe parts of your request were eaten by Google Groups? Or maybe it was from someone else?
Do you have any additional hints?

Would be happy to help,
Thomas

Jan

unread,
Jul 10, 2017, 5:41:00 AM7/10/17
to tiddl...@googlegroups.com
Hallo Thomas,
it was one of the first Emails where I read your name...and I think it was demonstrating a Mathtask in JavaScript.
I just remember I liked it...but perhaps it is a false Memory.

Yours Jan
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/bb3f2970-e903-4d17-8fba-8eea8fda3d95%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thomas Elmiger

unread,
Jul 10, 2017, 8:54:35 AM7/10/17
to TiddlyWiki

Jan

unread,
Jul 10, 2017, 12:18:07 PM7/10/17
to tiddl...@googlegroups.com
Hello THomas
Great, it was exactly what I looked for. For I am bloody beginner to
java script, this seems to be a very good start for me.
Perhaps I will use some of the elements of your cours in school,
therefor it is practical that it is in german.

Yours Jan

Jan

unread,
Jul 10, 2017, 12:18:09 PM7/10/17
to tiddl...@googlegroups.com
Hello Thomas
Great, it was exactly what I looked for. For I am bloody beginner to
java script, this seems to be a very good start for me.
Perhaps I will use some of the elements of your cours in school,
therefor it is practical that it is in german.

Yours Jan





Am 10.07.2017 um 14:54 schrieb Thomas Elmiger:
Reply all
Reply to author
Forward
0 new messages