#!/usr/local/bin/node
(function($){
var keysOf = function(o){
var keys = [];
for (var k in o) keys[keys.length] = k;
return keys;
};
json2dl = function(json){
var dl = $('
');
$.each(keysOf(json).sort(), function(i, k){
$('').text(k).appendTo(dl);
var dd = $('').text(json[k])
if (k.match(/^std/)) dd.css({fontFamily:'monospace',whiteSpace:'pre'});
dd.appendTo(dl);
});
return dl;
};
LLEval = function(srcNode, dstNode, lang){
var query = {s:(srcNode.value || $(srcNode).text())};
if (lang) query['l'] = lang;
var url = '//api.dan.co.jp/lleval.cgi';
var proto = 'json';
if ($.browser.msie || $.browser.opera){
url += '?c=?';
proto += 'p';
} /* falls back to JSONP */
$.get(url, query, function(json){
$(dstNode).html(json2dl(json));
}, proto);
};
})(jQuery);