Trinithis
09-14-2007, 04:42 PM
1) CODE TITLE: TextFormatter
2) AUTHOR NAME/NOTES: Thomas Eding
3) DESCRIPTION: A simple class to help format strings within an element
4) URL TO CODE: http://trinithis.awardspace.com/TextFormatter/TextFormatter.js
Tested in IE6 and Fx2
Demo: http://trinithis.awardspace.com/TextFormatter/TextFormatter.html
How to use:
var tf = new TextFormatter(document.getElementById("theElement"));
tf.print("This");
tf.println(" is");
tf.setFontFamily("monospace");
tf.println("a test!");
tf.setWidth(15);
tf.setWidthAlign("left");
tf.print("x").print("y").println("f(x,y)"); //you can chain any of TextFormatter's methods like this
tf.print(3.6).print(4.9).println(4.51);
tf.setWidth(); //sets the width to normal if argument is <1 or absent
There are more methods than shown. Just look at the source code and look at the method names. Should be fairly obvious.
NOTE: The methods format(), formatNumber(), and newWrapper() are intended to be used indirectly through other methods.
2) AUTHOR NAME/NOTES: Thomas Eding
3) DESCRIPTION: A simple class to help format strings within an element
4) URL TO CODE: http://trinithis.awardspace.com/TextFormatter/TextFormatter.js
Tested in IE6 and Fx2
Demo: http://trinithis.awardspace.com/TextFormatter/TextFormatter.html
How to use:
var tf = new TextFormatter(document.getElementById("theElement"));
tf.print("This");
tf.println(" is");
tf.setFontFamily("monospace");
tf.println("a test!");
tf.setWidth(15);
tf.setWidthAlign("left");
tf.print("x").print("y").println("f(x,y)"); //you can chain any of TextFormatter's methods like this
tf.print(3.6).print(4.9).println(4.51);
tf.setWidth(); //sets the width to normal if argument is <1 or absent
There are more methods than shown. Just look at the source code and look at the method names. Should be fairly obvious.
NOTE: The methods format(), formatNumber(), and newWrapper() are intended to be used indirectly through other methods.