]> git.sesse.net Git - remoteglot/commitdiff
Make engine URL, move source and similar values dynamic instead of hard-coding them...
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 28 Jun 2015 00:10:55 +0000 (02:10 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 28 Jun 2015 00:11:11 +0000 (02:11 +0200)
Also change 'id' to 'engine' in a long-standing cleanup, and remove the unused author information.

config.pm
remoteglot.pl
www/css/remoteglot.css
www/index.html
www/js/remoteglot.js

index 3a57206699b88baefe47dcbd8d30ec672af10b15..77fa74e1a094762ad805c732b7bb0a88d581df65 100644 (file)
--- a/config.pm
+++ b/config.pm
@@ -66,6 +66,12 @@ our @masters = (
 # you probably need specific prior permission to use this.
 our $tb_serial_key = undef;
 
+# Credits to show in the footer.
+our $engine_url = "http://www.stockfishchess.org/";
+our $engine_details = undef;  # For hardware.
+our $move_source = "FICS";
+our $move_source_url = "http://www.freechess.org/";
+
 # Postgres configuration.
 our $dbistr = "dbi:Pg:dbname=remoteglot";
 our $dbiuser = undef;
index 5a5d4c556ad4d6607111f12a8012ed79cf37eccc..d4a0d73183a2388c5f8930e922680cc3e80fedaf 100755 (executable)
@@ -482,10 +482,9 @@ sub parse_ids {
        my ($engine, @x) = @_;
 
        while (scalar @x > 0) {
-               if ($x[0] =~ /^(name|author)$/) {
-                       my $key = shift @x;
+               if ($x[0] eq 'name') {
                        my $value = join(' ', @x);
-                       $engine->{'id'}{$key} = $value;
+                       $engine->{'id'}{'author'} = $value;
                        last;
                }
 
@@ -738,10 +737,23 @@ sub output_json {
 
        my $json = {};
        $json->{'position'} = $pos_calculating->to_json_hash();
-       $json->{'id'} = $engine->{'id'};
+       $json->{'engine'} = $engine->{'id'};
+       if (defined($remoteglotconf::engine_url)) {
+               $json->{'engine'}{'url'} = $remoteglotconf::engine_url;
+       }
+       if (defined($remoteglotconf::engine_details)) {
+               $json->{'engine'}{'details'} = $remoteglotconf::engine_details;
+       }
+       if (defined($remoteglotconf::move_source)) {
+               $json->{'move_source'} = $remoteglotconf::move_source;
+       }
+       if (defined($remoteglotconf::move_source_url)) {
+               $json->{'move_source_url'} = $remoteglotconf::move_source_url;
+       }
        $json->{'score'} = long_score($info, $pos_calculating, '');
        $json->{'short_score'} = short_score($info, $pos_calculating, '');
        $json->{'plot_score'} = plot_score($info, $pos_calculating, '');
+       $json->{'using_lomonosov'} = defined($remoteglotconf::tb_serial_key);
 
        $json->{'nodes'} = $info->{'nodes'};
        $json->{'nps'} = $info->{'nps'};
@@ -875,7 +887,7 @@ sub output_json {
                my $new_depth = $json->{'depth'} // 0;
                my $new_nodes = $json->{'nodes'} // 0;
                if (!defined($old_engine) ||
-                   $old_engine ne $json->{'id'}{'name'} ||
+                   $old_engine ne $json->{'engine'}{'name'} ||
                    $new_depth > $old_depth ||
                    ($new_depth == $old_depth && $new_nodes >= $old_nodes)) {
                        atomic_set_contents($filename, $encoded);
@@ -884,7 +896,7 @@ sub output_json {
                                $dbh->do('DELETE FROM scores WHERE id=?', undef, $id);
                                $dbh->do('INSERT INTO scores (id, plot_score, short_score, engine, depth, nodes) VALUES (?,?,?,?,?,?)', undef,
                                        $id, $json->{'plot_score'}, $json->{'short_score'},
-                                       $json->{'id'}{'name'}, $new_depth, $new_nodes);
+                                       $json->{'engine'}{'name'}, $new_depth, $new_nodes);
                                $dbh->commit;
                        }
                }
index 21a3a85661385007cf45d1ac58f0b08cdc985ab4..09b6b089cee4884d7bbcff3eab857d37c4efafd4 100644 (file)
@@ -178,6 +178,9 @@ a.move:hover {
 #linenav {
        display: none;
 }
+#lomonosov {
+       display: none;
+}
 
 #games {
        font-size: smaller;
index 3c1eb85f870c7c57fe0b7680d542f3ba4ba8d43a..72b017ef47aacfaa42633aa355b9f35cc785f2ce 100644 (file)
 </ul>
 <p id="credits"><a href="http://git.sesse.net/?p=remoteglot;a=summary">remoteglot</a>
   &copy; 2007&ndash;2015 <a href="http://www.sesse.net/">Steinar H. Gunderson</a>.
-  Chess analysis by <a href="http://stockfishchess.org/" id="engineid">Stockfish</a> (main analysis: 20x2.3GHz Haswell-EP,
-  multi-PV search: 16x2.4GHz Haswell-EP).
-  Moves provided by <a href="http://live.fide.com/sochi/">FIDE</a>.
-  Hosting and multi-PV analysis hardware by <a href="http://www.samfundet.no/">Studentersamfundet i Trondhjem</a>.
+  Chess analysis by <a href="http://stockfishchess.org/" id="engineid">Stockfish</a><span id="enginedetails"></span>.
+  <span id="movesource"></span>
+  Hosting and additional analysis hardware by <a href="http://www.samfundet.no/">Studentersamfundet i Trondhjem</a>.
   JavaScript chessboard powered by <a href="http://chessboardjs.com/">chessboard.js</a>
   and <a href="https://github.com/jhlywa/chess.js">chess.js</a>.
   Ding sound by <a href="https://www.freesound.org/people/Aiwha/sounds/196106/">Aiwha</a> (CC-BY-3.0).
-  7-man Lomonosov tablebase lookup by <a href="http://tb7.chessok.com/">ChessOK</a>.</p>
+  <span id="lomonosov">7-man Lomonosov tablebase lookup by <a href="http://tb7.chessok.com/">ChessOK</a>.</span></p>
 
 <!-- For faster development -->
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
index 0462252af64610ab297d8c5e5a6221954c469b34..673fd12eacb0e3cf9a2e7b4b5c8b4f330d81a389 100644 (file)
@@ -771,6 +771,50 @@ var update_board = function(current_data, display_data) {
                headline = 'Analysis';
        }
 
+       // Credits, where applicable. Note that we don't want the footer to change a lot
+       // when e.g. viewing history, so if any of these changed during the game,
+       // use the current one still.
+       if (current_data['using_lomonosov']) {
+               $("#lomonosov").show();
+       } else {
+               $("#lomonosov").hide();
+       }
+
+       // Credits: The engine name/version.
+       if (current_data['engine'] && current_data['engine']['name'] !== null) {
+               $("#engineid").text(current_data['engine']['name']);
+       }
+
+       // Credits: The engine URL.
+       if (current_data['engine'] && current_data['engine']['url']) {
+               $("#engineid").attr("href", current_data['engine']['url']);
+       } else {
+               $("#engineid").removeAttr("href");
+       }
+
+       // Credits: Engine details.
+       if (current_data['engine'] && current_data['engine']['details']) {
+               $("#enginedetails").text(" (" + current_data['engine']['details'] + ")");
+       } else {
+               $("#enginedetails").text("");
+       }
+
+       // Credits: Move source, possibly with URL.
+       if (current_data['move_source'] && current_data['move_source_url']) {
+               $("#movesource").text("Moves provided by ");
+               var movesource_a = document.createElement("a");
+               movesource_a.setAttribute("href", current_data['move_source_url']);
+               var movesource_text = document.createTextNode(current_data['move_source']);
+               movesource_a.appendChild(movesource_text);
+               var movesource_period = document.createTextNode(".");
+               document.getElementById("movesource").appendChild(movesource_a);
+               document.getElementById("movesource").appendChild(movesource_period);
+       } else if (current_data['move_source']) {
+               $("#movesource").text("Moves provided by " + current_data['move_source'] + ".");
+       } else {
+               $("#movesource").text("");
+       }
+
        var last_move;
        if (display_data) {
                // Displaying some non-current position, pick out the last move
@@ -839,11 +883,6 @@ var update_board = function(current_data, display_data) {
 
        update_clock();
 
-       // The engine id.
-       if (data['id'] && data['id']['name'] !== null) {
-               $("#engineid").text(data['id']['name']);
-       }
-
        // The score.
        if (data['score'] !== null) {
                $("#score").text(data['score']);