forked from hackasaurus/webxray
-
Notifications
You must be signed in to change notification settings - Fork 6
/
save-dialog.html
78 lines (73 loc) · 1.91 KB
/
save-dialog.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE html>
<meta charset="utf-8">
<title>Save Your Data</title>
<link rel="stylesheet" href="dialog-common/stylesheets/base.css">
<style>
.big-button {
display: inline-block;
width: 200px;
text-align: center;
cursor: pointer;
background-color: #f8a339;
font-style: italic;
color: white;
border-radius: 10px;
padding: 20px;
}
.big-button:after {
content: ' »';
}
.big-button:hover {
background-color: #ffc833;
}
</style>
<div class="container">
<div id="buttons">
<div class="close-button" id="close"
data-l10n="dialog-common:close">Close</div>
</div>
<div id="header"><h1 class="title"><span data-l10n="dialog-common:product-name">Haystax Extractor</span> <span class="subtitle" data-l10n="header">Save Your Data</span></h1></div>
<div id="sample-csv" style="display: none;">
<a id="save" data-l10n="save-dialog:save">Download</a>
</div>
</div>
<script src="jquery.min.js"></script>
<script src="src/localization.js"></script>
<script>
function init(csv) {
$('#save')
.attr('href', 'data:text/csv;charset=UTF=8,' + encodeURIComponent(csv))
.attr('download', 'data.csv')
.addClass('big-button')
.appendTo('.container');
}
function loadLocalization(languages, cb) {
jQuery.localization.loadLocale({
languages: languages,
path: "src/locale/",
complete: function(locale) {
$(document.body).localize(locale, "save-dialog");
cb();
}
});
}
if (top === self) {
// We're not in an iframe, so we're being used for development.
$(window).ready(function() {
var csv = $("#sample-csv").text();
loadLocalization(["en", "es"], function() {
init(csv);
});
});
} else {
window.addEventListener("message", function(event) {
$("#close").click(function() {
window.parent.postMessage("close", "*");
});
var data = JSON.parse(event.data);
loadLocalization(data.languages, function() {
init(data.csv);
});
}, false);
}
</script>