XML
  Home arrow XML arrow Page 6 - Back to XUL: Completing the JavaScript Log...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

Back to XUL: Completing the JavaScript Logic
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2006-02-13

    Table of Contents:
  • Back to XUL: Completing the JavaScript Logic
  • Defining a Function
  • The Help Menu
  • The About Window
  • Making the Toolbar Work
  • Finishing up the Functions

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Back to XUL: Completing the JavaScript Logic - Finishing up the Functions


    (Page 6 of 6 )

    As you can see it isn’t as good as standard parameter passing, in which case any value can be used as a parameter, but it works in its own quirky kind of way and saves some code (somewhere) too.  Add the code for the other two insert functions:

    function insert2(str) {

      var str1 = '<radiogroup>  <radio id="" label=""/>  </radiogroup>';
      var str2 = '<window id="" title="" height="" width="" xmlns="http://www.mozilla.org/keymaster/gatekeeper/
    there.is.only.xul"/>  </window>';
      var str3 = '<wizard id="" title="" xmlns="http://www.mozilla.org/keymaster/gatekeeper/
    there.is.only.xul">  <wizardpage>  </wizardpage>  </wizard>';
      var str4 = '<editor id="" editortype="" type="" src=""/>';
      var str5 = '<browser id="" homepage="" type=""/>';
      var str6 = '<iframe id="" src=""/>';

      var editor = document.getElementById('mainContent');
      editor = editor.getEditor(editor.contentWindow).QueryInterface
    (Components.interfaces.nsIPlaintextEditor);

      if (str == menubar) {
        editor.insertText(str1);
      } else if (str == toolbar) {
        editor.insertText(str2);
      } else if (str == directories) {
        editor.insertText(str3);
      } else if (str == locationbar) {
        editor.insertText(str4);
      } else if (str == statusbar) {
        editor.insertText(str5);
      } else if (str == scrollbars) {
        editor.insertText(str6);
      }

    }

    function insert3(str) {

      var str1 = '<titlebar id=""/>'

      var editor = document.getElementById('mainContent');
      editor = editor.getEditor(editor.contentWindow).QueryInterface
    (Components.interfaces.nsIPlaintextEditor);

      if (str == menubar) {
        editor.insertText(str1);
      }

    }

    The last curly brace above sees the end of the code required in the JavaScript file, but you still need to add calls to the insert() function to each of the menuitems, passing in one of the BarProp parameters, for example:

    <menuitem id="buttonMenubar" label="&menubarLabel;"
    oncommand="insert(menubar)"/>

    With both the XUL and JS files saved, your application (version 1 at least) is complete.  Now, it’s still a little buggy in places; the new file command (where we set the src of the editor to about:blank) only seems to work once for example.  Overall however, I don’t think this is too much of a problem; look at the number of bugs in a Windows OS release!

    This also now sees the end of this series on creating an application with XUL.  I hope you’ve followed along with the tutorial and I hope that you haven’t had too many difficulties getting it to work.  If this has just got your appetite for XUL going, please continue to build, adapt and refine the application; you can extend the program in any way you can think of by simply adding elements to the XUL file and functions to the script file and are limited only by the bounds of your imagination.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Hi,This article follows on neatly from the last and shows you the code needed to...
     

    XML ARTICLES

    - Datatypes and More in RELAX NG
    - Providing Options in RELAX NG
    - An Introduction to RELAX NG
    - Path, Predicates, and XQuery
    - Using Predicates with XQuery
    - Navigating Input Documents Using Paths
    - XML Basics
    - Introduction to XPath
    - Simple Web Syndication with RSS 2.0
    - Java UI Design with an IDE
    - UI Design with Java and XML Toolkits
    - Displaying ADO Retrieved Data with XML Islan...
    - Widget Walkthrough
    - Introduction to Widgets
    - The Why and How of XML Data Islands






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT