132
edits
No edit summary |
|||
Line 1: | Line 1: | ||
< [[FUEL/0.2]]<br/> | < [[FUEL/0.2]]<br/> | ||
'''Due Date:''' | '''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:''' | ||
Open, and activate, a new tab | |||
App.browser.open("http://google.com/").active = true; | |||
=== | Open, and activate, a tab just after the current tab | ||
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 = | var b = Application.bookmarks.all; | ||
while ( b.hasNext() ) { | while ( b.hasNext() ) { | ||
Line 38: | Line 78: | ||
}); | }); | ||
=== | === 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 | 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 ); | ||
} | } | ||
edits