Scott Hanselman

A JavaScript implementation of innerText (not innerHtml) for FireFox and non-IE browsers.

February 8, '05 Comments [10] Posted in ASP.NET | Javascript
Sponsored By

In the sick, twisted word of cross-browser DOM-based JavaScript, sometimes you need to get the contents of an element. You usually use element.innerHTML, but often you don't want any existing sub-tags that might be in there. You want .innerText! But, innerText is only available on IE. Poop.

So, I needed this today, and my buddy Stuart found a solution here. Sick, yes. Twisted, yes. Works, yes. Moving on.

    <script type="text/javascript">
      var regExp = /<\/?[^>]+>/gi;
      function ReplaceTags(xStr){
        xStr = xStr.replace(regExp,"");
        return xStr;
      }
    </script>

All you need to do is pass it a string and it returns the string stripped of the tags. An example is shown below to grab the text from a div without the tags.

<html>
  <head>
    <script type="text/javascript">
      var regExp = /<\/?[^>]+>/gi;
      function ReplaceTags(xStr){
        xStr = xStr.replace(regExp,"");
        return xStr;
      }
    </script>
  </head>
  <body>
    <div id="test">
      <span id="span1">Test <u><b>Test</b></u> Test <br/><a href="#">Wow</a>!</span>
    </div>
    <script type="text/javascript">
      var xContent = document.getElementById("test").innerHTML;
      var fixedContent = ReplaceTags(xContent);
      alert(fixedContent);
    </script>
  </body>
</html>
[Eric's Weblog]

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Adding Tabs to Internet Explorer (IE) and the Rise, no, uh, er, fall of the Integrated Application

February 5, '05 Comments [6] Posted in Speaking | Tools
Sponsored By

I was asked today how to add Tabs and Tabbed Browsing to IE. Since "Use FireFox" wasn't appreciated as an answer, I pointed them to:

  • MyIE2/Maxthon - Renamed Maxthon recently, this has a load of toolbars, Skins, Gestures and
  • AvantBrowser - Feels from MDI and is free. Includes Skins, cleans up your tracks and filters Flash.

Which got me thinking. Is there room for IE-based browsers? Or are they just potential spyware-carriers? Do we need another browser? So many people were lamenting the lack of an IE7 on the Horizon and have been moving away from the "one browser/webapp for them all" view as RSS Readers are being favored by many over the integrated experience. Are there too many apps out there? We seem to oscillate between lots of 'applets' and lots of do-it-all apps.

Visual Studio seems to be taking lots of the best Add-In (applet) ideas and merging them into the mainline making Visual Studio the "Outlook" of development. I'm the guy with lists of utils, but in an average day, I may only touch:

  • iTunes
  • VS.NET (with a crapload of addins)
  • Virtual PC
  • Dragon NaturallySpeaking
  • Word
  • Outlook (with NewsGator)
  • BlogJet
  • VS.NET Command Prompt
  • Messenger

This is a pretty small list. Does this show some kind of pattern? Are apps becoming more laser focused? or more shotgun approach? Is there room for a dozen different RSS Readers? or just a few?

I also wonder if we're "red vs. blue-ing" the desktop application space:

  • Thunderbird vs. Outlook/Entourage
  • Newsgator vs. FeedDemon
  • Word vs. OpenOffice
  • Messenger vs. Trillian
  • VS.NET vs. Eclipse
  • Virtual PC vs. VMWare

I know it's not that really that polarized, but sometimes it feels as such. I guess that's just the magic of evolution/opensource/freemarket ecomony.

Hm.

Now playing: Mos Def - Next Universe..

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

The DebuggerDisplayAttribute in Visual Studio 2005 and IFormattable

February 4, '05 Comments [5] Posted in ASP.NET | Ruby | Bugs
Sponsored By

I didn't realize this when I did my generic IFormattableObject implementation last week, but this week finds me writing a chapter on Debugging for an ASP.NET 2.0 book.

I was checking out the DebuggerDisplayAttribute and realized that it uses a similar format string style as my stuff. (Of course, my stuff isn't new, languages like Ruby and others have done it for years).

Anyway, the point was that I had been wondering if my idea "fit" into the world of .NET, but the syntax of this DebuggerDisplay attribute left me feeling more justified for my work. It's interesting though, that they are offering this attribute, when I always used ToString to do the same basic thing in the debugger. So, in a Whidbey world of DebuggerDisplayAttribute, what's ToString() for? I guess just Console.WriteLine(myObject)?

UPDATE: The "TracePoint" syntax in the VS 2005 Debugger is the same.
For example: {i.FirstName} Function: $FUNCTION, Thread: $TID $TNAME
prints out the variable i's property FirstName as well as some psuedo-variables like the current function, the Thread ID and Thread Name

Syntax Description
[DebuggerDisplay(
  "{_forename} {_surname}")]
Uses the private _forename and _surname members
[DebuggerDisplay(
  "Employee- {ToString()}")]
The ToString method is called to provide the textual representation to be displayed as the value of the object
[DebuggerDisplay("Employee
  ( {Forename} {(_wizard) ?
  \"Is a Wizard\" : \"Is 
  \"Is not a Wizard\" } )")]
An expression is evaluated in order to provide a differing representation to the user based on the value of a flag

Now playing: Kevin Lyttle - Turn Me On

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

TestDriven.NET Keyboard Bindings for Visual Studio.NET

February 2, '05 Comments [4] Posted in Bugs | Tools
Sponsored By

I've been meaning to do this for months, and Gordon reminds me to. If you are a TDD person and you use Test Driven.NET, nothing has changed your development life in the last year than right-click "Run Tests."  I was always irritated by the mouse action, and never got around to assigning keys. Now I've assigned Ctrl-Alt-F5 to "TestDriven.NET.Debugger." That along will save me at least 10 minutes of mousing in a development day.  I've also added Shift-Ctrl-T (Test) to compliment Shift-Ctrl-B (Build).

TestDriven.NET Keyboard Bindings -I did a little exploring today and discovered that you can assign keystrokes to these commands. Under Tools | Options, Keyboard, the commands you're looking for are:

TestDriven.NET.Client - The equivalent of the run test cases menu option, this will run test cases on whatever the active window is.
TestDriven.NET.Debugger - This is the same as the run in debbuger option, it will run the code in the active window in the debugger.
TestDriven.NET.Solution - This will run all the test cases in the current solution
The 80/20 Solution - TestDriven.NET Keyboard Bindings

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Explaining the Ethiopic Numbering System and a tiny lesson on Amharic

February 1, '05 Comments [7] Posted in ASP.NET | Speaking | Nant | Africa
Sponsored By

Fantastic stuff from Michael Kaplan today, he did me a favor and dissected the Ethiopic numbering system. He points us to two good sites on Ethiopic Numerals. One at Geez.org and one at the venerable AbyssiniaCyberGateway.

You can test your browser's support for the Fidel here. Personally, I use the GF Zemen Unicode font (TrueType) as it appears to be the most complete with 608 glyphs.

For example, the number 2345 is represented by

2,345 = (20 + 3)*100^1 + (40 + 5)*100^0
      = 20 3 100 40 5
      = TWENTY THREE HUNDRED FORTY FIVE
      =
1373 136b 137b 1375 136d 
      = ፳፫፻፵፭

There's a lot of rich Ethiopian culture in the states. There are more Ethiopians in Washington D.C. than anywhere else outside of Addis Ababa. The NW, where I live, experienced an influx of Ethiopians and Eritreans during the 80s. There are many thousands in both Portland and Seattle.

I'd posted previously touting Word's support for Amharic. I went to junior college with a number of Ethiopians and picked up a colloquial chunk of Ethiopian Amharic, the language of the Amhara people.  It's a fantasticly interesting language to learn. Here's a few interesting bits.

  • Ethiopians and call themselves "'Abesha" or "Habesha" with a soft h. One would ask a person if they are Ethiopian by saying "Habeshane?" (Male) or "Habeshanesh?" (Female) or "Hebeshanot?" (Elder).
  • The Fidel is the Ethiopian alphabet - however, not that Amharic isn't strictly an alphabet, it's a syllabary. I have a number of Amharic dictionaries, as well as a number of "Fidel" hanging in my house.
  • Very roughly, Ge'ez is to Amharic as Latin is to English. If you go to an Ethiopian Orthodox church or read an older bible, they will use Ge'ez.
  • The syllabary uses a consonant root then modifies it with a vowel addition. This might make more sense looking at the SERA Syllabary for the Fidel. The root is on the far left as a GIF and is modified as we move to the right.
  • English speakers learn our A,B,Cs, but Amharic/Fidel learners sing "Ha, Hu, Hi, He, HE, h, ho" and do each consonant with each vowel as if they were doing a traversal of a grid.
  • Amharic is an "afro-semetic" language, which feels slightly like Hebrew with some Arabic twists.
  • A graphic illustrating the history of the written language is found here. Note the slighly Coptic pictographic look of the Old-North Semitic that morphs into a more structured, but still pictographic Old Abyssinian. However, you can see elements of current Ethiopic (Ge'ez) in all of them. The letters each take up one row in this graphic.
  • There isn't an explicit word for "No" - instead there are "negations" that indicate what you just said "isn't so." If you ask an Amharic-speaking Ethiopian what the word for "No" is, they will likely say "Aye" which is short for "Ayedellum" which means "It isn't so." So, it wasn't good (t'iru) you might says "t'iru ayedellum" indicating "good it was not."
  • The negation isn't added until the very end of a sentence, where verbs are typically added as well. That means you may be a while into a sentence before the "no" comes along.
  • "Amharigna k'wank'wa ba'tam aschaGari' nowe" = "Amharic language very difficult [it] is" versus "Amharigna k'wank'wa ba'tam aschaGari' ayedellum" = "Amharic language very difficult [it] is NOT"
  • There are a number of 'official' and quasi-official transliteratons to English lettering, most use ' to indicate glottal or aspirated tones. Meaning T and T' are different, with the latter being more explosive.
  • Some details on the UNICODE representation of Ge'ez are here in PDF.
  • COOL: You can GOOGLE in Amharic or Tigrigna (the language of the Tigre [teg-gray], or Eritrea)
  • You can learn lots about Amharic or Tigrinya with software this company or use the Lonely Planet phrasebook. Don't even try to pronounce it without a native (or a pompous white guy). They also have a rocking sweet Fidel-"Matrix" Screen Saver.
  • Supposedly the news of Christ's birth didn't reach Ethiopia for seven years, so their calendar is different. Today is the 24th of T'er 1997. They have 12 months of 30 days and 1 small 13th month that everyone takes as vacation of 5 days.

Wow, that was a lot of info that just came pouring out. Well, I've got more in my head so if you ever want to hear about it, come find me.

- ሰካት (s'ka't ~ Scott)

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.