Skip to content

Commit

Permalink
#34 - fixing examples so that they work with addEventListener on IE <9
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKinlan committed Jun 21, 2011
1 parent c7595fa commit a2dedff
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion server/controller.js
Expand Up @@ -40,7 +40,7 @@ var IntentController = new (function() {
actionLink.href = action.url;
actionLink.target = "_blank";
actionLink.textContent = action.title;
addEventListener(actionLink, "click", launch(intent), false);
attachEventListener(actionLink, "click", launch(intent), false);

domain.textContent = action.domain || "Unknown domain";

Expand Down
2 changes: 1 addition & 1 deletion server/picker.js
@@ -1,4 +1,4 @@
addEventListener(window, "load", function() {
attachEventListener(window, "load", function() {
// Tell the opener that we are ready for business
window.opener.postMessage(JSON.stringify({ "request": "ready", "id": window.name }), "*");
}, false);
12 changes: 6 additions & 6 deletions server/webintents.js
@@ -1,11 +1,11 @@
var id;
var callbacks = {};

var addEventListener = function(obj, type, func, capture) {
if(!!window.addEventListener) {
obj.addEventListener(type, func, capture):
var attachEventListener = function(obj, type, func, capture) {
if(!!obj.addEventListener) {
obj.addEventListener(type, func, capture);
}
else {
else if(!!obj.attachEvent) {
obj.attachEvent("on" + type, func);
}
};
Expand Down Expand Up @@ -69,7 +69,7 @@ var Intents = new (function() {
};
})();

addEventListener(window, "message", function(e) {
attachEventListener(window, "message", function(e) {
var data = JSON.parse(e.data);
var timestamp = (new Date()).valueOf();

Expand Down Expand Up @@ -119,7 +119,7 @@ addEventListener(window, "message", function(e) {
}
}, false);

addEventListener(window, "storage", function(e) {
attachEventListener(window, "storage", function(e) {
// Intent messages are stored in localStorage as a synch mechanism.
// This is a dirty hack.
var vals = localStorage[e.key];
Expand Down

0 comments on commit a2dedff

Please sign in to comment.