Skip to content
Permalink
Browse files

action log viewer

  • Loading branch information...
Manuel-777 committed May 10, 2019
1 parent 27ddb6c commit c734baf289a831481e14092d90acfd9fa2d8ceb8
@@ -811,4 +811,58 @@ span {
/*when navigating through the items using the arrow keys:*/
background-color: DodgerBlue !important;
color: #ffffff;
}

.actionlog {
text-shadow: 2px 2px 2px rgb(0, 0, 0);
white-space: nowrap;
overflow: hidden;
height: 24px;
line-height: 24px;
width: 100%;
display: flex;
font-size: 14px;
background: linear-gradient(to right, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0));
}

.log_p1 {
color: rgba(255, 200, 200, 1);
}

.log_p2 {
color: rgba(200, 200, 255, 1);
}

.log_p-1 {
color: rgba(255, 255, 255, 0.9);
font-weight: bold;
}

.actionlog_time {
margin-left: 8px;
color: rgba(255, 255, 255, 0.8);
}

.actionlog_text {
margin-left: 8px;
}

.action_log_container {
margin: 0 auto;
max-width: 600px;
}

.action_log_container .actionlog {
background-color: rgba(0, 0, 0, 0.3);
}

log-card {
text-decoration: none;
font-weight: bold;
cursor: pointer;
text-decoration: underline;
}
log-ability {
text-decoration: underline !important;
cursor: pointer;
}
@@ -376,6 +376,28 @@ function openDeck(deck, deck_type) {
});
}

function openActionLog(actionLog) {
actionLog.sort(compare_logs);

actionLog.forEach(function(log) {
log.str = striptags(log.str, ["log-card", "log-ability"]);
var d = new Date(log.time);
var hh = ("0" + d.getHours()).slice(-2);
var mm = ("0" + d.getMinutes()).slice(-2);
var ss = ("0" + d.getSeconds()).slice(-2);

var box = $('<div class="actionlog log_p' + log.seat + '"></div>');
var time = $(
'<div class="actionlog_time">' + hh + ":" + mm + ":" + ss + "</div>"
);
var str = $('<div class="actionlog_text">' + log.str + "</div>");

box.append(time);
box.append(str);
deckListDiv.append(box);
});
}

module.exports = {
open_deck: openDeck
};
@@ -425,7 +425,7 @@ span.top_nav_item_text {
.moving_ux {
position: relative;
display: flex;
width: calc(200%);
width: calc(300%);
height: 100%;
-webkit-transition: left .1s ease-in-out-expo;
}
@@ -80,6 +80,9 @@

<div class="ux_item" id="ux_1">
</div>

<div class="ux_item" id="ux_2">
</div>
</div>
</div>

@@ -49,6 +49,7 @@ const Menu = remote.Menu;
const MenuItem = remote.MenuItem;

require("time-elements");
const striptags = require("striptags");

const FilterPanel = require("./FilterPanel.js");
const StatsPanel = require("./StatsPanel.js");
@@ -2062,7 +2063,7 @@ function open_match(id) {
}

$(".openLog").click(function() {
shell.openItem(path.join(actionLogDir, id + ".txt"));
openActionLog(id, $("#ux_1"));
});

$(".exportDeckPlayer").click(function() {
@@ -2092,6 +2093,54 @@ function open_match(id) {
});
}

function openActionLog(actionLogId) {
$("#ux_2").html("");
let top = $(
`<div class="decklist_top"><div class="button back actionlog_back"></div><div class="deck_name">Action Log</div><div class="deck_name"></div></div>`
);

let actionLogContainer = $(`<div class="action_log_container"></div>`);

let actionLogFile = path.join(actionLogDir, actionLogId + ".txt");
let str = fs.readFileSync(actionLogFile).toString();

let actionLog = str.split("\n");
for (let line = 1; line < actionLog.length; line += 3) {
let seat = actionLog[line];
let time = actionLog[line + 1];
let str = actionLog[line + 2];
str = striptags(str, ["log-card", "log-ability"]);

var boxDiv = $('<div class="actionlog log_p' + seat + '"></div>');
var timeDiv = $('<div class="actionlog_time">' + time + "</div>");
var strDiv = $('<div class="actionlog_text">' + str + "</div>");

boxDiv.append(timeDiv);
boxDiv.append(strDiv);
actionLogContainer.append(boxDiv);
}

$("#ux_2").append(top);
$("#ux_2").append(actionLogContainer);

$$("log-card").forEach(obj => {
let grpId = obj.getAttribute("id");
addCardHover(obj, cardsDb.get(grpId));
});

$$("log-ability").forEach(obj => {
let grpId = obj.getAttribute("id");
let abilityText = cardsDb.getAbility(grpId);
obj.title = abilityText;
});

$(".moving_ux").animate({ left: "-200%" }, 250, "easeInOutCubic");

$(".actionlog_back").click(() => {
$(".moving_ux").animate({ left: "-100%" }, 250, "easeInOutCubic");
});
}

//
function toggleVisibility(...ids) {
ids.forEach(id => {
@@ -278,48 +278,3 @@ body {
display: inline-block;
background: center no-repeat url("../images/quantity_orange.png");
}

.actionlog {
text-shadow: 2px 2px 2px rgb(0, 0, 0);
white-space: nowrap;
overflow: hidden;
height: 24px;
line-height: 24px;
width: 100%;
display: flex;
font-size: 14px;
background: linear-gradient(to right, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0));
}

.log_p1 {
color: rgba(255, 200, 200, 1);
}

.log_p2 {
color: rgba(200, 200, 255, 1);
}

.log_p-1 {
color: rgba(255, 255, 255, 0.9);
font-weight: bold;
}

.actionlog_time {
margin-left: 8px;
color: rgba(255, 255, 255, 0.8);
}

.actionlog_text {
margin-left: 8px;
}

log-card {
text-decoration: none;
font-weight: bold;
cursor: pointer;
text-decoration: underline;
}
log-ability {
text-decoration: underline !important;
cursor: pointer;
}
@@ -754,12 +754,6 @@ function setDraft(_packN = -1, _pickN = -1) {
}
}

function compare_logs(a, b) {
if (a.time < b.time) return -1;
if (a.time > b.time) return 1;
return 0;
}

function compare_draft_picks(a, b) {
var arank = cardsDb.get(a).rank;
var brank = cardsDb.get(b).rank;

0 comments on commit c734baf

Please sign in to comment.
You can’t perform that action at this time.