forked from karatebuilderboy/Scratch-to-Phonegap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
embed.js
28 lines (23 loc) · 854 Bytes
/
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
(function(global) {
'use strict';
var script = document.currentScript || (function(scripts) {
return scripts[scripts.length - 1];
})(document.getElementsByTagName('script'));
var hasUI = true;
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';
}
});
var iframe = document.createElement('iframe');
iframe.setAttribute('allowfullscreen', true);
iframe.setAttribute('allowtransparency', true);
iframe.src = script.src.replace(/^https:/, 'http:').replace(/embed\.js/, 'embed.html');
iframe.width = hasUI ? 482 : 480;
iframe.height = hasUI ? 393 : 360;
iframe.style.border = '0';
iframe.className = 'phosphorus';
script.parentNode.replaceChild(iframe, script);
}(this));