Comparing version 1.0.1 to 1.1.0
{ | ||
"name": "sysend", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Send messages to other tabs/windows in the same origin and browser", | ||
@@ -16,2 +16,4 @@ "main": "sysend.js", | ||
"events", | ||
"callback", | ||
"notifications", | ||
"browser" | ||
@@ -18,0 +20,0 @@ ], |
@@ -21,2 +21,9 @@ ## sysend.js | ||
or bower | ||
``` | ||
bower install sysend | ||
``` | ||
## Usage | ||
@@ -23,0 +30,0 @@ |
@@ -10,3 +10,11 @@ /**@license | ||
*/ | ||
var sysend = (function() { | ||
(function (root, factory) { | ||
if (typeof define === 'function' && define.amd) { | ||
define(['sysend'], factory); | ||
} else if (typeof exports === 'object') { | ||
module.exports = factory(); | ||
} else { | ||
root.sysend = factory(); | ||
} | ||
})(typeof window !== "undefined" ? window : this, function() { | ||
// we use prefix so `foo' event don't collide with `foo' locaStorage value | ||
@@ -41,3 +49,5 @@ var uniq_prefix = '___sysend___'; | ||
function to_json(input) { | ||
var obj = [id++]; | ||
// save random_value in storage to fix issue in IE that storage event | ||
// is fired on same page where setItem was called | ||
var obj = [id++, random_value]; | ||
// undefined in array get stringified as null | ||
@@ -55,4 +65,3 @@ if (typeof input != 'undefined') { | ||
window.addEventListener('storage', function(e) { | ||
// Fix issue in IE that storage event is fired on same page where setItem was called | ||
if (e.key.match(re) && e.url != location.href) { | ||
if (e.key.match(re)) { | ||
var key = e.key.replace(re, ''); | ||
@@ -63,6 +72,6 @@ if (callbacks[key]) { | ||
var obj = JSON.parse(value); | ||
if (obj) { | ||
if (obj && obj[1] != random_value) { | ||
// don't call on remove | ||
callbacks[key].forEach(function(fn) { | ||
fn(obj[1], key); | ||
fn(obj[2], key); | ||
}); | ||
@@ -73,2 +82,3 @@ } | ||
} | ||
origin_page = false; | ||
}, false); | ||
@@ -103,2 +113,2 @@ return { | ||
}; | ||
})(); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44209
8
133
64