-
Notifications
You must be signed in to change notification settings - Fork 1
/
client_FormMethods.html
51 lines (46 loc) · 1.72 KB
/
client_FormMethods.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<script>
//helps to avoid already wrong sends
function initElement(){
// Set handler for team number change
getTeamElem().oninput = onTeamNumberChanged;
// Set handler for problem number change
getProblemElem().oninput = onProblemNumberChanged;
}
function onTeamNumberChanged(){
var team = getTeamValue();
var realTeam = Math.trunc(team/10);
var sum = team % 10;
if( (Math.trunc(team/1000) + Math.trunc(team/100) + Math.trunc(team/10) + 7) % 10 == sum){
var teamnames = JSON.parse(sessionStorage.getItem("teamnames"));
if(realTeam > 0 && realTeam < (getVersionValue() + 1) ){
document.getElementById('current_team_name').innerText = teamnames[ realTeam - 1];
}
enableSubmitElem();
}else{
disableSubmitElem("Добавить");
document.getElementById("current_team_name").innerText = "Неправильный номер";
}
}
function onProblemNumberChanged(){
team = Math.trunc(getTeamValue()/10);
if(isNaN(getProblemValue())){
document.getElementById('current_problem_results').innerText = "";
return;
}
google.script.run.withSuccessHandler(OnTeamResultsFetched).getTeamResults(team, getProblemValue(), getIDValue());
}
function OnTeamResultsFetched(problem_result /* string */) {
document.getElementById('current_problem_results').innerText = problem_result;
}
function switchCommentFieldVisibility() {
button = document.getElementById('comment_button');
div = document.getElementById('comment_div');
if (div.hidden) {
div.hidden = false;
button.value = 'Скрыть коммент.';
} else {
div.hidden = true;
button.value = 'Показать коммент.';
}
}
</script>