- 2004-11-04 (木) 23:04
- MovableType
相当前にエントリー編集画面で、<blockquote>タグをボタン一発で挿入してくれる改造方法について書いたのですが、ここをさらに拡張するネタについて書いてあるところを発見しました。
こちらによりますと、<や>などの記号を変換してくれるボタンなどの設置方法が書いてありました。
このMTのエントリー編集画面でHTMLのタグを書いて保存すると、HTMLとして解釈されてしまうので HTMLやMTの改造について書いたりするとごちゃごちゃのそれはそれはひどいことになるのですが、このボタンを使えば一発OK!
いやー 便利になったものです。
以下、やったことをずらずらっと。
修正するファイル
/mt/tmpl/cms/edit_entry.tmpl
スクリプトタグ内にペースト
function deCode() {
if (!document.selection) return;
strSelection = document.selection.createRange().text
if (!strSelection) return;
strSelection = strSelection.replace(new RegExp(“&”,”g”), “&”);
strSelection = strSelection.replace(new RegExp(“<”,”g”), “<”);
strSelection = strSelection.replace(new RegExp(“>”,”g”), “>”);
document.selection.createRange().text = strSelection;
return;
}
こういうところを探して
<script language=”javascript”>
if (document.selection) {
document.write(‘<table border=”0″ cellspacing=”0″ cellpadding=”0″ width=”107″>’);
document.write(‘<tr>’);
document.write(‘<td width=”24″><a href=”javascript:formatStr(\’b\’)”><img src=”<TMPL_VAR NAME=STATIC_URI>images/bold-button.gif” alt=”bold” width=”24″ height=”18″ border=”0″></a></td>’);
document.write(‘<td width=”24″><a href=”javascript:formatStr(\’i\’)”><img src=”<TMPL_VAR NAME=STATIC_URI>images/italic-button.gif” alt=”italic” width=”24″ height=”18″ border=”0″></a></td>’);
document.write(‘<td width=”24″><a href=”javascript:formatStr(\’u\’)”><img src=”<TMPL_VAR NAME=STATIC_URI>images/underline-button.gif” alt=”underline” width=”24″ height=”18″ border=”0″></a></td>’);
document.write(‘<td width=”26″><a href=”javascript:insertLink()”><img src=”<TMPL_VAR NAME=STATIC_URI>images/url-button.gif” alt=”link” width=”26″ height=”18″ border=”0″></a></td>’);
document.write(‘</tr>’);
document.write(‘</table>’);
} else {
document.write(‘ ’);
}
</script>
こうすると
<script language=”javascript”>
if (document.selection) {
document.write(‘<table border=”0″ cellspacing=”0″ cellpadding=”0″ width=”107″>’);
document.write(‘<tr>’);
document.write(‘<td width=”24″><a href=”javascript:deCode()”><img src=”<TMPL_VAR NAME=STATIC_URI>images/decode-button.gif” alt=”decode” width=”24″ height=”18″ border=”0″></a></td>’);
document.write(‘<td width=”24″><a href=”javascript:formatStr(\’b\’)”><img src=”<TMPL_VAR NAME=STATIC_URI>images/bold-button.gif” alt=”bold” width=”24″ height=”18″ border=”0″></a></td>’);
document.write(‘<td width=”24″><a href=”javascript:formatStr(\’i\’)”><img src=”<TMPL_VAR NAME=STATIC_URI>images/italic-button.gif” alt=”italic” width=”24″ height=”18″ border=”0″></a></td>’);
document.write(‘<td width=”24″><a href=”javascript:formatStr(\’u\’)”><img src=”<TMPL_VAR NAME=STATIC_URI>images/underline-button.gif” alt=”underline” width=”24″ height=”18″ border=”0″></a></td>’);
document.write(‘<td width=”26″><a href=”javascript:insertLink()”><img src=”<TMPL_VAR NAME=STATIC_URI>images/url-button.gif” alt=”link” width=”26″ height=”18″ border=”0″></a></td>’);
document.write(‘</tr>’);
document.write(‘</table>’);
} else {
document.write(‘ ’);
}
</script>
decode-button.gifというなまえで /mt/images に画像ファイルをUPしておきます。
- Newer: さらに色つけボタンも付けてみよう
- Older: 新五千円札
Comments:0
Trackbacks:0
- Trackback URL for this entry
- http://blog.eternalmiracle.net/taka/archives/2004/11/04-230428/trackback
- Listed below are links to weblogs that reference
- デコードボタンを付けよう from eternal miracle blog mode

