[JSONP-SE] JSONP Static Emulation

JSONP, JSON with Padding, is available not only with dynamic contents from server-side CGI etc., but also with static contents, just static files.

However, such static JSONP files do NOT allow to change Padding, name of callback function.
JSON with FIXED padding is a kind of JSONP? It's just a mere JavaScript file?
    { foo: 'HOGE', bar: 'POMU' } // JSON content
You may need to manage a queue when you handle multiple JSONP calls.

Now, the JSONP-SE is the solution for this.
JSON-SE means JSON Static Emulation.
Change the padding, "callback" in code above, to the six lines below:
( function (data) {
    var list = document.getElementsByTagName( 'script' );
    var temp = list[list.length-1].src.match( /[\?\&]callback=([A-Za-z0-9\_\.\[\]]*)/ );
    var func = temp ? temp[1] : 'callback';
    eval( func+"(data)" );
    { foo: 'HOGE', bar: 'POMU' } // JSON content

This is still a static file, however, you could specify any callback function name you like.
The JSON content in JSON-SE is exactly the same as it in JSON.

You could load JSONP-SE file via <script> element in <body> element.
<script type="text/javascript" src="test.js?callback=hello"></script>
The callback function "hello" would be called.
<script type="text/javascript" src="test.js"></script>
Without ?callback=... argument is not specified, the default function "callback" would be called instead.

You could generate <script> element via DOM.
    var script = document.createElement( 'script' );
    script.charset = 'utf-8';
    script.type = 'text/javascript';
    script.src = 'test.js?callback=hello';
    document.lastChild.appendChild( script );
JSONP-SE must be loaded in the bottom of the dom tree.

Such trick, fetching argument from the src attribute of the script element loaded, is used in script.aculo.us as well.

* The original post of this was written in Japanese.

[Event] Tokyo ActionScript Meetup 2008 F/ Colin Moock

When I heard that Colin Moock would come to Japan to make a talk in a seminar event sponsored by Adobe Systems Inc., it hit me that we could welcome and counter him with top ActionScript engineers in Japan!
I'd like to show him the cutting-edge ActionScript techs developed in Japan, are not introduced yet to the world in English, unfortunately.

As the result, at the day of January 16, the Tokyo ActionScript Meetup 2008 F/ Colin Moock was taken a place in Adobe Japan.
Very deep tech talks about ActionScript 2, 3 & also 4(!) were told.

Colin (left) and Ota-san.

The last of all, I asked him some of questions invited by the audiences on ahead.

I think the most of audiences including me would surprised that he could speak Japanese much fluently.
As Larry Wall could speak JavaScript as well, such great programmers would be good at speaking multiple natural languages as well as programming languages.

Tokyo ActionScript Meetup 2008 F/ Colin Moock

* Colin Moock http://moock.org/

* yossy http://www.be-interactive.org/
* munegon http://void.heteml.jp/blog/
* id:secondlife http://d.hatena.ne.jp/secondlife/

* Muraken http://www.muraken.biz/ & tera http://www.trick7.com/blog/
* Iwasaki http://www.cosmo-int.com/
* Kobayashi http://d.hatena.ne.jp/yukoba/

* Q: Kawasaki http://www.kawa.net/ on behalf of the all audiences
* A: Colin Moock http://moock.org/

We much enjoyed the session with you.
Thank you, Colin! See you again!

* The original longer post of this was written in Japanese.

Hatsumode at the Sanno Hie Shrine

At the first business day of this year, I and my all colleagues went to the Sanno Hie Shrine for Hatsumode.
This is the most important ritual on the begging of new year, I think.
We prayed for our fine health and also our success in business.