Creating Applications with Mozilla
| resources: | Home Chapters Examples Figures Corrections Bugs Resources Mailing List Authors Reviews |
|---|
Examples
All numbered examples from the book are available here as individually downloadable text files. To avoid having to type in long examples, save these files or copy and paste the contents into your own files. Note that copying and pasting may cause formatting problems with some examples. If you have any suggestions or queries about the examples, send a message to the reviewers@mozdev.org mailing list.
Note: Some readers are reporting problems with some of the examples in the book. If you are experiencing any problems, please look at the User Notes section at the bottom of each of the HTML version of the chapters. You might also want to check out the xFly project which features a working installable version of many of the examples used in the book.
- Archive of all examples (Zip file)
- Chapter 2
- Chapter 3
- Chapter 4
- Chapter 5
- Chapter 6
- Chapter 7
- Chapter 8
- Chapter 9
- Chapter 10
- Chapter 11
- Chapter 12
- Appendix
- Example 2-1: Hello xFly
- Example 2-2: The XUL namespace declaration
- Example 2-3: Mixed namespaces in an XML document
- Example 2-4: Sample XUL window
- Example 2-5: chrome/xfly/content/contents.rdf file
- Example 2-6: chrome/xfly/skin/contents.rdf file
- Example 2-7: chrome/xfly/locale/contents.rdf file
- Example 2-8: The contents of the xfly.css file
- Example 2-9: XUL using external style data
- Example 2-10: XUL using an external script
- Example 2-11: The contents of the xfly.js file
- Example 2-12: The contents of the xfly.dtd file
- Example 2-13: XUL using an external DTD file
- Example 2-14: Tree structure of a completed sample xFly package
- Example 2-15: Additions to the installed-chrome.txt file
- Example 3-1: XUL dialog
- Example 3-2: XUL page
- Example 3-3: A XUL wizard
- Example 3-4: Toolbar with buttons and spacing
- Example 3-5: Application menu bar
- Example 3-6: A sample menu
- Example 3-7: Context menu using pop up
- Example 3-8: XUL menu list
- Example 3-9: Listbox widget
- Example 3-10: Tree base model
- Example 3-11: Multilevel tree content view
- Example 3-12: XUL grid
- Example 3-13: Text autocomplete
- Example 3-14: A radio group choice of options
- Example 3-15: Shortcut keys with command observers
- Example 3-16: Tabbed panels
- Example 3-17: A deck with three image layers
- Example 3-18: Deck layer switching
- Example 3-19: Content positioning in a stack
- Example 3-20: Flexible buttons
- Example 3-21: Positioning attributes
- Example 3-22: xFly application main workspace
- Example 3-23: Example tree in the xFly application
- Example 4-1: Class selector in CSS
- Example 4-2: Attribute selector in CSS
- Example 4-3: !important keyword in CSS
- Example 4-4: Image in CSS
- Example 4-5: Mixing CSS and XUL
- Example 4-6: CSS for print button in navigator skin
- Example 4-7: CSS Import statements in global skin
- Example 4-8: CSS information from communicator.css
- Example 4-9: CSS rules for xFly window
- Example 4-10: Custom styles for buttons
- Example 4-11: Skin manifest for the xFly sample
- Example 4-12: Manifest for the communicator package of the modern skin in Mozilla
- Example 4-13: CSS and XBL example
- Example 4-14: userChrome.css style rules
- Example 5-1: Printing element properties to the console
- Example 5-2: Printing the window properties
- Example 5-3: Adding toggle functionality to xFly
- Example 5-4: Adding Toggle menus to xFly
- Example 5-5: Basic event handler attributes
- Example 5-6: Getting event handler attributes from an element
- Example 5-7: Event propagation
- Example 5-8: stopPropagation( ) event function
- Example 5-9: Dynamic menu generation
- Example 5-10: Scriptable component example
- Example 5-11: Scripting components from HTML
- Example 6-1: Package installation script
- Example 6-2: Simple theme package manifest
- Example 6-3: Locale package manifest
- Example 6-4: manifest.rdf describing the XMLTerm extension
- Example 6-5: The xFly overlay
- Example 6-6: Overlay information in the manifest
- Example 6-7: Overlays in navigator.xul
- Example 6-8: Top level of the browser.xpi archive
- Example 6-9: Simple install script
- Example 6-10: Script that explicitly prefixes the Install object
- Example 6-11: A more complicated install script
- Example 6-12: Trigger script on a web page
- Example 6-13: Scriptless install of a JAR
- Example 6-14: Getting the operating system in an install script
- Example 6-15: install.log
- Example 6-16: Common XPInstall functions
- Example 6-17: Install script callback
- Example 6-18: Non-Mozilla software installation script
- Example 6-19: Package metadata in the xFly manifest
- Example 6-20: xFly installation script
- Example 7-1: XBL implementation element
- Example 7-2: An XBL property setting and getting a value
- Example 7-3: Performing a Google search when setting a property
- Example 7-4: Accessing a bound document from a binding
- Example 7-5: Selective inclusion of child content in a binding
- Example 7-6: Binding inheritance
- Example 7-7: Inheriting XUL widget characteristics using extends
- Example 7-8: XBL attribute inheritance
- Example 7-9: Inheritance of behavior between bindings
- Example 8-1: Using an XPCOM object in script
- Example 8-2: progIDs
- Example 8-3: QueryInterface method for nsISimple interface
- Example 8-4: JavaScript implementation of nsISimple
- Example 8-5: Scripting the "simple" component in xpcshell
- Example 8-6: Reference implementation of QueryInterface
- Example 8-7: Platform macros in xpcom/base/nscore.h
- Example 8-8: NS_IMETHOD macro
- Example 8-9: Manual reference counting using raw pointers
- Example 8-10: Using nsCOMPtr in your code
- Example 8-11: nsISimple header file generated by xpidl compiler
- Example 8-12: The component header file nsSimple.h
- Example 8-13: nsSimple.cpp
- Example 8-14: nsSimpleModule.cpp
- Example 8-15: Sample Makefile
- Example 8-16: Sample use of component in xpcshell
- Example 8-17: Example 8-17: Testing for nsresults from component methods
- Example 8-18: Sample Python component implementation
- Example 8-19: IDL for the Python component
- Example 8-20: Using the Python component in script
- Example 9-1: Simple XUL template in a listbox element
- Example 9-2: Basic structure of a XUL template
- Example 9-3: Hardcoded representation of generated XUL
- Example 9-4: XUL tree template in Figure 9-3
- Example 9-5: Simplified version of 10-4 RDF data
- Example 9-6: Tree template code of Figure 9-3
- Example 9-7: Tree template with rules
- Example 9-8: Menubar template with three rules
- Example 9-9: Template implemented in a box with buttons as content
- Example 10-1: Simple RDF file with "fly" namespace
- Example 10-2: RDF root sequence
- Example 10-3: The Horse sequence
- Example 10-4: Entire RDF file
- Example 10-5: Content model of email datasources
- Example 10-6: RDF-specific components built into Mozilla
- Example 10-7: Creating a root node
- Example 10-8: Manipulating datasources
- Example 10-9: Parse an RDF/XML string into a datasource
- Example 10-10: Setup nsIRDFXMLSink with event handlers
- Example 10-11: Binding with in-memory datasource and
template - Example 10-12: Creating and modifying an RDF file using JSLib
- Example 10-13: Initialization
- Example 10-14: Data updating
- Example 10-15: Skin manifest
- Example 10-16: Overlay for a sample application menu
- Example 10-17: Overlay for an xFly menu item in the browser
- Example 11-1: XUL menu with entity references for text and accesskeys
- Example 11-2: The Editor's Doctype definitions
- Example 11-3: String bundles used by the Mozilla browser
- Example 11-4: Creating the bundle via XPConnect
- Example 11-5: Using multiple <description> elements
- Example 11-6: Using the HTML break tag
- Example 11-7: Binding with attribute inheritance
- Example 11-8: RDF Description node with localizable text
- Example 11-9: The locale XPI install script, install.js
- Example 11-10: Locale-switching script
- Example 12-1: Remote XUL example
- Example 12-2: Enabling universal XPConnect
- Example 12-3: A sample static XUL file
- Example 12-4: Using PHP to generate the correct XUL MIME type
- Example 12-5: A simple Perl-generated XUL file
- Example 12-6: A Python-generated dynamically updated form
- Example 12-7: SQL script with User and Project data
- Example 12-8: XUL generated from database
- Example 12-9: Creating a root certificate
- Example 12-10: Creating a distribution certificate
- Example 12-11: Create a signing certificate
- Example 12-12: Sample redirect into a signed application
- Example 12-13: Function for switching screen modes
- Example 12-14: Minimal .NET web service
- Example 12-15: Abbreviated WSDL as produced by .NET web service
- Example 12-16: XML format for SOAP calls of Mozilla
- Example 12-17: .NET format for SOAP calls of Mozilla
- Example 12-18: Preloading scores.js into cache with an HTML association
- Example 12-19: SaveScore SOAP function
- Example 12-20: Code for GetScore and GetHighScores
- Example B-1: Sample application template
- Example B-2: Sample XPCOM component template
- Example B-3: makexpi.conf file