How to post chess games

General discussion about computer chess...
pgn4web
Posts: 97
Joined: Mon Jun 14, 2010 10:26 pm

Re: How to post chess games

Post by pgn4web » Sun May 08, 2011 6:26 pm

Jeremy Bernstein wrote:Thanks, I saw, and will (try to) merge those changes in at some point (the code bases are divergent enough [in places] at this point to make merging non-trivial -- I need to find the time and patience to deal with it...).
definitely drop me a note before starting, so that I can finish off anything that might be pending.
Jeremy Bernstein wrote:Btw, I just added some code to handle auto-scrolling of the move list (so that the move list follows the move on the board), which works well in every browser I've tested. Might be worth integrating into the trunk.
excellent idea. I looked at your code though I dont think that code belongs to the main js file since you are making assumptions on the placement of the moves in the page; for instance some page might not have a "headerMoves" container as defined in board.html

I still need to test with Internet Explorer (it's always a pain) but I think I will add this code, derived from yours, in the board.html file:

Code: Select all

function customFunctionOnMove() {
  if (theContainerObject = document.getElementById("headerMoves")) {
    if (CurrentPly === 0) { theContainerObject.scrollTop = 0; }
    else if (theMoveObject = document.getElementById('Mv' + CurrentPly)) {
      if (theMoveObject.offsetTop + theMoveObject.offsetHeight > theContainerObject.scrollTop + theContainerObject.offsetHeight) {
        theContainerObject.scrollTop = theMoveObject.offsetTop + theMoveObject.offsetHeight - theContainerObject.offsetHeight;
      } else if (theMoveObject.offsetTop < theContainerObject.scrollTop) {
        theContainerObject.scrollTop = theMoveObject.offsetTop;
      }
    }
  }
}

pgn4web
Posts: 97
Joined: Mon Jun 14, 2010 10:26 pm

Re: How to post chess games

Post by pgn4web » Sun May 08, 2011 7:02 pm

on second thoughts, depending on the effect you want to achieve, this might work better, especially with comments and variations after each move:

Code: Select all

function customFunctionOnMove() {
  if (theContainerObject = document.getElementById("headerMoves")) {
    if (CurrentPly === 0) { theContainerObject.scrollTop = 0; }
    else if (theMoveObject = document.getElementById('Mv' + CurrentPly)) {
      if (theMoveObject.offsetTop + theMoveObject.offsetHeight > theContainerObject.scrollTop + theContainerObject.offsetHeight) {
        theContainerObject.scrollTop = theMoveObject.offsetTop;
        // theContainerObject.scrollTop = theMoveObject.offsetTop + theMoveObject.offsetHeight - theContainerObject.offsetHeight;
      } else if (theMoveObject.offsetTop < theContainerObject.scrollTop) {
        theContainerObject.scrollTop = theMoveObject.offsetTop;
      }
    }
  }
}

pgn4web
Posts: 97
Joined: Mon Jun 14, 2010 10:26 pm

Re: How to post chess games

Post by pgn4web » Tue May 10, 2011 1:37 pm

pgn4web wrote:on second thoughts, depending on the effect you want to achieve, this might work better, especially with comments and variations after each move...
actually MUCH harder to do that I initially thought. Look what happens with the open-chess code to this game:
http://tinyurl.com/42tfrxd

I managed in the end to modify the auto-scroll code like to get this:
http://tinyurl.com/3pzp6b2

Not yet perfect, still some snags with IE7

Code: Select all

function objectOffsetVeryTop(object) {
  for (offset = object.offsetTop; object = object.offsetParent; offset += object.offsetTop) {}
  return offset;
}

function customFunctionOnMove() {
  if (theContainerObject = document.getElementById("headerMoves")) {
    if (CurrentPly == StartPly) { theContainerObject.scrollTop = 0; }
    else if (theMoveObject = document.getElementById('Mv' + CurrentPly)) {
      theContainerObjectOffsetVeryTop = objectOffsetVeryTop(theContainerObject);
      theMoveObjectOffsetVeryTop = objectOffsetVeryTop(theMoveObject);
      if ((theMoveObjectOffsetVeryTop + theMoveObject.offsetHeight >
           theContainerObjectOffsetVeryTop + theContainerObject.scrollTop + theContainerObject.clientHeight) ||
          (theMoveObjectOffsetVeryTop < theContainerObjectOffsetVeryTop + theContainerObject.scrollTop)) {
        theContainerObject.scrollTop = theMoveObjectOffsetVeryTop - theContainerObjectOffsetVeryTop;
      }
    }
  }
}

Jeremy Bernstein
Site Admin
Posts: 1226
Joined: Wed Jun 09, 2010 7:49 am
Real Name: Jeremy Bernstein
Location: Berlin, Germany
Contact:

Re: How to post chess games

Post by Jeremy Bernstein » Tue May 10, 2011 2:26 pm

pgn4web wrote:
pgn4web wrote:on second thoughts, depending on the effect you want to achieve, this might work better, especially with comments and variations after each move...
actually MUCH harder to do that I initially thought. Look what happens with the open-chess code to this game:
http://tinyurl.com/42tfrxd

I managed in the end to modify the auto-scroll code like to get this:
http://tinyurl.com/3pzp6b2

Not yet perfect, still some snags with IE7
Nice find. Thanks for looking at the issue. It's a tough problem.

pgn4web
Posts: 97
Joined: Mon Jun 14, 2010 10:26 pm

Re: How to post chess games

Post by pgn4web » Tue May 10, 2011 7:57 pm

Jeremy Bernstein wrote:Nice find. Thanks for looking at the issue. It's a tough problem.
very tough, the more I look into it the tougher it looks.

for instance, in the code posted above there is a nasty bug with Internet Explorer that makes it fail occasionally, unless you set "position: relative" to the css classes move and moveOn

then I realized that if you set an initialHalfmove different from 0 it would fail positioning correctly at startup

then I noticed that it would be nice to auto-scroll and position the text each time the window size is changed

very nasty feature...

too many changes to post here in details, but the code in the project trunk (and live on my site) has all the fixes in the board.html file

User avatar
Ubaldo Andrea Farina
Posts: 6
Joined: Sun Jul 03, 2011 5:53 pm
Real Name: Ubaldo Andrea Farina

Re: How to post chess games

Post by Ubaldo Andrea Farina » Tue Jul 19, 2011 3:41 pm

Is it possible to use a refresh interval of less of a minute when doing a live broadcast? I tried to use 0.25 (=15 seconds) but it doesn't seem to work. I'm using FTP-WatchDog to upload the updated PGN every time a move is made.

BTW thanks Paolo for this great tool!

User avatar
Ubaldo Andrea Farina
Posts: 6
Joined: Sun Jul 03, 2011 5:53 pm
Real Name: Ubaldo Andrea Farina

Re: How to post chess games

Post by Ubaldo Andrea Farina » Tue Jul 19, 2011 5:32 pm

Is it possible to use a refresh interval of less of a minute when doing a live broadcast? I tried to use 0.25 (=15 seconds) but it doesn't seem to work. I'm using FTP-WatchDog to upload the updated PGN every time a move is made.

BTW thanks Paolo for this great tool!

pgn4web
Posts: 97
Joined: Mon Jun 14, 2010 10:26 pm

Re: How to post chess games

Post by pgn4web » Tue Jul 19, 2011 7:18 pm

Ubaldo Andrea Farina wrote:Is it possible to use a refresh interval of less of a minute when doing a live broadcast? I tried to use 0.25 (=15 seconds) but it doesn't seem to work. I'm using FTP-WatchDog to upload the updated PGN every time a move is made.
there's nothing in the system that wuold prevent a very short live refresh interval, but some web server might have issues if several users hit the server so often.
more important, it does not make any sense to have an update so fast... unless you are watching blitz, but I never tried that.

also, what do you mean with "does not work"?
anything reported if you click square A8?
anything reported by your webserver?

do you have a URL for me to look at?

User avatar
Ubaldo Andrea Farina
Posts: 6
Joined: Sun Jul 03, 2011 5:53 pm
Real Name: Ubaldo Andrea Farina

Re: How to post chess games

Post by Ubaldo Andrea Farina » Fri Jul 22, 2011 3:31 pm

pgn4web wrote:
Ubaldo Andrea Farina wrote:Is it possible to use a refresh interval of less of a minute when doing a live broadcast? I tried to use 0.25 (=15 seconds) but it doesn't seem to work. I'm using FTP-WatchDog to upload the updated PGN every time a move is made.
there's nothing in the system that wuold prevent a very short live refresh interval, but some web server might have issues if several users hit the server so often.
more important, it does not make any sense to have an update so fast... unless you are watching blitz, but I never tried that.

also, what do you mean with "does not work"?
anything reported if you click square A8?
anything reported by your webserver?

do you have a URL for me to look at?
The url is http://liverelay.chironchess.com
I was indeed relaying a 5+0 blitz game. With "does not work" I meant that after I set 0.25 as interval, it got even more than one minute to show the updates on the web page ( I played only 2-3 moves). No errors were reported on the debug dialog. I didn't check my web server.
As soon as I have time I'll try again relaying a blitz game and report back. Anyway, you are right, it doesn't make much sense relaying a blitz game :)

pgn4web
Posts: 97
Joined: Mon Jun 14, 2010 10:26 pm

Re: How to post chess games

Post by pgn4web » Fri Jul 22, 2011 4:28 pm

Ubaldo Andrea Farina wrote:The url is http://liverelay.chironchess.com
I was indeed relaying a 5+0 blitz game. With "does not work" I meant that after I set 0.25 as interval, it got even more than one minute to show the updates on the web page ( I played only 2-3 moves). No errors were reported on the debug dialog. I didn't check my web server.
As soon as I have time I'll try again relaying a blitz game and report back. Anyway, you are right, it doesn't make much sense relaying a blitz game :)
Not sure, I would have to see the page during a live event.
However, in the current page you got the URL wrong, instead of

Code: Select all

live-compact.html?pgnData=ChironACCA.pgn?refreshMinutes=1?showComments=true
you should have

Code: Select all

live-compact.html?pgnData=ChironACCA.pgn&refreshMinutes=1&showComments=true
With your current URL it should not work at all as expected.

Post Reply