summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichaƂ Zimniewicz <michzimny@users.noreply.github.com>2018-05-01 23:43:37 +0200
committerGitHub <noreply@github.com>2018-05-01 23:43:37 +0200
commit1deaabd8dc17dce7417f29cf0ee3b57281c8183c (patch)
tree15fedd672825cf0eaa472ced381dadeef371f8b8
parent46652656fc42df252cd8cadc82ced2f6e002bdc3 (diff)
parenteed37183c3abb9fa5a559feb3155e1ca78fe6e0d (diff)
Merge pull request #8 from emkael/master
Support PBN files not starting from Board 1
-rw-r--r--sklady/tdd.js6
-rw-r--r--tdd-bootstrap.php9
2 files changed, 12 insertions, 3 deletions
diff --git a/sklady/tdd.js b/sklady/tdd.js
index bc75356..70a8424 100644
--- a/sklady/tdd.js
+++ b/sklady/tdd.js
@@ -39,10 +39,14 @@ var TDD = {
ev.stopPropagation();
},
+ lastRefererNumber: undefined,
detectReferer: function() {
var regex = document.referrer.match(/\d+t(\d+)-\d+\.htm/);
if (regex) {
- return regex[1];
+ if (regex[1] != TDD.lastRefererNumber) {
+ TDD.lastRefererNumber = regex[1];
+ return regex[1];
+ }
}
return undefined;
},
diff --git a/tdd-bootstrap.php b/tdd-bootstrap.php
index 48b088f..bdd68b6 100644
--- a/tdd-bootstrap.php
+++ b/tdd-bootstrap.php
@@ -183,8 +183,13 @@ function load_deals_for_tables($prefix, $round, $board_in_teamy) {
$file_table = $match[1];
$file_start_board = $match[2];
- // 1 in teamy -> 1 in pbn; 24 in teamy -> 1 in pbn; 25 in teamy -> 1 in pbn
- $num_in_pbn = $board_in_teamy - $file_start_board + 1;
+ $first_num_in_pbn = array();
+ preg_match('/\[Board "(\d+)"\]/', file_get_contents($filename), $first_num_in_pbn);
+ $first_num_in_pbn = $first_num_in_pbn ? intval($first_num_in_pbn[1]) : 1;
+
+ // 1 in teamy -> 1 in pbn; 24 in teamy -> 24 in pbn; 25 in teamy -> 1 in pbn
+ // if PBN doesn't start with Board 1, it's been adjusted
+ $num_in_pbn = $board_in_teamy - $file_start_board + $first_num_in_pbn;
try {
$deal = new Deal($filename, $num_in_pbn);