Monday, September 14, 2015

Some Crazy Javascript

I've just finished an improvement for my Card Creator. Now if you click on a text area to edit it, rather than a popup that you have to type HTML into, you will be able to edit the text in place. You still have to use HTML tags for things like bold and italic text, but you don't need to use the "br" tag for newlines anymore, which makes it much easier to lay out elements on the larger text areas. It doesn't always look terribly pretty during editing, but it does make it a lot easier to use.

There was some interesting javascript involved, which included creating text boxes when you click on an element, removing the onclick function so it doesn't interfere with the editing process, then when the text box loses focus copying the text back to the original area, deleting the text box, and restoring the onclick function. It's trickier than it sounds, and inserting it into Blogspot took a bit of faffing about too.

Now if only I could figure out a way to export the cards without having to resort to using screenshots.

No comments:

Post a Comment