forked from webduinoio/webduino-blockly
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlauncher.html
More file actions
58 lines (48 loc) · 1.7 KB
/
Copy pathlauncher.html
File metadata and controls
58 lines (48 loc) · 1.7 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<script src="components/webcomponentsjs/webcomponents-lite.min.js"></script>
<script src="lib/jquery-2.2.1.min.js"></script>
<script src="launcher.js"></script>
<script>
function getUrlParam(name, defaultValue) {
var val = location.search.match(new RegExp('[?&]' + name + '=([^&]+)'));
return val ? decodeURIComponent(val[1].replace(/\+/g, '%20')) : defaultValue;
}
window.addEventListener('load', function() {
var url = window.location.href.split('#')[0],
dataStr = localStorage.getItem(url);
if (dataStr) {
var config = JSON.parse(dataStr),
tpl = getUrlParam('tpl', (config.tpl || 'default'));
launcher.loadTemplate('./templates/' + tpl + '.html', function (data) {
// Load translation
window.MSG = {};
$('head').append('<script src="msg/' + tpl + '/' + config.lang + '.js' + '"><\/script>');
// Translate string in head
var $head = $('<div/>', {
html: data.head
});
$head.find('[data-translation]').each(function () {
$(this).html(window.MSG[$(this).data('translation')]).removeAttr('data-translation');
});
data.head = $head.clone().wrap('<div/>').html();
// Translate string in body
var $body = $('<div/>', {
html: data.body
});
$body.find('[data-translation]').each(function () {
$(this).html(window.MSG[$(this).data('translation')]).removeAttr('data-translation');
});
data.body = $body.clone().wrap('<div/>').html();
$.extend(config.data, data);
launcher.jsbin(config);
});
}
});
</script>
</head>
<body>
</body>
</html>