Confirmed users
595
edits
Line 44: | Line 44: | ||
=== Examples === | === Examples === | ||
This is a selection of possibilities, changing filtering can achieve many more actions. | |||
'''Get module''' | '''Get module''' | ||
Line 60: | Line 57: | ||
// a 0-length results indicates there are no more results. | // a 0-length results indicates there are no more results. | ||
} | } | ||
// See PlacesQuery for description of the query configuration object. | // See PlacesQuery for description of the query configuration object. | ||
places.history.filter({ host: "^www.moz" }, callbackFunc, callbackScope); | places.history.filter({ host: "^www.moz" }, callbackFunc, callbackScope); | ||
Line 83: | Line 81: | ||
places.history.filter({ host: "remove.host.com" }) | places.history.filter({ host: "remove.host.com" }) | ||
.remove(callbackFunc, callbackScope); | .remove(callbackFunc, callbackScope); | ||
</pre> | |||
'''Remove bookmarks''' | |||
<pre class="brush:js;toolbar:false;"> | |||
places.bookmarks.filter({ bookmarked: { tags: ["removeme"] } }) | |||
.remove(callbackFunc, callbackScope); | |||
</pre> | |||
'''Annotations''' | |||
<pre class="brush:js;toolbar:false;"> | |||
// Add bookmark annotations. If the result is not required to be bookmarked, | |||
// a page annotation is added instead. | |||
places.bookmarks.filter({ uri: "^http://mozilla.org/annotateme/$" }) | |||
.annotate([{ name: "annoToAdd", value: "annoValue" }], | |||
myCallback, callbackScope); | |||
// To remove an annotation omit value. | |||
places.bookmarks.filter({ uri: "^http://mozilla.org/annotateme/$" }) | |||
.annotate([{ name: "annoToAdd" }], myCallback, callbackScope); | |||
</pre> | |||
'''Bookmarks''' | |||
<pre class="brush:js;toolbar:false;"> | |||
// Add a bookmark. | |||
places.bookmarks.save({ uri: "http://moz.org/" | |||
, title: "a bookmark" | |||
, parent: 3 | |||
, position: 12 | |||
}, myCallback, callbackScope); | |||
// Edit a bookmark: set title, remove tag foo, add tag bar. | |||
places.bookmarks.filter({ uri: "http://moz.org/" | |||
, sort: { by: "time", dir: "desc" } | |||
, limit: 1 | |||
}).save({ title: "a new title" | |||
, tags: ["-foo", "bar"] | |||
}, myCallback, callbackScope); | |||
</pre> | </pre> |