/* ---------------------------------------------------------------------- * MocaScript File * $Id: xhtmlRuby.ms,v 1.6 2004/07/05 14:09:20 nzawa Exp nzawa $ * * [Title] * ruby要素入力支援スクリプト * * * Copyright (c) 2002-2004 Nzawa * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * ----------------------------------------------------------------------*/ ///////////////////////////////////////////////////////////////////////////// // コマンド宣言 #command InsertRubyElement "ruby要素挿入" ///////////////////////////////////////////////////////////////////////////// // オプション // ruby要素非対応環境用括弧を出力しない // var disableParenthesis = true; // ruby要素非対応環境用括弧の指定 var openParenthesis = "("; // 開き括弧 var closeParenthesis = ")"; // 閉じ括弧 // IE5.0独自拡張形式での出力 // var asIE5Extension = true; ///////////////////////////////////////////////////////////////////////////// // コマンド処理 // ウインドウの有無をチェックする。 if (!view) error("編集ウィンドウが開いていません."); switch (command) { case "InsertRubyElement": insertRubyElement(); break; default: error(command + ": 不明なコマンドです."); } ///////////////////////////////////////////////////////////////////////////// // ruby要素挿入 function insertRubyElement() { // 変数宣言 var defaultRubyBase; var rubyDialog; var rubyBase; var rubyText; var rubyElement; // 矩形選択時は処理を中断 if (getSelection().block) error("矩形選択されています."); // 選択文字列を対象テキストのデフォルト値にする defaultRubyBase = getSelectedText(); // 入力ダイアログの表示 rubyDialog = inputBox( "ruby要素挿入", "ルビを振る対象テキストとルビテキストを入力して下さい.", ["対象テキスト(&t)", defaultRubyBase], "ルビテキスト(&r)"); // キャンセル時の処理 if (!rubyDialog) exit(); // 入力されたテキストの抽出 rubyBase = rubyDialog[0]; rubyText = rubyDialog[1]; // ruby要素の生成 if ( !asIE5Extension && !disableParenthesis ) rubyElement = "" + rubyBase + "" + openParenthesis + "" + rubyText + "" + closeParenthesis + ""; else if ( !asIE5Extension && disableParenthesis ) rubyElement = "" + rubyBase + "" + rubyText + ""; else rubyElement = "" + rubyBase + "" + rubyText + ""; // ruby要素の挿入 insertText(rubyElement); }