システム・ブートファイル
[boot]
Fid = function(obj){ return document.getElementById(obj) };
Fce = function(str){ return document.createElement(str) };
Fctn = function(str){ return document.createTextNode(str) };
Fap = function(a,b){ return a.appendChild(b) };
Ftag = function(a,b){ return a.getElementsByTagName(b) };
Ftn = function(o){ return o.firstChild ? o.firstChild.nodeValue : ""; };

Fcn = function(o,a,b){
var o = Ftag(o, a),a,n = [];
for(var i = 0; i < o.length; i++){
a = o[i]; if(!a.className) continue;
if(a.className == b) n.push(a);
}
return n;
};

Fcea = function(a,b){
var o = Fce("a"); o.href = a;
o.appendChild(Fctn(b));
return o;
};
Po = new Object();
Po.dateByDay = function(date, type){
var c = (new Date(date.replace(/(^\d{4})\s/, "$1/"))).getDay();
var d = type ? ["日","月","火","水","木","金","土"] :
["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];
return '\x3cspan class="day' + (!c ? 0 : c > 5 ? 6 : 1) + '">(' + d[c] + ')\x3c/span>';
};

Re = new Object();
Lo = new Object();
Vis = new Object();

Fx.e = function(uri,key){
if(key == undefined) key = "entry";
Lo[key].uri = uri;
Lo[key].file = uri.match(/(bbs|diary|footprint).cgi/) ? RegExp.$1 :
uri.match(/\/diary\//) ? "diary" : "other";
Lo[key].mode = Fx.loc.match(/fx=no/) ? 1 : 0;
Lo[key].user = uri.match(/(\/home\/|oid=)([\w\-]+)/) ? RegExp.$2 : "nancyan";
if(typeof(Lo[key].bef) == "function") Lo[key].bef();
var a = Re[key] = Freq();
a.onreadystatechange = function(){
if(a.readyState == 4){
if(a.status == 200){
Lo[key]();
} else {
if(typeof(Lo[key].err) == "function") Lo[key].err();
else Fx.err();
}
}
};
a.open("get", uri.replace(/#.*$/, ""), true);
a.send(null);
};
echo = function(){
var a = arguments;
var n = a.length;
var o = typeof(a[0]) == "string" ? Fid(a[0]) : a[0];
if(n == 1) return o.innerHTML;
else o.innerHTML = Fx.t2n(a[1]);
};

Fx.t2n = function(s){ return s.replace(/\t/g, "\n") };
Fx.loc = document.URL;
Fx.err = function(){};

reqEntry = function(){
if(req.readyState == 4){
if(req.status == 200){
Fx.str = req.responseText;
Fx.ent();
} else Fx.err();
}
};

Fget = function(){
var uri = Fx.uri;
req = Freq();
req.onreadystatechange = reqEntry;
req.open("GET", uri, true);
req.send(null);
};


Fx.footer = function(){
var s = "sys_update&page=" + Fx.no;
if(Fx.no > 99 && Fx.no < 200){
s = "sys_update2&page=" + (146295 + Fx.no);
}
echo("footerDisp",
"\x3chr size=1 noshade='noshade' />" +
"(C)2007-2009 main.html改(1.1) なんちゃん \x3ca href='" + Fx.loc + "'>self\x3c/a> " +
"\x3ca href='main.html?no=1'>top\x3c/a> \x3ca href='main.html?" + s +
"' id='footerEdit' target='_blank'>EDIT\x3c/a> \x3ca href='/cgi-bin/main_editor.cgi?oid=nancyan'>update\x3c/a> " +
"\x3ca href='/home/nancyan/' target='_top'>nancyan@eclat\x3c/a>  "
);
};

Fx.ent = function(){
if(Fx.file == "css"){
var s = Fx.str.replace(/ /g, "&" + "nbsp;");
s = s.replace(/\r?\n/g, "\x3cbr />");
Fid("mainDisp").innerHTML = s;
}

if(Fx.file== "diary" || Fx.file == "bbs" || Fx.file == "article"){
var str = Fx.dec(Fx.str);
var a = key(str, "reDirect");
if(a != ""){
location.replace("main.html?" + a);
return;
}
Fx.bef = key(str, "beforeExec");
Fx.body = key(str, "body");
Fx.exe = key(str, "exec");
Fx.css = key(str, "cssText");
if(Fx.bef != "") eval(Fx.bef);
if(Fx.css != "") Fx.cssText(Fx.css);
echo("mainDisp",Fx.body != "" ? Fx.body :
"\x3cdiv class='nonOwner'>申し訳ありませんがログインしていないか\x3cbr />" +
"編集権限を持ち合わせていないと思われます。\x3cbr />\x3cbr >" +
"\x3ca href='javascript:history.go(-1)'>仕方がないので履歴で戻る\x3c/a>"
);
if(Fx.exe != "") eval(Fx.exe);
Fx.footer();
}
};

Fx.dec = function(s){
var e = "_";
s = s.replace(/\[\[(.+?)\]\]/gm, function(e0,e1){
return e1.replace(/\x3cbr \/>/g, "\/\/\/");
});
s = s.replace(/(\x26)amp;/g, "$1");
s = s.replace(/\x3cbr \/>/g, " ");
s = s.replace(/\x26quot;/g, '"');
s = s.replace(/\x26lt;/g, "<").replace(/\x26gt;/g, ">");
s = s.replace(/\x26#39;/g, "'");
s = s.split("&" + "#95;").join(e);
s = s.split(e + e + ".").join(">").split(e + e).join("<$$");
s = s.replace(/<$$\-/g, "\&" + "lt;");
s = s.replace(/>\-/g, "\&" + "gt;");
s = s.replace(/\/\/\//g, "\x3cbr \/>");
if(Fx.dec2){
s = s.replace(/\$\$/g, "");
s = s.replace(/(\x3cimg\s)yukikko/g, '$1src="files/yukikko2b.gif" alt="" width="350" height="190"');
s = s.replace(/(\x3cimg\s)hamu(\d)/g, '$1src="files/hamu_folder$2.gif" alt="" height="35" width="35"');
}
return s;
};

Fx.rep = function(s){ return s; };

Fx.bbsUri = function(){ return "/cgi-bin/bbs.cgi?oid=nancyan&n=1&s=" + Fx.no };
Fx.diaryUri = function(){
var date = new Date();
date.setTime(Fx.no * 1000);
return (
"diary/" + date.getFullYear() + "/" +
("0" + (date.getMonth() + 1)).slice(-2) + "/" + Fx.no + ".html"
);
};

Fx.times = function(n, fg){
var a = new Date();
a.setTime(n * 1000);
return (
(fg ? "diary/" : "") + a.getFullYear() +
(fg ? "/" : " ") + ("0" + (a.getMonth() + 1)).slice(-2) + "/" +
(fg ? n + ".html" : ("0" + a.getDate()).slice(-2) + " " + ("0" + a.getHours()).slice(-2) +
":" + ("0" + a.getMinutes()).slice(-2))
);
};

Fx.articleUri = function(){
return "/cgi-bin/diary_form.cgi?oid=nancyan&mode=edit&article_id=" + Fx.no;
};

Fx.loader = function(){
switch(Fx.file){
case "bbs" : Fx.uri = Fx.bbsUri(); break;
case "diary" : Fx.uri = Fx.diaryUri(); break;
case "article" : Fx.uri = Fx.articleUri(); break;
default : break;
}

Fget();
};

Fx.cssText = function(s){
var cs = { "b":"border", "m":"margin", "p":"padding" };
var cp = { "l":"left", "r":"right", "t":"top", "b":"bottom", "1":"radius" };
var str = s.replace(/\r?\n/g, " ");
str = Fx.rep(str);
str = str.replace(/\/\*.*?\*\//g, "");
str = str.replace(/[^\}]+\{\s*\}/g, "");
str = str.replace(/([pmb])\-([lrtb1]):/g, function(e0,e1,e2){
return cs[e1] + "-" + cp[e2] + ":";}
);
var o = document.styleSheets;
o = o[o.length -1];
document.createStyleSheet ?
o.cssText = str :
str.replace(/.+?\{.+?\}/g, function(e){o.insertRule(e, o.cssRules.length); return "";});
};

Fx.getDiaryUri = function(str){
if(str.match(/uri=(.+)$/)) return RegExp.$1;
var user = str.match(/user=([a-z0-9_\-]+)/) ? RegExp.$1 : "nancyan";
var no = str.match(/page=(\d+)/) ? Number(RegExp.$1) : 1196521475;
var type = str.match(/pageType=([a-z]+)/) ? RegExp.$1 : "def";
var uri = "/cgi-bin/diary.cgi?oid=" + user + ";n=20";
if(str.match(/pageType=one/)){
var date = new Date();
date.setTime(Fx.pageNo * 1000);
uri = "/home/" + user + "/diary/" + date.getFullYear() + "/" +
("0" + (date.getMonth() + 1)).slice(-2) + "/" + no + ".html";
}
return uri;
};
Fx.getCalenUri = function(n){
return "/cgi-bin/diary.cgi?oid=nancyan;n=1;s=" + (146295 + n);
};


checkFrame = function(s){};

Fx.bootSystem = function(){
var o = document.body;
o.removeChild(document.forms[0]);

Ftag(o, "div")[0].id = "mainDisp";
Fx.mode = Fx.loc.match(/fx=no/) ? "Link" :
document.cookie.match(/mode=Ajax/) ? "Ajax" : "Link";
Fx.file = Fx.loc.match(/file=([a-z_0-9\-]+)/) ? RegExp.$1 : "bbs";
Fx.no = Fx.loc.match(/no=(\d+)/) ? Number(RegExp.$1) : 1;
Fx.dec2 = true;
if(Fx.loc.match(/sys_([a-z_0-9\-]+)/)){
switch(RegExp.$1){
case "update" : Fx.no = 10; Fx.file = "bbs"; break;
case "update2" : Fx.no = 136695; Fx.file = "article"; Fx.dec2 = false; break;
case "diary" : case "diry2" : Fx.no = 103; break;
case "bbs" : Fx.no = 105; break;
case "footprint" : Fx.no = 104; break;
default : break;
}
}
if(Fx.no > 99 && Fx.no < 200) Fx.uri = Fx.getCalenUri(Fx.no);
else {
switch(Fx.file){
case "bbs" : Fx.uri = Fx.bbsUri(); break;
case "diary" : Fx.uri = Fx.diaryUri(); break;
case "article" : Fx.uri = Fx.articleUri(); break;
default : break;
}
}
Fget();
};
cVis = function(key){
document.cookie =
key.toUpperCase() + "=" + escape(Vis[key]) + "; path=/home/nancyan/;" +
"expires=Tue, 31-Dec-2030 23:59:59;";
};

Lo.sVis = function(){
var s = Re.sVis.responseText.replace(/\r?\n/g, "\t");
Vis.from = s.match(/name="from" value="([^"]+)/) ? RegExp.$1 : null;
Vis.oid = s.match(/name="address" .+?eclat.cc\/home\/([\w\-]+)\//) ? RegExp.$1 : null;
if(Vis.from != null) cVis("from");
if(Vis.oid != null) cVis("oid");
};

gVis = function(){
var s = unescape(document.cookie) + ";";
Vis.sid = s.match(/SID=([a-z0-9]+)/) ? RegExp.$1 : null;
Vis.home = s.match(/HOME=1/) ? true : false;
Vis.login = Vis.sid != null ? true : false;
Vis.oid = s.match(/OID=([\w\-]+)/) ? RegExp.$1 : null;
Vis.from = s.match(/FROM=([^;]+)/) ? RegExp.$1 : null;
if(Vis.login && Vis.oid == null) Fx.e("/cgi-bin/bbs_form.cgi?oid=nancyan", "sVis");
};

gVis();
if(Fx.boot) Fx.bootSystem();
else Fx.boot = true;

[/boot]