-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.889daa91.js.map
1 lines (1 loc) · 7.03 KB
/
index.889daa91.js.map
1
{"mappings":"AAEA,SAASA,EAAOC,GACZ,IAAIC,EAAQC,SAASF,EAAC,SAAaG,OAAO,GAAI,IAC1CC,EAAa,YAGbA,GADAH,EAAQ,EACM,IACNA,GAAS,GAAOA,EAAQ,GAClB,IACNA,GAAS,IAAQA,EAAQ,GACnB,IAEA,IAGlB,IAAII,EAAYC,SAASC,eAAeH,GAEpCI,EAAUF,SAASG,cAAc,OACrCD,EAAQE,UAAY,yCACpBF,EAAQG,aAAa,KAAM,UAAYV,GAEvC,IAAIW,EAAUN,SAASG,cAAc,OACrCG,EAAQF,UAAY,6BAEpB,IAAIG,EAASP,SAASG,cAAc,MACpCI,EAAOH,UAAY,iCACnBG,EAAOC,WAAad,EAAC,MAAY,KAAMe,QA3BzB,GA2B8C,SAC5DF,EAAOF,aAAa,KAAM,SAAWV,GAErC,IAAIe,EAAOV,SAASG,cAAc,OAClCO,EAAKN,UAAY,qBACjBM,EAAKF,UAAYb,EAAQ,QAAUA,EAAQ,GAAK,IAChDe,EAAKL,aAAa,KAAM,OAASV,GAEjCI,EAAUY,YAAYT,GAASS,YAAYL,GAASK,YAAYJ,GAAQI,YAAYD,GASxF,SAASE,EAASC,GACd,IAAIC,EAAS,GAEb,IAAK,IAAIC,KAASF,EACdC,EAAOE,KAAKC,YAAYJ,EAAEE,GAAF,MAAoB,KAAMN,QAhDxC,KAmDd,IAAIS,EAAOC,KAAKC,OAAON,GACnBO,EAAOF,KAAKG,OAAOR,GACnBS,EAAOT,EAAOU,QAAO,CAACC,EAAGC,EAAGC,EAAGC,IAAMH,EAAIC,EAAIE,EAAEC,QAAQ,GACvDC,EAAOb,WAhBf,SAA8Bc,GAC1B,MAAMC,EAAID,EAAMF,OACVI,EAAOF,EAAMP,QAAO,CAACI,EAAGM,IAAMN,EAAIM,IAAKF,EAC7C,OAAOb,KAAKgB,KAA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F,MAAKG,GAzBV,SAAaA,GACTA,EAAI,SAAa,GAAjB,kBAA4CC,QAAQ5E,GAEpDmB,EAASwD,EAAI,SAAa,GAAjB,mBAsBKE,CAAIF","sources":["src/js/index.ts"],"sourcesContent":["const DECIMALES = 4\n\nfunction pintar(v) {\n let _hora = parseInt(v['datetime'].substr(11, 2))\n let _dashboard = \"dashboard\"\n\n if (_hora < 6) {\n _dashboard += \"1\"\n } else if ((_hora >= 6) && (_hora < 12)) {\n _dashboard += \"2\"\n } else if ((_hora >= 12) && (_hora < 18)) {\n _dashboard += \"3\"\n } else {\n _dashboard += \"4\"\n }\n\n let dashboard = document.getElementById(_dashboard)\n\n let tarjeta = document.createElement('div')\n tarjeta.className = \"bg-white shadow-2xl p-3 rounded-lg m-2\"\n tarjeta.setAttribute(\"id\", \"tarjeta\" + _hora)\n\n let esquema = document.createElement('div')\n esquema.className = \"flex flex-col items-center\"\n\n let precio = document.createElement('h2')\n precio.className = \"text-2xl font-bold text-center\"\n precio.innerText = (v['value'] / 1000).toFixed(DECIMALES) + \" €/kWh\"\n precio.setAttribute(\"id\", \"precio\" + _hora)\n\n let hora = document.createElement('div')\n hora.className = \"text-sm font-light\"\n hora.innerText = _hora + \"h - \" + (_hora + 1) + \"h\"\n hora.setAttribute(\"id\", \"hora\" + _hora)\n\n dashboard.appendChild(tarjeta).appendChild(esquema).appendChild(precio).appendChild(hora)\n}\n\nfunction getStandardDeviation(array) {\n const n = array.length\n const mean = array.reduce((a, b) => a + b) / n\n return Math.sqrt(array.map(x => Math.pow(x - mean, 2)).reduce((a, b) => a + b) / n)\n}\n\nfunction calculos(d) {\n let _datos = []\n\n for (let value in d) {\n _datos.push(parseFloat((d[value]['value'] / 1000).toFixed(DECIMALES)))\n }\n\n let _min = Math.min(..._datos)\n let _max = Math.max(..._datos)\n let _avg = _datos.reduce((p, c, _, a) => p + c / a.length, 0)\n let _std = parseFloat(getStandardDeviation(_datos).toFixed(DECIMALES))\n\n _avg = parseFloat(_avg.toFixed(DECIMALES))\n\n let _horaMinima = _datos.indexOf(_min)\n let _horaMaxima = _datos.indexOf(_max)\n\n let _divHoraMinima = document.getElementById(\"horaminima\")\n _divHoraMinima.innerText = \"Franja horaria: \" + _horaMinima + \"h - \" + (_horaMinima + 1) + \"h\"\n\n let _divHoraMaxima = document.getElementById(\"horamaxima\")\n _divHoraMaxima.innerText = \"Franja horaria: \" + _horaMaxima + \"h - \" + (_horaMaxima + 1) + \"h\"\n\n let precioMedio = document.getElementById(\"preciomedio\")\n precioMedio.innerText = _avg + \" €/kWh\"\n\n let precioMinimo = document.getElementById(\"preciominimo\")\n precioMinimo.innerText = _min + \" €/kWh\"\n\n let precioMaximo = document.getElementById(\"preciomaximo\")\n precioMaximo.innerText = _max + \" €/kWh\"\n\n for (let i = 0; i < 25; i++) {\n let tarjetaHora = document.getElementById(\"tarjeta\" + i)\n let _precio = _datos[i]\n\n if (_precio < (_avg - _std)) {\n tarjetaHora.className = \"bg-green-400 shadow-2xl p-3 rounded-lg m-2\"\n } else {\n if (_precio > (_avg + _std)) {\n tarjetaHora.className = \"bg-red-400 shadow-2xl p-3 rounded-lg m-2\"\n } else {\n tarjetaHora.className = \"bg-orange-400 shadow-2xl p-3 rounded-lg m-2\"\n }\n }\n }\n}\n\nfunction etl(data) {\n data[\"included\"][0]['attributes']['values'].forEach(pintar)\n\n calculos(data[\"included\"][0]['attributes']['values'])\n}\n\nlet divFecha = document.getElementById(\"fechadehoy\")\nlet _hoy = new Date(Date.now())\n\nlet _day = _hoy.toLocaleDateString('es-ES', { weekday: 'long' })\nlet _dayN = _hoy.getDate()\nlet _month = _hoy.toLocaleDateString('es-ES', { month: 'long' })\nlet _monthN = _hoy.getMonth() + 1\nlet _year = _hoy.getFullYear()\ndivFecha.innerText = \"Precios de la energía para hoy, \" + _day + \" \" + _dayN + \" de \" + _month + \" del \" + _year\n\n\nlet dateStart = [_year, _monthN, _dayN].join(\"-\") + \"T00:00\"\nlet dateEnd = [_year, _monthN, _dayN].join(\"-\") + \"T23:59\"\n\nlet url = \"https://apidatos.ree.es/es/datos/mercados/precios-mercados-tiempo-real?start_date=\" + dateStart + \"&end_date=\" + dateEnd + \"&time_trunc=hour\"\n\n\nfetch(url)\n .then(response => response.json())\n .then(data => etl(data))"],"names":["pintar","v","_hora","parseInt","substr","_dashboard","dashboard","document","getElementById","tarjeta","createElement","className","setAttribute","esquema","precio","innerText","toFixed","hora","appendChild","calculos","d","_datos","value","push","parseFloat","_min","Math","min","_max","max","_avg","reduce","p","c","_","a","length","_std","array","n","mean","b","sqrt","map","x","pow","getStandardDeviation","_horaMinima","indexOf","_horaMaxima","i","tarjetaHora","_precio","divFecha","_hoy","Date","now","_day","toLocaleDateString","weekday","_dayN","getDate","_month","month","_monthN","getMonth","_year","getFullYear","dateStart","join","dateEnd","fetch","then","response","json","data","forEach","etl"],"version":3,"file":"index.889daa91.js.map"}