汎用エディタ関数群
[body]
<$$img yukikko />
このページはデータです。。

[/body]
[exec]
document.title = "汎用エディタ関数群";
[/exec]
[addFunc]
tubeEntry = function(obj){
Fid("td1").className = "ch1";
var o = obj.options[obj.selectedIndex];
if(tubeEntry.bef != null) tubeEntry.bef.style.color = "gold";
tubeEntry.bef = o;
o.style.color = "#0f0";
var s = o.value;
var s1 = "<object id='tube' width='320' height='1' ";
var uri = "http://www.youtube.com/v/" + s + "&hl=ja&fs=1&autoplay=0&enablejsapi=1" +
"&loop=1&rel=0";
var str = s1 + "type='application/x-shockwave-flash' data='" +
uri + "'><param name='allowScriptAccess' value='always'></param></object>";
if(document.all){
str = s1 + "classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'>" +
"<param name='movie' value='" + uri + "'></param><param name='allowScriptAccess' value='always'></param>" +
"<param name='allowFullScreen' value='true'></param></object>";
}
echo("oDisp",str);

Fx.moonMove(1);
o = Fid("tubeBuff");
var num = parseInt(o.options[o.selectedIndex].value) * 1000;
setTimeout("tubeControl()", num);
};

Fx.moonMove = function(n){
var o = Fid("moon");
var str;
if(n == 0) str = 0;
if(n == 1) str = o.offsetHeight - 290;
if(n == 2) str = o.offsetHeight - 290 - 24;
if(n == 3) str = o.offsetHeight - 290 - 264;
o.style.backgroundPosition = "right " + str + "px";
};

osc = function(no){
var obj = Fid("tube");
if(no == 0){
if(Fid("tubeLoop").selectedIndex == 1){
var o = tubeEntry.bef.parentNode;
var n1 = o.options.length;
var n2 = o.selectedIndex;
o.selectedIndex = n2 < n1 - 1 ? n2 + 1 : 0;
seBuEntry();
}
}
};

tubeControl = function(){
Fx.moonMove(2);
var o = Fid("tube"); o.height = 24;
o.addEventListener("onStateChange", "osc");
o.playVideo();
setTimeout("tubePlayEntry()", 1000);
};

tubePlayEntry = function(){
var o = Fid("tube");
o.height = 264;
Fx.moonMove(3);
setTimeout("Fx.moonMove(0)", 2000);
};

funcError = function(){
alert("エラーです");
return true;
};

Fx.setExec = function(num){
var obj = Fid("T1");
var str = obj.value;
var i,j,a,b,c,obj,s;
if(num){
if(num == 1) obj.value = Fx.setExec.Bef || "";
} else {
var o = Fid("setExec");
var n = o.options[o.selectedIndex].value;
if(n == ""){
if( str != ""){
window.onerror = funcError;
eval(str);
}
return;
}
}
Fx.setExec.Bef = str;
switch(n){
case "isD" :
obj.value = str.replace(/\x3c(\/?)(img|a|div|span|br|hr)/g, "\x3c\x24\x24\x24\x24$1$2");
break;
case "isUnD" : obj.value = str.replace(/\x24\x24/g, ""); break;
case "isAsciiBy10" : a = "";
for(i = 0; i < str.length; i++) a += str.charCodeAt(i) + " ";
obj.value = a; break;
case "isAsciiBy16" : a = "";
for(i = 0; i < str.length; i++){
b = str.charCodeAt(i).toString(16);
if(b.length == 1) b = "0" + b;
a += b + " ";
}
obj.value = a; break;
case "isC34C44" : str = str.replace(/\x22/g, "~~" + "1").replace(/\x27/g, "\x22");
str = str.replace(/\x7e\x7e1/g, "\x27"); obj.value = str; break;
case "isObj" :
s = Fid("I1").value;
if(s == ""){
alert("オブジェクトを入力欄(I1)に記述して下さい。");
return;
}
a = eval(s); b = "";
for(i in a) b += i + " = " + a[i] + "\n";
obj.value = b; break;
default : break;
}
textChange();
};

ctr = function(n){ return;
var o1 = Fid("td1").style;
var o2 = Fid("tube");
var w = parseInt(o1.width);
w += n ? 15 : -15;
o1.width = w + "px";
o2.width = w;
o2.height = parseInt(w * .84);
};


seChange = function(n){
var o = n.options[n.selectedIndex];
if(seChange.bef == null) seChange.bef = Fid("se0");
if(seChange.bg == null) seChange.bg = Fid("se0").options[0];
seChange.bef.style.display = "none";
seChange.bg.style.color = "gold";
o.style.color = "#00ff00";
var s = o.value;
var a = Fid(s);
a.style.display = "inline";
seChange.bef = a;
seChange.bg = o;
o.blur(); window.focus();
};

seBuEntry = function(){
var o = Fid("seMe");
var s = o.options[o.selectedIndex].value;
if(s == "se0"){
Fid("oDisp").innerHTML = "";
window.onresize = null;
} else {
tubeEntry(Fid(s));
}
};

pageChg = function(n){

};
midiEntry = function(o){
alert("まだ実装していません");
};

midiPlay = function(obj, s){
window.onresize = null;
var str = s = "" ? "" : "<embed src='http://www11.plala.or.jp/nancyan/gaiax/goo/midi/" + s +
"' repeat='true' loop='true' autostart='true' width='320' height='40' style='background-color:#000'></embed>";
obj.className = "mon";
if(midiPlay.bef != null){
if(midiPlay.bef == obj){
str = "";
obj.className = "moff";
midiPlay.bef.className = "moff";
}
}
midiPlay.bef = obj;
Fid("oDisp").innerHTML = str;
return false;
};

fileReDecode = function(s){
return s.replace(/\t/g, " ").replace(/\r?\n/g, "\t");
};

fileDecode = function(a){
s = a.replace(/\x26amp\x3b/g, "\x26");
s = s.replace(/\x26quot\x3b/g, "\x22").replace(/\x26#39\x3b/g, "\x27");
s = s.replace(/\x26lt\x3b/g, "\x3c").replace(/\x26gt\x3b/g, "\x3e");
s = s.replace(/\x26amp\x3b/g, "\x26");
s = s.replace(/\t/g, "\n");
return s;
};
fileLoadEntry = function(){
var s = fileReDecode(Fx.str);
Fid("T2").value = s.match(/\x3c(textarea)[^>]+>(.+)\x3c\/\1/) ? fileDecode(RegExp.$2) : "削除されています。\n\nまたは、最新の記事番号よりも多く番号を取得しています";
var F2 = document.forms["editForm"];
F2.elements["category_id"].value = s.match(/.+?"(\d+)" selected=/) ? RegExp.$1 : "0";
F2.elements["article_title"].value = s.match(/article_title" value="(.+?)"/) ? RegExp.$1 : "";
F2.elements["article_id"].value = s.match(/name="article_id" value="(\d+)" \/>.+?$/) ? RegExp.$1 : "-1";


/*

name="category_id">
<option value="1" selected="selected">日記</option>
<option value="253">ツー
s = s.replace(/^.+?(<form\s)/, function(e0,e1){
return (
e1 + "target='" + (window.name == "main_nancyan" ? "winTEMP" : "main_nancyan") +
"' name='updateForm' "
)}
);
s = s.replace(/(<\/form>).+?$/, "$1");
s = s.replace(/<th>.+?<\/th>/g, "");
s = s.replace(/cols="50"\srows="8"/, 'cols="120" rows="30"');
s = s.replace(/(<select)/, "カテゴリ:$1");
s = s.replace(/(<input)/, '新規:$1 size="8"');
s = s.replace(/<\/td>.+?<td>/, "タイトル:");
Fx.dec2 = false;
s = Fx.dec(s);
s = s.replace(/\t/g, "\n");
Fid("calen").innerHTML = s;
var F1 = document.forms["updateForm"];
var F2 = document.forms["editForm"];
var b = F1.elements["category_id"];
F2.elements["category_id"].value = b.options[b.selectedIndex].value;
Fid("T2").value = F1.elements["article_sentences"].value;
F2.elements["article_title"].value = F1.elements["article_title"].value;
F2.elements["article_id"].value = F1.elements["article_id"].value;
F2.elements["article_notify"].value = F1.elements["article_notify"].value;
*/
};


I2Exec = function(no){
var str = Fid("I2").value;
var num;
var n1 = "";
if(str.match(/[^#0-9]/) || str == ""){
alert("数値、または#noを入力して下さい。");
Fid("I2").focus();
return;
}
if(str.match(/#([0-9]+)/)){
var a = parseInt(RegExp.$1);
if(a < 100 || a > 199){
alert("#は領域確保のファイルです。100~199の数値を入れて下さい。");
return;
}
num = a + 146295;
a += no;
if(a >= 100 && a < 200) n1 = "#" + a;
} else num = parseInt(str);
num += no;
if(n1 == "") n1 = num;
Fid("I2").value = n1;
Fx.uri = "/cgi-bin/diary_form.cgi?oid=nancyan&mode=edit&article_id=" + num;
Fx.ent = fileLoadEntry;
Fget();
};

pEnt = function(obj){
if(pEnt.bef == null) pEnt.bef = Fid("help");
if(pEnt.bef == obj) return;
if(pEnt.bef2 != null) pEnt.bef2.style.color = pEnt.bef2.dat == "" ? "#aaa" : "#000";
Fid("menu2").className = obj.className;
Fid("showDisp").className = obj.className;
var a = pEnt.bef;
var o = Fid("T1");
/*
var f = document.forms["updateForm"];
*/
a.dat = o.value;
a.scr = o.scrollTop;
a.style.color = a.dat == "" ? "#aaa" : "#00f";
/*
if(a.className == "file"){
a.T = f.elements["article_title"].value || "";
a.C = f.elements["category_id"].value || "1";
a.N = f.elements["article_notify"].value || "0";
}
*/
o.value = obj.dat || "";
/*
if(obj.className == "show3"){
var fg = obj.value == "";
f.elements["article_title"].value = fg ? "" : obj.T;
f.elements["category_id"].value = fg ? "1" : obj.C;
f.elements["article_notify"].value = fg ? "0" : obj.N;
f.elements["article_notify"].checked = fg ? "false" : obj.N;
}
*/
obj.style.color = "#f00";
pEnt.bef2 = a;
pEnt.bef = obj;
setTimeout(function(){ Fid("T1").scrollTop = pEnt.bef.scr; textChange(); }, 0);

if(obj.className == "file"){
Fid("I2").focus();
}
};

Fx.cmd = function(n){
var s = Fx.strBuff;
var m = "beforeExec body exec cssText DATA".split(" ");
var o = Ftag(Fid("eButton"), "button");
var str = "", no, u;
for(i = 0; i < 5; i++){
no = i + 1;
u = Fx.dec(key(s, m[i]));
o[no].dat = u;
o[no].scr = "0";
o[no].style.color = "#00ff00";
str += "[" + m[i] + "]\n" + u + "\n[/" + m[i] + "]\n";
}
o[0].dat = str;
o[0].scr = "0";
o[0].style.color = "#00ff00";
pEnt(o[0]);
};

textChange = function(){
var s = Fid("T1").value;
var s1 = s.length;
var s2 = s.replace(/[\x00-\xff]/g, "").length;
var s3 = s.split("\n").length;
Fid("textInfo").value = " " + s3 + " " + s1 + "/" + (s1 + s2);
};

mSizeSet = function(o){
var obj = Fid("T1");
if(mSizeSet.bef == null) mSizeSet.bef = 10.5;
var n = o.options[o.selectedIndex].value - 0;
obj.style.fontSize = n + "pt";
obj.rows += (mSizeSet.bef - n) * 6;
mSizeSet.bef = n;
o.blur(); obj.focus();
};

bgcSet = function(o){
var a = o.options[o.selectedIndex];
var obj = Fid("T1");
obj.style.color = "#" + a.value;
obj.style.backgroundColor = "#" + a.bg;
o.blur(); obj.focus();
};


[/addFunc]