Пояснительная записка (1231610), страница 8
Текст из файла (страница 8)
<script type = "text/javascript" src = "//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<link rel = "stylesheet" type = "text/css" href = "css/table.css">
<link rel = "stylesheet" type = "text/css" href = "css/setting.css">
</head>
<body>
<div id = "scriptLoad"><script type = "text/javascript" src = "js/loadLogFromFilePCMS2.js"></script></div>
<div id = "setting">
<table class = "tableSetting">
<thead class = "tableSettingHead">
<tr>
<td colspan = "2">Настройки</td>
</tr>
</thead>
<tbody class = "tableSettingBody">
<tr>
<td>Формат лога</td>
<td>
<input type = "radio" name = "scriptLoad" id = "loadPCMS2" onchange = "setScriptLoad( 'js/loadLogFromFilePCMS2.js' );" checked>PCMS2</input>
<br>
<input type = "radio" name = "scriptLoad" id = "loadCats" onchange = "setScriptLoad( 'js/loadLogFromFileCATS+.js' );" >CATS+</input>
</td>
</tr>
<tr>
<td>Загрузить лог с компьютера</td>
<td>
<input type = "file" id = "fileLog"> </input>
<br>
<input type = "button" id = "loadLogFromUser" onclick = "loadLogFromUser();" value = "Загрузить"> </input>
</td>
</tr>
<tr>
<td>Загрузить лог с сервера</td>
<td>
<?php include "php/logs.php"; ?>
<br>
<input type = "button" id = "loadLogFromServer" onclick = "loadLogFromServer();" value = "Загрузить"> </input>
</td>
</tr>
<tr>
<td>Время заморозки</td>
<td>
<input type = "time" id = "freezeTime" onchange = "setFreezeTime();" value = "04:00" min = "00:00" max = "06:00"> </input>
<br>
<input type = "button" id = "goFreezeTime" onclick = "goFreezeTime();" value = "Перейти на момент заморозки"></input>
<br>
<input type = "button" id = "goStart" onclick = "goStart();" value = "Перейти на начало"></input>
</td>
</tr>
<tr>
<td>Скорость</td>
<td>
<input type = "range" id = "speed" onchange = "setSpeed();" min = "-2000" max = "-5" value = "-500"></input>
</td>
</tr>
<tr>
<td>Порядок разморозки</td>
<td>
<input type = "radio" name = "modeOrder" id = "modeOrderSuccessively" checked>Последовательно</input>
<br>
<input type = "radio" name = "modeOrder" id = "modeOrderChronology">Хронологически</input>
</td>
</tr>
<tr>
<td>Режим разморозки</td>
<td>
<input type = "radio" name = "modeStep" id = "modeStepOn" onchange = "setModeStep();" checked>Пошаговый</input>
<br>
<input type = "radio" name = "modeStep" id = "modeStepOff" onchange = "setModeStep();" >Автоматический</input>
</td>
</tr>
<tr>
<td>Дополнительные настройки</td>
<td>
<input type = "checkbox" id = "showTime" onchange = "setShowTime();" checked>Показывать время</input>
<br>
<input type = "checkbox" id = "showSubmit" onchange = "setShowSubmit();">Показывать посылки</input>
<br>
<input type = "checkbox" id = "showAllSubmit">Только последняя посылка</input>
</td>
</tr>
</tbody>
</table>
</div>
<div>
<input type = "button" id = "buttonSetting" onclick = "hideSetting();" class = "buttonStyle"></input>
<input type = "button" id = "buttonStep" onclick = "doStep();" class = "buttonStyle"></input>
</div>
<div id = "printTable"></div>
</body>
</html>
Листинг А.2 – Файл setting.css
.buttonStyle {
height: 50px;
width: 50px;
display: inline-block;
color: black;
font-size: 125%;
font-weight: 700;
text-decoration: none;
user-select: none;
padding: .25em .5em;
outline: none;
border: 1px solid rgb(250,172,17);
border-radius: 25px;
background: rgb(255,212,3) linear-gradient(rgb(255,212,3), rgb(248,157,23));
box-shadow: inset 0 -2px 1px rgba(0,0,0,0), inset 0 1px 2px rgba(0,0,0,0), inset 0 0 0 60px rgba(255,255,0,0);
transition: box-shadow .2s, border-color .2s;
}
.buttonStyle:hover {
box-shadow: inset 0 -1px 1px rgba(0,0,0,0), inset 0 1px 2px rgba(0,0,0,0), inset 0 0 0 60px rgba(255,255,0,.5);
}
.buttonStyle:active {
padding: calc(.25em + 1px) .5em calc(.25em - 1px);
border-color: rgba(177,159,0,1);
box-shadow: inset 0 -1px 1px rgba(0,0,0,.1), inset 0 1px 2px rgba(0,0,0,.3), inset 0 0 0 60px rgba(255,255,0,.45);
}
.tableSetting {
margin: 25px;
}
.tableSetting input, .tableSetting select {
font-family: "Comic Sans MS";
}
.tableSettingHead td {
font-family: "Comic Sans MS";
font-size: 20px;
text-align: center;
background-color: #FFFFFF;
border-radius: 10px;
padding: 10px;
}
.tableSettingBody td {
font-family: "Comic Sans MS";
background-color: #BDBDBD;
border-radius: 10px;
padding: 10px;
}
#buttonSetting {
position: fixed;
top: 10px; left: 10px;
}
#buttonStep {
position: fixed;
top: 70px;
left: 10px;
}
#setting {
background-color: #424242;
position: fixed;
left: 70px;
border-radius: 10px;
}
#table {
margin-left: 60px;
}
Листинг А.3 – Файл table.css
.tdAccepted, .tdReject, .tdSubmit, .tdFirstAccepted, .tdNewSubmit,
.tdNull, .tdHeadSqr, .tdHead, .tdStatistic, .tdBody1, .tdBody2, .tdTeamSubmit {
color: #FFFFFF;
font-family: "Comic Sans MS";
text-align: center;
border-radius: 10px;
height: 50px;
}
.tdAccepted, .tdReject, .tdSubmit, .tdFirstAccepted, .tdNewSubmit, .tdNull, .tdHeadSqr {
width: 50px;
}
.tdAccepted {
background-color: #32CD32;
}
.tdReject {
background-color: #DD0000;
}
.tdSubmit {
background-color: #0000DD;
}
.tdFirstAccepted {
background-color: #316404;
}
.tdNewSubmit {
background-color: #0000DD;
-webkit-animation-name: flashing;
-webkit-animation-duration: 1s;
animation: infinite;
animation-name: flashing;
animation-duration: 1s;
}
@keyframes flashing {
0% { background-color: #0000DD; }
50% { background-color: orange; }
}
.tdNull {
background-color: #E0E0E0;
}
.tdHeadSqr {
background-color: #000000;
font-size: 20px;
}
.tdHead {
background-color: #000000;
font-size: 20px;
}
.tdStatistic {
background-color: #000000;
}
.tdBody1 {
background-color: #606060;
}
.tdBody2 {
background-color: #A0A0A0;
}
.tdTeamSubmit {
background-color: orange;
}
.tdSeparator {
background-color: #000000;
height: 6px;
border-radius: 10px;
}
.table {
border: 2px solid black;
border-spacing: 2px;
border-radius: 10px;
}
Листинг А.4 – Файл class StringWithIndex.js
function StringWithIndex( text ) {
this.text = text;
this.index = 0;
}
StringWithIndex.prototype.getNextTagValue = function( tag ) {
var left = this.text.indexOf( "<" + tag + ">", this.index ) + 2 + tag.length;
var right = this.text.indexOf("</" +tag+ ">", this.index);
if( left == -1 || right == -1 )
return;
this.index = right + 3 + tag.length;
return this.text.slice( left, right );
}
StringWithIndex.prototype.getTagValue = function( tag ) {
var index = this.index;
var text = this.getNextTagValue( tag );
this.index = index;
if( text == null )
return;
return text;
}
StringWithIndex.prototype.getTagText = function( tag ) {
var text = this.getTagValue( tag );
if( text == null )
return;
return new StringWithIndex( text );
}
StringWithIndex.prototype.getNextTagText = function( tag ) {
var text = this.getNextTagValue( tag );
if( text == null )
return;
return new StringWithIndex( text );
}
StringWithIndex.prototype.nextTagText = function() {
var left = this.text.indexOf( "<", this.index );
var right = this.text.indexOf( ">", this.index );
if( left == -1 || right == -1 )
return;
this.index = right + 1;
return new StringWithIndex(this.text.slice(left, right+1));
}
function checkSymbol( sym ) {
var symbol = [ '<', '>', ' ' ];
for( var i = 0; i < symbol.length; i ++ ) {
if( sym == symbol[i] ) {
return true;
}
}
return false;
}
StringWithIndex.prototype.getTagName = function() {
var i = 0;
while( i < this.text.length && checkSymbol(this.text[i])) {
i ++;
}
var res = "";
while(i < this.text.length && !checkSymbol(this.text[i])) {
res += this.text[i];
i ++;
}
return res;
}
StringWithIndex.prototype.getParamsValue = function( key ) {
var start = this.text.indexOf( key, this.index );
if( start == -1 )
return;
var left = this.text.indexOf( "\"", start );
var right = this.text.indexOf( "\"", left + 1 );
if( left == -1 || right == -1 )
return;
return this.text.slice( left + 1, right );
}
Листинг А.5 – Файл loadLogFromFileCATS+.js
function loadLogFromFile( text, teams, problems, submits ) {
var log = new StringWithIndex( text );
getTeamsFromFile( teams, log.getTagText( "teams" ) );
getProblemsFromFile(problems, log.getTagText("problems"));
getSubmitsFromFile( submits, log.getTagText( "reqs" ) );
}
function getTeamsFromFile( teams, log ) {
if( log == null )
return;
while( true ) {
var team = log.getNextTagText( "team" );
if( team == null )
break;
var id = parseInt( team.getTagValue( "id" ) );
var name = team.getTagValue( "name" );
teams.push( new Team( id, name ) );
}
}
function getProblemsFromFile( problems, log ) {
if( log == null )
return;
while( true ) {
var problem = log.getNextTagText( "problem" );
if( problem == null )
break;
var code = problem.getTagValue( "code" );
problems.push( new Problem( code ) );
}
}
function getSubmitsFromFile( submits, log ) {
if( log == null )
return;
while( true ) {
var submit = log.getNextTagText( "req" );
if( submit == null )
break;
var time = 86400 * Number( submit.getTagValue( "time_since_start" ) );
var teamId = parseInt( submit.getTagValue("team_id") );
var problem = submit.getTagValue( "code" );
var state = submit.getTagValue( "state" );
var test = parseInt(submit.getTagValue("failed_test") );
submits.push( new Submit( time, teamId, problem, state, test ) );
}
}
Листинг А.6 – Файл loadLogFromFilePCMS2.js
function loadLogFromFile( text, teams, problems, submits ) {
var log = new StringWithIndex( text );