From 71dba40ff9ed73dc4e78c477fbfe6a32bd980df5 Mon Sep 17 00:00:00 2001 From: dav1312 <63931154+dav1312@users.noreply.github.com> Date: Wed, 24 Jul 2024 18:51:21 +0200 Subject: [PATCH] Update StockfishCommits --- StockfishCommits/script.js | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/StockfishCommits/script.js b/StockfishCommits/script.js index 2ee3a06..7dd0ec2 100644 --- a/StockfishCommits/script.js +++ b/StockfishCommits/script.js @@ -26,11 +26,17 @@ function setSign(v) { function getPatchType(message) { const gainerRegex = /LLR:.*?[<\[\{]0/; const simplRegex = /LLR:.*?[<\[\{]-/; - if (message.includes("functional change")) { + const nonFuncionalChange = message + .split('\n') + .slice(-5) + .some(line => line.includes('functional change')); + if (nonFuncionalChange) { return "var(--bs-secondary)"; - } else if (gainerRegex.test(message)) { + } + if (gainerRegex.test(message)) { return "rgba(var(--bs-success-rgb), 1)"; - } else if (simplRegex.test(message)) { + } + if (simplRegex.test(message)) { return "var(--bs-blue)"; } return "initial"; @@ -153,21 +159,33 @@ function escapeHtml(string) { function formatCommitMessage(message) { const urlRegex = /\bhttps?:\/\/[^\s\/$.?#].[^\s]*/gi; - message = message.replace(urlRegex, '$&'); + message = message.replace(urlRegex, match => { + const link = document.createElement('a'); + link.href = encodeURI(match); + link.target = '_blank'; + link.textContent = match; + return link.outerHTML; + }); const nnueRegex = /\bnn-\w{12}\.nnue/g; - message = message.replace(nnueRegex, '$&'); + message = message.replace(nnueRegex, match => { + const link = document.createElement('a'); + link.href = encodeURI(`https://tests.stockfishchess.org/api/nn/${match}`); + link.target = '_blank'; + link.textContent = match; + return link.outerHTML; + }); - const ptnmlRegex = /Ptnml\(0-2\): (\d+), (\d+), (\d+), (\d+), (\d+)/g; + const ptnmlRegex = /Ptnml\(0-2\): (\d+), ?(\d+), ?(\d+), ?(\d+), ?(\d+)/g; message = message.replace(ptnmlRegex, (match, ll, ld, d, wd, ww) => { - const l = parseInt(ll) + parseInt(ld); - const w = parseInt(ww) + parseInt(wd); + const l = parseInt(ll) * 2 + parseInt(ld); + const w = parseInt(ww) * 2 + parseInt(wd); const elo = calcEloFromWDL(parseInt(w), parseInt(d), parseInt(l)) / 2; const sign = setSign(elo); return `${match} (Elo: ${sign + elo.toFixed(2)})`; }); - const eloRegex = /Total: \d+ W: (\d+) L: (\d+) D: (\d+)/g; + const eloRegex = /Total: \d+ W: ?(\d+) L: ?(\d+) D: ?(\d+)/g; message = message.replace(eloRegex, (match, w, l, d) => { const elo = calcEloFromWDL(parseInt(w), parseInt(d), parseInt(l)); const sign = setSign(elo);