-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathembed.js
33 lines (28 loc) · 1.06 KB
/
embed.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(function(global) {
'use strict';
var script = document.currentScript || (function(scripts) {
return scripts[scripts.length - 1];
})(document.getElementsByTagName('script'));
var hasUI = true;
var resolution = 480;
var params = script.src.split('?')[1].split('&');
params.forEach(function(p) {
var parts = p.split('=');
if (parts.length > 1 && parts[0] === 'ui') {
hasUI = parts[1] !== 'false';
}
if (parts.length > 1 && parts[0] === 'resolution-x'){
resolution = parts[1];
}
});
var iframe = document.createElement('iframe');
iframe.setAttribute('allowfullscreen', true);
iframe.setAttribute('allowtransparency', true);
iframe.src = script.src.replace(/^https:/, 'https:').replace(/embed\.js/, 'embed.html');
//width: 482, height: 393
iframe.width = hasUI ? Number(resolution)+2 : resolution;
iframe.height = hasUI ? Number(resolution)*3/4+33 : resolution*3/4;
iframe.style.border = '0';
iframe.className = 'phosphorus';
script.parentNode.replaceChild(iframe, script);
}(this));