JavaScript

Constant Prototyping and Design

A co-worker gave a presentation on a project we worked on a long time ago and he asked me to update an feature in the web application. The web app was originally programmed in ASP and I had almost forgotten how painful it was to work in that environment. The new request was to enable live presence information in a web part using the new RTC libraries. Fortunately, another developer had a component to perform all of the calls using the RTC libraries, but I needed to retrieve the group members for the selected group and cross-reference the group members...

posted @ Thursday, July 31, 2008 11:28 AM | Feedback (0)

Just the facts, ma'am

I was looking at Douglas Crockford's 360 blog today and came across a hilarious quote: Do you write regularly for any publications in this field? Just the blogs. In researching the book, did you come across any surprising facts, figures, or statistics that the press might be interested in? Surprisingly, facts have very little to do with web development. Douglas Crockford is simply amazing and is the original author of expat (one of the first XML parsing libraries), as well as JSLint, JSMin, and JSON (one of the primary components of AJAX). P.S. Bonus points for...

posted @ Monday, April 21, 2008 10:15 AM | Feedback (0)

SVG Building Map (Part 1)

Due to blog restrictions, the sample is located on a separate page. building.html: SVG sample BuildingSample01.zip: source (6KB) Note: In my previous blog entry, I stated that SVG is a technology with diminishing support and that ultimately I plan to convert this building map to SilverLight. The first example is a very basic building map. I created a simple SVG file to represent a building and then created occupants for the building (as if you could keep these crazy rascals in a building -- look at the names and you should know what I mean). For simplicity this sample does...

posted @ Thursday, December 06, 2007 11:33 PM | Feedback (0)

Best Practice for Verbatim String Text Block

I was browsing various blogs today and I came across a good example for using a verbatim string instead of a StringBuilder object. The code I came across looked like this (I mean absolutely no disrespect to the author, so I won't include the original link):private void ClientScript() { StringBuilder sb_Script = new StringBuilder(); sb_Script.Append("<script language=\"javascript\">"); sb_Script.Append("\r"); sb_Script.Append("\r"); sb_Script.Append("function cb_verify(sender) {"); sb_Script.Append("\r"); sb_Script.Append("var val = document.getElementById(document.getElementById" +"(sender.id).controltovalidate);"); sb_Script.Append("\r"); sb_Script.Append("var col = val.getElementsByTagName(\"*\");"); sb_Script.Append("\r"); sb_Script.Append("if ( col != null ) {"); ...

posted @ Friday, November 23, 2007 12:05 AM | Feedback (0)

Using dpSyntaxHighlighter in Subtext

I finally worked on my blog theme last night and I managed to get the dp.SyntaxHighlighter to work with Subtext. I recall seeing someone else use it with Subtext, but I can't locate the blog anymore. Here are the steps involved: Create a custom skin for Subtext Copy the shCore.js, shBrushCSharp.js, shBrushXxx.js files in the custom skin Scripts directory (~/Skins/YourCustomSkin/Controls) Copy the SyntaxHighlighter.css file to the custom skin Styles directory (~/Skins/YourCustomSkin/Styles). If you choose to use the Flash clipboard.swf functionality, place it in the root Scripts directory. Create a Skins.User.config file in the ~/Admin directory. Add...

posted @ Friday, November 16, 2007 12:00 PM | Feedback (0)

Throw Away Knowledge

I have spent the past hour trying to modify a VBScript / JavaScript utility to print out my password expiration date and it is driving me a little crazy. I cannot understand why something that should be so simple can be so blasted difficult. I have several account at client sites and the password expires periodically. In order to make sure I don't let the account lapse, I wanted to print the password expiration date. I had a version that worked before but the distinguishedName had to be exact. I used the adfind utility to figure out my distinguished name...

posted @ Tuesday, November 13, 2007 3:59 PM | Feedback (0)

Formatting Exponentials in Javascript

A while back I needed the dashboard for the Key Performance Indicators (KPI) to display nicely formatted numbers. When the KPI values started to get large (millions, billions, etc.) the numbers became almost unreadable. In order to simplify the display of the numbers, I ended up converting the values to scientific notation. However in order to make the numbers even more readable, I converted the scientific notation into powers of 103. I converted the floating point number into a string that was still a valid floating point number, but it used the exponential notation such as 1.0e6. I then used a regular expression to convert the exponent into...

posted @ Thursday, March 01, 2007 12:54 PM | Feedback (0)

Convert date to UTC format in JavaScript

A couple of years ago I had to print dates in JavaScript in UTC (ISO-8601) format. Here is the function that I developed. It assumes the date object has the correct time zone offset and uses the time zone offset from the object. I also developed server-side C# code for formatting dates in ASP.NET pages which I'll post soon. function pad(value, digits, padtext) { if (!padtext) padtext = "00000000"; if ((digits == null) || (typeof(digits) == "undefined")) return value; if ((value == null) || (typeof(value) == "undefined")) return value; var length = value.toString().length; if ((length < digits) && (digits < padtext.length)) return padtext.substr(0, digits - length) + value.toString(); else return value; } function...

posted @ Tuesday, January 23, 2007 10:45 AM | Feedback (0)