564
edits
| Line 82: | Line 82: | ||
jetpack.places.fetch({ where:bookmarks, | jetpack.places.fetch({ where:bookmarks, | ||
tags: ["marx-brothers"] }, callback); | tags: ["marx-brothers"] }, callback); | ||
</pre> | |||
== Full Example == | |||
<pre class="brush:js;"> | |||
// an example jetpack using the places API | |||
// if the title of the contentDocument contains the word 'foo' always bookmark it | |||
jetpack.future.import("places"); | |||
function titleParse(doc) { | |||
let title = doc.title.split(); | |||
for (let idx in title) { | |||
if (title[idx] === 'foo'){ | |||
jetpack.tabs.current.bookmark({tags:['foo', 'jetpack-auto-tag']}); | |||
} | |||
} | |||
// lets alert the user - tell them how many bookmarks we have with 'foo': | |||
function callback(results) { | |||
alert("You have " + results.count + " bookmarks where the title contains 'foo'! Very Nice!"); | |||
} | |||
jetpack.places.fetch({where: 'bookmarks', phrase: 'foo', tags: ['foo']}, callback); | |||
} | |||
jetpack.tabs.onReady( titleParse ); | |||
</pre> | |||
edits