-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathconfigure.html
120 lines (117 loc) · 4.09 KB
/
configure.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
114
115
116
117
118
119
120
<html>
<head>
<title>Octowatch Configuration</title>
<style>
body{
background-color: black;
color: white;
font:bold 12px "helvetica neue", helvetica, arial, sans-serif;
}
button.minimal {
background: #e3e3e3;
border: 1px solid #bbb;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: inset 0 0 1px 1px #f6f6f6;
-moz-box-shadow: inset 0 0 1px 1px #f6f6f6;
box-shadow: inset 0 0 1px 1px #f6f6f6;
color: #333;
font: bold 12px "helvetica neue", helvetica, arial, sans-serif;
line-height: 1;
padding: 8px 0 9px;
text-align: center;
text-shadow: 0 1px 0 #fff;
width: 150px; }
button.minimal:hover {
background: #d9d9d9;
-webkit-box-shadow: inset 0 0 1px 1px #eaeaea;
-moz-box-shadow: inset 0 0 1px 1px #eaeaea;
box-shadow: inset 0 0 1px 1px #eaeaea;
color: #222;
cursor: pointer; }
button.minimal:active {
background: #d0d0d0;
-webkit-box-shadow: inset 0 0 1px 1px #e3e3e3;
-moz-box-shadow: inset 0 0 1px 1px #e3e3e3;
box-shadow: inset 0 0 1px 1px #e3e3e3;
color: #000; }
input.minimal {
background: #e3e3e3;
border: 1px solid #bbb;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: inset 0 0 1px 1px #f6f6f6;
-moz-box-shadow: inset 0 0 1px 1px #f6f6f6;
box-shadow: inset 0 0 1px 1px #f6f6f6;
color: #333;
font: bold 12px "helvetica neue", helvetica, arial, sans-serif;
line-height: 1;
padding: 8px 0 9px;
text-align: center;
text-shadow: 0 1px 0 #fff;
width: 150px; }
button.minimal:hover {
background: #d9d9d9;
-webkit-box-shadow: inset 0 0 1px 1px #eaeaea;
-moz-box-shadow: inset 0 0 1px 1px #eaeaea;
box-shadow: inset 0 0 1px 1px #eaeaea;
color: #222;
cursor: pointer; }
button.minimal:active {
background: #d0d0d0;
-webkit-box-shadow: inset 0 0 1px 1px #e3e3e3;
-moz-box-shadow: inset 0 0 1px 1px #e3e3e3;
box-shadow: inset 0 0 1px 1px #e3e3e3;
color: #000; }
</style>
</head>
<body>
<br>
<center>
<h1>Octoprint server settings:</h1>
<table>
<tr><td>Name or IP Address:</td><td><input class="minimal" id="host" type="text"></td></tr>
<tr><td>Port:</td><td><input class="minimal" id="port" type="text"></td></tr>
<tr><td>API Key:</td><td><input class="minimal" id="api_key" type="text"></td></tr>
<tr><td colspan=2 align="right"><button class="minimal" id="save_button" onclick="saveSettings()">Save</button></tr></td>
</table>
</center>
<script>
// get values
var server_host = document.getElementById('host'),
server_port = document.getElementById('port'),
server_api_key = document.getElementById('api_key');
window.onload=function loadSettings(){
var uri = window.location
server_host.value = gup('host');
server_port.value = gup('port');
server_api_key.value = gup('key');
}
function saveSettings(){
// create options object
var options = {};
options.server_host = server_host.value;
options.server_port = server_port.value;
options.server_api_key = server_api_key.value;
var location = "pebblejs://close#" + encodeURIComponent(JSON.stringify(options));
document.location = location;
}
// function stolen from:
// http://www.netlobo.com/url_query_string_javascript.html
// thanks!
function gup( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return null;
else
return results[1];
}
</script>
</body>
</html>