Replace two uses of deprecated request
This commit is contained in:
parent
d3f76d205a
commit
1a809c304e
|
@ -221,8 +221,8 @@
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$("[href='#basetunewarning']").trigger('click');
|
$("[href='#basetunewarning']").trigger('click');
|
||||||
|
|
||||||
var select = document.getElementById('basetunesSelect');
|
const select = document.getElementById('basetunesSelect');
|
||||||
let selectedTune = select.options[select.selectedIndex];
|
const selectedTune = select.options[select.selectedIndex];
|
||||||
document.getElementById("tuneBoard").innerHTML = selectedTune.dataset.board;
|
document.getElementById("tuneBoard").innerHTML = selectedTune.dataset.board;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
"electron-dl": "^3.5.0",
|
"electron-dl": "^3.5.0",
|
||||||
"json5": "^2.2.3",
|
"json5": "^2.2.3",
|
||||||
"marked": "^4.2.5",
|
"marked": "^4.2.5",
|
||||||
"request": "^2.88.0",
|
|
||||||
"semver": "^7.3.8",
|
"semver": "^7.3.8",
|
||||||
"@serialport/bindings-cpp": "^10.8.0",
|
"@serialport/bindings-cpp": "^10.8.0",
|
||||||
"usb": "^2.6.0"
|
"usb": "^2.6.0"
|
||||||
|
|
133
renderer.js
133
renderer.js
|
@ -46,7 +46,7 @@ function refreshSerialPorts()
|
||||||
document.getElementById('serialDetectError').textContent = 'No ports discovered'
|
document.getElementById('serialDetectError').textContent = 'No ports discovered'
|
||||||
}
|
}
|
||||||
|
|
||||||
select = document.getElementById('portsSelect');
|
const select = document.getElementById('portsSelect');
|
||||||
|
|
||||||
//Clear the current options
|
//Clear the current options
|
||||||
while (select.options.length)
|
while (select.options.length)
|
||||||
|
@ -127,29 +127,26 @@ function refreshDetails()
|
||||||
var version = selectElement.options[selectElement.selectedIndex].value;
|
var version = selectElement.options[selectElement.selectedIndex].value;
|
||||||
var url = "https://api.github.com/repos/noisymime/speeduino/releases/tags/" + version;
|
var url = "https://api.github.com/repos/noisymime/speeduino/releases/tags/" + version;
|
||||||
|
|
||||||
|
document.getElementById('detailsText').innerHTML = "";
|
||||||
document.getElementById('detailsHeading').innerHTML = version;
|
document.getElementById('detailsHeading').innerHTML = version;
|
||||||
|
|
||||||
var request = require('request');
|
fetch(url)
|
||||||
const options = {
|
.then((response) => {
|
||||||
url: url,
|
if (response.ok) {
|
||||||
headers: {
|
return response.json();
|
||||||
'User-Agent': 'request'
|
|
||||||
}
|
}
|
||||||
};
|
return Promise.reject(response);
|
||||||
|
})
|
||||||
|
.then((result) => {
|
||||||
|
console.log(result);
|
||||||
|
|
||||||
request.get(options, function (error, response, body) {
|
//Need to convert the Markdown that comes from Github to HTML
|
||||||
if (!error ) {
|
var myMarked = require('marked');
|
||||||
|
document.getElementById('detailsText').innerHTML = myMarked.parse(result.body);
|
||||||
console.log(body);
|
document.getElementById('detailsHeading').innerHTML = version + " - " + result.name;
|
||||||
var result = JSON.parse(body);
|
})
|
||||||
|
.catch((error) => {
|
||||||
// Continue with your processing here.
|
console.log('Could not download details.', error);
|
||||||
textField = document.getElementById('detailsText');
|
|
||||||
|
|
||||||
//Need to convert the Markdown that comes from Github to HTML
|
|
||||||
var myMarked = require('marked');
|
|
||||||
textField.innerHTML = myMarked.parse(result.body);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -164,61 +161,61 @@ function refreshAvailableFirmwares()
|
||||||
ChoosePortButton.disabled = true;
|
ChoosePortButton.disabled = true;
|
||||||
basetuneButton.disabled = true;
|
basetuneButton.disabled = true;
|
||||||
|
|
||||||
var request = require('request');
|
const select = document.getElementById('versionsSelect');
|
||||||
request.get('https://speeduino.com/fw/versions', {timeout: 20000}, function (error, response, body)
|
|
||||||
{
|
|
||||||
select = document.getElementById('versionsSelect');
|
|
||||||
if (!error && response.statusCode == 200) {
|
|
||||||
|
|
||||||
var lines = body.split('\n');
|
fetch('https://speeduino.com/fw/versions', { signal: AbortSignal.timeout(5000) } )
|
||||||
// Continue with your processing here.
|
.then((response) => {
|
||||||
|
if (response.ok) {
|
||||||
for(var i = 0;i < lines.length;i++)
|
return response.text();
|
||||||
{
|
|
||||||
var newOption = document.createElement('option');
|
|
||||||
newOption.value = lines[i];
|
|
||||||
newOption.innerHTML = lines[i];
|
|
||||||
select.appendChild(newOption);
|
|
||||||
}
|
|
||||||
select.selectedIndex = 0;
|
|
||||||
|
|
||||||
//Remove the loading spinner
|
|
||||||
loadingSpinner = document.getElementById("fwVersionsSpinner");
|
|
||||||
loadingSpinner.style.display = "none";
|
|
||||||
|
|
||||||
refreshBasetunes();
|
|
||||||
|
|
||||||
//Re-enable the buttons
|
|
||||||
DetailsButton.disabled = false;
|
|
||||||
ChoosePortButton.disabled = false;
|
|
||||||
basetuneButton.disabled = false;
|
|
||||||
}
|
}
|
||||||
else if(error)
|
return Promise.reject(response);
|
||||||
|
})
|
||||||
|
.then((result) => {
|
||||||
|
var lines = result.split('\n');
|
||||||
|
// Continue with your processing here.
|
||||||
|
|
||||||
|
for(var i = 0;i < lines.length;i++)
|
||||||
{
|
{
|
||||||
console.log("Error retrieving available firmwares: " + error);
|
|
||||||
var newOption = document.createElement('option');
|
var newOption = document.createElement('option');
|
||||||
if(error.code === 'ETIMEDOUT')
|
newOption.value = lines[i];
|
||||||
{
|
newOption.innerHTML = lines[i];
|
||||||
newOption.value = "Connection timed out";
|
|
||||||
newOption.innerHTML = "Connection timed out";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
newOption.value = "Cannot retrieve firmware list";
|
|
||||||
newOption.innerHTML = "Cannot retrieve firmware list. Check internet connection and restart";
|
|
||||||
}
|
|
||||||
select.appendChild(newOption);
|
select.appendChild(newOption);
|
||||||
|
|
||||||
//Remove the loading spinner
|
|
||||||
loadingSpinner = document.getElementById("fwVersionsSpinner");
|
|
||||||
loadingSpinner.style.display = "none";
|
|
||||||
}
|
}
|
||||||
else if(response.statusCode == 404)
|
select.selectedIndex = 0;
|
||||||
|
|
||||||
|
//Remove the loading spinner
|
||||||
|
loadingSpinner = document.getElementById("fwVersionsSpinner");
|
||||||
|
loadingSpinner.style.display = "none";
|
||||||
|
|
||||||
|
refreshBasetunes();
|
||||||
|
|
||||||
|
//Re-enable the buttons
|
||||||
|
DetailsButton.disabled = false;
|
||||||
|
ChoosePortButton.disabled = false;
|
||||||
|
basetuneButton.disabled = false;
|
||||||
|
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.log("Error retrieving available firmwares. ", error);
|
||||||
|
|
||||||
|
var newOption = document.createElement('option');
|
||||||
|
if(error.code === 'ETIMEDOUT')
|
||||||
{
|
{
|
||||||
|
newOption.value = "Connection timed out";
|
||||||
|
newOption.innerHTML = "Connection timed out";
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
);
|
{
|
||||||
|
newOption.value = "Cannot retrieve firmware list";
|
||||||
|
newOption.innerHTML = "Cannot retrieve firmware list. Check internet connection and restart";
|
||||||
|
}
|
||||||
|
select.appendChild(newOption);
|
||||||
|
|
||||||
|
//Remove the loading spinner
|
||||||
|
loadingSpinner = document.getElementById("fwVersionsSpinner");
|
||||||
|
loadingSpinner.style.display = "none";
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshBasetunes()
|
function refreshBasetunes()
|
||||||
|
@ -321,7 +318,7 @@ function refreshBasetunes()
|
||||||
function refreshBasetunesFilters()
|
function refreshBasetunesFilters()
|
||||||
{
|
{
|
||||||
//Get the display list object
|
//Get the display list object
|
||||||
var select = document.getElementById('basetunesSelect');
|
const select = document.getElementById('basetunesSelect');
|
||||||
|
|
||||||
//Get the currently selected Author
|
//Get the currently selected Author
|
||||||
selectElement = document.getElementById('basetunesAuthor');
|
selectElement = document.getElementById('basetunesAuthor');
|
||||||
|
|
Loading…
Reference in New Issue