modules-for-icab-mobileの日本語訳

「modules-for-icab-mobileの日本語訳」の編集履歴(バックアップ)一覧はこちら

modules-for-icab-mobileの日本語訳」(2011/10/20 (木) 00:24:25) の最新版変更点

追加された行は緑色になります。

削除された行は赤色になります。

このページは http://www.icab.de/blog/2010/02/17/modules-for-icab-mobile/ の日本語訳をつける作業ページです。&link_edit(text=ページを編集) [[「この日本語訳おかしくね?」と思ったら]] 超意訳ですが、ざっくり意味が伝わればそれでオーケーぐらいのスタンスです。 細かいことには目をつむってください ---- ここにコメントをどうぞ: - autorun機能についての追記を翻訳 -- 管理人 (2010-08-02 20:22:04) - postRequest関数についての追記を翻訳 -- 管理人 (2010-08-23 10:51:36) - titleの訳せていないかったところを翻訳 -- vmeniv (2011-01-01 16:24:23) - モジュールのvarプロパティにappinstalledが増えました。ほかのアプリと連携させるモジュールに使えます。また、プラットフォームで分岐もでき、「navigator.platform == &quot;iPad&quot;」でiPadかどうかわかるみたいです。(ソースは元から入っているOpenInGoodreader.icabmodule) -- 名無し (2011-10-20 00:19:17) #comment ---- *Modules for iCab Mobile (Updated) &font(gray){The version 2.1 of iCab Mobile introduces a new “modules” feature. Modules make it possible to add new features in iCab Mobile just by downloading them. They can be used for simple things like increasing the font size so a page is more easy to read on the small iPhone screen, but also more complex tasks can be done, like downloading YouTube videos or to post a web page URL at Twitter (including the login and creating a tiny URL). iCab Mobile 2.1 comes with a few built-in modules, and there are also several modules available for download.} バージョン2.1以上のiCab Mobileにはモジュールという機能が備わっています。モジュールによってiCab Mobileは、それらをダウンロードするだけで新たな機能を追加することができます。モジュールはiPhoneの小さなスクリーンでも読みやすくするためにフォントを大きくする、といったシンプルなことにも使えますし、もっと複雑な、たとえばYouTubeからビデオをダウンロードしたりウェブページのURLをTwitterでつぶやく(ログインや短縮URL作成ももちろん含む)、といったこともできます。 iCab Mobile 2.1にはいくつかのモジュールを内蔵していますし、ダウンロード可能なさまざまなモジュールが存在します。 &font(gray){This blog post will explain, how you can write your own modules for iCab Mobile and how you (and maybe other users) can install them in iCab Mobile.} このブログ記事では、あなたがどのようにしてモジュールを書けばいいか、またどのようにしてインストールするかを説明しています。 **技術的背景 (Technical background) &font(gray){Technically, modules are somehow similar to bookmarklets, but with more features and more flexibility. This means the modules are written in JavaScript code and they can do everything that can be done with JavaScript. Unlike bookmarklets, where the complete JavaScript code must be squeezed in one single line so that it can be used as a URL with “javascript” scheme, the modules can be nicely formatted, without any line limitation. Modules have a special header section where the module properties are defined. The properties include an icon that is displayed in the Modules panel of iCab Mobile, but also settings which do allow the user to configure the module in the iCab Mobile module settings panel.} 技術的にはモジュールはブックマークレットと似ていますが、より機能的でより柔軟です。それは、モジュールはJavaScriptで書かれており、JavaScriptで可能なことはすべて可能だという意味でです。ブックマークレットと違うのは、ブックマークレットはjavascriptスキームのURLとして扱われるためにスクリプトをまるごと一行に圧縮しなければなりませんが、モジュールは複数行の見やすいフォーマットでよい点です。モジュールはモジュールのプロパティを定義する特殊なヘッダーセクションを持ちます。プロパティにはiCab Mobileのモジュールパネルに表示されるアイコンや、ユーザがiCab Mobileの設定パネルから変更することができる設定などがあります。 **モジュールの構造 (The module structure) &font(gray){The module is a normal text file with JavaScript code. There’s a header section and the code section. Here’s an example, how this looks like:} モジュールはJavaScriptのコードが書かれた普通のテキストファイルです。ヘッダーセクションとコードセクションが存在します。サンプルを下に示します: //startconfig //id=de.icab.crazy //icon=iVBORw0KGgoAAAANSUhEUgAAACwAAAAkCAYAAADy19hsAAAWrGlDQ1BJQ0... //title=Crazy Layout //description=The module sets random colors for the page elements //description.de=Das Modul setzt alle Farben der Seite auf Zufallswerte //var=confirmation;type=confirmation;default=false; //var=language;type=language; //endconfig var hex = "0123456789abcdef"; function iCabMobileGoCrazyForElement(element) { if (element.nodeType == 1) { if (element.style.display != "none" && element.nodeName.toLowerCase() != 'select') { element.style.backgroundColor = "#" + hex.charAt(Math.random()*16) + hex.charAt(Math.random()*16) + hex.charAt(Math.random()*16); element.style.color = "#" + hex.charAt(Math.random()*16) + hex.charAt(Math.random()*16) + hex.charAt(Math.random()*16); for (var i=0; i<element.childNodes.length; i++) { iCabMobileGoCrazyForElement(element.childNodes[i]); } } } } var doAction = (confirmation == false); if (confirmation) { var text = "Go crazy?"; doAction = confirm(text); } if (doAction) { iCabMobileGoCrazyForElement(window.document.body); } &font(gray){The header section defines the properties of the module. The header section starts with the line} ヘッダセクションではモジュールのプロパティを定義します。ヘッダセクションはこの一行から始まります //startconfig &font(gray){and ends with the line} 終わりはこの一行です //endconfig &font(gray){Between these two lines all the properties are defined, each individual property definition occupies exactly one line, so currently you can’t split the definition of a property into multiple lines. Also no empty lines are allowed in the header section. Each property definition has the following format:} この二行の間にすべてのプロパティを定義し、それら個々のプロパティ定義は一行ごとに解釈されます。(訳注※ひとつのプロパティごとに一行ということ。)そのため、複数行にわたる内容の定義はできません。また、空行は含んではいけません。どのプロパティも以下のようなフォーマットになります: //property=value;additional paramaters (additional paramaters = 追加パラメータ) &font(gray){The additional parameters are optional and not always needed or required.} 追加パラメータはオプションであり、いつも必要なわけではありません。 &font(gray){There are some properties which are required. If they are missing, iCab Mobile will ignore the module. Other properties are optional and do not need to be present. Here are the properties which are currently supported:} いくつかのプロパティは必須です。もしそれが間違っていたら、iCab Mobileはそのモジュールを無視します。(インストールされません。) その他のプロパティはオプションなのでなくても動作します。ここに現在サポートしているプロパティを挙げます: ''id'' (required[必須]) &font(gray){This property identifies the module. When updating or reinstalling a module, the value of the “id” will be used to find the old module that has to be replaced by the new one. So when updating a module, you must not change the value of the “id”. Everything else can be modified, even the name of the module. The value of the “id” property should be unique among all existing modules. The best way to find a good “id” value is to use a reverse domain name appended with the module name. If your own web page has the domain “www.your-domain.com” you should set the “id” value to “com.your-domain.moduleName”. All of your own modules will have the same reverse domain prefix and the module name as suffix. If you don’t have your own domain, you can use your name and city as a prefix and maybe some random numbers, anything which makes it unlikely that someone else uses the same id value. The “id” is not visible to the user within iCab Mobile. Its only used to identify the module.} このプロパティはモジュールを識別するためのものです。モジュールをアップデートや再インストールするときにこの"id"の値が、新しいものに置き換える必要のある古いモジュールを見つけるときに使用されます。ですからモジュールをアップデートするときに、この"id"の値を変更してはいけません。そのほかなら何を変えても構いません、モジュールの名前でさえ。このidというプロパティは、この世に存在する他のすべてのモジュールとかぶらないユニークなものである必要があります。良いidを見つけるベストな手段として、ドメイン名をひっくり返しモジュール名を足して使うという手があります。もしあなたが"www.your-domain.com"というドメインをあなたのウェブページに使っているならば、あなたはidに"com.your-domain.moduleName"を使うべきでしょう。あなた作ったすべてのモジュールは、ひっくり返したドメイン名を接頭辞に、モジュール名を接尾語に持つということになります。もしあなたがドメインを持っていないならば、あなたは接頭辞にあなたの名前や都市の名前にいくつかのランダムな数字(不幸にも同じidを持ってしまわないために)を足して使うといいでしょう。idはiCab Mobileのユーザの目に触れることはありません。モジュールの識別のためだけに使用されます。 Example: 例: //id=de.icab.crazy &font(gray){or if you don’t have your own domain, you may use something like this:} もしドメインを持ってないならば、例としてはこんな感じです: //id=de.darmstadt.clauss.alexander.crazy //id=ja.saitama.taro.yamada.crazy ''title'' (required[必須]) &font(gray){The title defines the name of the module and is displayed within the modules settings of iCab mobile. The title property is needed so that the user can enable or disable the modules in the in-app settings and also configure the modules settings.} titleでモジュールの名前を定義します。iCab Mobileのモジュール設定で表示されるものです。タイトルプロパティはユーザがアプリ内設定でモジュールを有効化/無効化するときやモジュールの設定をするときのために必要です。 Example: 例: //title=Crazy Colors &font(gray){You can also define localized versions of the title. Just append the language code (for example “en” for English, “de” for German, “it” for Italian etc.) of any of the languages which are supported by the iPhone OS to the “title” keyword} あなたはローカライズされたタイトルを定義することができます。iPhone OS がサポートする言語の言語コード(たとえば英語なら"en", ドイツ語なら"de", イタリア語なら"it")を"title"という語の後につけるだけです &font(gray){(日本語はjaですが、日本語が使えるのかどうかは未確認です)} like this: こんな風に: //title.de=Verrückte Farben //title.ja=狂った色 &font(gray){This way you can easily localize the module in many languages. The key “title” without a language code appended will be used as default language which is used when none of the defined languages does match the current language of the iPhone or iPod Touch.} この方法で、簡単にモジュールを多言語にローカライズできます。言語コードのついていない「title」というキーは言語コードが現在の[デバイス]の言語に適合する定義済みの言語コードが無かったときに使われる既定の言語として使用されます。 &font(gray){ In general the default language should be English. If no default language is defined, then the very first language that is define will be used as default language. But it is highly recommended, that you simply use English as the default language (without language code).} 一般には既定の言語は英語であるべきです。もし既定の言語が定義されていないときは、一番最初に定義されている言語が既定の言語として使われますが、既定の言語(言語コードの無いtitleキー)として英語を使うことが大いに推薦されます。 #co{(この文章は意味が通るように訳せませんでした。とりあえずの意味としては、上の方法を使って簡単に多言語対応が可能になるということと、言語コードをつけない"title"は既定の言語として働くんだけど、既定の言語というのは英語を使うのがベターだ、ということ)} &font(gray){So if the module supports English and German, the title would be defined this way:} ですので、もしモジュールが英語とドイツ語をサポートするのであれば、titleは次のように定義されます: //title=Crazy Colors //title.de=Verrückte Farben ''description'' (optional[オプション]) &font(gray){The description is displayed in the settings panel of the module in iCab Mobile. The description should explain what the module is doing. Localizing is done in the same way as described above for the title. Append the language code to the “description” keyword:} descriptionはiCab Mobileのモジュール設定パネルで表示されます。descriptionはモジュールが何をするものなのかの説明がよいでしょう。titleプロパティと同様の手段を用いて次のようにローカライズが可能です: //description=The module sets random colors for the page elements //description.de=Das Modul setzt alle Farben der Seite auf Zufallswerte ''icon'' (optional, but highly recommended[オプションだが強く推奨]) &font(gray){The icon is displayed when the user opens the modules panel where the modules can be activated by tapping on their icon. The icon should be an image file in PNG or JPG format. The data of the image file must be encoded with “base64″ and this “base64″ encoded data can be then used as value for the “icon” property. Usually the base64 data is formatted in lines of at most 64 characters length, but for the modules, all line breaks must be removed, so the icons data can be completely included in one line. The size of the module icons (the visible part) should be approx. 41*32. You can use the following empty icon image as a template for your own icons:} iconはユーザがモジュールのアイコンをタップすることによってそのモジュールを動作させることができるモジュールパネルを開いたときに表示されます。iconはPNGかJPGフォーマットの画像ファイルです。画像ファイルはBase64でエンコードされている必要があり、このBase64でエンコードされたデータをiconプロパティに指定します。通常、Base64データは64種類の文字からなる複数行で成りますが、モジュールに組み込むにあたり、改行を削除し一行にする必要があります。モジュールのアイコンは41*32が推奨されます。あなたのアイコンを作るにあたって空のアイコンイメージを用意したので使ってください: http://www.icab.de/img/empty.png (iCabが用意した空のボタン画像) //icon=iVBORw0KGgoAAAANSUhEUgAAACwAAAAkCAYAAADy19hsAAAWrGlDQ1BJQ0... ''var'' &font(gray){The “var” property defines JavaScript variables, which are initialized by iCab Mobile. These variables can be used to allow the user to configure the modules, but also to get certain system properties, like the system language.} "var"プロパティはiCab Mobileによって初期化されるJavaScriptの変数を定義します。これらの変数はユーザがモジュールの設定として変更することができ、またそれだけでなく、システム言語のようなシステムプロパティを得ることもできます。 &font(gray){Variables do have the following format:} 変数は次のような形式をとります: //var=NameOfVar;type=typeOfVar;default=defaultValue;title=labelForSettings; &font(gray){iCab Mobile will create a standard JavaScript variable declaration and initialization for all of these variable properties and adds these to the JavaScript code of the module. So your JavaScript code of the module can check and use these variables just like any other variables.} iCab Mobileはこれら変数プロパティをJavaScriptから利用するために変数宣言と初期化をするJavaScriptコードを生成し、モジュールのJavaScriptコードに追加します。 そのため、それらはJavaScriptの変数であるため、特別な利用方法などいらず普通の変数として扱うことができます。 &font(gray){The value of the “var” property is the name of the variable.} "var"プロパティの値は変数の名前となります。 &font(gray){The “title” property is required, when the variable should be presented to the user in the module settings, so the user can change the value of the variable. The value of the “title” property is used as the label in the settings panel. You can add additional localized versions of the title, just by appending the language code (as described above).} "title"プロパティはユーザがモジュール設定にて変更可能であるときに必要で、これによってユーザは変数の値を変更することができます。"title"プロパティの値は設定パネルのラベルにて使用されます。言語コードを付加すればローカライズされた表示をすることも可能です。 &font(gray){The “default” property can be used to define a certain default value for the variable.} "default"プロパティで変数の規定値を定義することができます。 &font(gray){The value of the “type” property is the type of the variable, which can be one of the following:} "type"プロパティは変数の型で、次のうちのひとつをとることができます: &font(green){&b(●){bool or boolean 真偽型}} &font(gray){The variable can have the values true or false. In the module settings this variable will be represented by a “switch” control. If the user switches it on, the variable will have the value true otherwise the variable will have the value false. The title attribute is required for this type. The title is shown as label for the switch in the module settings. } trueかfalseの値をとる真偽値型です。モジュール設定でスイッチコントロールによってユーザによる状態変更が可能です。この型にはモジュール設定でラベルとして表示するための"title"プロパティが必要です。 &font(green){&b(●){int or integer 数値型}} &font(gray){The variable can have a numerical value. In the module settings, this variable is represented with a text field where you can enter digits. The title attribute is required for this type. The title is shown as label for the edit field in the module settings. } 数値型です。モジュール設定では数字しか入力できないテキストフィールドによってユーザによる数値の変更が可能です。この型にはモジュール設定でラベルとして表示するための"title"プロパティが必要です。 &font(green){&b(●){string or text 文字列型}} &font(gray){The variable can have a string value. In the module settings, it is represented as a text field. The title attribute is required for this type. The title is shown as label for the edit field in the module settings. } 文字列型です。モジュール設定ではテキストフィールドによってユーザによる文字列の変更が可能です。この型にはモジュール設定でラベルとして表示するための"title"プロパティが必要です。 &font(green){&b(●){pass or password パスワード文字列型}} &font(gray){The variable can have a string value. In the module settings, it is represented as a text field where the input is hidden. The title attribute is required for this type. The title is shown as label for the edit field in the module settings. } パスワード文字列型です。セキュリティのために入力した文字列が隠される点を除いて、文字列型と一緒です。この型にはモジュール設定でラベルとして表示するための"title"プロパティが必要です。 &font(green){&b(●){lang or language システム言語コード型}} &font(gray){The value of this variable is a string that contains the language code of the currently selected system language. This variable is not presented in the settings panel of the module. Therefore no title property is required here. } システムの既定の言語の言語コードが代入される文字列型です。"title"プロパティは不要です。"en", "de", "it", "ja"といった値をとります。 &font(green){&b(●){confirm or confirmation 確認ダイアログ設定型}} &font(gray){The variable has a boolean value. It is represented in the module settings by a switch where the user can enable or disable a confirmation box. If enabled, iCab Mobile will ask each time the module is activated, if it should be really executed. This variable does not need a “title” property because it is automatically localized within the module settings panel.} 確認ダイアログ設定が代入される真偽型です。モジュール設定でできる確認ダイアログを有効にするか無効にするかの設定がどうなっているかを提供します。もし有効にされているなら、iCab Mobileはモジュールが作動するときに毎回本当に実行するかどうかを訪ねます。この変更オプションはiCab Mobileによって提供され自動的にローカライズされるので、この変数には"title"プロパティはいりません。 &font(green){&b(●){autorun 自動実行}} &font(gray){The variable has a boolean value. It is represented in the module settings by a switch where the user can configure, if the module should be automatically run when the page has finished loading. This variable does not need a “title” property because it is automatically localized within the module settings panel. If there’s no variable of the type “autorun” set, the module can only be opened manually. You can set the default value for the variable to switch on or off the “autorun” feature for the module. But the user will be always able to disable the “autorun” feature in the module settings. When the modul is executed, the variable that is defined with the type “autorun” will have the value “true” if the module was executed automatically (which means when the page has finished loading) and the value “false” if the module was opened manually by the user. So a module is able to do different thing when called automatically and when called manually (for example it can mark elements when called automatically to notify the user about something, and modify the elements when called manually, to do the real work). [This feature will be available in iCab Mobile 3.3, it's not yet available in version 3.2]} この変数は真偽値を持ちます。もしページロード完了時にモジュールが自動的に起動されるように推奨される場合、モジュール設定にあるユーザが設定することができるスイッチが提供されます。この変数には"title"プロパティは必要ありません。勝手にローカライズされます。もし"autorun"変数が定義されていない場合、モジュールは手動によってのみ起動できます。あなたはあなたのモジュールにおける"autorun"機能のデフォルトの設定をオン、オフのどちらにも設定することが出来ます。しかし、ユーザはいつでも"autorun"機能を停止することができます。モジュールが実行されたとき、autorun型の変数は自動実行されたとき(つまりページロード完了時にiCab Mobileがモジュールを起動させたとき)は"true"、もしくはユーザによって手動起動されたときは"false"の値をとります。なのでモジュールは自動実行と手動実行のときで別々の振る舞いをすることができます。[この機能はiCab Mobile 3.3から利用可能になります。バージョン3.2では利用不能です] &font(green){&b(●){select 列挙型}} The variable of this type can be used to select one item from an array of items. This variable type uses the title property in the same way as the other types to define the label in the module settings. ようするに列挙型です。ラジオボタンの方が近いかもしれません。"title"プロパティを設定すればモジュール設定で反映されます。 &font(gray){This variable type requires that two other properties are defined as well. The “values” property must be defined to create the array of values the user can choose from, and the “valuetitles” property must be defined to define the array of titles for these values. The “valuetitles” properties is localizable again, so append the language code as shown above for the “title” property. For the “values” and “valuetitles” property, all items must be separated by the “|” character.} この変数では後述する二つのプロパティが定義されている必要があります。"values"プロパティはユーザが選んだ項目がとる値の配列で、"valuetitles"プロパティはユーザが選ぶ項目名の配列です。"valuetitles"プロパティもまた、"title"プロパティと同じように言語コードをつければローカライズすることができます。"values"と"valuetitles"プロパティは項目を区切るために"|"で区切る必要があります。 An example: 例: //var=s;type=select;valuetitles=One|Two|Three;values=1|2|3;title=Number;default=2 //var=j;type=select;valuetitles=壱|弐|参;values=1|2|3;title=数値;default=2 &font(gray){In the settings the user would be able to choose between “One”, “Two” and “Three”. If the user selects “One” the variable s would have the value 1, if the user selects “Two” the variable s would have the value 2 etc. The default value would be 2 and the user would see that “Two” is preselected. The whole setting would have the label “Number”.} この設定の場合、ユーザは"One" "Two" "Three"のうちからひとつを選ぶことができます。もしユーザが"One"を選んだなら変数の値は 1 になり、もし"Two"を選んだなら 2 になる、とっった具合です。"default"によって変数は 2 に、最初から"Two"を選んだ状態になります。このラジオ選択自体に"title"でラベルをつけることができます。 &font(gray){When the user activates a module, iCab Mobile will process the header sections and creates JavaScript variable declarations for all the variable definitions from the header section. The values for these variables will be determined by the module settings. Technically, iCab will add these variable declarations before the JavaScript code section of the module, so the module can access these variables. These variables and the JavaScript code section will be embedded in a block, so they have their own scope and do not interfere with the JavaScript code and variables which are already present in the web page.} ユーザがモジュールを動作させるとき、iCab Mobileはヘッダーセクションを読み込み、ヘッダーセクションのすべての変数定義のためにJavaScriptコードを作り出します。それらの変数の値はモジュール設定によって決定されます。技術的には、iCab Mobileはそれらの変数宣言をモジュールのJavaScriptコードセクションの前に追加するので、それによってモジュールがそれらの変数にアクセスできるようになります、それらの変数やJavaScriptコードセクションはブロックに組み込まれて実行されるため、現在表示しているウェブページのスコープを汚すことはありません。 &font(gray){This means, when the module looks like this:} それはつまり、以下のモジュールを例に考えると: //startconfig //id=de.icab.module //icon=iVBORw0KGgoAAAANSUhEUgAAACwAAAAkCAYAAADy19hsAAAWrGlDQ1BJQ0... //title=Some Module //var=confirmation;type=confirmation;default=false; //var=language;type=language; //var=text;type=string;title=Text; //endconfig function DoSomething() { // here's the actual code which is doing all the work of the module // ここにモジュールの実際のコードを書きます } if (confirmation) { //doAction = confirm("Really activate the module?"); doAction = confirm("本当にこのモジュールを実行しますか?"); } else { doAction = true; } if (doAction) { DoSomething(); } &font(gray){the resulting code that is actually executed in the context of the web page looks like this:} 実際に実行されるコードはこのようになります: { var confirmation = true; var language = "en"; var text = "User Input"; function DoSomething() { // here's the actual code which is doing all the work // ここにモジュールの実際のコードを書きます } if (confirmation) { //doAction = confirm("Really activate the module?"); doAction = confirm("本当にこのモジュールを実行しますか?"); } else { doAction = true; } if (doAction) { DoSomething(); } } **JavaScriptの特別関数 (Special JavaScript functions) &font(gray){Modules can also call special JavaScript functions, which are defined by iCab Mobile to do certain tasks.} モジュールはiCab Mobileによって定義された特殊な関数を呼ぶことができます。 &font(gray){There are the following functions available:} 次のような関数が利用可能です: ''startDownload(url,file)'' &font(gray){This function starts a download. The parameters are the URL and a suggestion for the filename under which the download should be saved.} この関数はダウンロードを開始します。引数はURLと保存されるファイル名です。 ''postRequest(url,content,”callBackFunction”)'' &font(red){&b(){new!!}} &font(gray){This function gets the data from the URL using the HTTP POST command (posting “content” to the server) and then passes the HTTP status code and the data to a function called “callBackFunction” (see getRequest() below for a description of the callback function).} この関数はHTTPのPOSTコマンド(”content”をサーバにポスト)でデータを取得し、HTTPステータスとデータを引数にコールバック関数を呼びます。(コールバック関数に関しては下のgetRequest()関数の説明をご覧ください) ''getRequest(url,”callBackFunction”)'' &font(gray){This function gets the data from the URL (using the HTTP GET command) and then passes the HTTP status code and the data to a function called “callBackFunction” (the second parameter is a string with the name of the callback function that must be implemented by the Module to process the data):} この関数は指定されたURLからHTTPのGETコマンドを使ってデータを取得し、HTTPステータスとデータを引数にコールバック関数を呼びます。(二番目の引数はモジュール内で実装されたコールバック関数の関数名の文字列です) function callBackFunction(status, data) { // "status" is an integer value with the HTTP status code (200, 404, etc) // "data" is a string with the URL data // "status"はHTTPステータスコードの数値です // "data"は取得したデータ(文字列)です } **モジュールのインストール (Installing the modules) &font(gray){Installing the modules is done by simply downloading them from a web site. So all you need to do is to provide a web page which contains a link to your module. The link URL must use the URL scheme “icabmodule” or “javascriptmodule” instead of the usual “http” scheme. This is how iCab Mobile detects that it should download and install a module.} モジュールをインストールは、ウェブサイトからダウンロードするだけです。ですからあなたがすべきことはモジュールへのリンクが含まれるウェブページを用意するだけです。モジュールへのURLは、通常の"http"スキームの代わりに "icabmobule"スキームか"javascriptmodule"スキームを使ってください。 &font(gray){For example, if your module can be accessed with the URL} &font(gray){http://your.webspace.com/modules/TheModule.icabmodule} &font(gray){the HTML link you would have to include in your web page would look like this:} たとえば、もしあなたのモジュールに次のURLでアクセスできるとしたら http://your.webspace.com/modules/TheModule.icabmodule あなたがウェブページに盛り込むべきHTMLのリンクは次のようになります: <a href="icabmodule://your.webspace.com/modules/TheModule.icabmodule">Download TheModule</a> &font(gray){or alternatively look like this:} あるいは、次のようにします: <a href="javascriptmodule://your.webspace.com/modules/TheModule.icabmodule">Download TheModule</a> &font(gray){If you include these links on a web page which is accessible to other people as well, other iCab Mobile users would be also able to install your module. So you can easily share your modules with other users.} もし、誰もがアクセスできるウェブページにこれらのリンクを組み込んでいるのであれば、ほかのiCab Mobileユーザも同じようにあなたのモジュールをインストールすることができます。 ですからあなたは簡単にあなたのモジュールをほかのユーザーとシェアすることができます。 &font(gray){I’ve created two URL schemes for the modules. In case other iPhone developers are interested in this module feature (candidates would be developers of other iPhone browsers), it would be great if all these modules would be compatible.} 我々はモジュールのために二種類のURLスキームを用意しました。ほかのiPhoneデベロッパー(とくにiPhoneのウェブブラウザ開発者)がこのモジュール機能に興味をもってくれた場合、すべてのモジュールが互換性を持っているならすばらしいでしょう。 &font(gray){In this case the general URL scheme “javascriptmodule” could be used by all the Apps supporting the modules feature. And the other URL scheme could be used for application specific-modules (so “icabmodule” would be only accepted by iCab Mobile).} &font(gray){Just a reminder: My AppLink Proposal can be also used by other iPhone Apps.} この場合において、"javascriptmodule"スキームはモジュール機能をサポートするすべてのアプリに使われます。もう一方は、特化したモジュール(つまり、"icabmodule"スキームはiCab Mobileしか受け付けません)に使われます。 &font(gray){You can also sent the module to me so I can include it into the modules download page, which is accessible through the “Download” module that is built-in in iCab Mobile. This way the module can be immediately found by all iCab Mobile users.} あなたはモジュールを私(訳注※iCab Mobileの作者)に送ることができ、そうすれば私はそれらのモジュールをiCab Mobileに元から入っている"Download"モジュールを通してアクセス可能なモジュールダウンロードページに取り入れます。この方法ならすべてのiCab Mobileユーザがモジュールを即座に発見することができるでしょう。 ----
このページは http://www.icab.de/blog/2010/02/17/modules-for-icab-mobile/ の日本語訳をつける作業ページです。&link_edit(text=ページを編集) [[「この日本語訳おかしくね?」と思ったら]] 超意訳ですが、ざっくり意味が伝わればそれでオーケーぐらいのスタンスです。 細かいことには目をつむってください ---- ここにコメントをどうぞ: - autorun機能についての追記を翻訳 -- 管理人 (2010-08-02 20:22:04) - postRequest関数についての追記を翻訳 -- 管理人 (2010-08-23 10:51:36) - titleの訳せていないかったところを翻訳 -- vmeniv (2011-01-01 16:24:23) - モジュールのvarプロパティにappinstalledが増えました。ほかのアプリと連携させるモジュールに使えます。また、プラットフォームで分岐もでき、「navigator.platform == &quot;iPad&quot;」でiPadかどうかわかるみたいです。(ソースは元から入っているOpenInGoodreader.icabmodule) -- 名無し (2011-10-20 00:19:17) - ×appinstalled、○installed -- 名無し (2011-10-20 00:24:25) #comment ---- *Modules for iCab Mobile (Updated) &font(gray){The version 2.1 of iCab Mobile introduces a new “modules” feature. Modules make it possible to add new features in iCab Mobile just by downloading them. They can be used for simple things like increasing the font size so a page is more easy to read on the small iPhone screen, but also more complex tasks can be done, like downloading YouTube videos or to post a web page URL at Twitter (including the login and creating a tiny URL). iCab Mobile 2.1 comes with a few built-in modules, and there are also several modules available for download.} バージョン2.1以上のiCab Mobileにはモジュールという機能が備わっています。モジュールによってiCab Mobileは、それらをダウンロードするだけで新たな機能を追加することができます。モジュールはiPhoneの小さなスクリーンでも読みやすくするためにフォントを大きくする、といったシンプルなことにも使えますし、もっと複雑な、たとえばYouTubeからビデオをダウンロードしたりウェブページのURLをTwitterでつぶやく(ログインや短縮URL作成ももちろん含む)、といったこともできます。 iCab Mobile 2.1にはいくつかのモジュールを内蔵していますし、ダウンロード可能なさまざまなモジュールが存在します。 &font(gray){This blog post will explain, how you can write your own modules for iCab Mobile and how you (and maybe other users) can install them in iCab Mobile.} このブログ記事では、あなたがどのようにしてモジュールを書けばいいか、またどのようにしてインストールするかを説明しています。 **技術的背景 (Technical background) &font(gray){Technically, modules are somehow similar to bookmarklets, but with more features and more flexibility. This means the modules are written in JavaScript code and they can do everything that can be done with JavaScript. Unlike bookmarklets, where the complete JavaScript code must be squeezed in one single line so that it can be used as a URL with “javascript” scheme, the modules can be nicely formatted, without any line limitation. Modules have a special header section where the module properties are defined. The properties include an icon that is displayed in the Modules panel of iCab Mobile, but also settings which do allow the user to configure the module in the iCab Mobile module settings panel.} 技術的にはモジュールはブックマークレットと似ていますが、より機能的でより柔軟です。それは、モジュールはJavaScriptで書かれており、JavaScriptで可能なことはすべて可能だという意味でです。ブックマークレットと違うのは、ブックマークレットはjavascriptスキームのURLとして扱われるためにスクリプトをまるごと一行に圧縮しなければなりませんが、モジュールは複数行の見やすいフォーマットでよい点です。モジュールはモジュールのプロパティを定義する特殊なヘッダーセクションを持ちます。プロパティにはiCab Mobileのモジュールパネルに表示されるアイコンや、ユーザがiCab Mobileの設定パネルから変更することができる設定などがあります。 **モジュールの構造 (The module structure) &font(gray){The module is a normal text file with JavaScript code. There’s a header section and the code section. Here’s an example, how this looks like:} モジュールはJavaScriptのコードが書かれた普通のテキストファイルです。ヘッダーセクションとコードセクションが存在します。サンプルを下に示します: //startconfig //id=de.icab.crazy //icon=iVBORw0KGgoAAAANSUhEUgAAACwAAAAkCAYAAADy19hsAAAWrGlDQ1BJQ0... //title=Crazy Layout //description=The module sets random colors for the page elements //description.de=Das Modul setzt alle Farben der Seite auf Zufallswerte //var=confirmation;type=confirmation;default=false; //var=language;type=language; //endconfig var hex = "0123456789abcdef"; function iCabMobileGoCrazyForElement(element) { if (element.nodeType == 1) { if (element.style.display != "none" && element.nodeName.toLowerCase() != 'select') { element.style.backgroundColor = "#" + hex.charAt(Math.random()*16) + hex.charAt(Math.random()*16) + hex.charAt(Math.random()*16); element.style.color = "#" + hex.charAt(Math.random()*16) + hex.charAt(Math.random()*16) + hex.charAt(Math.random()*16); for (var i=0; i<element.childNodes.length; i++) { iCabMobileGoCrazyForElement(element.childNodes[i]); } } } } var doAction = (confirmation == false); if (confirmation) { var text = "Go crazy?"; doAction = confirm(text); } if (doAction) { iCabMobileGoCrazyForElement(window.document.body); } &font(gray){The header section defines the properties of the module. The header section starts with the line} ヘッダセクションではモジュールのプロパティを定義します。ヘッダセクションはこの一行から始まります //startconfig &font(gray){and ends with the line} 終わりはこの一行です //endconfig &font(gray){Between these two lines all the properties are defined, each individual property definition occupies exactly one line, so currently you can’t split the definition of a property into multiple lines. Also no empty lines are allowed in the header section. Each property definition has the following format:} この二行の間にすべてのプロパティを定義し、それら個々のプロパティ定義は一行ごとに解釈されます。(訳注※ひとつのプロパティごとに一行ということ。)そのため、複数行にわたる内容の定義はできません。また、空行は含んではいけません。どのプロパティも以下のようなフォーマットになります: //property=value;additional paramaters (additional paramaters = 追加パラメータ) &font(gray){The additional parameters are optional and not always needed or required.} 追加パラメータはオプションであり、いつも必要なわけではありません。 &font(gray){There are some properties which are required. If they are missing, iCab Mobile will ignore the module. Other properties are optional and do not need to be present. Here are the properties which are currently supported:} いくつかのプロパティは必須です。もしそれが間違っていたら、iCab Mobileはそのモジュールを無視します。(インストールされません。) その他のプロパティはオプションなのでなくても動作します。ここに現在サポートしているプロパティを挙げます: ''id'' (required[必須]) &font(gray){This property identifies the module. When updating or reinstalling a module, the value of the “id” will be used to find the old module that has to be replaced by the new one. So when updating a module, you must not change the value of the “id”. Everything else can be modified, even the name of the module. The value of the “id” property should be unique among all existing modules. The best way to find a good “id” value is to use a reverse domain name appended with the module name. If your own web page has the domain “www.your-domain.com” you should set the “id” value to “com.your-domain.moduleName”. All of your own modules will have the same reverse domain prefix and the module name as suffix. If you don’t have your own domain, you can use your name and city as a prefix and maybe some random numbers, anything which makes it unlikely that someone else uses the same id value. The “id” is not visible to the user within iCab Mobile. Its only used to identify the module.} このプロパティはモジュールを識別するためのものです。モジュールをアップデートや再インストールするときにこの"id"の値が、新しいものに置き換える必要のある古いモジュールを見つけるときに使用されます。ですからモジュールをアップデートするときに、この"id"の値を変更してはいけません。そのほかなら何を変えても構いません、モジュールの名前でさえ。このidというプロパティは、この世に存在する他のすべてのモジュールとかぶらないユニークなものである必要があります。良いidを見つけるベストな手段として、ドメイン名をひっくり返しモジュール名を足して使うという手があります。もしあなたが"www.your-domain.com"というドメインをあなたのウェブページに使っているならば、あなたはidに"com.your-domain.moduleName"を使うべきでしょう。あなた作ったすべてのモジュールは、ひっくり返したドメイン名を接頭辞に、モジュール名を接尾語に持つということになります。もしあなたがドメインを持っていないならば、あなたは接頭辞にあなたの名前や都市の名前にいくつかのランダムな数字(不幸にも同じidを持ってしまわないために)を足して使うといいでしょう。idはiCab Mobileのユーザの目に触れることはありません。モジュールの識別のためだけに使用されます。 Example: 例: //id=de.icab.crazy &font(gray){or if you don’t have your own domain, you may use something like this:} もしドメインを持ってないならば、例としてはこんな感じです: //id=de.darmstadt.clauss.alexander.crazy //id=ja.saitama.taro.yamada.crazy ''title'' (required[必須]) &font(gray){The title defines the name of the module and is displayed within the modules settings of iCab mobile. The title property is needed so that the user can enable or disable the modules in the in-app settings and also configure the modules settings.} titleでモジュールの名前を定義します。iCab Mobileのモジュール設定で表示されるものです。タイトルプロパティはユーザがアプリ内設定でモジュールを有効化/無効化するときやモジュールの設定をするときのために必要です。 Example: 例: //title=Crazy Colors &font(gray){You can also define localized versions of the title. Just append the language code (for example “en” for English, “de” for German, “it” for Italian etc.) of any of the languages which are supported by the iPhone OS to the “title” keyword} あなたはローカライズされたタイトルを定義することができます。iPhone OS がサポートする言語の言語コード(たとえば英語なら"en", ドイツ語なら"de", イタリア語なら"it")を"title"という語の後につけるだけです &font(gray){(日本語はjaですが、日本語が使えるのかどうかは未確認です)} like this: こんな風に: //title.de=Verrückte Farben //title.ja=狂った色 &font(gray){This way you can easily localize the module in many languages. The key “title” without a language code appended will be used as default language which is used when none of the defined languages does match the current language of the iPhone or iPod Touch.} この方法で、簡単にモジュールを多言語にローカライズできます。言語コードのついていない「title」というキーは言語コードが現在の[デバイス]の言語に適合する定義済みの言語コードが無かったときに使われる既定の言語として使用されます。 &font(gray){ In general the default language should be English. If no default language is defined, then the very first language that is define will be used as default language. But it is highly recommended, that you simply use English as the default language (without language code).} 一般には既定の言語は英語であるべきです。もし既定の言語が定義されていないときは、一番最初に定義されている言語が既定の言語として使われますが、既定の言語(言語コードの無いtitleキー)として英語を使うことが大いに推薦されます。 #co{(この文章は意味が通るように訳せませんでした。とりあえずの意味としては、上の方法を使って簡単に多言語対応が可能になるということと、言語コードをつけない"title"は既定の言語として働くんだけど、既定の言語というのは英語を使うのがベターだ、ということ)} &font(gray){So if the module supports English and German, the title would be defined this way:} ですので、もしモジュールが英語とドイツ語をサポートするのであれば、titleは次のように定義されます: //title=Crazy Colors //title.de=Verrückte Farben ''description'' (optional[オプション]) &font(gray){The description is displayed in the settings panel of the module in iCab Mobile. The description should explain what the module is doing. Localizing is done in the same way as described above for the title. Append the language code to the “description” keyword:} descriptionはiCab Mobileのモジュール設定パネルで表示されます。descriptionはモジュールが何をするものなのかの説明がよいでしょう。titleプロパティと同様の手段を用いて次のようにローカライズが可能です: //description=The module sets random colors for the page elements //description.de=Das Modul setzt alle Farben der Seite auf Zufallswerte ''icon'' (optional, but highly recommended[オプションだが強く推奨]) &font(gray){The icon is displayed when the user opens the modules panel where the modules can be activated by tapping on their icon. The icon should be an image file in PNG or JPG format. The data of the image file must be encoded with “base64″ and this “base64″ encoded data can be then used as value for the “icon” property. Usually the base64 data is formatted in lines of at most 64 characters length, but for the modules, all line breaks must be removed, so the icons data can be completely included in one line. The size of the module icons (the visible part) should be approx. 41*32. You can use the following empty icon image as a template for your own icons:} iconはユーザがモジュールのアイコンをタップすることによってそのモジュールを動作させることができるモジュールパネルを開いたときに表示されます。iconはPNGかJPGフォーマットの画像ファイルです。画像ファイルはBase64でエンコードされている必要があり、このBase64でエンコードされたデータをiconプロパティに指定します。通常、Base64データは64種類の文字からなる複数行で成りますが、モジュールに組み込むにあたり、改行を削除し一行にする必要があります。モジュールのアイコンは41*32が推奨されます。あなたのアイコンを作るにあたって空のアイコンイメージを用意したので使ってください: http://www.icab.de/img/empty.png (iCabが用意した空のボタン画像) //icon=iVBORw0KGgoAAAANSUhEUgAAACwAAAAkCAYAAADy19hsAAAWrGlDQ1BJQ0... ''var'' &font(gray){The “var” property defines JavaScript variables, which are initialized by iCab Mobile. These variables can be used to allow the user to configure the modules, but also to get certain system properties, like the system language.} "var"プロパティはiCab Mobileによって初期化されるJavaScriptの変数を定義します。これらの変数はユーザがモジュールの設定として変更することができ、またそれだけでなく、システム言語のようなシステムプロパティを得ることもできます。 &font(gray){Variables do have the following format:} 変数は次のような形式をとります: //var=NameOfVar;type=typeOfVar;default=defaultValue;title=labelForSettings; &font(gray){iCab Mobile will create a standard JavaScript variable declaration and initialization for all of these variable properties and adds these to the JavaScript code of the module. So your JavaScript code of the module can check and use these variables just like any other variables.} iCab Mobileはこれら変数プロパティをJavaScriptから利用するために変数宣言と初期化をするJavaScriptコードを生成し、モジュールのJavaScriptコードに追加します。 そのため、それらはJavaScriptの変数であるため、特別な利用方法などいらず普通の変数として扱うことができます。 &font(gray){The value of the “var” property is the name of the variable.} "var"プロパティの値は変数の名前となります。 &font(gray){The “title” property is required, when the variable should be presented to the user in the module settings, so the user can change the value of the variable. The value of the “title” property is used as the label in the settings panel. You can add additional localized versions of the title, just by appending the language code (as described above).} "title"プロパティはユーザがモジュール設定にて変更可能であるときに必要で、これによってユーザは変数の値を変更することができます。"title"プロパティの値は設定パネルのラベルにて使用されます。言語コードを付加すればローカライズされた表示をすることも可能です。 &font(gray){The “default” property can be used to define a certain default value for the variable.} "default"プロパティで変数の規定値を定義することができます。 &font(gray){The value of the “type” property is the type of the variable, which can be one of the following:} "type"プロパティは変数の型で、次のうちのひとつをとることができます: &font(green){&b(●){bool or boolean 真偽型}} &font(gray){The variable can have the values true or false. In the module settings this variable will be represented by a “switch” control. If the user switches it on, the variable will have the value true otherwise the variable will have the value false. The title attribute is required for this type. The title is shown as label for the switch in the module settings. } trueかfalseの値をとる真偽値型です。モジュール設定でスイッチコントロールによってユーザによる状態変更が可能です。この型にはモジュール設定でラベルとして表示するための"title"プロパティが必要です。 &font(green){&b(●){int or integer 数値型}} &font(gray){The variable can have a numerical value. In the module settings, this variable is represented with a text field where you can enter digits. The title attribute is required for this type. The title is shown as label for the edit field in the module settings. } 数値型です。モジュール設定では数字しか入力できないテキストフィールドによってユーザによる数値の変更が可能です。この型にはモジュール設定でラベルとして表示するための"title"プロパティが必要です。 &font(green){&b(●){string or text 文字列型}} &font(gray){The variable can have a string value. In the module settings, it is represented as a text field. The title attribute is required for this type. The title is shown as label for the edit field in the module settings. } 文字列型です。モジュール設定ではテキストフィールドによってユーザによる文字列の変更が可能です。この型にはモジュール設定でラベルとして表示するための"title"プロパティが必要です。 &font(green){&b(●){pass or password パスワード文字列型}} &font(gray){The variable can have a string value. In the module settings, it is represented as a text field where the input is hidden. The title attribute is required for this type. The title is shown as label for the edit field in the module settings. } パスワード文字列型です。セキュリティのために入力した文字列が隠される点を除いて、文字列型と一緒です。この型にはモジュール設定でラベルとして表示するための"title"プロパティが必要です。 &font(green){&b(●){lang or language システム言語コード型}} &font(gray){The value of this variable is a string that contains the language code of the currently selected system language. This variable is not presented in the settings panel of the module. Therefore no title property is required here. } システムの既定の言語の言語コードが代入される文字列型です。"title"プロパティは不要です。"en", "de", "it", "ja"といった値をとります。 &font(green){&b(●){confirm or confirmation 確認ダイアログ設定型}} &font(gray){The variable has a boolean value. It is represented in the module settings by a switch where the user can enable or disable a confirmation box. If enabled, iCab Mobile will ask each time the module is activated, if it should be really executed. This variable does not need a “title” property because it is automatically localized within the module settings panel.} 確認ダイアログ設定が代入される真偽型です。モジュール設定でできる確認ダイアログを有効にするか無効にするかの設定がどうなっているかを提供します。もし有効にされているなら、iCab Mobileはモジュールが作動するときに毎回本当に実行するかどうかを訪ねます。この変更オプションはiCab Mobileによって提供され自動的にローカライズされるので、この変数には"title"プロパティはいりません。 &font(green){&b(●){autorun 自動実行}} &font(gray){The variable has a boolean value. It is represented in the module settings by a switch where the user can configure, if the module should be automatically run when the page has finished loading. This variable does not need a “title” property because it is automatically localized within the module settings panel. If there’s no variable of the type “autorun” set, the module can only be opened manually. You can set the default value for the variable to switch on or off the “autorun” feature for the module. But the user will be always able to disable the “autorun” feature in the module settings. When the modul is executed, the variable that is defined with the type “autorun” will have the value “true” if the module was executed automatically (which means when the page has finished loading) and the value “false” if the module was opened manually by the user. So a module is able to do different thing when called automatically and when called manually (for example it can mark elements when called automatically to notify the user about something, and modify the elements when called manually, to do the real work). [This feature will be available in iCab Mobile 3.3, it's not yet available in version 3.2]} この変数は真偽値を持ちます。もしページロード完了時にモジュールが自動的に起動されるように推奨される場合、モジュール設定にあるユーザが設定することができるスイッチが提供されます。この変数には"title"プロパティは必要ありません。勝手にローカライズされます。もし"autorun"変数が定義されていない場合、モジュールは手動によってのみ起動できます。あなたはあなたのモジュールにおける"autorun"機能のデフォルトの設定をオン、オフのどちらにも設定することが出来ます。しかし、ユーザはいつでも"autorun"機能を停止することができます。モジュールが実行されたとき、autorun型の変数は自動実行されたとき(つまりページロード完了時にiCab Mobileがモジュールを起動させたとき)は"true"、もしくはユーザによって手動起動されたときは"false"の値をとります。なのでモジュールは自動実行と手動実行のときで別々の振る舞いをすることができます。[この機能はiCab Mobile 3.3から利用可能になります。バージョン3.2では利用不能です] &font(green){&b(●){select 列挙型}} The variable of this type can be used to select one item from an array of items. This variable type uses the title property in the same way as the other types to define the label in the module settings. ようするに列挙型です。ラジオボタンの方が近いかもしれません。"title"プロパティを設定すればモジュール設定で反映されます。 &font(gray){This variable type requires that two other properties are defined as well. The “values” property must be defined to create the array of values the user can choose from, and the “valuetitles” property must be defined to define the array of titles for these values. The “valuetitles” properties is localizable again, so append the language code as shown above for the “title” property. For the “values” and “valuetitles” property, all items must be separated by the “|” character.} この変数では後述する二つのプロパティが定義されている必要があります。"values"プロパティはユーザが選んだ項目がとる値の配列で、"valuetitles"プロパティはユーザが選ぶ項目名の配列です。"valuetitles"プロパティもまた、"title"プロパティと同じように言語コードをつければローカライズすることができます。"values"と"valuetitles"プロパティは項目を区切るために"|"で区切る必要があります。 An example: 例: //var=s;type=select;valuetitles=One|Two|Three;values=1|2|3;title=Number;default=2 //var=j;type=select;valuetitles=壱|弐|参;values=1|2|3;title=数値;default=2 &font(gray){In the settings the user would be able to choose between “One”, “Two” and “Three”. If the user selects “One” the variable s would have the value 1, if the user selects “Two” the variable s would have the value 2 etc. The default value would be 2 and the user would see that “Two” is preselected. The whole setting would have the label “Number”.} この設定の場合、ユーザは"One" "Two" "Three"のうちからひとつを選ぶことができます。もしユーザが"One"を選んだなら変数の値は 1 になり、もし"Two"を選んだなら 2 になる、とっった具合です。"default"によって変数は 2 に、最初から"Two"を選んだ状態になります。このラジオ選択自体に"title"でラベルをつけることができます。 &font(gray){When the user activates a module, iCab Mobile will process the header sections and creates JavaScript variable declarations for all the variable definitions from the header section. The values for these variables will be determined by the module settings. Technically, iCab will add these variable declarations before the JavaScript code section of the module, so the module can access these variables. These variables and the JavaScript code section will be embedded in a block, so they have their own scope and do not interfere with the JavaScript code and variables which are already present in the web page.} ユーザがモジュールを動作させるとき、iCab Mobileはヘッダーセクションを読み込み、ヘッダーセクションのすべての変数定義のためにJavaScriptコードを作り出します。それらの変数の値はモジュール設定によって決定されます。技術的には、iCab Mobileはそれらの変数宣言をモジュールのJavaScriptコードセクションの前に追加するので、それによってモジュールがそれらの変数にアクセスできるようになります、それらの変数やJavaScriptコードセクションはブロックに組み込まれて実行されるため、現在表示しているウェブページのスコープを汚すことはありません。 &font(gray){This means, when the module looks like this:} それはつまり、以下のモジュールを例に考えると: //startconfig //id=de.icab.module //icon=iVBORw0KGgoAAAANSUhEUgAAACwAAAAkCAYAAADy19hsAAAWrGlDQ1BJQ0... //title=Some Module //var=confirmation;type=confirmation;default=false; //var=language;type=language; //var=text;type=string;title=Text; //endconfig function DoSomething() { // here's the actual code which is doing all the work of the module // ここにモジュールの実際のコードを書きます } if (confirmation) { //doAction = confirm("Really activate the module?"); doAction = confirm("本当にこのモジュールを実行しますか?"); } else { doAction = true; } if (doAction) { DoSomething(); } &font(gray){the resulting code that is actually executed in the context of the web page looks like this:} 実際に実行されるコードはこのようになります: { var confirmation = true; var language = "en"; var text = "User Input"; function DoSomething() { // here's the actual code which is doing all the work // ここにモジュールの実際のコードを書きます } if (confirmation) { //doAction = confirm("Really activate the module?"); doAction = confirm("本当にこのモジュールを実行しますか?"); } else { doAction = true; } if (doAction) { DoSomething(); } } **JavaScriptの特別関数 (Special JavaScript functions) &font(gray){Modules can also call special JavaScript functions, which are defined by iCab Mobile to do certain tasks.} モジュールはiCab Mobileによって定義された特殊な関数を呼ぶことができます。 &font(gray){There are the following functions available:} 次のような関数が利用可能です: ''startDownload(url,file)'' &font(gray){This function starts a download. The parameters are the URL and a suggestion for the filename under which the download should be saved.} この関数はダウンロードを開始します。引数はURLと保存されるファイル名です。 ''postRequest(url,content,”callBackFunction”)'' &font(red){&b(){new!!}} &font(gray){This function gets the data from the URL using the HTTP POST command (posting “content” to the server) and then passes the HTTP status code and the data to a function called “callBackFunction” (see getRequest() below for a description of the callback function).} この関数はHTTPのPOSTコマンド(”content”をサーバにポスト)でデータを取得し、HTTPステータスとデータを引数にコールバック関数を呼びます。(コールバック関数に関しては下のgetRequest()関数の説明をご覧ください) ''getRequest(url,”callBackFunction”)'' &font(gray){This function gets the data from the URL (using the HTTP GET command) and then passes the HTTP status code and the data to a function called “callBackFunction” (the second parameter is a string with the name of the callback function that must be implemented by the Module to process the data):} この関数は指定されたURLからHTTPのGETコマンドを使ってデータを取得し、HTTPステータスとデータを引数にコールバック関数を呼びます。(二番目の引数はモジュール内で実装されたコールバック関数の関数名の文字列です) function callBackFunction(status, data) { // "status" is an integer value with the HTTP status code (200, 404, etc) // "data" is a string with the URL data // "status"はHTTPステータスコードの数値です // "data"は取得したデータ(文字列)です } **モジュールのインストール (Installing the modules) &font(gray){Installing the modules is done by simply downloading them from a web site. So all you need to do is to provide a web page which contains a link to your module. The link URL must use the URL scheme “icabmodule” or “javascriptmodule” instead of the usual “http” scheme. This is how iCab Mobile detects that it should download and install a module.} モジュールをインストールは、ウェブサイトからダウンロードするだけです。ですからあなたがすべきことはモジュールへのリンクが含まれるウェブページを用意するだけです。モジュールへのURLは、通常の"http"スキームの代わりに "icabmobule"スキームか"javascriptmodule"スキームを使ってください。 &font(gray){For example, if your module can be accessed with the URL} &font(gray){http://your.webspace.com/modules/TheModule.icabmodule} &font(gray){the HTML link you would have to include in your web page would look like this:} たとえば、もしあなたのモジュールに次のURLでアクセスできるとしたら http://your.webspace.com/modules/TheModule.icabmodule あなたがウェブページに盛り込むべきHTMLのリンクは次のようになります: <a href="icabmodule://your.webspace.com/modules/TheModule.icabmodule">Download TheModule</a> &font(gray){or alternatively look like this:} あるいは、次のようにします: <a href="javascriptmodule://your.webspace.com/modules/TheModule.icabmodule">Download TheModule</a> &font(gray){If you include these links on a web page which is accessible to other people as well, other iCab Mobile users would be also able to install your module. So you can easily share your modules with other users.} もし、誰もがアクセスできるウェブページにこれらのリンクを組み込んでいるのであれば、ほかのiCab Mobileユーザも同じようにあなたのモジュールをインストールすることができます。 ですからあなたは簡単にあなたのモジュールをほかのユーザーとシェアすることができます。 &font(gray){I’ve created two URL schemes for the modules. In case other iPhone developers are interested in this module feature (candidates would be developers of other iPhone browsers), it would be great if all these modules would be compatible.} 我々はモジュールのために二種類のURLスキームを用意しました。ほかのiPhoneデベロッパー(とくにiPhoneのウェブブラウザ開発者)がこのモジュール機能に興味をもってくれた場合、すべてのモジュールが互換性を持っているならすばらしいでしょう。 &font(gray){In this case the general URL scheme “javascriptmodule” could be used by all the Apps supporting the modules feature. And the other URL scheme could be used for application specific-modules (so “icabmodule” would be only accepted by iCab Mobile).} &font(gray){Just a reminder: My AppLink Proposal can be also used by other iPhone Apps.} この場合において、"javascriptmodule"スキームはモジュール機能をサポートするすべてのアプリに使われます。もう一方は、特化したモジュール(つまり、"icabmodule"スキームはiCab Mobileしか受け付けません)に使われます。 &font(gray){You can also sent the module to me so I can include it into the modules download page, which is accessible through the “Download” module that is built-in in iCab Mobile. This way the module can be immediately found by all iCab Mobile users.} あなたはモジュールを私(訳注※iCab Mobileの作者)に送ることができ、そうすれば私はそれらのモジュールをiCab Mobileに元から入っている"Download"モジュールを通してアクセス可能なモジュールダウンロードページに取り入れます。この方法ならすべてのiCab Mobileユーザがモジュールを即座に発見することができるでしょう。 ----

表示オプション

横に並べて表示:
変化行の前後のみ表示:
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。