-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoptions.html
113 lines (106 loc) · 2.85 KB
/
options.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
101
102
103
104
105
106
107
108
109
110
111
112
113
<html>
<head><title>Shortmail Options</title>
<script>
function updateStatus(text, wait) {
var status = document.getElementById("status");
status.innerHTML = text;
if (wait) {
setTimeout(function() {
status.innerHTML = "";
}, wait);
}
}
function testConnection() {
updateStatus("connecting...", 0);
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://api.shortmail.com/home/api/accounts');
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Authorization", "Basic " + btoa(localStorage["email"] + ":" + localStorage["password"]));
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 200 || xhr.status === 304) {
updateStatus("Success! Options Saved", 1500);
} else {
updateStatus("Email address or password incorrect", 2500);
}
}
}
xhr.send(null);
}
function saveOptions() {
localStorage["email"] = document.getElementById("email").value;
localStorage["password"] = document.getElementById("password").value;
testConnection();
}
function restoreOptions() {
document.getElementById("email").value = localStorage["email"];
document.getElementById("password").value = localStorage["password"];
}
</script>
<style>
body {
padding: 20px 0;
background: url(http://assets0.shortmail.com/images/body-bg.jpg);
font-size: 24px;
font-family: sans-serif;
color: #333;
}
#status {
height: 30px;
margin: 0;
padding: 0;
font-size: 18px;
text-align: center;
color: #999;
}
#wrapper {
margin: 20px auto;
width: 500px;
padding: 30px 30px 60px;
background: url(http://assets1.shortmail.com/images/wood.png) -9px -9px repeat-y;
-webkit-border-radius: 10px;
-webkit-box-shadow: 0 0 7px rgba(0,0,0,.7);
}
#top {
margin: 0 0 20px 0;
}
input {
display: block;
margin-bottom: 10px;
}
input {
width: 480px;
padding: 20px;
font-size: 24px;
color: #333;
-webkit-border-radius: 5px;
}
button {
display: block;
padding: 5px 15px;
border: 1px solid #00709f;
-webkit-border-radius: 3px;
font-size: 18px;
color: #fff;
text-shadow: 1px 1px 1px #00709f;
font-weight:bold;
background: -webkit-gradient(linear, left top, left bottom, from(#2CA1E5), to(#0D89BC));
}
button:hover {
cursor: pointer;
background: -webkit-gradient(linear, left top, left bottom, from(#2CA1E5), to(#0D79AC));
}
</style>
</head>
<body onload="restoreOptions()">
<div id="status"></div>
<div id="wrapper">
<div id="top">
<a href="https://shortmail.com/"><img src="http://assets2.shortmail.com/images/twitter-avatar.png"/></a>
</div>
<input type="text" id="email" placeholder="Shortmail email address"/>
<input type="password" id="password" placeholder="Password"/>
<button onclick="saveOptions()">Save</button>
</div>
</body>
</html>