logo

scripts

A bunch of scripts, some to be moved to their own repository
commit: 05b314cdd3bee4b00b239fba75a74fca1f61bc47
parent: 03ee345b84c8c702ccfd3c5f0f4860fb9f211d18
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Thu, 27 Sep 2018 16:24:28 +0200

js/userscripts/low-tech-solar-stats.js: Initial Version

Diffstat:

Ajavascript/userscript/low-tech-solar-stats.user.js40++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+), 0 deletions(-)

diff --git a/javascript/userscript/low-tech-solar-stats.user.js b/javascript/userscript/low-tech-solar-stats.user.js @@ -0,0 +1,40 @@ +// ==UserScript== +// @name Low-Tech JS +// @namespace https://hacktivis.me/ +// @description jQuery-less JS version to display the power stats on the page +// @include https://solar.lowtechmagazine.com/* +// @version 0.0.1 +// @grant none +// ==/UserScript== + +// Upstream should try to do it via CSS instead IMO +document.getElementById("menu").child.style.display = "inline-block"; + +var url = "https://solar.lowtechmagazine.com/api/stats.json"; +var weather_ignore = ["snow", "sleet", "wind", "fog"]; +var weather_data = ["today", "tomorrow", "day_after_t"]; +var weather_days = ["today", "tomorrow", "day after tomorrow"]; +var forecast = ""; +var request = new XMLHttpRequest(); + +request.onload = function() { + res = JSON.parse(request.response); + + // @DONE: Location + Hardware + document.getElementById("dashboard_level").innerText = res.bat_capacity; + document.getElementById("battery").innerText = res.bat_capacity; + document.getElementById("battery").style.height = res.bat_capacity; + document.getElementById("time").innerText = res.local_time; + document.getElementById("uptime").innerText = res.uptime; + + if(res.ac_power == "0W") { + document.getElementById("power").innerText = res.bat_power; + } else { + document.getElementById("power").innerText = res.ac_power; + } + + // @TODO: Forecast +} + +request.open('GET', url, true) +request.send(null)