Javascript turned into a function

User avatar
John Gray
PlatinumLounger
Posts: 5401
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Javascript turned into a function

Post by John Gray »

Some years ago 'someone' was kind enough to explain how to change a chunk of javascript into a Javascript function.

The format of what I need to modify has changed and is now something like:

Code: Select all

<script type="text/javascript">
//<![CDATA[
<!--
var x="function f(x){var i,o=\"\",ol=x.length,l=ol;while(x.charCodeAt(l/13)!" +
"=48){try{x+=x;l+=l;}catch(e){}}for(i=l-1;i>=0;i--){o+=x.charAt(i);}return o" +
".substr(0,ol);}f(\")19,\\\"330\\\\/%4>%{6$rxzq~}C0.V|~av 030\\\\720\\\\r\\\\"+
"630\\\\!S230\\\\100\\\\400\\\\'K;X600\\\\r\\\\+4/yut\\\\8$a*9&i+* RR_\\\\\\" +
"\\ZZ@qJCDLJJP330\\\\piwpvx1M2kn{o%b=\\\\\\\\T420\\\\420\\\\320\\\\000\\\\33" +
"0\\\\200\\\\130\\\\B630\\\\600\\\\300\\\\t\\\\720\\\\300\\\\18\\\"(f};o nru" +
"ter};))++y(^)i(tAedoCrahc.x(edoCrahCmorf.gnirtS=+o;721=%y;++y)19<i(fi{)++i;" +
"l<i;0=i(rof;htgnel.x=l,\\\"\\\"=o,i rav{)y,x(f noitcnuf\")"                  ;
while(x=eval(x));
//-->
//]]>
</script>
I need to prefix the above with something like
<script type="text/javascript">Someone();</script>
to make it a callable function.

Basically, I need to top and tail the javascript, and insert a { at the top, and a } at the bottom - but exactly where?

I have tried putting the { before the first var and } after the last semicolon, but it doesn't seem to work.

Help!
John Gray

Venison is quiet deer, and quite dear.

User avatar
John Gray
PlatinumLounger
Posts: 5401
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Javascript turned into a function

Post by John Gray »

OK, panic over - I had mistakenly put a ? instead of a }, which caused the complete javascript file to fail...

(I've not deleted the original post in case someone has been working on it...)
John Gray

Venison is quiet deer, and quite dear.

User avatar
StuartR
Administrator
Posts: 12577
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Javascript turned into a function

Post by StuartR »

John Gray wrote:...(I've not deleted the original post in case someone has been working on it...)
Thank you for this courtesy, it can be very annoying when a post is deleted.
StuartR