Chapter 21. JavaScript Outside the Box
■21.1 Creating a Browser Add-0n, Plug-in, or Extension
この本が出たときはまだsafariとOperaにJavaScriptベースな拡張を書ける機能はなかったんだなー- Google Chrome Extension
- Mozilla extensions
- Greasemonkey
■21.2 Creating Desktop and Mobile Widgets
HTML&JavaScriptを使ってWindowやYahooウィジェットを作成できる。- Mac Dashboard widgets
- Opera Widgets
■21.3 Creating JavaScript Applications for the iPhone, Android, and BlackBerry with PhoneGap
PhoneGapを使ってJavaScriptでモバイルアプリも作れるよ。最近だとTitaniumでデスクトップとモバイル両方いける
■21.4 Enhancing Tools with JavaScript
Adobe CSにはBridge SDK and the ExtendScript Toolkit (ESTK)があり、JavaScriptでPhotoshop scriptが書けたりします。SDKはAdobe Photoshop SDKからダウンロード。
またOpenOfficeもJavaScriptでマクロを書く事ができる。
jsを読み込むparcel-descriptor.xmlというファイルを作る。
<?xml version="1.0" encoding="UTF-8"?>
<parcel language="JavaScript" xmlns:parcel="scripting.dtd">
<script language="JavaScript">
<locale lang="en">
<displayname value="Shelley's Hello World"/>
<description>
Adds the the string "Hello World, from Shelley!"
into the current text doc.
</description>
</locale>
<functionname value="helloworldfromshelley.js"/>
<logicalname value="ShelleyHelloWorld.JavaScript"/>
</script>
</parcel>
js側に実行コードを書く/ Hello World in JavaScript importClass(Packages.com.sun.star.uno.UnoRuntime); importClass(Packages.com.sun.star.text.XTextDocument); importClass(Packages.com.sun.star.text.XText); importClass(Packages.com.sun.star.text.XTextRange); //get the document from the scripting context oDoc = XSCRIPTCONTEXT.getDocument(); //get the XTextDocument interface xTextDoc = UnoRuntime.queryInterface(XTextDocument,oDoc); //get the XText interface xText = xTextDoc.getText(); //get an (empty) XTextRange interface at the end of the text xTextRange = xText.getEnd(); //set the text in the XTextRange xTextRange.setString( "Hello World, from Shelley!" );これはOpenOffice APIのXScriptContextオブジェクトを通して実行される。
詳細はWriting Macros - OpenOffice.org Wikiを読む。
■21.5 Creating Efficient Desktop Applications with Web Workers and the File API
ブラウザベースのアプリケーション。File APIを使ってローカルのアプリを読み込む事ができる。
Javaのようなマルチスレッドを行うためにはWeb Workersを使う。
JavaScriptはシングルスレッドなものだけどWeb Workersではバックグラウンドにスレッドを走らせて処理を行える。
Web WorkersはW3C WebApps 1.0 specificationsの1つとして用意されたが今後良くも悪くも全てを変えるかもしれない。
マルチスレッドは処理能力が上がるかもしれないが、スレッドプログラミングは大変。
Web Workersは今は大して便利ではないけど。
これでJavaScript Cookbookは終わり。
コメント(0件)
- TB-URL http://efcl.info/adiary/084/tb/