WebToolkit.info Scripts Wrapped

by Jon Davis 30. March 2008 02:59

A buddy and I were poking around at the sample scripts at http://tide4javascript.com when my buddy noticed a crc32 implementation. I followed the trail and found a number of interesting utility scripts at webtoolkit.info.

I thought they were pretty worthy so I wrapped them up and packaged them as a utility library and posted it here:

http://cachefile.net/scripts/webtoolkit.info/ 

I also added a test page, which also makes for a decent quick and dirty demo page.

http://cachefile.net/scripts/webtoolkit.info/2008.03.30/test.html 

UPDATE: I stumbled upon a blog post called "Top Ten Javascript Functions of All Time" (http://www.dustindiaz.com/top-ten-javascript/). I decided to append these functions. I quickly deprecated the webtoolkit.info URL and made it just "webtoolkit".

Currently rated 1.5 by 2 people

  • Currently 1.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Web Development

innerXHTML DOM-to-XHTML Generator in Javascript

by Jon Davis 13. March 2008 00:25

Developers often need XHTML-compliant HTML markup when they fetch DOM elements' innerHTML. Since the W3C hasn't standardized on this property (and I don't know why?!), the browsers have been inconsistent in their approaches to innerHTML. Firefox doesn't put the trailing slash in <br> tags, for instance, while Internet Explorer shows tags in all-caps and strips the quotation marks from some attributes.

This week after my rant got posted on Ajaxian.com, I figured I'd do my part to express my sincerity with the situation of by creating innerXHTML() and outerXHTML() functions in Javascript. Not the first-ever effort, but seemed appropriate considering the strong weight of my public rant. I intended to add it to the prototype of HTMLElement, but *gasp* .. wouldn't you know it, Internet Explorer doesn't expose a prototype for DOM elements!! Ack!! (Dang it, IE team, get out of your cave. :P )

So, take it or leave it, I wrote the innerXHTML() and outerXHTML() functions anyway, added them to the HTMLElement prototype for browsers that support it (yay Firefox), and added xhtml() for innerXHTML() equivalence for jQuery.

I posted it up at http://cachefile.net/scripts/xhtmljs/ with a lightweight test for initial coding efforts. More code than desirable is devoted to formatting (pretty line breaks and tabs), and if you don't like any of that fluff you can turn it off by setting the global variable xhtmlFormatting to "none" or, for now, to anything other than "formatted".

http://cachefile.net/scripts/xhtmljs/ 

Hope everyone likes it. Please give feedback (ideas, concerns, complaints, bug reports, etc) to jon@jondavis.net. I might post this on CodePlex if I get a lot of feedback, but in the absence of feedback I don't see much point.  

kick it on DotNetKicks.com

Currently rated 4.0 by 4 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , , , , , , ,

Web Development

Iconize with CacheFile

by Jon Davis 4. December 2007 02:11

I still owe myself that virtual tarball / .mrr app.

Meanwhile, I've been busy with CacheFile.net in other ways.

  • I set up a new dedicated machine to host the site without worrying about others' sites taking the server down. It runs on Fedora / Apache.
  • On the new dedicated machine, I finally enabled gzip and caching.
  • I've been regularly adding popular script libraries as I find and qualify them.
  • The Graphics section now has two new additions:
    • famfamfam, and
    • Iconify

The latter addition, Iconify, is worth noting. http://cachefile.net/graphics/iconize/cachefile/index.html If you just drop this tag on your page:

<link rel="stylesheet" type="text/css" href="http://cachefile.net/graphics/iconize/cachefile/iconize.css" />

.. or ..

<link rel="stylesheet" type="text/css" href="http://cachefile.net/graphics/iconize/cachefile/iconize_left.css" />

.. you'll instantly get icons to show up on your hyperlinks. No image downloads necessary!

Update: Of course, this doesn't work across different domains when using Internet Explorer. *sigh* 

kick it on DotNetKicks.com

The Virtual Tarball - Second Draft

by Jon Davis 22. November 2007 17:50

In prototyping yesterday's blogged idea with .vtb / .mrr files, I've run into some design flaws with the proposed "schema". Main problem among them is that directory structures are typically not described in flat lists but as <ul> trees. A local file name should not be described as

<li>dir</li>
<li>dir/subdir</li>
<li>dir/subdir/file.ext</li>

.. but rather as..

<ul class="mrrdir">
  <li>dir
     <ul>
       <li class="mrrdir">subdir
       <ul>
          <li class="mrrfile">file</li>
       </ul></li>
     </ul>
   </li>
 </ul>

This makes more sense because it when it is rendered in HTML it is more legible and maintainable in the DOM.

  • dir
    • subdir
      • file.ext

Imagine if this was "fuzzy" and not strict. If the filename could be "subsubdir/file.ext", or worse "C:/windows/system32/file.ext", you run into all sorts of problems trying to target the download destination path. Directory seperators are completely disallowed, then, in the text value of the file's <li> entity.

This changes the programming a bit on the Windows app side, in both easier and more difficult ways. It becomes easier to manage the directories, but now the files' download names have to be managed within the directories virtually. Note that by "difficult" I mean a few extra minutes, not a few extra hours; on the other hand, thinking this through, I've already lost a few hours and decided to start over in my code while it's still a brand new and barely written prototype codebase.

Meanwhile, the href value must assume that the base URI is always the base URI for the entire document, not for the listed directory.

Here's a proposed valid sample .mrr doc, where the base URI is: http://cachefile.net/  

<ul class="mrr">
 <li class="mrrdir">
  <a href="scripts">scripts</a>
  <ul class="mrrdir">
   <li class="mrrdir">
    <a href="scripts/jquery">jquery</a>
    <ul class="mrrdir">
     <li class="mrrdir">
      <a href="scripts/jquery/1.2.1">1.2.1</a>
      <ul class="mrrdir">
       <li class="mrrfile">
        <a href="scripts/jquery/1.2.1/jquery-1.2.1.js">jquery-1.2.1.js</a>
       </li>
       <li class="mrrfile">
        <a href="scripts/jquery/1.2.1/jquery-1.2.1.min.js">jquery-1.2.1.js</a>
       </li>
       <li class="mrrfile">
        <a href="scripts/jquery/1.2.1/jquery-1.2.1.pack.js">jquery-1.2.1.pack.js</a>
       </li>
      </ul>
     </li>
    </ul>
   </li>
  </ul>
 </li> 
</ul>

Rendered in plain HTML:

I'll update this post with a revised Windows app (C#) prototype soon.

The Virtual Tarball

by Jon Davis 21. November 2007 16:11

AFAIK, no one has done this, at least not in this specific way, I have a need for it, and I can see it being used everywhere. So I'm proposing it, and I'm going to implement it.

My idea: The virtual tarball. (Or something?) A file extension of something like .vtb, or .mrr (mirror file). Inside, it looks like it's just an XML file with XHTML-renderable hyperlinks, but the file type is used by an executable that pulls the files down into the specified directory with the <a> tags' text as the save-to file name.

Example contents:

<ul class="mrr">
 <li class="mrrfile">
  <a
 href="
http://cachefile.net/file_a.bin">file_a.bin</a>
 </li>
 <li class="mrrfile">
  <a
 href="
http://cachefile.net/file_b.bin">file_b.bin</a>
 </li>
 <li class="mrrdir">dir1</li>
 <li class="mrrfile">
  <a
 href="
http://cachefile.net/dir1/file_c.bin">dir1/file_c.bin</a>
 </li>
 <li class="mrrfile-alternate">
  <a
 href="
http://otherurl.net/dir1/file_c.bin">dir1/file_c.bin</a>
 </li>
</ul>

Given this sample, here's what Visual Studio outputted as an XML Schema file from automatic conversion:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified"
 elementFormDefault="qualified"
 xmlns:xs="
http://www.w3.org/2001/XMLSchema">
 <xs:element name="ul">
  <xs:complexType>
   <xs:sequence>
    <xs:element maxOccurs="unbounded" name="li">
     <xs:complexType mixed="true">
      <xs:sequence minOccurs="0">
       <xs:element name="a">
        <xs:complexType>
         <xs:simpleContent>
          <xs:extension base="xs:string">
           <xs:attribute name="href"
             type="xs:string" use="required" />
          </xs:extension>
         </xs:simpleContent>
        </xs:complexType>
       </xs:element>
      </xs:sequence>
      <xs:attribute name="class" type="xs:string" use="required" />
     </xs:complexType>
    </xs:element>
   </xs:sequence>
   <xs:attribute name="class" type="xs:string" use="required" />
  </xs:complexType>
 </xs:element>
</xs:schema>

The point of this is that it would look like HTML but it could be processed like a .zip file. Only difference between a .mrr file and a .zip file, other than the fact that a .zip file is compressed and isn't human-readable when introspected, is that a .zip contains the contents, whereas a .mrr file only contains hyperlinks to the downloadable files. In the above example, I also have an "-alternate" class so that the processor can see that as a mirrored repository for the same file.

Oh, and yeah, the point of the XHTML compatibility is partly for inspection and previewing, but also for Javascript DOM support. I'm thinking this could be my "engine" for a web browser script library pre-loader page idea I have for adding as a new feature for cachefile.net.

I'm going to get to work on an open source C# console application for Windows, as well as a Javascript browser caching implementation.

Update: I've spent most of the night prototyping the C# app. I'm calling it Mrrki ("murky"), and settled on .mrr (for "mirror"). Here's my first rough draft build: http://www.jondavis.net/codeprojects/Mrrki/0.1/Mrrki.zip.

kick it on DotNetKicks.com

Introducing CacheFile.net - The Central Repository for Common Internet Resources

by Jon Davis 19. November 2007 05:23

Alright so maybe it's a crappy generic domain name but it's a start. The idea is simple: Get all the popular JavaScript scripts and RSS feed graphics on one common URI. If all web sites can point to that URI for common resources, and the URI never changes for the specified resources, then their users are guarenteed to have a faster and more productive user experience than if all the web sites each had their own copies of the same resources.

It's simple math, really. And a site like this is much needed in the Internet community. Personally I'm shocked and amazed that no one has done it already.

http://cachefile.net/

So then, now it's done. And I'm gonna go get back to work on my other productive projects.

kick it on DotNetKicks.com

Currently rated 4.5 by 2 people

  • Currently 4.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Pet Projects | Computers and Internet | Web Development


 

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

Jon Davis (aka "stimpy77") has been a programmer, developer, and consultant for web and Windows software solutions professionally since 1997, with experience ranging from OS and hardware support to DHTML programming to IIS/ASP web apps to Java network programming to Visual Basic applications to C# desktop apps.
 
Software in all forms is also his sole hobby, whether playing PC games or tinkering with programming them. "I was playing Defender on the Commodore 64," he reminisces, "when I decided at the age of 12 or so that I want to be a computer programmer when I grow up."

Jon was previously employed as a senior .NET developer at a very well-known Internet services company whom you're more likely than not to have directly done business with. However, this blog and all of jondavis.net have no affiliation with, and are not representative of, his former employer in any way.

Contact Me 


Tag cloud

Calendar

<<  May 2018  >>
MoTuWeThFrSaSu
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

View posts in large calendar