Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <!-- Nagłówek dokumentu HTML. -->
- <head>
- <!-- Metadane pliku HTML. -->
- <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
- <meta charset="utf-8">
- <!-- Używane style CSS. -->
- <style>
- body {
- font-family: 'Courier';
- }
- div.button {
- display: inline;
- background-color: #FF8888;
- padding: 5px;
- user-select: none;
- cursor: pointer;
- }
- </style>
- </head>
- <!-- Ciało dokumentu HTML. Funkcja 'onload' wywoływana jest zaraz pozaładowaniu
- dokumentu to przeglądarki. -->
- <body onload="startApp()" onload="check()">
- <!-- Kod JavaScript do obsługi aplikacji HTML. -->
- <script>
- var n = 0;
- var s = 0;
- var srd = 0;
- var odchyl = 0;
- var t = [];
- var j = 0;
- var temp = 0;
- var xi = 0;
- var odchylenie = 0;
- var v = 0;
- var b = 0;
- // Funkcja wywoływana po załadowaniu strony (zobacz powyżej, onload="startApp()").
- function startApp()
- {
- document.getElementById('view').innerHTML = 'Calculator' ;
- //check();
- }
- // Funkcja wywoływana po naciśnięciu przycisku 'A'.
- function add()
- {
- n += 1;
- s += Number(document.getElementById('num').value);
- t[j]= Number(document.getElementById('num').value);
- j += 1;
- srd = s/n;
- //tu
- //tu
- check();
- }
- // Funkcja wywoływana po naciśnięciu przycisku 'C'.
- function clean()
- {
- srd = 0;
- n = 0;
- s = 0;
- t = [];
- a = 0;
- b = 0;
- v = 0;
- document.getElementById('view').innerHTML = 'Clean';
- }
- function check()
- {
- var checkBox = document.getElementById("box1");
- if (checkBox.checked == true)
- {
- var x = document.getElementById("srednia").innerHTML = srednia1('a');
- }
- else
- {
- var x = document.getElementById("srednia").innerHTML = "";
- }
- var checkBox2 = document.getElementById("box2");
- if (checkBox2.checked == true)
- {
- var x = document.getElementById("suma").innerHTML = sumka('b');
- }
- else
- {
- var x = document.getElementById("suma").innerHTML = "";
- }
- var checkBox3 = document.getElementById("box3");
- if (checkBox3.checked == true)
- {
- var x = document.getElementById("odchylenie").innerHTML = odchyleniestandardowe('v');
- }
- else
- {
- var x = document.getElementById("odchylenie").innerHTML = "";
- }
- function srednia1()
- {
- var a = 0;
- for (var i = 0; i < t.length; i++)
- {
- a += t[i];
- }
- return a / t.length;
- }
- function sumka()
- {
- var b = 0;
- for (var i = 0; i < t.length; i++)
- {
- b += t[i];
- }
- return b;
- }
- function odchyleniestandardowe()
- {
- for (var i = 0; i < t.length; i++)
- {
- temp = t[i] - srd;
- xi += Math.pow(temp, 2);
- Odchylenie = Math.sqrt(xi/(n-1));
- v = Odchylenie;
- return v;
- }
- }
- setTimeout("check()",1000);
- }
- </script>
- <p id="view"></p>
- <div class="button" onclick="clean()">C</div>
- <input id="num" type="number">
- <div class="button" onclick="add()">A</div>
- Srednia: <input type = "checkbox" id = "box1">
- Suma: <input type = "checkbox" id = "box2">
- Odchylenia Standardowe: <input type = "checkbox" id = "box3">
- <p id="srednia"></p>
- <p id="suma"></p>
- <p id="odchylenie"></p>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement