Skip to content

Commit

Permalink
deletion added;
Browse files Browse the repository at this point in the history
changeview enabled;
cosmetic changes in headers and other text fields
  • Loading branch information
UltimateHikari committed Nov 28, 2018
1 parent 3b3d3e1 commit 6a8812d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
23 changes: 18 additions & 5 deletions client_Core.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

function handleLogin(){
applyJudgeName();
//changeView("backform","mainlayer"); // disabled now for comfortable debug
changeView("backform","mainlayer"); // disabled now for comfortable debug
}

function applyJudgeName(){
Expand Down Expand Up @@ -78,7 +78,7 @@
}
resetInput();
formToken();
pushServerResponse(resp.formLink,resp.team,resp.problem,resp.result,resp.serverResponse);
pushServerResponse(resp.formLink,resp.team,resp.problem,resp.result,resp.serverResponse,resp.token);
}

function resetInput(){
Expand All @@ -88,15 +88,28 @@
document.getElementById("bad_radio").checked = false;
}

function pushServerResponse(link,a,b,c,d){
function pushServerResponse(link,a,b,c,d,token){
//push data to special structure
//var TeamNames = JSON.parse(sessionStorage.getItem("myKey"));
// instead of a - TeamNames[a - 1]
var teamnames = JSON.parse(sessionStorage.getItem("teamnames"));
document.getElementById("log"+link).innerText = teamnames[a-1] +
" (" + a + ") " + "; " + b + "; " + c + "; " + d + " ";
document.getElementById("log" + link).innerHTML = teamnames[a-1] +
" (" + a + ") " + "; " + b + "; " + c + "; " + d + "; " +
"<a id='del" + link + "'> Удалить </a>";
document.getElementById("del" + link).onclick = function () { var res = confirm('Подтведите удаление'); handleDelete(res, token,link); };

}

function handleDelete(res, token, link){
if(res){
google.script.run.withFailureHandler(handleError).withSuccessHandler(deleteSuccess).deleteForm(token,link, getIDValue());
}
}

function deleteSuccess(link){
document.getElementById("del"+link).innerText = "Удалено";
document.getElementById("del"+link).onclick = null;
}


/**
Expand Down
6 changes: 3 additions & 3 deletions client_Page.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<!--login "page"-->
<div class="mui-container-fluid" align="left">

<h1 id="header" class="headclass"></h1>
<h1 id="header" class="headclass">Загрузка...</h1>

<form сlass="mui-form" id="backform" onsubmit="handleLogin(); return false;" autocomplete="off">
<input hidden="true" id="version" value="none">
Expand Down Expand Up @@ -43,7 +43,7 @@ <h1 id="header" class="headclass"></h1>

</div>

<div id="mainlayer">
<div id="mainlayer" hidden="true">
<div class="mui-container-fluid" align="left">
<!--customizable form parts here-->
<?!= include('module_form'); ?>
Expand All @@ -52,7 +52,7 @@ <h1 id="header" class="headclass"></h1>
<div class="mui-row">
<div class="mui-col-md-4">
<div align="center">
<p> Имя; задача; результат; ответ сервера</p>
<p> Имя; задача; результат; статус; ссылка на удаление</p>
<ol reversed id="logslist">
</ol>
</div>
Expand Down
20 changes: 20 additions & 0 deletions server_Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,24 @@ function SaveRes(message){
];
//ends
sheet.appendRow(pack);
}

function deleteForm(token, link, id){
var modelSheet = GetSheet(RAW,id);
var modelSize = modelSheet.getRange(C_X, C_Y).getValue();
var modelRange = modelSheet.getRange(MODEL_START, 1, modelSize);
var modelData = modelRange.getValues();
for(i in modelData){
try{
var item = JSON.parse(modelData[i][0]);
if(item.token == token){
modelData[i][0] = "";
modelRange.setValues(modelData);
return link;
}
} catch(err){
continue;
}
}
throw "Не удалено";
}

0 comments on commit 6a8812d

Please sign in to comment.