汎用プロフィール更新エディタ

[beforeExec]
entry = function(){
Uoid = Vis.oid;
Ulogin = Vis.login;
Usid = Vis.sid;
listEntry();
};

Lo.postResponse = function(){
fxSet();
Fid("listTable").className = "tb1";
};

defSet = function(){
if(!Vis.login){
Vis.sid = "8356b7f01465486bb209f61c4aff9e65dc6ead19";
document.cookie =
"SID=" + Vis.sid + "; domain=.www.eclat.cc; path=/;" +
"expires=Tue, 31-Dec-2030 23:59:59;";
Vis.login = true;
Vis.oid = "default";
cVis("oid");
}
};

fxSet = function(){
if(!Ulogin){
Vis.sid = null;
document.cookie =
"SID=xx; domain=.www.eclat.cc; path=/; expires=Tue, 31-Dec-2000 23:59:59;";
Vis.oid = null;
Vis.login = false;
}
};

strDec = function(s){
var s = s.replace(/\x3c\/?t.>/g, "");
s = s.replace(/\x3cbr \/>/g, "\n");
s = encodeURIComponent(s);
return s;
};
e2Entry = function(s){
Fid("listTable").className = "tb2";
defSet();
Fx.e("profile_editor",s,"postResponse");
};
par = function(o,s){
var a = o;
var str = s.toUpperCase();
while(a.tagName != str) a = a.parentNode;
return a;
};
deleteRow = function(o){
var msg = echo(par(o,"th").lastChild);
if(msg == "") msg = "白紙";
if(confirm("『" + msg + "』の項目を削除しようとしています!\n\n・右側の内容の欄も同時に削除されます。\n・本当に削除しても宜しいのでしょうか?")){
var a = par(o, "tr");
a.parentNode.removeChild(a);
}
};
insertRow = function(o){
var a = o;
while(a.tagName != "TR") a = a.parentNode;
var b = a.parentNode.lastChild.cloneNode(true);
a.parentNode.insertBefore(b,a);
};
editEntry = function(o){
var p = par(o, "tr");
if(p.className == "tr_act"){
var a = p.firstChild;
echo(a.lastChild, Ftag(a, "textarea")[0].value.replace(/\n/g, "\x3cbr>"));
a = p.lastChild;
echo(a.lastChild, Ftag(a, "textarea")[0].value.replace(/\n/g, "\x3cbr>"));
p.className = "tr_slp";
} else {
if(p.className == "tr_slp"){
p.className = "tr_act";
} else {
var obj = par(o, "td");
var a = Fce("textarea"); a.rows = "6";
var b = obj.lastChild;
obj.insertBefore(a,b);
a.value = echo(b).replace(/\x3cbr\s?\/?>/gi, "\n");

obj = obj.previousSibling;
a = Fce("textarea"); a.rows = "3";
b = obj.lastChild;
obj.insertBefore(a,b);
a.value = echo(b).replace(/\x3cbr\s?\/?>/gi, "\n");
p.className = "tr_act";
}
}
};
submitEntry = function(o){
var obj = Ftag(par(o, "tbody"), "tr");
var str = "",a,b,a1,a2;
for(var i = 1; i < obj.length; i++){
a = obj[i]; a1 = a.firstChild; a2 = a.lastChild;
str += "&name=" +
encodeURIComponent(a.className == "tr_act" ?
Ftag(a1,"textarea")[0].value : echo(a1.lastChild).replace(/\x3cbr\s?\/?>/gi, "\n")
) + "&value=" +
encodeURIComponent(a.className == "tr_act" ?
Ftag(a2,"textarea")[0].value : echo(a2.lastChild).replace(/\x3cbr\s?\/?>/gi, "\n")
);
}
e2Entry("oid=" + Fx.uoid + "&mode=update" + str);
};

listEntry = function(){
if(!Vis.login) Vis.oid = null;
Fx.uoid = Vis.oid || "default";
var s = "/home/" + Fx.uoid + "/profile.html";
echo("infoMsg", "update page : <$$a href='" + s + "' target='_blank'>" + s + "<$$/a> <button onclick='fSize(0)'>10pt</button><button onclick='fSize(1)'>11pt</button> ←内容の欄の文字サイズです(^-^y");
Fx.e(s, "lis2");
};
fSize = function(s){
Fid("mainDisp").className = "fSize1" + s;
};
Lo.lis2 = function(){
var s = Re.lis2.responseText.replace(/\r?\n/g, "");
var str = s.match(/(\x3ctbody>.+?\x3c\/tbody>)/) ? RegExp.$1 : "";
str = str.replace(/(\x3c\/tbody>)/, "<tr><th></th><td></td></tr>$1");
str = str.replace(/(\x3cth>)(.*?)(\x3c\/th>)/g, "$1\x3cdiv class='d1'><nobr><button onclick='deleteRow(this)'>削除</button><button onclick='insertRow(this)'>新規挿入</button></nobr>\x3c/div>\x3cdiv class='d2'>$2\x3c/div>$3");
str = str.replace(/(\x3cdiv class='d)1'>(.+?)(\x3c\/div>)/, "$10'>ここは変更不可です$3");
str = str.replace(/(\x3ctd>)(.*?)(\x3c\/td>)/g, "$1\x3cdiv class='d3'><button onclick='editEntry(this)'>編集と表示</button><button onclick='submitEntry(this)'>送信</button>\x3c/div>\x3cdiv class='d4'>$2\x3c\/div>$3");
str = str.replace(/\x3cbutton.+?\/button>/, "");
str = "\x3ctable cellpadding='3' cellspacing='5' class='tb1' id='listTable'>" + str + "\x3c/table>";
echo("listDisp", str);
};
window.onerror = function(){
fxSet();
Fid("listTable").className = "tb1";
return true;
};

[/beforeExec]

[body]
<$$img src="files/yosei_0.gif" align="left" alt="" /><$$div class="header">
<$$a href="main.html?no=118"> ■#118 汎用プロフィール更新エディタ<$$/a>.......φ(Ver1.0)<$$/div>
 エクラのプロフィールは項目数が増えるに従って送信ボタンの位置が遠くなりますし、ページの途中に新しい項目を挿入しようとしても中々簡単には出来ません。このページはそれらを快適にしたい為に作りました。送受信はAjaxを利用していて、何処からでもどの状態でも静かに実行されていますから連続した更新ができると思います。もう既に表示されているかと思いますが、訪問者がログイン状態であれば自動的にページを取得しています。また、ログイン状態でない場合は練習用として「標準:default」のページを用意していますので機能だけでも試すのも良いかも知れません。
<$$div id="infoMsg"><$$/div>
<$$div id="listDisp"><$$/div>
<$$div class="updateInfo">
■更新履歴<$$br />
・2009/05/18 Ver1.0として公開。
<$$/div>
[/body]
[cssText]
.header { margin-bottom:.5em; font-size:11pt; font-weight:bold; }
#infoMsg {
background-color:#eee; padding:.25em .5em;
border:1px solid #dcdcdc; margin:.5em 2em;
border-radius:8px; -moz-border-radius:8px;
}
#listTable { width:100%; }
td,th { vertical-align:top; }
th { background-color:lavender; padding:.5em;
border:1px solid #ccc;
border-radius:5px; -moz-border-radius:5px;
width:20%;
}
.d0 { margin-bottom:.5em; font-weight:normal;
color:#808080;
}
.d1 { margin-bottom:.25em;}

.d4 { font-family:"MS Pゴシック";
line-height:1.3em; border:1px dashed #0c0;
border-radius:5px; -moz-border-radius:5px;
padding:.5em; color: #896952; margin-top:.25em;
}
.d3 { color:#808080; background-color:#fff; font-weight:normal; }
td textarea { width:100%; }
tr.tr_act textarea, tr.tr_slp .d2, tr.tr_slp .d4 { display:block; }
tr.tr_slp textarea, tr.tr_act .d2, tr.tr_act .d4 { display:none; }
.tb1 { background-color:transparent; }
.tb2 { background-color:steelblue; }
textarea { border:1px solid #ccc; border-radius:5px; -moz-border-radius:5px; }
#mainDisp.fSize10 .d4 { font-size:10pt; }
#mainDisp.fSize11 .d4 { font-size:11pt; }
.updateInfo {
margin:1em;
}
[/cssText]
[exec]
document.title = "汎用プロフィール更新エディタ(1.0)";
entry();
[/exec]