| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369 | 
							- <!DOCTYPE html>
 
- <html lang="en">
 
- 	<head>
 
- 		<meta charset="utf-8"/>
 
- 		<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
 
- 		<meta name="apple-mobile-web-app-capable" content="yes" />
 
- 		<script src="/jquery.js"></script>
 
- 		<link rel="stylesheet" href="/style.css">
 
- 		<script src="/code.js"></script>
 
- 		<title>esp32-wifi-manager</title>
 
- 	</head>
 
- 	<script>
 
- var ws, sel, host, old, once = 0, jso, m;
 
- var to = 0, set_int = 0;
 
- function get_radio(name)
 
- {
 
- 	var s = document.getElementsByName(name), sel;
 
- 	for ( var i = 0; i < s.length; i++)
 
- 	    if (s[i].checked) {
 
- 	        sel = s[i].value;
 
- 	        break;
 
- 	    }
 
- 	return sel;
 
- }
 
- function get_radio_index(name)
 
- {
 
- 	var s = document.getElementsByName(name), i;
 
- 	for (i = 0; i < s.length; i++)
 
- 	    if (s[i].checked)
 
- 	        return i;
 
- 	return -1;
 
- }
 
- function do_reset()
 
- {
 
- 	var s = "{\"reset\":\"1\"}";
 
- 	try {
 
- 		ws.send(s);
 
- 	} catch(exception) {
 
- 		alert('Sorry, there was a problem' + exception);
 
- 	}
 
- 	ws.close();
 
- 	alert("Rebooting...");
 
- }
 
- function file_change()
 
- {
 
-         document.getElementById('update').disabled = 0;
 
- }
 
- function do_upload(f)
 
- {
 
- 	var xhr = new XMLHttpRequest();
 
-         document.getElementById('update').disabled = 1;
 
- 	//ws.close();
 
- 	document.getElementById("progr").class = "progr-ok";
 
- 	xhr.upload.addEventListener("progress", function(e) {
 
- 		document.getElementById("progr").value = parseInt(e.loaded / e.total * 100);
 
- 		if (e.loaded == e.total) {
 
- 		//	document.getElementById("realpage").style.display = "none";
 
- 		//	document.getElementById("waiting").style.display = "block";
 
- 		}
 
- 	
 
- 	}, false);
 
- 	xhr.onreadystatechange = function(e) {
 
- 		   console.log("rs" + xhr.readyState + " status " + xhr.status); 
 
- 		if (xhr.readyState == 4) {
 
- 			/* it completed, for good or for ill */
 
- 		//	document.getElementById("realpage").style.display = "none";
 
- 		//	document.getElementById("waiting").style.display = "block";
 
- 			document.getElementById("progr").class = "progr-ok";
 
- 			console.log("upload reached state 4: xhr status " + xhr.status);
 
- 			setTimeout(function() { window.location.href = location.origin + "/"; }, 9000 );
 
- 		}
 
- 	};
 
- 	/* kill the heart timer */
 
- 	clearInterval(set_int);
 
- 	xhr.open("POST", f.action, true);
 
- 	xhr.send(new FormData(f));
 
- 	return false;
 
- }
 
- function do_settings(f)
 
- {
 
- 	var xhr = new XMLHttpRequest();
 
- 	xhr.onreadystatechange = function(e) {
 
- 		   console.log("do_settings" + xhr.readyState + " status " + xhr.status); 
 
- 		if (xhr.readyState == 4) {
 
- 			document.getElementById("updsettings").style.opacity = "1.0";
 
- 			document.getElementById("updsettings").disabled = 0;
 
- 		}
 
- 	};
 
- 	xhr.open("POST", f.action, true);
 
- 	document.getElementById("updsettings").style.opacity = "0.3";
 
- 	document.getElementById("updsettings").disabled = 1;
 
- 	xhr.send(new FormData(f));
 
- 	return false;
 
- }
 
- function get_latest(n)
 
- {
 
- 	if (n == 0)
 
- 		ws.send("update-ota");
 
- 	else
 
- 		ws.send("update-factory");
 
- }
 
- function heart_timer() {
 
- 	var s;
 
- 	
 
- 	s = Math.round((95 * to) / (40 * 10)) / 100;
 
- 	
 
- 	if (s < 0) {
 
- 		clearInterval(set_int);
 
- 		set_int = 0;
 
- 		
 
- 		ws.close();
 
- 		
 
- 		document.getElementById("realpage").style.opacity = "0.3";
 
- 	}
 
- 		
 
- 	
 
- 	to--;
 
- 	document.getElementById("heart").style.opacity = s;
 
- }
 
- function heartbeat()
 
- {
 
- 	to = 40 * 10;
 
- 	if (!set_int) {
 
- 		set_int = setInterval(heart_timer, 100);
 
- 	}
 
- 		
 
- }
 
- function handleClick(cb) {
 
-     console.log(cb);
 
-     if (cb.id == 'autoexec-cb') {
 
-         if (cb.checked) {
 
-             $("#autoexec-command").show(200);
 
-         } else {
 
-             $("#autoexec-command").hide(200);
 
-         }
 
-     } else if (cb.id == 'autoexec-cb') {
 
-     }
 
- }
 
- </script>
 
- 	<body>
 
- 		<div id="app">
 
- 			<div id="app-wrap">
 
-                 <div id="command_line">
 
-                     <header>
 
-                         <h1>Startup command</h1>
 
-                     </header>
 
-                     <h2>
 
-                         <div id="autoexec" class="toggle">
 
-                             <label>Run squeezelite automatically at boot
 
-                                 <input id="autoexec-cb" type="checkbox" checked="checked" onclick='handleClick(this);'/><span class="slider"></span>
 
-                             </label>
 
-                         </div>
 
-                     </h2>
 
-                     <div id="autoexec-command">
 
-                         <div id="audioout" class="toggle-buttons">
 
-                             <h2>Audio output</h2>
 
-                             <input type="radio" id="i2s" name="audio" checked='checked' />
 
-                             <label for="i2s">I2S</label>
 
-                             <input type="radio" id="spdif" name="audio" />
 
-                             <label for="spdif">SPDIF</label>
 
-                             <input type="radio" id="bt" name="audio" />
 
-                             <label for="bt">Bluetooth</label>
 
-                         </div>
 
-                         <div id="btsinkdiv">
 
-                             <input id="btsink" type="text" value="BT sink name" />
 
-                         </div>
 
-                         <div>
 
-                             <h2>Player name</h2>
 
-                             <input id="player" type="text" value="squeezelite" />
 
-                         </div>
 
-                         <div>
 
-                             <h2>Optional setting (e.g. for LMS IP address)</h2>
 
-                             <input id="optional" type="text" value="" placeholder="-s 192.168.0.1" />
 
-                         </div>
 
-                         <div class="buttons">
 
-                             <input id="generate-command" type="button" value="Generate" />
 
-                         </div>
 
-                         <h2>Squeezelite command to run</h2>
 
-                         <section id="command-list">
 
-                             <textarea id="autoexec1" maxlength="120">squeezelite -o I2S -b 500:2000 -d all=info -M esp32</textarea>
 
-                         </section>
 
-                     </div>
 
-                     <div class="buttons">
 
-                         <input id="update-command" type="button" value="Save" />
 
-                     </div>
 
-                 </div>
 
-                 <div id="recoverydiv">
 
-                     <header><h1>System management</h1></header>
 
-                     <h2>Check for firmware upgrade</h2>
 
-                     <div class="buttons">
 
-                         <input type="button" id="fwcheck" value="Check" onclick='handleClick(this);' />
 
-                         <p><span id="currentfw">Currently running: 0.1</span> - <span id="latestfw">latest available version: 0.2</span></p>
 
-                     </div>
 
-                     <h2>Reboot to recovery system to perform firmware upgrade</h2>
 
-                     <div class="buttons">
 
-                         <input type="button" id="recovery" value="Recovery" onclick='handleClick(this);' />
 
-                     </div>
 
-                 </div>
 
-                 <div id="otadiv">
 
-                     <header><h1>Firmware upgrade</h1></header>
 
-                     <form name="multipart" action="otaform" method="post" enctype="multipart/form-data" onsubmit="do_upload(this); return false;">
 
-                         <progress id="progr" value="0" max="100" >Upload Progress</progress>
 
-                         <input type="file" name="ota" id="ota" size="20" accept=".bin" onchange="file_change();" style="font-size: 12pt">
 
-                         <span id="file_info" style="font-size:12pt;"></span>
 
-                         <input type="submit" id="update" disabled="" value="upload">
 
-                         <input type="submit" id="factory"  disabled="" value="factory">
 
-                     </form>
 
-                 </div>
 
- 				<div id="wifi">
 
- 					<header>
 
- 						<h1>Wi-Fi</h1>
 
- 					</header>
 
- 					<div id="wifi-status">
 
- 						<h2>Connected to:</h2>
 
- 						<section id="connected-to">
 
- 							<div class="ape"><div class="w0"><div class="pw"><span></span></div></div></div>
 
- 						</section>
 
- 					</div>
 
- 					<h2>Manual connect</h2>
 
- 					<section id="manual_add">
 
- 					<div class="ape">ADD (HIDDEN) SSID<div>
 
- 					</section>
 
- 					<h2>or choose a network...</h2>
 
- 					<section id="wifi-list">
 
- 					</section>
 
- 					<div id="pwrdby"><em>Powered by </em><a id="acredits" href="#"><strong>esp32-wifi-manager</strong></a>.</div>
 
- 				</div>
 
- 				<div id="connect_manual">
 
- 					<header>
 
- 						<h1>Enter Details</h1>
 
- 					</header>
 
- 					<h2>Manual Connection</h2>
 
- 					<section>
 
- 						<input id="manual_ssid" type="text" placeholder="SSID" value="">
 
- 						<input id="manual_pwd" type="password" placeholder="Password" value="">
 
- 					</section>
 
- 					<div class="buttons">
 
- 							<input id="manual_join" type="button" value="Join" data-connect="manual" />
 
- 							<input id="manual_cancel" type="button" value="Cancel"/>
 
- 					</div>
 
- 				</div>
 
- 				<div id="connect">
 
- 					<header>
 
- 						<h1>Enter Password</h1>
 
- 					</header>
 
- 					<h2>Password for <span id="ssid-pwd"></span></h2>
 
- 					<section>
 
- 						<input id="pwd" type="password" placeholder="Password" value="">
 
- 					</section>
 
- 					<div class="buttons">
 
- 							<input id="join" type="button" value="Join" />
 
- 							<input id="cancel" type="button" value="Cancel"/>
 
- 					</div>
 
- 				</div>
 
- 				<div id="connect-wait">
 
- 					<header>
 
- 						<h1>Please wait...</h1>
 
- 					</header>
 
- 					<h2>Connecting to <span id="ssid-wait"></span></h2>
 
- 					<section>
 
- 						<div id="loading">
 
- 							<div class="spinner"><div class="double-bounce1"></div><div class="double-bounce2"></div></div>
 
- 							<p class="tctr">You may lose wifi access while the esp32 recalibrates its radio. Please wait until your device automatically reconnects. This can take up to 30s.</p>
 
- 						</div>
 
- 						<div id="connect-success">
 
- 							<h3 class="gr">Success!</h3>
 
- 						</div>
 
- 						<div id="connect-fail">
 
- 							<h3 class="rd">Connection failed</h3>
 
- 							<p class="tctr">Please double-check wifi password if any and make sure the access point has good signal.</p>
 
- 						</div>
 
- 					</section>
 
- 					<div class="buttons">
 
- 						<input id="ok-connect" type="button" value="OK" class="ctr" />
 
- 					</div>
 
- 				</div>
 
- 				<div id="connect-details">
 
- 					<div id="connect-details-wrap">
 
- 						<header>
 
- 							<h1></h1>
 
- 						</header>
 
- 						<h2></h2>
 
- 						<section>
 
- 							<div class="buttons">
 
- 								<input id="disconnect" type="button" value="Disconnect" class="ctr"/>
 
- 							</div>
 
- 						</section>
 
- 						<h2>IP Address</h2>
 
- 						<section>
 
- 							<div class="ape brdb">IP Address:<div id="ip" class="fr"></div></div>
 
- 							<div class="ape brdb">Subnet Mask:<div id="netmask" class="fr"></div></div>
 
- 							<div class="ape">Default Gateway:<div id="gw" class="fr"></div></div>
 
- 						</section>
 
- 						<div class="buttons">
 
- 							<input id="ok-details" type="button" value="OK" class="ctr" />
 
- 						</div>
 
- 					</div>					
 
- 					<div id="diag-disconnect" class="diag-box">
 
- 						<div class="diag-box-win">
 
- 							<p>Are you sure you would like to disconnect from this wifi?</p>
 
- 							<div class="buttons">
 
- 								<input id="no-disconnect" type="button" value="No" />
 
- 								<input id="yes-disconnect" type="button" value="Yes" />
 
- 							</div>
 
- 						</div>
 
- 					</div>
 
- 				</div>
 
- 			</div>
 
- 		</div>
 
- 		<div id="credits">
 
- 			<header>
 
- 				<h1>About this app...</h1>
 
- 			</header>
 
- 			<h2></h2>
 
- 			<section>
 
- 				<p><strong>esp32-wifi-manager</strong>, © 2017-2019, Tony Pottier<br />Licender under the MIT License.</p>
 
- 				<p>
 
- 					This app would not be possible without the following libraries:
 
- 				</p>
 
- 				<ul>
 
- 					<li>SpinKit, ©  2015, Tobias Ahlin. Licensed under the MIT License.</li>
 
- 					<li>jQuery, The jQuery Foundation. Licensed under the MIT License.</li>
 
- 					<li>cJSON, © 2009-2017, Dave Gamble and cJSON contributors. Licensed under the MIT License.</li>
 
- 				</ul>
 
- 			</section>
 
- 			<div class="buttons">
 
- 				<input id="ok-credits" type="button" value="OK" class="ctr" />
 
- 			</div>
 
- 		</div>
 
- 	</body>
 
- <html>
 
 
  |