hta_apps/CalcAverageScore.hta

161 lines
5.3 KiB
HTML
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!--
-- Калькулятор среднего балла
-- Author: Alexander Popov
-- License: Public Domain
-- Version: 1.0
-- History: see EOF.
-->
<html>
<head>
<HTA:APPLICATION
applicationName="Калькулятор среднего балла"
version="1.0"
maximizeButton="no"
border="dialog"
innerBorder="no"
scroll="no"
singleInstance="yes"
contextMenu="no"
/>
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta charset="utf-8">
<title>Калькулятор среднего балла</title>
<script type="text/javascript">
window.onload = function() {
var w = 340; // Ширина окна
var h = 310; // Высота окна
// Изменение размера окна и размещение по центру
window.resizeTo(w, h);
window.moveTo((window.screen.width - w) / 2, (window.screen.height - h) / 2);
}
/**
* Функция для подсчёта результата среднего балла
*
* Вызывается каждый раз при изменении значения
*/
function calc() {
// Количество проверенных человек, число на колотое делится сумму баллов
var checked = parseInt(document.getElementById('checked').value);
// Элемент для отображения результата
var result = document.getElementById('result');
// Подсчёт баллов
var n5 = parseInt(document.getElementById('5').value);
var n4 = parseInt(document.getElementById('4').value);
var n3 = parseInt(document.getElementById('3').value);
var n2 = parseInt(document.getElementById('2').value);
var total = (((n5 * 5) + (n4 * 4) + (n3 * 3) + (n2 * 2)) / checked).toFixed(2);
// Подсчёт среднего балла
if ((n5 + n4 + n3 + n2) != checked) {
result.value = 'Ошибка суммы значений';
}
else {
if (total >= 4.6) {
result.value = total + ' Отлично';
}
else if (total >= 3.6) {
result.value = total + ' Хорошо';
}
else if (total >= 2.6) {
result.value = total + ' Удовлетворительно';
}
else {
result.value = total + ' Неудовлетворительно';
}
}
}
</script>
<style>
* { margin: 0; padding: 0; }
body { font-family: 'Segoe UI'; font-size: 14px; }
p.hero {
background-color: #000; color: #fff;
font-weight: bold; text-align: center;
padding: 8px; margin-bottom: 8px;
}
div.footer {
margin-top: 8px; padding: 8px;
background-color: #000; color: #fff;
font-weight: bold;
}
div.line { margin: 8px; }
p.line-title {
display: inline-block; width: 165px;
font-weight: bold;
margin-right: 8px;
}
p.line-total {
font-weight: bold;
display: inline-block; width: 48px;
margin-right: 8px;
}
input {
border: 1px solid #000;
font-family: 'Segoe UI'; font-size: 14px;
width: 110px;
padding: 0 8px;
}
input:focus {
background-color: #7f0000; color: #fff;
border-color: #ff0;
}
input.input-total {
width: 240px;
padding: 0 8px;
background-color: #444; color: #fff;
}
.text-right { text-align: right; }
</style>
</head>
<body>
<p class="hero">Калькулятор среднего балла</p>
<div class="line text-right">
<p class="line-title">Всего личного состава:</p>
<input id="total" type="text" onchange="calc();" value="1">
</div>
<div class="line text-right">
<p class="line-title">Всего проверено л/с:</p>
<input id="checked" type="text" onchange="calc();" value="1">
</div>
<div class="line text-right">
<p class="line-title">Оценок «5»:</p>
<input id="5" type="text" onchange="calc();" value="1">
</div>
<div class="line text-right">
<p class="line-title">Оценок «4»:</p>
<input id="4" type="text" onchange="calc();" value="0">
</div>
<div class="line text-right">
<p class="line-title">Оценок «3»:</p>
<input id="3" type="text" onchange="calc();" value="0">
</div>
<div class="line text-right">
<p class="line-title">Оценок «2»:</p>
<input id="2" type="text" onchange="calc();" value="0">
</div>
<div class="line">
<p class="line-total">Итого:</p>
<input id="result" class="input-total" type="text" value="Измените значения">
</div>
<div class="footer">
<p>Version: 1.0 || by iiiypuk</p>
</div>
</body>
</html>
<!--
VERSION 1.0
- Init version
-->