Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit 2a082f04c6222e954cd5e7c4e8b9e65df42ae67e 0 parents
@abi authored
1  README
@@ -0,0 +1 @@
+Yip is a Firefox extension that ports the Fluid and Prism notification APIs over to Firefox so you can receive Growl notifications (or plain Firefox notifications if you're on Windows or Linux) from web applications. For more information, head over to http://abcdefu.wordpress.com
3  chrome.manifest
@@ -0,0 +1,3 @@
+resource yip ./
+content yip content/
+overlay chrome://browser/content/browser.xul chrome://yip/content/browser.xul
38 components/about-yip.js
@@ -0,0 +1,38 @@
+// Thanks to https://developer.mozilla.org/En/Custom_about:_URLs
+
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+
+function YipAboutHandler() {
+}
+
+YipAboutHandler.prototype = {
+ newChannel : function(aURI) {
+ var ios = Cc["@mozilla.org/network/io-service;1"].
+ getService(Ci.nsIIOService);
+
+ var channel = ios.newChannel(
+ "chrome://yip/content/yip.html",
+ null,
+ null
+ );
+
+ channel.originalURI = aURI;
+ return channel;
+ },
+
+ getURIFlags: function(aURI) {
+ return Ci.nsIAboutModule.ALLOW_SCRIPT;
+ },
+
+ classDescription: "About Yip Page",
+ classID: Components.ID("50681bf0-4d31-11de-8a39-0800200c9a66f"),
+ contractID: "@mozilla.org/network/protocol/about;1?what=yip",
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule])
+}
+
+function NSGetModule(aCompMgr, aFileSpec) {
+ return XPCOMUtils.generateModule([YipAboutHandler]);
+}
79 components/yip.js
@@ -0,0 +1,79 @@
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+
+const Ci = Components.interfaces;
+const Cc = Components.classes;
+
+function Yip() { }
+
+Yip.prototype = {
+ classDescription: "Yip Notifications Javascript XPCOM Component",
+ classID: Components.ID("{102DF778-5108-11DE-86DB-AAF855D89593}"),
+ contractID: "@foyrek.com/yip;1",
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIYip, Ci.nsIClassInfo]),
+ _xpcom_categories: [{category: "JavaScript global property", entry: "fluid"},
+ {category: "JavaScript global property", entry: "platform"}],
+ implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT,
+ flags: Ci.nsIClassInfo.DOM_OBJECT,
+ getInterfaces: function(countRef) {
+ var interfaces = [Ci.nsIYip, Ci.nsIClassInfo, Ci.nsISupports];
+ countRef.value = interfaces.length;
+ return interfaces;
+ },
+ getHelperForLanguage: function(count) {return null;},
+ showGrowlNotification : function showGrowlNotification(aNotifyObject){
+
+ var title = aNotifyObject.title ? aNotifyObject.title : "Yip Notification";
+ var text = aNotifyObject.description ? aNotifyObject.description : "";
+ var icon = aNotifyObject.icon ? aNotifyObject.icon : "chrome://yip/content/images/icon.png";
+ var textClickable = false;
+ var cookie = "";
+ var alertListener = null;
+
+ var {onclick, onfinished} = aNotifyObject;
+ if (onclick || onfinished) {
+ textClickable = true;
+ alertListener = {
+ observe: function alertObserver(subject, topic, data) {
+ if (topic === "alertclickcallback" && onclick)
+ onclick();
+ else if (topic === "alertfinished" && onfinished)
+ onfinished();
+ }
+ };
+ }
+
+ //This is dumb but we have to do this
+ if(icon == "http://www.meebo.com")
+ icon = "http://s2.meebo.com/skin/onyx/img/network/meebome_20_online.png";
+
+ try {
+ var classObj = Cc["@mozilla.org/alerts-service;1"];
+ var alertService = classObj.getService(Ci.nsIAlertsService);
+ alertService.showAlertNotification(icon, title, text, textClickable, "", alertListener);
+ } catch (e) {
+ Components.utils.reportError(e);
+ }
+
+ },
+ showNotification : function showNotification(aTitle, aText, aImageURI){
+
+ //This is dumb but we have to do this
+ if(aImageURI == "http://www.meebo.com")
+ aImageURI = "http://s2.meebo.com/skin/onyx/img/network/meebome_20_online.png";
+
+ try {
+ var classObj = Cc["@mozilla.org/alerts-service;1"];
+ var alertService = classObj.getService(Ci.nsIAlertsService);
+ alertService.showAlertNotification(aImageURI, aTitle, aText);
+ } catch (e) {
+ dump(e);
+ }
+ }
+ // displayNotification : function(){ //supports all options }
+};
+
+var components = [Yip];
+
+function NSGetModule(compMgr, fileSpec) {
+ return XPCOMUtils.generateModule(components);
+}
BIN  components/yip.xpt
Binary file not shown
14 content/browser.xul
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <!-- NOTE: We are using jquery 1.2.6. 1.3 has a bug when running from browser.xul (seems to be the same as https://ubiquity.mozilla.com/trac/ticket/535). Only simple workaround is to go back to 1.2.x -->
+ <script src="chrome://yip/content/js/ext/jquery.js"></script>
+ <script type="application/javascript;version=1.7"
+ src="chrome://yip/content/js/browser.js"></script>
+ <statusbar id="status-bar">
+ <statusbarpanel id="yip-statusbar">
+ <image id="yip-image" src="chrome://yip/content/images/icon.png"
+ width="16" height="16" style="margin:0 5px"
+ onclick="gYip.openAboutYip()"/>
+ </statusbarpanel>
+ </statusbar>
+</overlay>
BIN  content/images/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 content/js/browser.js
@@ -0,0 +1,47 @@
+(function(){
+
+ const VERSION_PREF ="extensions.yip.version";
+ const YIP_URL = "about:yip";
+ const YIP_ID = "yip@foyrek.com";
+
+ //When the user first installs the extension, we show the about:yip page
+ var currVersion = Application.prefs.getValue(VERSION_PREF, "firstrun");
+ var realVersion = Application.extensions.get(YIP_ID).version;
+
+ if (currVersion != realVersion) {
+ Application.prefs.setValue(VERSION_PREF, realVersion);
+ window.addEventListener(
+ "load",
+ function onWindowLoad() {
+ window.removeEventListener("load", onWindowLoad, false);
+ var tabbrowser = window.getBrowser();
+ tabbrowser.addEventListener(
+ "load",
+ function onBrowserLoad() {
+ tabbrowser.removeEventListener("load", onBrowserLoad, false);
+ var tab = tabbrowser.addTab(YIP_URL);
+ tabbrowser.selectedTab = tab;
+ },
+ false
+ );
+ },
+ false
+ );
+ }
+
+ const Ci = Components.interfaces;
+ const Cc = Components.classes;
+
+ Yip = {
+ url : function url(spec) {
+ var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
+ return ios.newURI(spec, null, null);
+ },
+ openAboutYip : function openAboutYip(){
+ Application.activeWindow.open(this.url(YIP_URL)).focus();
+ }
+ }
+
+ window.gYip = Yip;
+
+})()
4,241 content/js/ext/jquery-latest.js
4,241 additions, 0 deletions not shown
3,549 content/js/ext/jquery.js
3,549 additions, 0 deletions not shown
107 content/yip.html
@@ -0,0 +1,107 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+ <title>Yip</title>
+ <script src="resource://yip/content/js/ext/jquery.js"></script>
+ <script type="application/javascript;version=1.7"
+ src="chrome://yip/content/js/browser.js"></script>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+ <meta http-equiv="Content-Language" content="en-us"/>
+ <link rel="icon" type="image/png" href="resource://yip/content/images/icon.png" />
+</head>
+<body>
+
+ <script type="text/javascript" charset="utf-8">
+
+ window.fluid.showGrowlNotification({title:"Yip!", description:"This is a test notification that shows up when you load the about:yip page. Try clicking it!", onclick:function(){
+ fluid.showGrowlNotification(
+ {title:"You just clicked!",
+ description: "This behavior can be implemented with the onclick callback. Read about:yip for more information."
+ });
+ }});
+
+ </script>
+
+ <style type="text/css" media="screen">
+ body{
+ font-family: Garamond, Georgia, sans-serif;
+ }
+
+ #content{
+ margin:auto;
+ width:400px;
+ text-align: center;
+ margin-top:50px;
+ }
+
+ h1{
+ margin-bottom:30px;
+ }
+
+ #footer{
+ margin-top:70px;
+ text-align:center;
+ color:#999;
+ }
+
+ a{
+ text-decoration: none;
+ color:inherit;
+ }
+
+ p{
+ width:300px;
+ text-align:justify;
+ font-size:16px;
+ margin:auto;
+ line-height:1.4em;
+ margin-bottom:20px;
+ }
+
+ p a{
+ border-bottom: 1px solid #999;
+ }
+
+ ul{
+ list-style: none;
+ padding:0px;
+ }
+
+ li{
+ font-size:13px;
+ display:inline;
+ font-family: Garamond;
+ cursor:pointer;
+ }
+
+ li:hover{
+ color:#000;
+ }
+
+ li:first-child{
+ padding-right:10px;
+ }
+
+ li:last-child{
+ padding-left:10px;
+ }
+
+
+ </style>
+
+ <div id="content">
+ <img src="resource://yip/content/images/icon.png" />
+ <h1>You're using Yip!</h1>
+ <p>Yip is a small extension that ports the Fluid and Prism notification APIs over to Firefox so you can receive notifications from web applications. If you log into <a href="http://www.meebo.com">Meebo</a> or another site that supports notifications, the next time your friends send you an IM, you should see a notification (obviously, Meebo should not be your focused window/tab at that point).
+ </p>
+ <p>To learn more about Yip, its future and how to support notifications on your site, <a href="http://abcdefu.wordpress.com"> visit this page.</a> Yip's source code is <a href="http://github.com/abi/yip/tree/master">available on Github.</a></p>
+ <ul id="footer">
+ <li><a href="http://abcdefu.wordpress.com"> created by Abi</a></li>
+ <li onclick="platform.showNotification('You clicked the star.', 'Why would you do that?', 'resource://yip/content/images/icon.png')">✭</li>
+ <li><a href="http://www.dapino-colada.nl">icon by Dapino</a></li>
+ </ul>
+ </div>
+
+</body>
+</html>
1  defaults/preferences/preferences.js
@@ -0,0 +1 @@
+pref("extensions.yip.version", "firstrun");
10 idl/yip.idl
@@ -0,0 +1,10 @@
+#include "nsISupports.idl"
+
+interface nsIVariant;
+
+[scriptable, uuid(102DF778-5108-11DE-86DB-AAF855D89593)]
+interface nsIYip : nsISupports
+{
+ void showGrowlNotification(in nsIVariant aNotifyObject);
+ void showNotification(in AString aTitle, in AString aText, in AString aImageURI);
+};
28 install.rdf
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+ <Description about="urn:mozilla:install-manifest">
+ <em:id>yip@foyrek.com</em:id>
+ <em:version>0.1</em:version>
+
+ <!-- Target Application this extension can install into,
+ with minimum and maximum supported versions. -->
+ <em:targetApplication>
+ <Description>
+ <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+ <em:minVersion>3.0</em:minVersion>
+ <em:maxVersion>3.6a1pre</em:maxVersion>
+ </Description>
+ </em:targetApplication>
+
+ <!-- Front End MetaData -->
+ <em:name>Yip</em:name>
+ <em:description>Notifications for Web Apps</em:description>
+ <em:creator>Abimanyu Raja</em:creator>
+ <em:iconURL>chrome://yip/content/images/icon.png</em:iconURL>
+ <em:homepageURL>http://abcdefu.wordpress.com/</em:homepageURL>
+ <em:updateURL>http://www.foyrek.com/yip/update.rdf</em:updateURL>
+ <em:updateKey>MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCxTfPIbnVZ6apY54iHhI2Ie6pnextOfWz5bKKV0ixoyHay+f3s/vzGfBTxrNx/J2pvxtXWSP3Q/aApy168WytcMKlr2kM9vtWHJTleqYcWLMd2vfwO9owXrnoC7eCq1AX7j8KlCzbiUX/A1hWwTOH1+RMH7e7FXStQaUwE3Zhb/QIDAQAB</em:updateKey>
+ </Description>
+</RDF>
Please sign in to comment.
Something went wrong with that request. Please try again.