fix typo, add radio input, display ssid on device
parent
45a76871be
commit
8e5c1202d9
|
|
@ -3,10 +3,14 @@
|
||||||
<link rel="stylesheet" href="../../css/spectre.min.css">
|
<link rel="stylesheet" href="../../css/spectre.min.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<input type="radio" id="useUrl" name="useURL"/>
|
||||||
|
<label for="useURL">Use URL</label>
|
||||||
<p>Enter a URL: <input type="text" id="url" class="form-input" value="http://espruino.com"></p>
|
<p>Enter a URL: <input type="text" id="url" class="form-input" value="http://espruino.com"></p>
|
||||||
<p>or Enter Wifi name: <input type="text" id="ssid" class="form-input" value=""></p>
|
<hr>
|
||||||
<p>and Wifi password: <input type="password" id="password" class="form-input" value=""></p>
|
<input type="radiox" id="useWIFI" name="useWIFI"/>
|
||||||
|
<label for="useWIFI">Use WIFI</label>
|
||||||
|
<p>Enter Wifi name: <input type="text" id="ssid" class="form-input" value=""></p>
|
||||||
|
<p>Wifi password: <input type="password" id="password" class="form-input" value=""></p>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="encryption" class="control-label">Encryption</label>
|
<label for="encryption" class="control-label">Encryption</label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
|
|
@ -18,7 +22,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<input type="checkbox" id="hidden" name="hidden" >
|
<input type="checkbox" id="hidden" name="hidden"/>
|
||||||
<label for="hidden">Hidden</label>
|
<label for="hidden">Hidden</label>
|
||||||
</div>
|
</div>
|
||||||
<p>Try your QR Code: <div id="qrcode"></div></p>
|
<p>Try your QR Code: <div id="qrcode"></div></p>
|
||||||
|
|
@ -53,14 +57,18 @@
|
||||||
}
|
}
|
||||||
return qrstring;
|
return qrstring;
|
||||||
}
|
}
|
||||||
function refreshWifiQRCode(){
|
function refreshQRCode(){
|
||||||
const ssid = document.getElementById("ssid").value;
|
qrcode.clear(); // clear the code.
|
||||||
const password = document.getElementById("ssid").value;
|
if(document.getElementById("useWIFI").checked){
|
||||||
const encryption = document.getElementById("encryption").value;
|
const ssid = document.getElementById("ssid").value;
|
||||||
const hidden = document.getElementById("hidden").checked;
|
const password = document.getElementById("password").value;
|
||||||
const wifiString = generateWifiString(ssid, password, hidden, encryption);
|
const encryption = document.getElementById("encryption").value;
|
||||||
qrcode.clear();
|
const hidden = document.getElementById("hidden").checked;
|
||||||
qrcode.makeCode(wifiString);
|
const wifiString = generateWifiString(ssid, password, hidden, encryption);
|
||||||
|
qrcode.makeCode(wifiString);
|
||||||
|
}else{
|
||||||
|
qrcode.makeCode(document.getElementById("url").value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var qrcode = new QRCode("qrcode", {
|
var qrcode = new QRCode("qrcode", {
|
||||||
text: document.getElementById("url").value,
|
text: document.getElementById("url").value,
|
||||||
|
|
@ -70,26 +78,26 @@
|
||||||
colorLight : "#ffffff",
|
colorLight : "#ffffff",
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById("url").addEventListener("change", function() {
|
document.getElementById("url").addEventListener("change", refreshQRCode});
|
||||||
qrcode.clear(); // clear the code.
|
document.getElementById("ssid").addEventListener("change",refreshQRCode);
|
||||||
qrcode.makeCode(document.getElementById("url").value); // make another code.
|
document.getElementById("password").addEventListener("change",refreshQRCode);
|
||||||
});
|
document.getElementById("encryption").addEventListener("change",refreshQRCode);
|
||||||
document.getElementById("ssid").addEventListener("change",refreshWifiQRCode);
|
document.getElementById("hidden").addEventListener("change",refreshQRCode);
|
||||||
document.getElementById("password").addEventListener("change",refreshWifiQRCode);
|
|
||||||
document.getElementById("encryption").addEventListener("change",refreshWifiQRCode);
|
|
||||||
document.getElementById("hidden").addEventListener("change",refreshWifiQRCode);
|
|
||||||
document.getElementById("upload").addEventListener("click", function() {
|
document.getElementById("upload").addEventListener("click", function() {
|
||||||
var url = document.getElementById("url").value;
|
var content = document.getElementById("url").value;
|
||||||
|
if(document.getElementById("useWIFI").checked){
|
||||||
|
content = document.getElementById("ssid").value
|
||||||
|
}
|
||||||
var img = imageconverter.canvastoString(document.getElementsByTagName("canvas")[0],{mode:"1bit",output:"string",compression:true});
|
var img = imageconverter.canvastoString(document.getElementsByTagName("canvas")[0],{mode:"1bit",output:"string",compression:true});
|
||||||
var app = `var img = ${img};
|
var app = `var img = ${img};
|
||||||
var url = ${JSON.stringify(url)};
|
var content = ${JSON.stringify(content)};
|
||||||
g.setColor(1,1,1);
|
g.setColor(1,1,1);
|
||||||
g.fillRect(0,0,239,239);
|
g.fillRect(0,0,239,239);
|
||||||
g.drawImage(img,20,20);
|
g.drawImage(img,20,20);
|
||||||
g.setFontAlign(0,0);
|
g.setFontAlign(0,0);
|
||||||
g.setFont("6x8");
|
g.setFont("6x8");
|
||||||
g.setColor(0,0,0);
|
g.setColor(0,0,0);
|
||||||
g.drawString(url,120,230);
|
g.drawString(content,120,230);
|
||||||
g.setColor(1,1,1);
|
g.setColor(1,1,1);
|
||||||
`;
|
`;
|
||||||
sendCustomizedApp({
|
sendCustomizedApp({
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue