Calculator Tools Calculator Tools
Create

Nível de Bateria

Jan 2, 2024

About this app

Verifique o nível de bateria do seu dispositivo

Nível de Bateria Nível de Bateria

Related apps

Put this on your site

Source

                    <html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">

<title>Nível de Bateria</title>
<meta name="description" content="Verifique o nível de bateria do seu dispositivo">
<meta name="keywords" content="nível de bateria, bateria, dispositivo, celular, smartphone">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

<script type="text/javascript">
try {
// App Javascript Goes Here. Place your entire script content inside the try block for error handling.

// This will run when the DOM is ready.
document.addEventListener("DOMContentLoaded", function() {
// Get the battery level
navigator.getBattery().then(function (battery) {
// Update the battery level on the page
var batteryLevel = document.getElementById('battery-level');
batteryLevel.innerHTML = Math.floor(battery.level * 100) + '%';

// Update the battery status icon
var batteryIcon = document.getElementById('battery-icon');
if (battery.charging) {
batteryIcon.innerHTML = '<i class="fa fa-battery-full text-success"></i>';
} else {
if (battery.level >= 0.75) {
batteryIcon.innerHTML = '<i class="fa fa-battery-full text-success"></i>';
} else if (battery.level >= 0.5) {
batteryIcon.innerHTML = '<i class="fa fa-battery-three-quarters text-warning"></i>';
} else if (battery.level >= 0.25) {
batteryIcon.innerHTML = '<i class="fa fa-battery-half text-warning"></i>';
} else {
batteryIcon.innerHTML = '<i class="fa fa-battery-quarter text-danger"></i>';
}
}
});
});

} catch (error) {
// This will throw the error to the parent window.
throw error;
}
</script>

<style>
/* App CSS Goes Here */
body {
background-color: #f4f4f4;
font-family: 'Roboto', sans-serif;
}

.container {
text-align: center;
margin-top: 100px;
}

h1 {
font-size: 24px;
font-weight: bold;
color: #333;
margin-bottom: 20px;
}

.battery-level {
font-size: 48px;
font-weight: bold;
color: #333;
}

.battery-icon {
font-size: 72px;
margin-top: 20px;
}
</style>
</head>
<body>
<div id="main-container" class="container">
<h1>Nível de Bateria</h1>
<div class="battery-level" id="battery-level"></div>
<div class="battery-icon" id="battery-icon"></div>
</div>
</body>
</html>