infostats.js

JavaScript library for pulling battery info from the tweak infostats

Download Current Back to Libraries

Getting started

Pulls battery percent and battery state from batteryStats.txt. Requires the Cydia tweak infostats.

Call the batteryStats function with an object line 11, set your refresh time in milliseconds line 12, set your return function with the elements you would like to update with the battery percent or charging status.

There is an example project HERE (Lockscreen)

There is an example project SVG Round Widget

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<div id="battery"></div>
<div id="charging"></div>


<!--include infostats.js -->
<script src="js/infostats.js"></script>


<!-- get battery stuff -->
<script>
batteryStats({
  refresh : 1000, // in milliseconds
  success: function(battery){
    document.getElementById('battery').innerHTML = battery.percent + '%';                  
    document.getElementById('charging').innerHTML = battery.charging;                  
  }
});
</script>
Tweet Libraries hosted with ❤ by JunesiPhone