-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sidebar.html
100 lines (89 loc) · 2.51 KB
/
Sidebar.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css">
<style>
.branding-below {
bottom: 56px;
top: 0;
}
.branding-text {
left: 7px;
position: relative;
top: 3px;
}
.col-contain {
overflow: hidden;
}
.col-one {
float: left;
width: 50%;
}
.logo {
vertical-align: middle;
}
.radio-spacer {
height: 20px;
}
.width-100 {
width: 100%;
}
</style>
</head>
<body>
<div class="sidebar branding-below">
<div class="block" id="button-bar">
<button class="blue" id="pre-sne">Pre-SNE</button>
</div>
<div class="block" id="contents">
Click above to run the Pre-SNE checker.
</div>
</div>
<div class="sidebar bottom">
<img alt="Crimson" class="logo" src="https://s3.amazonaws.com/static.thecrimson.com/images/seal.jpg" width="27" height="27">
<span class="gray branding-text">Crimson Pre-SNE by Brian Yu</span>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<script>
/**
* On document load, assign click handlers to each button and try to load the
* user's origin and destination language preferences if previously set.
*/
$(function() {
$('#pre-sne').click(preSNE);
});
/**
* Runs a server-side function to translate the user-selected text and update
* the sidebar UI with the resulting translation.
*/
function preSNE() {
$('#error').remove();
$('#contents').html('Running Pre-SNE...');
google.script.run
.withSuccessHandler(
function(result, element) {
$('#contents').html(result.contents);
})
.withFailureHandler(
function(msg, element) {
showError(msg, $('#contents'));
element.disabled = false;
})
.withUserObject(this)
.runPreSNE();
}
/**
* Inserts a div that contains an error message after a given element.
*
* @param msg The error message to display.
* @param element The element after which to display the error.
*/
function showError(msg, element) {
var div = $('<div id="error" class="error">' + msg + '</div>');
$(element).after(div);
}
</script>
</body>
</html>