forked from Edzelf/Esp-radio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_html.h
136 lines (125 loc) · 4.24 KB
/
config_html.h
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// config.html file in raw data format for PROGMEM
//
const char config_html[] PROGMEM = R"=====(
<!DOCTYPE html>
<html>
<head>
<title>Configuration ESP-radio</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="Shortcut Icon" type="image/ico" href="favicon.ico">
</head>
<body>
<ul>
<li><a class="pull-left" href="#">ESP Radio</a></li>
<li><a class="pull-left" href="/index.html">Control</a></li>
<li><a class="pull-left active" href="/config.html">Config</a></li>
<li><a class="pull-left" href="/about.html">About</a></li>
</ul>
<br><br><br>
<center>
<h1>** ESP Radio **</h1>
<p>You can edit the configuration here. <i>Note that this will be effective on the next restart of the Esp-radio.</i></p>
<h4>Available WiFi networks</h4>
<select class="select" onChange="handletone(this)" id="ssid"></select>
<br><br>
<textarea rows="25" cols="100" id="inifile">Space for inifile</textarea>
<br><br>
<button class="button" onclick="fsav()">Save</button>
<button class="button buttonr" onclick="httpGet('reset')">Restart</button>
<form action="#" onsubmit="return uploadfile(this);" enctype="multipart/form-data" method="post" name="fileinfo">
<h4>Upload file:</h4>
<input type="file" name="file" size="50"><br>
<input type="submit" value="Send">
</form>
<br><input type="text" size="80" id="resultstr" placeholder="Waiting for input....">
<br><br>
<script>
function httpGet ( theReq )
{
var theUrl = "/?" + theReq + "&version=" + Math.random() ;
var xhr = new XMLHttpRequest() ;
xhr.onreadystatechange = function() {
if ( xhr.readyState == XMLHttpRequest.DONE )
{
resultstr.value = xhr.responseText ;
}
}
xhr.open ( "GET", theUrl, false ) ;
xhr.send() ;
}
function fsav()
{
var theUrl = "/?save=0" ;
var xhr = new XMLHttpRequest() ;
xhr.onreadystatechange = function() {
if ( xhr.readyState == XMLHttpRequest.DONE )
{
resultstr.value = xhr.responseText ;
}
}
xhr.open ( "POST", theUrl, true ) ;
xhr.setRequestHeader ( "Content-type", "application/x-www-form-urlencoded" ) ;
xhr.send ( "content=" + inifile.value ) ;
}
function uploadfile ( theForm )
{
var oData, oReq ;
oData = new FormData ( fileinfo ) ;
oReq = new XMLHttpRequest() ;
oReq.open ( "POST", "/upload", true ) ;
oReq.onload = function ( oEvent ) {
if ( oReq.status == 200 )
{
resultstr.value = oReq.responseText ;
}
else
{
resultstr.value = "Error " + oReq.statusText ;
}
}
oReq.send ( oData ) ;
return false ;
}
// Fill configuration initially
// First the available WiFi networks
var i, select, opt, networks, params ;
select = document.getElementById("selnet") ;
var theUrl = "/?getnetworks=0" + "&version=" + Math.random() ;
var xhr = new XMLHttpRequest() ;
xhr.onreadystatechange = function() {
if ( xhr.readyState == XMLHttpRequest.DONE )
{
networks = xhr.responseText.split ( "|" ) ;
for ( i = 0 ; i < ( networks.length - 1 ) ; i++ )
{
opt = document.createElement( "OPTION" ) ;
opt.value = i ;
opt.text = networks[i] ;
ssid.add( opt ) ;
}
}
}
xhr.open ( "GET", theUrl, false ) ;
xhr.send() ;
// Now get the configuration parameters from radio.ini
theUrl = "/radio.ini" ;
xhr.onreadystatechange = function() {
if ( xhr.readyState == XMLHttpRequest.DONE )
{
inifile.value = xhr.responseText ;
}
}
xhr.open ( "GET", theUrl, false ) ;
xhr.send() ;
</script>
<script type="text/javascript">
var stylesheet = document.createElement('link') ;
stylesheet.href = 'radio.css' ;
stylesheet.rel = 'stylesheet' ;
stylesheet.type = 'text/css' ;
document.getElementsByTagName('head')[0].appendChild(stylesheet) ;
</script>
</body>
</html>
)=====" ;