Created
February 10, 2018 20:26
-
-
Save ahmethakanbesel/dcc0ec5d2c3603e11af72a642689bd65 to your computer and use it in GitHub Desktop.
Javascript Battery Level GUI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pil = navigator.battery || navigator.webkitBattery || navigator.mozBattery; | |
function pilDurumu(pil) { | |
document.getElementById('seviye').innerHTML += ' %' + pil.level * 100; | |
document.getElementById('yuzde').value = pil.level * 100; | |
if (pil.charging === true) { | |
var durum = "Şarj oluyor"; | |
} else { | |
var durum = "Şarjda değil"; | |
} | |
document.getElementById('durum').innerHTML += durum; | |
document.getElementById('durum').innerHTML += dischargingTime; | |
} | |
if (navigator.getBattery) { | |
navigator.getBattery().then(pilDurumu); | |
} else if (battery) { | |
pilDurumu(battery); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment