XUL リファレンス
日本語 英語
サンプル
2013年4月1日月曜日
2013年3月29日金曜日
code snippets link
https://snipt.net/
http://stackoverflow.com
http://snipplr.com/
http://www.catswhocode.com/blog/snippets
http://www.codeproject.com/
css
http://www.csspop.com/
http://css-tricks.com/snippets/
php
http://phpsnips.com
http://www.phpclasses.org/
dot net
http://dotnetslackers.com/default.aspx
swt
http://www.eclipse.org/swt/snippets/
http://coding.smashingmagazine.com/2009/01/15/45-new-jquery-techniques-for-a-good-user-experience/
xul code snippet
1 read uri file
2 import js
3 File I/O(deal with local file)
4 nsIFile と nsIURI との相互変換
5 show console message
6 Alerts and Notifications
7 File Explorer
8
9
10
links:
Code snippets from mozilla
Mozilla 拡張機能勉強会
Dialogs and Prompts
How to enable locale switching in a XULRunner application
https://developer.mozilla.org/en-US/docs/Code_snippets/Miscellaneous
--------------------------------------------------------------
Output
Saving the current web page to a local file
Saving an arbitrary URL to a local file
Printing webpages without user input
System info
Operating system detection
Detecting the host application and version
Retrieving the version of an extension as specified in the extension's install.rdf
Receiving notification before an extension is disabled and/or uninstalled
Copying from an input stream to an output stream
Restarting Firefox/Thunderbird/SeaMonkey_2.0
Mouse and keyboard
Detecting mouse wheel events
Simulating mouse and key events
Getting the currently selected text
Discovering which element in the loaded document has focus
Inserting text at the cursor
Poor man's obfuscation
Disabling JavaScript programmatically
Using string bundles from JavaScript
Getting postData of a webpage
Getting postData of a request before the request is sent
Adding custom certificates to a XULRunner application
Generating Random Bytes
Detecting full screen mode on/off
Detecting window move
Getting a webpage's source code
----------------------------------------------------------
---------read uri file----------------------
read = function read(aURI) {
var Cc = Components.classes;
var Ci = Components.interfaces;
var IOService = Cc['@mozilla.org/network/io-service;1'].getService(Ci.nsIIOService);
var uri = IOService.newURI(aURI, null, null);
var channel = IOService.newChannelFromURI(uri);
var stream = channel.open();
var fileContents = null;
try {
var scriptableStream = Cc['@mozilla.org/scriptableinputstream;1']
.createInstance(Ci.nsIScriptableInputStream);
scriptableStream.init(stream);
fileContents = scriptableStream.read(scriptableStream.available());
scriptableStream.close();
}
finally {
stream.close();
}
return fileContents;
}
var str = read('chrome://myapp/content/browser.xul')
---------import js----------------------
var scope1 = {}, scope2 = {};
Components.utils.import("resource://gre/modules/JSON.jsm", scope1);
Components.utils.import("resource://gre/modules/JSON.jsm", scope2);
assert(scope2.XPCOMUtils === scope1.XPCOMUtils);
var someURL = "resource://gre/modules/JSON.jsm";
var obj1 = {}, obj2 = {};
var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader);
loader.loadSubScript(someURL, obj1)
loader.loadSubScript(someURL, obj2)
assert(obj2 === obj1);
--------File I/O(deal with local file)----------
resource://gre/modules/FileUtils.jsm
https://developer.mozilla.org/ja/docs/Code_snippets/File_I_O
http://stackoverflow.com/questions/6844265/javascript-utf-8-file-read-write-save-in-xul
---------nsIFile と nsIURI との相互変換-------------------------
var file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
file.initWithPath("C:\\WINDOWS");
// nsIFile to nsIURI
const IOS = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var uri = IOS.newFileURI(file);
// nsIURI to nsIFile
const FPH = Cc["@mozilla.org/network/protocol;1?name=file"].getService(Ci.nsIFileProtocolHandler);
var file = FPH.getFileFromURLSpec(uri.spec);
---------------show console message-----------------------------
var theConsoleListener =
{
observe:function( aMessage ){
alert("Log : " + aMessage.message);
},
QueryInterface: function (iid) {
if (!iid.equals(Components.interfaces.nsIConsoleListener) &&
!iid.equals(Components.interfaces.nsISupports)) {
throw Components.results.NS_ERROR_NO_INTERFACE;
}
return this;
}
};
var aConsoleService = Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService);
aConsoleService.registerListener(theConsoleListener);
var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService);
consoleService.logStringMessage(msg);
---------------File Explorer---------------
//chrome://communicator/content/directory/directory.js
<?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <tree id="my-tree" flex="1" sortActive="true" sortDirection="ascending" sortResource="http://home.netscape.com/NC-rdf#Name" persist="sortDirection sortResource sortResource2" datasources="rdf:files" ref="NC:FilesRoot" flags="dont-build-content"> <treecols> <treecol id="Name" label="Name" primary="true" flex="1"/> <splitter/> <treecol id="Date" label="Date" flex="1"/> <splitter/> <treecol id="extension" label="extension" flex="1"/> </treecols> <template> <rule> <treechildren> <treeitem uri="rdf:*"> <treerow> <treecell label="rdf:http://home.netscape.com/NC-rdf#Name" src="rdf:http://home.netscape.com/NC-rdf#Icon"/> <treecell label="rdf:http://home.netscape.com/WEB-rdf#LastModifiedDate"/> <treecell label="rdf:http://home.netscape.com/NC-rdf#extension"/> </treerow> </treeitem> </treechildren> </rule> </template> </tree> </window>
2 import js
3 File I/O(deal with local file)
4 nsIFile と nsIURI との相互変換
5 show console message
6 Alerts and Notifications
7 File Explorer
8
9
10
links:
Code snippets from mozilla
Mozilla 拡張機能勉強会
Dialogs and Prompts
How to enable locale switching in a XULRunner application
https://developer.mozilla.org/en-US/docs/Code_snippets/Miscellaneous
--------------------------------------------------------------
Output
Saving the current web page to a local file
Saving an arbitrary URL to a local file
Printing webpages without user input
System info
Operating system detection
Detecting the host application and version
Retrieving the version of an extension as specified in the extension's install.rdf
Receiving notification before an extension is disabled and/or uninstalled
Copying from an input stream to an output stream
Restarting Firefox/Thunderbird/SeaMonkey_2.0
Mouse and keyboard
Detecting mouse wheel events
Simulating mouse and key events
Getting the currently selected text
Discovering which element in the loaded document has focus
Inserting text at the cursor
Poor man's obfuscation
Disabling JavaScript programmatically
Using string bundles from JavaScript
Getting postData of a webpage
Getting postData of a request before the request is sent
Adding custom certificates to a XULRunner application
Generating Random Bytes
Detecting full screen mode on/off
Detecting window move
Getting a webpage's source code
----------------------------------------------------------
---------read uri file----------------------
read = function read(aURI) {
var Cc = Components.classes;
var Ci = Components.interfaces;
var IOService = Cc['@mozilla.org/network/io-service;1'].getService(Ci.nsIIOService);
var uri = IOService.newURI(aURI, null, null);
var channel = IOService.newChannelFromURI(uri);
var stream = channel.open();
var fileContents = null;
try {
var scriptableStream = Cc['@mozilla.org/scriptableinputstream;1']
.createInstance(Ci.nsIScriptableInputStream);
scriptableStream.init(stream);
fileContents = scriptableStream.read(scriptableStream.available());
scriptableStream.close();
}
finally {
stream.close();
}
return fileContents;
}
var str = read('chrome://myapp/content/browser.xul')
---------import js----------------------
var scope1 = {}, scope2 = {};
Components.utils.import("resource://gre/modules/JSON.jsm", scope1);
Components.utils.import("resource://gre/modules/JSON.jsm", scope2);
assert(scope2.XPCOMUtils === scope1.XPCOMUtils);
var someURL = "resource://gre/modules/JSON.jsm";
var obj1 = {}, obj2 = {};
var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader);
loader.loadSubScript(someURL, obj1)
loader.loadSubScript(someURL, obj2)
assert(obj2 === obj1);
--------File I/O(deal with local file)----------
resource://gre/modules/FileUtils.jsm
https://developer.mozilla.org/ja/docs/Code_snippets/File_I_O
http://stackoverflow.com/questions/6844265/javascript-utf-8-file-read-write-save-in-xul
---------nsIFile と nsIURI との相互変換-------------------------
var file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
file.initWithPath("C:\\WINDOWS");
// nsIFile to nsIURI
const IOS = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var uri = IOS.newFileURI(file);
// nsIURI to nsIFile
const FPH = Cc["@mozilla.org/network/protocol;1?name=file"].getService(Ci.nsIFileProtocolHandler);
var file = FPH.getFileFromURLSpec(uri.spec);
---------------show console message-----------------------------
var theConsoleListener =
{
observe:function( aMessage ){
alert("Log : " + aMessage.message);
},
QueryInterface: function (iid) {
if (!iid.equals(Components.interfaces.nsIConsoleListener) &&
!iid.equals(Components.interfaces.nsISupports)) {
throw Components.results.NS_ERROR_NO_INTERFACE;
}
return this;
}
};
var aConsoleService = Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService);
aConsoleService.registerListener(theConsoleListener);
var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService);
consoleService.logStringMessage(msg);
---------------File Explorer---------------
//chrome://communicator/content/directory/directory.js
<?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <tree id="my-tree" flex="1" sortActive="true" sortDirection="ascending" sortResource="http://home.netscape.com/NC-rdf#Name" persist="sortDirection sortResource sortResource2" datasources="rdf:files" ref="NC:FilesRoot" flags="dont-build-content"> <treecols> <treecol id="Name" label="Name" primary="true" flex="1"/> <splitter/> <treecol id="Date" label="Date" flex="1"/> <splitter/> <treecol id="extension" label="extension" flex="1"/> </treecols> <template> <rule> <treechildren> <treeitem uri="rdf:*"> <treerow> <treecell label="rdf:http://home.netscape.com/NC-rdf#Name" src="rdf:http://home.netscape.com/NC-rdf#Icon"/> <treecell label="rdf:http://home.netscape.com/WEB-rdf#LastModifiedDate"/> <treecell label="rdf:http://home.netscape.com/NC-rdf#extension"/> </treerow> </treeitem> </treechildren> </rule> </template> </tree> </window>
2013年3月25日月曜日
Deploying XULRunner
https://developer.mozilla.org/en-US/docs/XULRunner/Deploying_XULRunner_1.8
Debugging a XULRunner Application
https://developer.mozilla.org/ja/docs/Debugging_a_XULRunner_Application
pref("browser.dom.window.dump.enabled", true)
dump("my text here\n");
xulrunner.exe /path/to/application.ini -jsconsole
xulrunner.exe /path/to/application.ini -console
Debugging a XULRunner Application
https://developer.mozilla.org/ja/docs/Debugging_a_XULRunner_Application
pref("browser.dom.window.dump.enabled", true)
dump("my text here\n");
function jsdump(str)
{
Components.classes['@mozilla.org/consoleservice;1']
.getService(Components.interfaces.nsIConsoleService)
.logStringMessage(str);
}
xulrunner.exe /path/to/application.ini -jsconsole
xulrunner.exe /path/to/application.ini -console
Creating a XUL Application
http://www.xul.fr/tutorial/application.html
https://developer.mozilla.org/en-US/docs/Getting_started_with_XULRunner
https://developer.mozilla.org/en-US/docs/Getting_started_with_XULRunner
登録:
投稿 (Atom)