Warning: main(/home/sites/lolipop.jp/users/lolipop.jp-dp56011508/web/depot/java_individual.txt) [function.main]: failed to open stream: No such file or directory in /home/sites/lolipop.jp/users/lolipop.jp-dp56011508/web/mtk/archives/2004/05/15_1202.php on line 17

Warning: main() [function.include]: Failed opening '/home/sites/lolipop.jp/users/lolipop.jp-dp56011508/web/depot/java_individual.txt' for inclusion (include_path='.:/usr/local/lib/php:/usr/local/lib/php/Smarty') in /home/sites/lolipop.jp/users/lolipop.jp-dp56011508/web/mtk/archives/2004/05/15_1202.php on line 17

Warning: main(../../../banner.html) [function.main]: failed to open stream: No such file or directory in /home/sites/lolipop.jp/users/lolipop.jp-dp56011508/web/mtk/archives/2004/05/15_1202.php on line 51

Warning: main() [function.include]: Failed opening '../../../banner.html' for inclusion (include_path='.:/usr/local/lib/php:/usr/local/lib/php/Smarty') in /home/sites/lolipop.jp/users/lolipop.jp-dp56011508/web/mtk/archives/2004/05/15_1202.php on line 51
TIP集の一覧
カテゴリー
最近10件の記事
このサイトについて
今となっては大それたサイト名ですが、主旨は自分が納得できる形にMTを改造できるまでの道のりメモです。(紛らわしくてスミマセン;)
あと、Version2.661です。
ちょこっとBBS

Warning: main(../../../link.html) [function.main]: failed to open stream: No such file or directory in /home/sites/lolipop.jp/users/lolipop.jp-dp56011508/web/mtk/archives/2004/05/15_1202.php on line 60

Warning: main() [function.include]: Failed opening '../../../link.html' for inclusion (include_path='.:/usr/local/lib/php:/usr/local/lib/php/Smarty') in /home/sites/lolipop.jp/users/lolipop.jp-dp56011508/web/mtk/archives/2004/05/15_1202.php on line 60

2004/05/15

Decodeと文字色をつける

[ TIP集 ]

文字フォントを変えるに引き続き、エントリー画面をどんどん変更しまーす。
Trivial BLOGさんの「管理画面にDecodeボタンをつける」と「Color Selectorをつける」を参考にしました。

※補記:Decodeは<>を自動で<とか>(半角)に直してくれるボタンです。

やっぱりいじくるのは、“tmpl/cms/bm_entry.tmpl と edit_entry.tmpl”です。
Decodeだけでなく、CodeとQuoteも付けちゃいます。Trivial BLOGさんにはほんと感謝ですね!!
で、以下また完璧コピペ。(必要ないと思うものは削除で)
まず一番上の<script language="JavaScript">〜</script>内に、以下を貼り付け。
上から順に、Code、Decode、Quoteです。

function format_code() {
if (!document.selection) return;
var str = document.selection.createRange().text;
if (!str) return;
document.selection.createRange().text = "
" + str + "
";
return;
}

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;
}

function format_quote() {
if (!document.selection) return;
var str = document.selection.createRange().text;
if (!str) return;
document.selection.createRange().text = "

" + str + "
";
return;
}

色に関しては、
function colorSelect (obj) {
var v;
if (!document.selection) return;
var str = document.selection.createRange().text;
if (!str) return;
with(obj) {
if (options[selectedIndex].value == "------") return;
v = options[selectedIndex].value;
}
document.all.colcol.style.backgroundColor = v;
document.selection.createRange().text = '<font color="' + v + '">' + str + '</font>';}

function colorSet() {
var v;
if (!document.selection) return;
var str = document.selection.createRange().text;
if (!str) return;
if (document.all.colcol.options[document.all.colcol.selectedIndex].value == "------") return;
v = document.all.colcol.options[document.all.colcol.selectedIndex].value;
document.selection.createRange().text = '<font color="' + v + '">' + str + '</font>';}

次にフォントの大きさを自在に(EntryBody周辺)を参照しながら、変更していない場合は変更すると吉かも。
その下<script language="javascript">内にあるwidthなどは崩れないように微調整が必要かもしれません。

そして「document.write('');」の下に、(Code、Decode、Quote順)

document.write('<td width="24"><a href="javascript:format_code()"><img src="<TMPL_VAR NAME=STATIC_URI>images/code-button.gif" alt="code" width="24" height="18" border="0"></a></td>');

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:format_quote()"><img src="<TMPL_VAR NAME=STATIC_URI>images/quote-button.gif" alt="quote" width="24" height="18" border="0"></a></td>');

ボタンはTrivialBLOGさんからそのまま頂きました♪

色については、以下を貼り付け。

document.write('<td width="100"><form name="colform"><select name="colcol" onchange="colorSelect(this)" width="48"><option value="------" selected>------<option value="red">red<option value="yellow">yellow<option value="blue">blue<option value="green">green<option value="cyan">cyan</select><input type="button" onclick="colorSet()" value="set"></td>');

ただし、色は好きな色に変更してみました。
ひらがなで書いたら文字化けしたので、アルファベット・カタカナ・漢字での名前付けを。
こんなかんじになります。


by JK - 2004/05/15 12:02 | TIP集 | 編集
この記事のURL:
トラックバックURL:
"Decodeと文字色をつける"の関連記事
"Decodeと文字色をつける"へのコメント
コメントする
※は必須です。E-mailは管理人にのみ通知され、表示はされません。









Cookieを使いますか?