Ajax Bestiary: A Javascript Field Guide
 
Ajax Bestiary: A Javascript Field Guide
 
 

Entries Tagged as 'Tools'

Converting Between Wiki Markup & HTML with Prototype

Posted by Don Albrecht

Wiki’s are amazing and powerful tools, unfortunately their dependence on specialized markup creates a huge barrier to their general adoption in many organizations.  This is a first step at building a wysiwyg editor for wiki markup.  While I will be focussing on the syntax unique to the popular MediaWiki platform, these techniques should be applicable to any wiki system.

The general flow of the converter is as follows:

  1. Converter is passed the root node of an html fragment to translate.
  2. Converter recurses through each of the child nodes and converts them.
  3. Root node tag is replaced with wiki markup.

There’s really only 2 key components involved in this first pass. A converter object and the recursive method.

The Converter Object

The converter object is little more than a collection of name value pairs.  The name corresponds to an html tag.  The value is a Prototype template to use in the direct replacement of the given node. By convention we’ll write all of the tag names for the converter object in lower case.

var Converter = {
strong: new Template("'''#{body}'''"),
b:  new Template("'''#{body}'''"),
em: new Template("''#{body}''"),
i:  new Template("''#{body}''"),
h1: new Template('=#{body}='),
h2: new Template('===#{body}=='),

h3: new Template(’===#{body}===’),
h4: new Template(’====#{body}====’),
h5: new Template(’=====#{body}=====’),
h6: new Template(’======#{body}======’)  }

The Converter Function

The Converter function always performs 2 checks before attempting to convert a given node.  First it ensures that the node is in fact a node and not a stray function from the Prototype enhanced object.  Next it verifies that a converter exists for the tag.  The toLowerCase() on the tagName is necessary due to the inconsistent behavior browsers demonstrate with this attribute.  While all browsers return the variable in all caps for traditional html, they are not reliable about returning lower case values for xhtml markup.

function convertToWiki( textNode ){
//make sure textNode isn't a function on the object
if( typeof textNode != 'function'){

//provide a way to stop execution on select sub trees
if( !textNode.hasClassName( 'stop')){
$(textNode).childElements().each( convertToWiki );
}

//make sure a converter exists for the given tag
if( liteConverter[ textNode.tagName.toLowerCase() ] ){

//replace the text node with a converted version of itself
textNode.replace( liteConverter[textNode.tagName.toLowerCase()]
.evaluate({body:textNode.innerHTML}));
} } }

Simplify Your Workflow with GuiMags

Posted by Don Albrecht

Let’s face it, prototyping and mock-ups are a pain in the rear. I’m always looking for ways to streamline the early phases of the design process. Today I found one that is simply brilliant.

Meet GUIMags: Simple, whiteboard magnets of common UI components.

Now you can do mockups on the whiteboard with high fidelity symbols that photograph well. Instead of sketching out the entire design for each iteration, you can simply rearrange elements and erase / rewrite labels as you collaboratively work through a design. When you’re done. You can simply take a picture of the whiteboard and start coding your mockup.

You can find GuiMags here:

http://www.guimags.com/index.php

Expand your debugging aresnal with pi.debugger

Posted by Don Albrecht

pi.debugger is a new debug console that acts as a graceful counterpart to firebug.  I’ve  and Firebug is an awesome tool for debugging, hands down.  Unfortunately, it is Firefox specific and has to be installed on the clients machine.

Firebug lite is great, but it is extremely limited and provides little more than a logging console.  pi.debugger sits somewhere in between.  It’s not as full featured as firebug, but it does provide the ever useful evaluation console as well as a DOM browser.

Check it out here:

http://code.google.com/p/pi-js/

And test drive it here:

http://kodfabrik.com/app/pi.debugger/

Blueprint Layout Tool 0.4 New URL, Significant Polish

Posted by Don Albrecht

BLT4source

BLT4layout I’m pleased to announce a preview release of Blueprint Layout Tool 0.4. This version marks the migration of BLT to its own site at http://www.blueprintlayouttool.com and a focus on dramatic improvements to the source view. Unfortunately, the current development version only supports Firefox, IE, Opera & Safari support will be coming soon.

Key Features:

  • Improvements to style and polish of the interface
  • Dramatic improvements to source view (Powered by CodePress & PHPTidy)
    • Generated Source is well formatted and polished
    • Generated Source is Syntax Highlighted
    • Generated Source is cleaned of most extraneous markup

Known Issues:

  • Source View does not work in Safari and Opera
  • Formatting is off in IE
  • Generated source contains several Mozilla specific tags that still need to be cleaned.

I would also like to take a few moments and draw your attention to Christian Montoya’s Blueprint Constructor application. He takes a different approach to the interface and design of the Layout Tool and has created something quite useful and fun to use. We will be working together to try and achieve similar conventions between our apps.

Check out Constructor at http://lab.christianmontoya.com/construct/

You can read about his design process on his blog at http://www.christianmontoya.com/2007/12/08/construct-01-alpha/

Introducing SilkSprite 2.0 Same Great Icons, 46% less Bandwidth

Posted by Don Albrecht

Today I’m pleased to announce the release of SilkSprite 2.0.  Everything about SilkSprite stays the same but the decompressed file size drops by an astounding 46%.

Key Improvements

  • 11% decrease in size for sprite.css
  • 50% decrease in size for sprites.png

My special thanks go out to Andrew France for achieving such amazing compression of the png file.

You can find the new version here:

http://www.ajaxbestiary.com/Labs/SilkSprite/ 

Meet Microsoft Volta: .Net compiled Javascript

Posted by Don Albrecht

logo-voltaMuch like Google’s GWT, Microsoft’s new Volta project compiles .net assemblies into client side ajax interfaces without requiring a line of javascript.

From the press release:

You architect and build your application as a .NET client application, assigning the portions of the application that run on the server tier and client tier late in the development process. You can target either web browsers or the CLR as clients and Volta handles the complexities of tier-splitting. The compiler creates cross-browser JavaScript for the client tier, web services for the server tier, and all communication, serialization, synchronization, security, and other boilerplate code to tie the tiers together. In effect, Volta offers a best-effort experience in multiple environments without requiring tailoring of the application.

Check it out at labs.live.com/volta/

Google Charts API

Posted by Don Albrecht

Yellow line chartOutsource your charting to Google!  Yesterday I discussed my initial experiences with the Flot charting library.   Today, I’m going to give you a brief introduction to the excellent new Google Charting API.How it works, simply embed an image tag in your source that references the google chart API location followed by a set of parameters specifying the actual chart.  Google then renders the chart as a PNG that can be displayed in the browser.Features:

 

Parameter Line chart Scatter plot Bar chart Venn diagram Pie chart 
Chart title Yes Yes Yes Yes Yes
Chart legend Yes Yes Yes Yes Yes
Colors Yes Yes Yes Yes Yes
Chart and background fill Yes Yes Yes Yes Yes
Multiple axis labels Yes Yes Yes    
Grid lines Yes Yes      
Shape markers Yes Yes      
Horizontal range markers Yes Yes      
Vertical range markers Yes Yes      
Line styles Yes        
Fill area Yes        
Pie chart labels         Yes

Simplify Debugging With Firebug Lite

Posted by Don Albrecht

Firebug Lite in SafariMost of us are familiar with Firebug, the powerful & straightforward debugging extension for firefox.  You may not be familiar with it’s little brother, Firebug lite.

Firebug lite is exactly as it sounds, a light-weight firebug console for any browser.  Simply include the firebug script tag in any page and you’re console.log(); operations will work on any browser (IE, Safari, Firefox & More).  What’s more, if Firebug is installed in Firefox, it logs to the full Firebug console.  You can pull up the console by hitting F12 or CTRL + SHIFT + L at any time.

Don’t want to bother with hitting F12 every time you reload?  Just attach a debug=”true” attribute to the html element (<html debug=”true”> ).

But wait, There’s more.

Firebug Lite has an even littler sibling called Firebugx.  Replace the call to firebug.js with a call to firebugx.js and you neutralize any console calls in your code without having to hunt them down or find / replace.  Something that would have saved me a whole heap of trouble with the last BLT deployment.

Download Firebug Lite at:

http://www.getfirebug.com/lite.html 

Blueprint Layout Tool 0.3

Posted by Don Albrecht

BLT3

I’ve made some progress and BLT in the last week and thought it has reached a good point to release for feedback.

New Features

  • Border Support
  • All columns can be resized by clicking on them (even nested columns)
  • All columns can be selected by clicking on them
  • New Properties Panel
    • Control Border & Last attributes
    • Change ID on any div
  • Improved sorting

Please post your comments below.
Get it online here:

http://www.ajaxbestiary.com/Labs/BLT2/

Known Issues:

  • Interface doesn’t work well on narrow screens
  • Occasional problems with sorts falling outside of the page
  • Output needs dramatic cleanup
  • Files need minified & optimized to improve download time & performance
  • Issues remain with formatting & .png rendering on IE. I hope to address these ASAP.

This version has been tested in safari 3, FF 2 & IE 7. Please test in other browsers if possible.

FastInit: SuperCharge Your Pageloads

Posted by Don Albrecht

What is it:

FastInit is a small JS file to create a Faster window.onload. It implements a powerful onload function queue that fires once teh dom is ready and before all images have been downloaded. Ideally, this results in a dramatic decrease in a pages initialization time.

How it Works

You any functions to the queue by using the FastInit.addOnLoad( function 1, function 2, …); function. All functions are fired in the order in which they were added to the queue. addOnLoad can be called as many times as is necessary. It fails gracefully to standard handlers if the browser doesn’t support the faster methods.

Requirements

As of version 1.4.1 the need for Prototype has been removed freeing the code for use in any project where a speedy onload method is needed.

Check it out here:

http://tetlaw.id.au/view/javascript/fastinit