Shopping Cart

When you sign up for a class your PayPal email address will be used to send you a confirmation
and reminder the day before your class. If you want to use a different email, enter it above.

If you can't make a class please request a cancellation. Cancellations and rescheduling requests must be made at least one week prior to the class for a full refund. Cancellations submitted less than one week before the class will only be refunded if we can fill your slot.

The new TX/RX blog site uses WMD editor, a what-you-see-is-what-you-mean markdown editor. You can use this to add any image, but we have our own image library that we want to pull in images from (so that we can re-use photos elsewhere on the site, coming soon!), so we needed to overwrite the image button. This technique could easily be used to add buttons.

varimageButton=document.createElement("li");imageButton.className="wmd-button";imageButton.id="wmd-image-button";imageButton.title="Image <img> Ctrl+G";imageButton.XShift="-100px";imageButton.textOp=function(chunk,postProcessing,useDefaultText){returninsertImage(chunk,insertShortCode);// this line was changed};setupButton(imageButton,true);buttonRow.appendChild(imageButton);

The only line changed is commented above (only editing one line allows for easy updating and less unforeseen errors). Rather than modifying the whole file I created a function insertImage that accepts wmd-editor's chunk as an argument and a callback function insertShortCode.

This stashes the chunk and a few other variables away for future use and then opens an iFrame with my image library. Clicking on an image in the iFrame then calls window.parent.iframe_callback(image_object), which gets the "short code" from the image objects, inserts it into the editor and closes the modal.

Comments

chriscauley- Tuesday,
December 25, 2012
at 10:33 p.m.

Oh, I also added commenting functionality. That's kind of cool, but needs work.

About TXRX Labs

Established in 2008, TXRX Labs is a non-profit hackerspace for the greater Houston area.
Housed in the East End District, we offer courses in and access to our rapid prototyping lab,
woodshop, machineshop, electronics lab, and a wide variety of other tools. Our goal is to
educate the public about technology and show how seemingly complex techniques can be used
by anyone. If you like what we do, please donate.