Sunday, June 1, 2008

Install Manifests

←Older revision Revision as of 02:27, 20 March 2008 Line 370: Line 370: <noinclude> <noinclude>  +[[zh-cn:Install_Manifests]] [[es:Instalar el manifest]] [[es:Instalar el manifest]] [[fr:Manifestes d'installation]] [[fr:Manifestes d'installation]]

Category:Extensions

←Older revision Revision as of 02:23, 20 March 2008 Line 5: Line 5: [[Category:All Categories]] [[Category:All Categories]]  +[[zh-cn:Category:Extensions]] [[ja:Category:Extensions]] [[ja:Category:Extensions]] [[pl:Kategoria:Rozszerzenia]] [[pl:Kategoria:Rozszerzenia]]

XMLHttpRequest

added mozBackgroundRequest

←Older revision Revision as of 02:05, 20 March 2008 Line 113: Line 113: req.send(null); req.send(null); dump("Content-Type: " + req.getResponseHeader("Content-Type") + "\n"); dump("Content-Type: " + req.getResponseHeader("Content-Type") + "\n");  +</pre>  +  +===mozBackgroundRequest===  +This property can be used to cause the request to disable authentication and bad certificate dialogs. The request is also not part of a window's loadgroup and so is not closed if the window is closed. {{fx_minversion_inline|3}}  +<pre>  +var req = new XMLHttpRequest();  +req.mozBackgroundRequest = true;  +req.open('GET', 'http://www.mozilla.org/', true);  +req.send(null); </pre> </pre>

Using XPath

getXPathForElement - +comment

←Older revision Revision as of 01:55, 20 March 2008 Line 9: Line 9: For a very simple XPath usage example, see: [[Code_snippets:HTML_to_DOM#Using_a_hidden_XUL_iframe_.28complete_example.29]] For a very simple XPath usage example, see: [[Code_snippets:HTML_to_DOM#Using_a_hidden_XUL_iframe_.28complete_example.29]] -==Wrapper function==+==Node-specific evaluator function== The following function can be used to evaluate XPath expressions on given XML nodes. The first argument is a DOM node or Document object, while the second is a string defining an XPath expression. The following function can be used to evaluate XPath expressions on given XML nodes. The first argument is a DOM node or Document object, while the second is a string defining an XPath expression. Line 44: Line 44: If you are using [[XMLHttpRequest]] to read a local or remote XML file into a DOM tree (as described in [[Parsing and serializing XML]]), the first argument to <code>evaluateXPath()</code> should be <code>req.responseXML</code>. If you are using [[XMLHttpRequest]] to read a local or remote XML file into a DOM tree (as described in [[Parsing and serializing XML]]), the first argument to <code>evaluateXPath()</code> should be <code>req.responseXML</code>. -==Sample usage==+===Sample usage=== Assume we have the following XML document (see also [[How to Create a DOM tree]] and [[Parsing and serializing XML]]): Assume we have the following XML document (see also [[How to Create a DOM tree]] and [[Parsing and serializing XML]]): Line 81: Line 81: alert(results.length); alert(results.length); </pre> </pre>  +  +==getXPathForElement==  +  +The following function allows one to pass an element and an XML document to find a unique string XPath expression leading back to that element.  +  +<pre>function getXPathForElement(el, xml) {  + var xpath = '';  + var pos, tempitem2;  +  + while(el !== xml.documentElement) {  + pos = 0;  + tempitem2 = el;  + while(tempitem2) {  + if (tempitem2.nodeType === 1 && tempitem2.nodeName === el.nodeName) { // If it is ELEMENT_NODE of the same name  + pos += 1;  + }  + tempitem2 = tempitem2.previousSibling;  + }  +  + xpath = el.nodeName+'['+pos+']'+'/'+xpath;  + el = el.parentNode;  + }  + xpath = '/'+xml.documentElement.nodeName+'/'+xpath;  + xpath = xpath.replace(/\/$/, '');  + return xpath;  +}</pre> ==Resources== ==Resources==

Code snippets:File I/O

Writing to a file

←Older revision Revision as of 00:39, 20 March 2008 Line 290: Line 290: // use 0x02 | 0x10 to open file for appending. // use 0x02 | 0x10 to open file for appending. -foStream.init(file, 0x02 | 0x08 | 0x20, 0666, 0); // write, create, truncate+foStream.init(file, 0x02 | 0x08 | 0x20, 0666, 0); -In a c file operation, we have no need to set file mode with or operation, directly using "r" or "w" usually.+// write, create, truncate  +// In a c file operation, we have no need to set file mode with or operation,  +// directly using "r" or "w" usually. foStream.write(data, data.length); foStream.write(data, data.length); foStream.close(); foStream.close();

Introduction to using XPath in JavaScript

small positioning fix

←Older revision Revision as of 00:11, 20 March 2008 Line 299: Line 299: {{XPathResultConstants}} {{XPathResultConstants}}  +  +=See also=  +* [[Using XPath]] <div class="originaldocinfo"> <div class="originaldocinfo">

XPathResult

+see also, +cat

←Older revision Revision as of 00:08, 20 March 2008 Line 31: Line 31: {{XPathResultConstants}} {{XPathResultConstants}}  +  +==See also==  +  +* [[DOM:document.evaluate|document.evaluate()]]  +  +[[Category:XPath]]

DOM:document.evaluate

Result types - +q about merging with another template

←Older revision Revision as of 00:06, 20 March 2008 Line 36: Line 36: == Result types == == Result types ==  +  +(Merge with [[Template:XPathResultConstants]]?  + These are supported values for the <code>resultType</code> parameter of the <code>evaluate</code> method: These are supported values for the <code>resultType</code> parameter of the <code>evaluate</code> method: {| class="standard-table" {| class="standard-table" Line 103: Line 106: [[pl:DOM:document.evaluate]] [[pl:DOM:document.evaluate]]  +  +[[Category:XPath]]

Template:XPathResultConstants

adding page

New page

{| class="standard-table"
|-
|class="header"|Result Type Defined Constant
|class="header"|Value
|class="header"|Description
|-
|-
|ANY_TYPE
|0
|A result set containing whatever type naturally results from evaluation of the expression. Note that if the result is a node-set then UNORDERED_NODE_ITERATOR_TYPE is always the resulting type.
|-
|-
|NUMBER_TYPE
|1
|A result containing a single number. This is useful for example, in an XPath expression using the <code>count()</code> function.
|-
|-
|STRING_TYPE
|2
|A result containing a single string.
|-
|-
|BOOLEAN_TYPE
|3
|A result containing a single boolean value. This is useful for example, in an XPath expression using the <code>not()</code> function.
|-
|-
|UNORDERED_NODE_ITERATOR_TYPE
|4
|A result node-set containing all the nodes matching the expression. The nodes may not necessarily be in the same order that they appear in the document.
|-
|-
|ORDERED_NODE_ITERATOR_TYPE
|5
|A result node-set containing all the nodes matching the expression. The nodes in the result set are in the same order that they appear in the document.
|-
|-
|UNORDERED_NODE_SNAPSHOT_TYPE
|6
|A result node-set containing snapshots of all the nodes matching the expression. The nodes may not necessarily be in the same order that they appear in the document.
|-
|-
|ORDERED_NODE_SNAPSHOT_TYPE
|7
|A result node-set containing snapshots of all the nodes matching the expression. The nodes in the result set are in the same order that they appear in the document.
|-
|-
|ANY_UNORDERED_NODE_TYPE
|8
|A result node-set containing any single node that matches the expression. The node is not necessarily the first node in the document that matches the expression.
|-
|-
|FIRST_ORDERED_NODE_TYPE
|9
|A result node-set containing the first node in the document that matches the expression.
|-
|}

Code snippets:Miscellaneous

Operating system detection

←Older revision Revision as of 20:51, 19 March 2008 Line 16: Line 16: ==Operating system detection== ==Operating system detection== - // Returns WINNT on Windows XP, 2000, NT and returns Linux on GNU/Linux+ // Returns "WINNT" on Windows Vista, XP, 2000, and NT systems  + // and returns "Linux" on GNU/Linux var osString = Components.classes["@mozilla.org/xre/app-info;1"] var osString = Components.classes["@mozilla.org/xre/app-info;1"] .getService(Components.interfaces.nsIXULRuntime).OS; .getService(Components.interfaces.nsIXULRuntime).OS;

nsIUpdateTimerManager

new

New page

<breadcrumbs></breadcrumbs>
The <code>nsIUpdateTimerManager</code> interface provides a global application service that provides support for long-duration timers (on the order of many days, weeks, or even months). These timers are used to schedule update checks in the future, for example.

__TOC__
{{InterfaceStatus|nsIUpdateTimerManager|toolkit/mozapps/update/public/nsIUpdateService.idl|unfrozen|Mozilla 1.9|yes}}

Inherits from: {{interface|nsISupports}}

=Method overview=

{| class="standard-table"
|-
| <code>void [[#registerTimer()|registerTimer]](in AString id,
in nsITimerCallback callback,
in unsigned long interval);</code>
|-
|}

=Methods=

==registerTimer()==
Presents a user interface that checks for and displays the available updates.

void registerTimer(
in AString id,
in nsITimerCallback callback,
in unsigned long interval
);

<h5>Parameters</h5>

;<tt>id</tt>
:An ID used to identify the timer interval; used for persistence.
;<tt>callback</tt>
:An {{interface|nsITimerCallback}} object that is notified when the interval expires.
;<tt>interval</tt>
:The length of time, in seconds, until the timer should fire.

None.

=See also=

* {{interface|nsIUpdate}}
* {{interface|nsIUpdateCheckListener}}
* {{interface|nsIUpdateChecker}}
* {{interface|nsIUpdatePatch}}
* {{interface|nsIApplicationUpdateService}}
* {{interface|nsIUpdateManager}}
* {{interface|nsIUpdatePrompt}}

[[Category:Interfaces]]

nsIUpdatePrompt

new

New page

<breadcrumbs></breadcrumbs>
The <code>nsIUpdatePrompt</code> interface describes an object that can be used to show various update-related notifications to the user.

__TOC__
{{InterfaceStatus|nsIUpdatePrompt|toolkit/mozapps/update/public/nsIUpdateService.idl|unfrozen|Mozilla 1.9|yes}}

Inherits from: {{interface|nsISupports}}

=Method overview=

{| class="standard-table"
|-
| <code>void [[#checkForUpdates()|checkForUpdates]]();</code>
|-
| <code>void [[#showUpdateAvailable()|showUpdateAvailable]](in [[nsIUpdate]] update);</code>
|-
| <code>void [[#showUpdateDownloaded()|showUpdateDownloaded]](in [[nsIUpdate]] update, [optional] in boolean background);</code>
|-
| <code>void [[#showUpdateError()|showUpdateError]](in [[nsIUpdate]] update);</code>
|-
| <code>void [[#showUpdateHistory()|showUpdateHistory]](in [[nsIDOMWindow]] parent);</code>
|-
| <code>void [[#showUpdateInstalled()|showUpdateInstalled]](in [[nsIUpdate]] update);</code>
|-
|}

=Methods=

==checkForUpdates()==
Presents a user interface that checks for and displays the available updates.

void checkForUpdates();

<h5>Parameters</h5>

None.

==showUpdateAvailable()==
Shows a message advising the user that an update is available to be downloaded and installed.

void showUpdateAvailable(
in nsIUpdate update
);

<h5>Parameters</h5>

;<tt>update</tt>
:An {{interface|nsIUpdate}} describing the update that's available.

==showUpdateDownloaded()==
Shows a message advising the user that an update has been downloaded, and that the user should restart the application in order to install it.

void showUpdateDownloaded(
in nsIUpdate update,
[optional] in boolean background
);

<h5>Parameters</h5>
;<tt>update</tt>
:An {{interface|nsIUpdate}} describing the update that was downloaded.
;<tt>background</tt>
:An optional parameter that, if provided and <code>true</code>, presents a less-obtrusive, non-modal notification alert.

==showUpdateError()==
Displays an error message telling the user about an update failure, such as a failure to successfully apply a patch.

void showUpdateError(
in nsIUpdate update
);

<h5>Parameters</h5>
;<tt>update</tt>
:An {{interface|nsIUpdate}} describing the update that failed to install.

==showUpdateHistory()==
Shows a list of all updates that have been installed to date.

void showUpdateHistory(
in nsIDOMWindow parent
);

<h5>Parameters</h5>

;<tt>parent</tt>
:An {{interface|nsIDOMWindow}} indicating the parent window to which to anchor the update list window. This can be <code>null</code>.

==showUpdateInstalled()==
Shows a message detailing the update that was just installed.

void showUpdateInstalled(
in nsIUpdate update
);

<h5>Parameters</h5>

;<tt>update</tt>
:An {{interface|nsIUpdate}} describing the update that was installed.

=See also=

* {{interface|nsIUpdate}}
* {{interface|nsIUpdateCheckListener}}
* {{interface|nsIUpdateChecker}}
* {{interface|nsIUpdatePatch}}
* {{interface|nsIApplicationUpdateService}}
* {{interface|nsIUpdateManager}}
* {{interface|nsIUpdateTimerManager}}

[[Category:Interfaces]]