{"id":4815,"date":"2010-06-02T17:09:00","date_gmt":"2010-06-03T00:09:00","guid":{"rendered":"http:\/\/3.700"},"modified":"2010-06-02T17:09:00","modified_gmt":"2010-06-03T00:09:00","slug":"jetpack-0-4-extension-example-mailping","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/labs\/2010\/06\/jetpack-0-4-extension-example-mailping\/","title":{"rendered":"Jetpack 0.4 Extension Example &#8211; MailPing"},"content":{"rendered":"<p>With the release of <a href=\"http:\/\/mozillalabs.com\/jetpack\/2010\/05\/27\/announcing-jetpack-sdk-0-4\/\">Jetpack SDK 0.4<\/a>, developers have a variety of new APIs at their disposal. The following example will show you how to use the <a href=\"https:\/\/jetpack.mozillalabs.com\/sdk\/latest\/docs\/#module\/jetpack-core\/page-worker\">Page Worker<\/a> and <a href=\"https:\/\/jetpack.mozillalabs.com\/sdk\/latest\/docs\/#module\/jetpack-core\/widget\">Widget<\/a> APIs in your add-on code, but also have a look at the other notable APIs released in 0.4 &#8211; <a href=\"https:\/\/jetpack.mozillalabs.com\/sdk\/latest\/docs\/#module\/jetpack-core\/simple-storage\">Simple Storage<\/a> and <a href=\"https:\/\/jetpack.mozillalabs.com\/sdk\/latest\/docs\/#module\/jetpack-core\/private-browsing\">Private Browsing<\/a>.<\/p>\n<h2>You&#8217;ve got mail!<\/h2>\n<p>To show off the Jetpack SDK 0.4 release, I&#8217;ve constructed an add-on that checks Gmail and Yahoo Mail for unread inbox messages. It also lets you open tabs to both email services in a single click, and has some snazzy UI to boot! <\/p>\n<p><img decoding=\"async\" style=\"border: 1px solid #999999\" src=\"http:\/\/mozillalabs.com\/jetpack\/files\/2010\/05\/mailping.png\" \/><br \/>\n<!--more--><\/p>\n<h2>How it&#8217;s made<\/h2>\n<p>First you want to create a new Widget instance &#8211; the Widget API allows you to easily add UI to Firefox in a way friendly to the user &#8211; here&#8217;s what the code looks like:<\/p>\n<pre style=\"font-family: Consolas;font-size:12px;margin:15px 0px 30px 50px\">\nvar mpWidget = require('widget').Widget({\n    label:'MailPing',\n    content: '...HTML content goes here...',\n    onReady: function(){\n\t\/\/ onReady gives you access to your Widget when it's ready for manipulation\n\n        \/\/ My code was more extensive for this example so please view the source\n        \/\/ via the download link further down the page\n    },\n    onClick: function(){\n        \/\/ This is one of the events you can use to perform actions based on user input,\n        \/\/ see the documentation for the full list\n    }\n});\n\nrequire('widget').add(mpWidget);                      \n<\/pre>\n<p>I also used the Page Worker API to check the message counts, here is what an instantiation of a Page Worker instance looks like:<\/p>\n<pre style=\"font-family: Consolas;font-size:12px;margin:15px 0px 30px 50px\">\nvar gmail = require('page-worker').Page({\n    content: mpProviders.gmail.content,\n    onReady: function(){  \/\/ The onReady function is fired each time the content option is set\n        parse.run('gmail', gmail);\n        gmail.onReady = function(){}\n    }\n});\n\nrequire('page-worker').add(gmail);                 \n<\/pre>\n<h2>Get the source files<\/h2>\n<p>Download this <a href=\"http:\/\/people.mozilla.com\/~dbuchner\/demos\/extensions\/mailping.zip\">test extension package<\/a> and unpack it to the <i>packages\/<\/i> subdirectory in your Jetpack SDK directory. Make sure the SDK is activated per the <a href=\"https:\/\/jetpack.mozillalabs.com\/sdk\/latest\/docs\/\">instructions<\/a> in the docs. Then enter the <i>mailping\/<\/i> subdirectory and execute the command <i>cfx -a firefox run<\/i> to try it out.<\/p>\n<h2>Install the extension<\/h2>\n<p>To use the extension, you can <a href=\"https:\/\/addons.mozilla.org\/en-US\/firefox\/addon\/162066\/\">install the MailPing test extension<\/a> from addons.mozilla.org.<\/p>\n<p>&#8211; Daniel Buchner, on behalf of the Jetpack team<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With the release of Jetpack SDK 0.4, developers have a variety of new APIs at their disposal. The following example will show you how to use the Page Worker and Widget APIs in your add-on code, but also have a &hellip; <a class=\"go\" href=\"https:\/\/blog.mozilla.org\/labs\/2010\/06\/jetpack-0-4-extension-example-mailping\/\">Continue reading<\/a><\/p>\n","protected":false},"author":229,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/posts\/4815"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/users\/229"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/comments?post=4815"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/posts\/4815\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/media?parent=4815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/categories?post=4815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/tags?post=4815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}