Looking for the drawings? They're over here, and my drawing blog is this way.
showSource
- Current Version: 1.1
- Last Revision: 11.24.2003
- Requires: Gecko/Moz, Safari, MSIE6, Opera 7.5+
- Language: Javascript/PHP
This new favelet was inspired by a publishing accident yesterday morning where a tool used to move content from a database onto production servers malfunctioned and was spewing out malformed javascript in the onclick events of "a" tags. This of course caused no end of javascript error dialogs pointing to "line 25" and "line 140", etc. The errors themselves weren't difficult to spot in the code thanks to the nature of the screw up, but it got me thinking - why doesn't notepad or mozilla's source view have line numbers?
Enter the showSource favelet.
When I first started on this, I was using getElementsByTagName("html")[0].innerHTML and doing all the regexp work with javascript - this method worked fine in Mozilla, but thanks to MSIE's wacky interpretation of innerHTML, it was absolutely useless in that browser - not to mention a not entirely accurate view of the source since nothing above or below the HTML tags would have been represented.
So now this is a PHP script masquerading as javascript - when the favelet is activated, it passes the location.href of the page you are currently on to the script on slayeroffice, which then fopens() the url, does some regular expression work on the content, then creates a PRE element containing the source of the document with line numbers, alternating background colors for each line and color coded html.
It seems to work pretty well on the sites I've tried it on, and I suppose could come in handy.
That being said, since its PHP and being called from slayeroffice, it won't work for you if your development boxes are firewalled. You'll want to host the PHP file yourself and change the src for the javascript tag in the favelet accordingly. That will also make things nicer for this server. :)
It also will not work on a local file, ie file:///c:/source%20code/slayeroffice/index.html since slayeroffice.com can't connect to your hardrive.
Use the following link to add showSource to your Favorites/Bookmarks:
showSource v1.1