FUEL/0.2/Plan: Difference between revisions

no edit summary
No edit summary
Line 1: Line 1:
< [[FUEL/0.2]]<br/>
< [[FUEL/0.2]]<br/>
'''Due Date:''' Feb 28, 2007<br/>
'''Due Date:''' May 25, 2007<br/>
'''Deliverable:''' [[FUEL/0.2/API|Complete API]]
'''Deliverable:''' [[FUEL/0.2/API|Complete API]]


Line 12: Line 12:
'''Example:'''
'''Example:'''


   Browser.open("http://mozilla.org");
Open, and activate, a new tab
  Browser.find(/google/).close();
   App.browser.open("http://google.com/").active = true;
  Browser.current.location = "http://wiki.mozilla.org";
  var spans = Browser.current.select("#foo div > span");


=== File I/0 ===
Open, and activate, a tab just after the current tab
TBD
  var tab = App.browser.open("http://google.com/");
  App.browser.insertBefore( tab, App.browser.activeTab.next );
  tab.active = true;
 
or:
  var tab = App.browser.open("http://google.com/");
  tab.index = App.browser.activeTab + 1;
  tab.active = true;
 
Move the active tab to be the first tab
  App.browser.insertBefore( App.browser.activeTab, App.browser.tabs[0] );
 
or:
  App.browser.activeTab.index = 0;
 
Close the active tab
  App.browser.activeTab.close();
 
Do something when the active tab loads
  App.browser.activeTab.events.addListener( "load", function(){
    this.query("#foo div")
  });
 
Change the URL in the active tab
  App.browser.activeTab.url = "http://mozilla.org/";
 
Close all Google-related tabs
  App.browser.tabs.forEach(function(tab){
    if ( tab.url.match(/google/) )
      tab.remove();
  });
 
Re-use a tab, or open a new one
  var url = "http://google.com/";
  App.browser.tabs.some(function(tab){
    if ( tab.url == url )
      return tab.active = true;
  }) || App.browser.open( url ).active = true;
 
Stop the user from opening any new tabs
  App.browser.events.addListener( "TabOpen", function(e){
    e.target.close();
  });


=== Bookmarks ===
=== Bookmarks ===
Line 26: Line 66:
'''Example:'''
'''Example:'''


   var b = Bookmarks.getAll();
   var b = Application.bookmarks.all;
    
    
   while ( b.hasNext() ) {
   while ( b.hasNext() ) {
Line 38: Line 78:
   });
   });


=== Storage (SQLite) ===
=== Database (SQLite) ===
* Attach to an existing SQLite DB
* Attach to an existing SQLite DB
* Create DB
* Create DB
Line 46: Line 86:
'''Example:'''
'''Example:'''


   var db = new Storage("myfile.db");
   var db = new Database("myfile.db");
    
    
   var q = db.prepare("SELECT * FROM foo WHERE foo = ?;");
   var q = db.prepare("SELECT * FROM foo WHERE foo = ?;");
Line 56: Line 96:
     console.log( "username", row.username );
     console.log( "username", row.username );
   }
   }
Note: I'm not sure about the performance implications (maybe JS2 iterators help here), but a more JavaScriptic way of accessing the result would be as an array, i.e.: r = q.execute( "bar" ); for each (row in r) { ... } -myk
=== Application Storage ===
see: http://www.xulplanet.com/ndeakin/article/359/
* Allows extensions to store state during lifetime of application
* Model on DOM:Storage API
'''Example:'''
  Application.storage.set("password", "jimmy01");
 
  Extension.storage.set("blockedpagecount", "20");
132

edits