run |
new function(_name, _iframe){ with(document){
return self[_name = '_lister_'] = {
name: _name,
css: {
a: 'margin: 0px 2px; text-decoration: none',
div: 'padding: 4px 0px 1px 2px',
iframe: 'border: none',
shared: 'color: menutext; background-color: menu'
},
div: null,
iframe: null,
show: function(ls){ with(this){
div = createElement('div');
div.style.cssText = [
'position: absolute; z-index: 999; left: 0px',
'top: '+ Math.max(body.scrollTop, documentElement.scrollTop) +'px',
css.div, css.shared].join(';');
iframe = _iframe = createElement('iframe');
iframe.style.cssText = [
'display: none', css.iframe, css.shared].join(';');
var e, r = /^(.+?)\D?(\d+)$/, csa = css.a +';'+ css.shared;
for(var m, i = 0, l = ls.length; i < l; ++i){
if((m = r.exec(ls[i]))){
e = createElement('a');
e.href = ['javascript:', _name,'.load(', m[2], ')'].join('');
e.innerHTML = m[1];
e.style.cssText = csa;
} else e = createTextNode(ls[i] || '|');
div.appendChild(e);
}
e = createElement('a');
e.href = '#';
e.innerHTML = '[x]';
e.style.cssText = csa;
div.appendChild(e).onclick = function(){ return !body.removeChild(div) };
div.appendChild(createElement('br'));
body.appendChild(div).appendChild(iframe);
return this;
}},
load: function(id){
var s = createElement('script');
s.src = ['http://wedata.net/items/', id, '.json?callback=',
_name, '.run'].join('');
body.appendChild(s);
},
run: function(o){ with({open: this.open}) eval(o.data.run) },
open: function(url, nam, opt){ with(_iframe){
var m = /\bwidth\s*=\s*(\d+)/.exec(opt);
if(m) width = +m[1];
m = /\bheight\s*=\s*(\d+)/.exec(opt);
if(m) height = +m[1];
src = url;
name = contentWindow.name = nam;
style.display = 'block';
return contentWindow;
}}
}
}}
|
sample |
javascript:({id:2272,ls:['eijiro:2270','thesaurus:2285',,'delicious:2271','hatebu:2275',,'deleter:2284'],cb:'_f',d:document,_:function(s){with(this){self[cb+=id]=function(o){eval(o.data.run).show(ls)};s=d.createElement('script');s.src='http://wedata.net/items/'+id+'.json?callback='+cb;d.body.appendChild(s)}}}._()) |