-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #46 - Replace stderr with game log
- Loading branch information
1 parent
41d87c1
commit 552e4f3
Showing
10 changed files
with
201 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!doctype html> | ||
|
||
<html> | ||
<head> | ||
<title>CG Spunk match game log display</title> | ||
<link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.min.css"> | ||
<script src="../bower_components/jquery/dist/jquery.min.js"></script> | ||
<script src="../bower_components/bootstrap/dist/js/bootstrap.min.js"></script> | ||
<script src="../scripts/matchGameLogDialog.js"></script> | ||
</head> | ||
<body> | ||
|
||
<!-- Haven't implemented translation --> | ||
<div class="container"> | ||
<h1>Game log for this match</h1> | ||
|
||
<div class="row"> | ||
<div class="btn-group" data-toggle="buttons" id="selections"> | ||
<label class="btn btn-primary active"> | ||
<input type="checkbox" id="labels" autocomplete="off" checked> Labels | ||
</label> | ||
<label class="btn btn-success active" data-toggle="tooltip" title="To get stdin, log the inputs to stderr between two lines: 'IN' and '/IN'"> | ||
<input type="checkbox" id="stdin" autocomplete="off" checked> stdin | ||
</label> | ||
<label class="btn btn-danger active"> | ||
<input type="checkbox" id="stderr" autocomplete="off" checked> stderr | ||
</label> | ||
<label class="btn btn-warning active"> | ||
<input type="checkbox" id="stdout" autocomplete="off" checked> stdout | ||
</label> | ||
<label class="btn btn-info active"> | ||
<input type="checkbox" id="summary" autocomplete="off" checked> Summary | ||
</label> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<pre id="gameLog" style="background-color:white;"></pre> | ||
</div> | ||
</div> | ||
|
||
|
||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
'use strict'; | ||
|
||
var g_gameLog; | ||
|
||
$(document).ready(() => { | ||
chrome.runtime.sendMessage({ action: 'getLastGameLog' }, gameLog => { | ||
g_gameLog = gameLog; | ||
showLogData(); | ||
$('#stdin').tooltip({ trigger: 'hover' }); | ||
}); | ||
|
||
$('#selections').on('change', ':checkbox', function() { | ||
showLogData(); | ||
}); | ||
|
||
function showLogData() { | ||
let data = []; | ||
let showLabels = $('#labels').is(':checked'); | ||
let showStdin = $('#stdin').is(':checked'); | ||
let showStderr = $('#stderr').is(':checked'); | ||
let showStdout = $('#stdout').is(':checked'); | ||
let showSummary = $('#summary').is(':checked'); | ||
let agents = g_gameLog.agents; | ||
|
||
for (let t = 0; t < g_gameLog.data.length; t++) { | ||
let turn = g_gameLog.data[t]; | ||
let stderr = turn.stderr.find(_ => !!_); | ||
let stdin = getStdinFromStderr(stderr); | ||
if (showLabels) { | ||
data.push(`<span class="text-primary"> ** TURN ${t+1}</span>`); | ||
} | ||
if (showStdin && !!stdin) { | ||
data.push(`<span class="text-success">${stdin}</span>`); | ||
} | ||
if (showStderr && !!stderr) { | ||
stderr = stderr.replace(/IN\n[\s\S]*?\/IN\n/g, '').trim(); | ||
data.push(`<span class="text-danger">${stderr}</span>`); | ||
} | ||
if (showStdout) { | ||
for (let a = 0; a < agents.length; a++) { | ||
let stdout = turn.stdout[a]; | ||
if (!stdout) { | ||
continue; | ||
} | ||
if (showLabels) { | ||
data.push(`<span class="text-primary"> ** ${agents[a]}:</span>`); | ||
} | ||
data.push(`<span class="text-warning">${stdout.trim()}</span>`); | ||
} | ||
} | ||
if (showSummary && !!turn.summary) { | ||
let summary = turn.summary.replace(/\$(\d)/g, (grp, idx) => { | ||
return agents[idx]; | ||
}).trim(); | ||
data.push(`<span class="text-info">${summary}</span>`); | ||
} | ||
} | ||
|
||
$('#gameLog').html(data.join('\n')); | ||
} | ||
|
||
function getStdinFromStderr(stderr) { | ||
if (!stderr) { | ||
return null; | ||
} | ||
let stdin = stderr.match(/IN\n[\s\S]*?\/IN\n/g); | ||
if (!!stdin) { | ||
stdin = stdin.map(_ => _.match(/IN\n([\s\S]*)\/IN\n/)[1]).join(''); | ||
} | ||
return stdin.trim(); | ||
} | ||
}); |
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters