-
Notifications
You must be signed in to change notification settings - Fork 0
/
translator.html
58 lines (47 loc) · 2.03 KB
/
translator.html
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
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="jszip.min.js"></script>
<script type="text/javascript" src="polyfill.js"></script>
<script type="text/javascript" src="translator.js"></script>
<script type="text/javascript" src="table.js"></script>
<script type="text/javascript" src="tab_panel.js"></script>
<script type="text/javascript">
function generateZip(e) {
content = __translator.generateZip();
//location.href = "data:application/zip;base64," + content;//for button
e.setAttribute("download", "I18N.zip");
e.setAttribute("href","data:application/zip;base64," + content);
}
var __translator = new Translator();
var __table = new Table(__translator);
var __tabPanel = new TabPanel();
window.onload = function() {
document.getElementById("preview").appendChild(__tabPanel.render);
var fileInput = document.getElementById('fileUpload');
fileInput.addEventListener('change', function(e) {
__tabPanel.clear();
fileInput.files.foreach(function(file) {
var reader = new FileReader();
reader.onload = function(e) {
var lang = __translator.detectLang(file.name);
var content = reader.result;
//loadLang(lang, content);
__tabPanel.addTab(lang,content);
__translator.parse(file,content);
__table.refresh();
}
reader.readAsText(file);
});
__tabPanel.addTab("result",__table.render);
});
}
</script>
</head>
<body>
<label class="button" for="fileUpload"> upload files</label>
<input type="file" id="fileUpload" multiple="multiple" style="display: none;"/>
<a onclick="generateZip(this);" class="button"> download </a>
<div id="preview"></div>
</body>
</html>