Skip to content

Commit

Permalink
better hiding of iframe #49
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Dec 22, 2022
1 parent 0337ced commit 6d81926
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sysend",
"version": "1.14.2",
"version": "1.14.3",
"description": "Web application synchronization between different tabs",
"main": "sysend.js",
"typings": "sysend.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion sysend.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**@license
* sysend.js - send messages between browser windows/tabs version 1.14.2
* sysend.js - send messages between browser windows/tabs version 1.14.3
*
* Copyright (C) 2014-2022 Jakub T. Jankiewicz <https://jcubic.pl/me>
* Released under the MIT license
Expand Down
29 changes: 23 additions & 6 deletions sysend.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**@license
* sysend.js - send messages between browser windows/tabs version 1.14.2
* sysend.js - send messages between browser windows/tabs version 1.14.3
*
* Copyright (C) 2014-2022 Jakub T. Jankiewicz <https://jcubic.pl/me>
* Released under the MIT license
Expand Down Expand Up @@ -40,7 +40,7 @@
// identifier for making each call to list unique
var list_id = 0;

// id of the window/tabAnd two-way communication is tracked in
// id of the window/tabAnd two-way communication is tracked in
var target_id = generate_uuid();
var target_count = 1;
var domains;
Expand Down Expand Up @@ -95,6 +95,8 @@
domains.push(origin(url));
var iframe = document.createElement('iframe');
iframe.style.width = iframe.style.height = 0;
iframe.style.position = 'absolute';
iframe.style.top = iframe.style.left = '-9999px';
iframe.style.border = 'none';
var proxy_url = url;
if (!url.match(/\.html$/)) {
Expand Down Expand Up @@ -225,12 +227,18 @@
var host = (function() {
if (typeof URL !== 'undefined') {
return function(url) {
if (!url) {
return url;
}
url = new URL(url);
return url.host;
};
}
var a = document.createElement('a');
return function(url) {
if (!url) {
return url;
}
a.href = url;
return a.host;
};
Expand All @@ -245,16 +253,25 @@
}
// -------------------------------------------------------------------------
var origin = (function() {
function tc(f) {
return function origin(url) {
try {
return f(url);
} catch(e) {
return url;
}
};
}
if (window.URL) {
return function(url) {
return tc(function origin(url) {
return new URL(url).origin;
};
});
}
var a = document.createElement('a');
return function origin(url) {
return tc(function origin(url) {
a.href = url;
return a.origin;
};
});
})();
// -------------------------------------------------------------------------
// :: show only single message of this kind
Expand Down

0 comments on commit 6d81926

Please sign in to comment.