User:Thunder: Difference between revisions
Jump to navigation
Jump to search
(→People) |
(→People) |
||
Line 9: | Line 9: | ||
== People == | == People == | ||
sample people data: | Here's some sample people data. To use it, copy the whole thing (including the JS) and paste it into the error console: | ||
<pre> | <pre> | ||
Components.utils.import("resource://people/modules/people.js");People.add( | Components.utils.import("resource://people/modules/people.js"); | ||
{ | People.add( | ||
[{ | |||
guid: "guid1", | guid: "guid1", | ||
schema: "http://labs.mozilla.com/schemas/people/1", | schema: "http://labs.mozilla.com/schemas/people/1", | ||
Line 90: | Line 91: | ||
displayName: "Fred", | displayName: "Fred", | ||
emails: [ | emails: [ | ||
{value: "fred@example.com"} | {value: "fred@example.com"}, | ||
{value: "fred2@example.com"} | {value: "fred2@example.com"} | ||
] | ] | ||
Line 108: | Line 109: | ||
} | } | ||
} | } | ||
}) | }]); | ||
</pre> | |||
To then verify the contacts were added correctly, run these in the error console: | |||
Find all contacts: | |||
<pre> | |||
Components.utils.import("resource://people/modules/people.js"); | |||
People.find({}); | |||
</pre> | |||
Find all contacts and output raw data as JSON: | |||
<pre> | |||
Components.utils.import("resource://people/modules/people.js"); | |||
JSON.stringify(People.find({})); | |||
</pre> | </pre> |
Revision as of 00:01, 7 August 2009
Firefox 3
Firefox 3.0 distribution customizations feature proposal
Weave
People
Here's some sample people data. To use it, copy the whole thing (including the JS) and paste it into the error console:
Components.utils.import("resource://people/modules/people.js"); People.add( [{ guid: "guid1", schema: "http://labs.mozilla.com/schemas/people/1", displayName: "Dan Mills", givenName: "Dan", familyName: "Mills", documents: { default: { moz_schema: "http://portablecontacts.net/draft-spec.html", displayName: "Dan Mills", name: { givenName: "Dan", familyName: "Mills" }, emails: [ {value: "thunder@mozilla.com"} ] } } }, { guid: "guid2", schema: "http://labs.mozilla.com/schemas/people/1", displayName: "Myk Melez", givenName: "Myk", familyName: "Melez", documents: { default: { moz_schema: "http://portablecontacts.net/draft-spec.html", displayName: "Myk Melez", name: { givenName: "Myk", familyName: "Melez" }, emails: [ {value: "myk@mozilla.com"} ] } } }, { guid: "guid3", schema: "http://labs.mozilla.com/schemas/people/1", displayName: "Anant", givenName: "Anant", familyName: "Narayanan", documents: { default: { moz_schema: "http://portablecontacts.net/draft-spec.html", displayName: "Anant", name: { givenName: "Anant", familyName: "Narayanan" }, emails: [ {value: "anant@mozilla.com"} ] } } }, { guid: "guid4", schema: "http://labs.mozilla.com/schemas/people/1", displayName: "Fred", documents: { default: { moz_schema: "http://portablecontacts.net/draft-spec.html", displayName: "Fred", emails: [ {value: "fred@example.com"}, {value: "fred2@example.com"} ] } } }, { guid: "guid5", schema: "http://labs.mozilla.com/schemas/people/1", displayName: "Barney", documents: { default: { moz_schema: "http://portablecontacts.net/draft-spec.html", displayName: "Barney" } } }]);
To then verify the contacts were added correctly, run these in the error console:
Find all contacts:
Components.utils.import("resource://people/modules/people.js"); People.find({});
Find all contacts and output raw data as JSON:
Components.utils.import("resource://people/modules/people.js"); JSON.stringify(People.find({}));