View Single Post
Old 12-31-2002, 12:08 AM   PM User | #7
ca_redwards
Regular Coder

 
Join Date: Dec 2002
Posts: 169
Thanks: 0
Thanked 0 Times in 0 Posts
ca_redwards is an unknown quantity at this point
I think part of the problem is..

In my original code, the regular expressions replace not only the function name, but parts of the literal in the function's code too.

Namely, in each of these functions...

function Y(W){return' Y'+(W?('='+String.fromCharCode(34)+W+String.fromCharCode(34)):'')};
function X(W){return'<X'+(W?W:'')+'>'};
function Z(W){return'<Z'+(W?W:'')+'>'+this+'</'+'Z>'};
function G(W){return'<G'+(W?W:'')+'>'+this.join('<G'+(W?W:'')+'>')};
function R(W){return'<R'+(W?W:'')+'>'+this.join('</'+'R><R'+(W?W:'')+'>')+'</'+'R>'};

... it is important to replace not only the function name in the header, but also in the string literal returned by the function. By using the .toString() method of the "template" function, the word "function" is returned too. This is critical for writing a viable function definition onto the appropriate object (be it window, String.prototype or Array.prototype).

Incidentally, you also dropped the code that writes my copyright message into the status line!
ca_redwards is offline   Reply With Quote