Labs/Jetpack/Reboot/JEP/114: Difference between revisions

Line 53: Line 53:
'''Filter history'''
'''Filter history'''
<pre class="brush:js;toolbar:false;">
<pre class="brush:js;toolbar:false;">
function callbackFunc(results) {
function callbackFunc(results) {
   // results is an array of ResultItem objects.
   // results is an array of ResultItem objects.
Line 60: Line 61:
// 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);
</pre>
</pre>


'''Filter bookmarks'''
'''Filter bookmarks'''
<pre class="brush:js;toolbar:false;">
<pre class="brush:js;toolbar:false;">
places.history.filter({ phrase: "search words" }, callbackFunc, callbackScope);
places.history.filter({ phrase: "search words" }, callbackFunc, callbackScope);
</pre>
</pre>


'''Filter pages'''
'''Filter pages'''
<pre class="brush:js;toolbar:false;">
<pre class="brush:js;toolbar:false;">
places.filter({ phrase: "search words" }, callbackFunc, callbackScope);
places.filter({ phrase: "search words" }, callbackFunc, callbackScope);
</pre>
</pre>


'''Clear history'''
'''Clear history'''
<pre class="brush:js;toolbar:false;">
<pre class="brush:js;toolbar:false;">
places.history.remove(callbackFunc, callbackScope);
places.history.remove(callbackFunc, callbackScope);
</pre>
</pre>


'''Remove pages from history'''
'''Remove pages from history'''
<pre class="brush:js;toolbar:false;">
<pre class="brush:js;toolbar:false;">
places.history.filter({ host: "remove.host.com" })
places.history.filter({ host: "remove.host.com" })
               .remove(callbackFunc, callbackScope);
               .remove(callbackFunc, callbackScope);
</pre>
</pre>


'''Remove bookmarks'''
'''Remove bookmarks'''
<pre class="brush:js;toolbar:false;">
<pre class="brush:js;toolbar:false;">
places.bookmarks.filter({ bookmarked: { tags: ["removeme"] } })
places.bookmarks.filter({ bookmarked: { tags: ["removeme"] } })
                 .remove(callbackFunc, callbackScope);
                 .remove(callbackFunc, callbackScope);
</pre>
</pre>


'''Annotations'''
'''Annotations'''
<pre class="brush:js;toolbar:false;">
<pre class="brush:js;toolbar:false;">
// Add bookmark annotations. If the result is not required to be bookmarked,
// Add bookmark annotations. If the result is not required to be bookmarked,
// a page annotation is added instead.
// a page annotation is added instead.
Line 100: Line 113:
places.bookmarks.filter({ uri: "^http://mozilla.org/annotateme/$" })
places.bookmarks.filter({ uri: "^http://mozilla.org/annotateme/$" })
                 .annotate([{ name: "annoToAdd" }], myCallback, callbackScope);
                 .annotate([{ name: "annoToAdd" }], myCallback, callbackScope);
// XXX to simplify this could just be .save({ annotations: [...] });
</pre>
</pre>


'''Bookmarks'''
'''Bookmarks'''
<pre class="brush:js;toolbar:false;">
<pre class="brush:js;toolbar:false;">
// Add a bookmark.
// Add a bookmark.
places.bookmarks.save({ uri: "http://moz.org/"
places.bookmarks.save({ uri: "http://moz.org/"
Confirmed users
595

edits