21 lines
796 B
JavaScript
21 lines
796 B
JavaScript
(function() {
|
|
function myExtension() {}
|
|
|
|
myExtension.prototype.connectToWiFi = function(networkName, password) {
|
|
// Überprüfe, ob die "navigator.connection" API unterstützt wird
|
|
if ('connection' in navigator && 'wifi' in navigator.connection) {
|
|
// Verbinde mit dem WLAN
|
|
navigator.connection.wifi.associate({ ssid: networkName, password: password })
|
|
.then(function() {
|
|
console.log("Verbindung hergestellt");
|
|
})
|
|
.catch(function(error) {
|
|
console.log("Fehler bei der Verbindung:", error);
|
|
});
|
|
} else {
|
|
console.log("Die WLAN-Verbindung wird von dieser Plattform nicht unterstützt.");
|
|
}
|
|
};
|
|
|
|
Scratch.extensions.register(new myExtension());
|
|
})(); |