Jump to content

User:Fred Gandt/sandbox/chessDemo: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
LOL - slight layout problem - gonna get some lunch
and there
 
(20 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<includeonly>{{{{{|safesubst:}}}#invoke:User:Fred Gandt/sandbox/chessDemo|getDemo}}</includeonly><noinclude>{{documentation|content={{lua|Module:User:Fred Gandt/sandbox/chessDemo}}
<includeonly>{{{{{|safesubst:}}}#invoke:Sandbox/Fred Gandt/chessDemo|getDemo}}</includeonly><noinclude>{{documentation|content={{lua|Module:Sandbox/Fred Gandt/chessDemo}}
== Setup ==
== Setup ==
If deployed site wide, the CSS can be split in two; some delivered to style the demos for users with JavaScript disabled, and the rest to handle the scripted display.
If deployed site wide, the CSS can be split in two; some delivered to style the demos for users with JavaScript disabled, and the rest to handle the scripted display. The ''noscript'' rendering supports the display of an animated .gif which is hidden when the JS loads. The unscripted rendering is identical to the scripted except that the animated .gif shows instead of the interactive board and the controls (buttons) are omitted.
: These .gifs should be created by a MediaWiki Extension using the [[ImageMagick]] PHP library. This is an efficient method of obtaining standardised and consistent fallbacks for all demos.

The ''noscript'' rendering supports the display of an animated .gif which is hidden when the JS loads. The scripted version is thus a ''fall-forward'', rather than the .gif being a ''fallback''.
: These .gifs could be created by a BOT (to be created only if needed) which parses the instructions to calculate and create the result, uploads it to commons, and adds it to the demos. This would ensure each demo had a standardised, consistent fallback.
: An alternative to this BOT enabled fallback procedure, is to implement the demos as a MediaWiki Extension, and have the fallback .gif generated on-the-fly only when needed by users with JS disabled. This method would be by far the most efficient, and has many other benefits. It is a desirable possibility I will pursue.

To correctly render the examples below, and test creating more (on any other pages ''i.e.'' in [[Special:MyPage/sandbox|your user sandbox]]):
To correctly render the examples below, and test creating more (on any other pages ''i.e.'' in [[Special:MyPage/sandbox|your user sandbox]]):
: Add <code>mw.loader.load( '/enwiki/w/index.php?title=User:Fred_Gandt/chessDemo.js&action=raw&ctype=text/javascript' );</code> to [[Special:MyPage/common.js|your common.js]].
: Add <code>mw.loader.load( '/enwiki/w/index.php?title=[[User:Fred_Gandt/chessDemo.js]]&action=raw&ctype=text/javascript' );</code> to [[Special:MyPage/common.js|your common.js]].
For demonstration, all the CSS is loaded by the JS.

For demo, all the CSS is loaded by the JS, so to allow the ''noscript'' rendering to be seen, I've added a confirmation dialog to the initialisation; if you click {{button|OK}}, the scripted renderings will show, but clicking {{button|Cancel}} will show the unscripted renderings (since the script goes no further than loading the first part of the CSS). It's an ugly hack, but cuts to the chase.


== TODO ==
== TODO ==
<div style="text-align:center;border:2px solid #FFD100;border-radius:5px;box-shadow:0.1em 0.1em 0.75em 0 #444;padding:0.5em 0 0.75em;margin:1.5em 10%;background:white"><span style="vertical-align:text-bottom">[[File:Ambox_warning_yellow.svg|40px|link=]]</span>&nbsp;Demos may not render correctly at any time due to ongoing development. <span class="plainlinks">[https://en.wikipedia.org/enwiki/w/index.php?title=User:Fred_Gandt/sandbox/chessDemo&action=purge Purge]</span>.</div>
# Reduce "setup" markup.
# Accept various forms of ''move'' (including PGN) and ''setup'' (including FEN) inputs to empower a wider range of editors (no special knowledge required).
## Possibly also accept FEN.
# Remove need for "from" part of "moves".
## Possibly also accept PGN.
# Build extension to generate animated .gif fallback for users with JS disabled (ImageMagick).
# Build extension to generate animated .gif fallback for users with JS disabled (ImageMagick).


== Syntax ==
== Syntax ==
; Animated .gif for display to users with JavaScript disabled:
: <s>{{para|fallback}} gif file name</s>
: To be automatically handled by MW Extension

; Size, position and display adjustment:
; Size, position and display adjustment:
: {{para|width}} in pixels (''optional'' - defaults to "200")
: {{para|width}} in pixels (''optional'' - defaults to "200")
: {{para|float}} "left", "right" or "none" (''optional'' - defaults to "right")
: {{para|float}} "left", "right" or "none" (''optional'' - defaults to "right")
: {{para|clear}} "left", "right", "both" or "none" (''optional'' - defaults to "both")
: {{para|clear}} "left", "right", "both" or "none" (''optional'' - defaults to "both")
: {{para|notation}} scrolling container showing ''"number"'' of lines, "collapsible" or "collapsed", "left" or "right", or "hidden" (''optional'' - defaults to uncollapsible full length display)
: {{para|notation}} "collapsible" or "collapsed", "left" or "right", or "hidden" (''optional'' - defaults to uncollapsible display underneath the board)
:: {{para|columns}} ''"number"'' of columns of notation (''optional'' - defaults to "1"); has no effect on scrolling notation
:: {{para|columns}} ''"number"'' of columns of notation - will occasionally render one fewer than stated due to maths (''optional'' - defaults to "1")
:: {{para|columnwidth}} ''"number"'' of pixels each column should be wide (''optional'' - has no effect unless the notation is "left" or "right" - defaults to "120")
:: {{para|numbering}} ''"number"'' with which to begin the notation count or "no" to disable numbering (''optional'' - defaults to "1")
:: {{para|numbering}} ''"number"'' with which to begin the notation count or "no" to disable numbering (''optional'' - defaults to "1")
: {{para|controls}} "mini", "medi" or "none" (''optional'' - defaults to showing all controls)
: {{para|controls}} "mini", "medi" or "none" (''optional'' - defaults to showing all controls)
:: If controls are omitted, {{para|autostart}} will default to "yes"
:: If controls are omitted, {{para|autostart}} will default to "yes"

; Orientation of board:
: {{para|orientation}} "black" or empty (''optional'' - defaults to orientation from white's perspective)


; Demo title and details:
; Demo title and details:
Line 44: Line 37:
: {{para|autostart}} "yes" (''optional'')
: {{para|autostart}} "yes" (''optional'')


; Specify the pieces and positions at the start:
; Specify a move to start the demo at:
: {{para|initial}} ''"number"'' of the move after which to start or "end" to start at the end (''optional'' - defaults to the beginning) ''i.e.'':
:: "12" will show the board as if the first 12 moves had already been played
:: "end" will show the board as if '''all''' the moves had already been played

; Specify the pieces and positions at the beginning:
: {{para|setup}} ''"color alphanumeral, color alphanumeral, ... "'' (''optional'' - defaults to the full game start setup)
: {{para|setup}} ''"color alphanumeral, color alphanumeral, ... "'' (''optional'' - defaults to the full game start setup)


Line 79: Line 77:
Black pawn captures White pawn in passing.
Black pawn captures White pawn in passing.
}}</pre>{{User:Fred Gandt/sandbox/chessDemo
}}</pre>{{User:Fred Gandt/sandbox/chessDemo
| controls = none
| float = none
| float = none
| controls = none
| notation = hidden
| notation = hidden
| setup = white d2, black e4
| fallback = File:Ajedrez animación en passant.gif
| setup = white d2, black e4
| 1 = d2 d4
| 1 = d2 d4
White Queen's pawn moves two.
White Queen's pawn moves two.
| 2 = e4 exd3e.p.
| 2 = e4 exd3e.p.
Black pawn captures White pawn in passing.
Black pawn captures White pawn in passing.
}}
}}
Line 110: Line 107:
}}
}}
}}</pre>{{User:Fred Gandt/sandbox/chessDemo
}}</pre>{{User:Fred Gandt/sandbox/chessDemo
| fallback = File:Ajedrez animación en passant.gif
| float = none
| float = none
| controls = mini
| controls = mini
Line 141: Line 137:
Black pawn captures White pawn in passing.
Black pawn captures White pawn in passing.
}}</pre>{{User:Fred Gandt/sandbox/chessDemo
}}</pre>{{User:Fred Gandt/sandbox/chessDemo
| fallback = File:Ajedrez animación en passant.gif
| float = none
| float = none
| controls = mini
| controls = mini
Line 216: Line 211:
| title = Kingside castling
| title = Kingside castling
| numbering = no
| numbering = no
| orientation = black
| setup = black king e8, black rook h8
| setup = black king e8, black rook h8
| 1 = e8 0-0
| 1 = e8 0-0
Line 223: Line 219:
| title = Kingside castling
| title = Kingside castling
| numbering = no
| numbering = no
| orientation = black
| setup = black king e8, black rook h8
| setup = black king e8, black rook h8
| 1 = e8 0-0
| 1 = e8 0-0
Line 242: Line 239:
}}{{clear}}
}}{{clear}}


=== Full game demo with scrolling notation ===
=== Full game demo with collapsed notation with initial position at the end ===
<pre style="display: inline-block">{{User:Fred Gandt/sandbox/chessDemo
<pre style="display: inline-block">{{User:Fred Gandt/sandbox/chessDemo
| width = 300
| width = 300
| notation = 5
| title = Full demonstration game
| information = Includes several ''special'' moves.
| speed = 1
| 1 = e2 e4
White King's pawn moves two.
| 2 = e7 e5
Black King's pawn moves to block.
| 3 = g1 Nf3
White King's knight ...
| 4 = f8 Bb4
| 5 = c2 c3
| 6 = g8 Nf6
| 7 = f3 Nxe5
| 8 = e8 0-0
| 9 = f1 Bc4
| 10 = f6 Nxe4
| 11 = c3 cxb4
| 12 = f8 Re8
| 13 = b4 b5
| 14 = c7 c5
| 15 = b5 bxc6e.p.
| 16 = e8 Rxe5
| 17 = c6 cxb7
| 18 = d8 Qh4
Black Queen moves to attack.
| 19 = b7 bxc8=R+
| 20 = e5 Re8
| 21 = c8 Rxe8# 1–0
}}</pre>{{User:Fred Gandt/sandbox/chessDemo
| fallback = chess game demo
| width = 300
| notation = 5
| title = Full demonstration game
| information = Includes several ''special'' moves.
| speed = 1
| 1 = e2 e4
White King's pawn moves two.
| 2 = e7 e5
Black King's pawn moves to block.
| 3 = g1 Nf3
White King's knight ...
| 4 = f8 Bb4
| 5 = c2 c3
| 6 = g8 Nf6
| 7 = f3 Nxe5
| 8 = e8 0-0
| 9 = f1 Bc4
| 10 = f6 Nxe4
| 11 = c3 cxb4
| 12 = f8 Re8
| 13 = b4 b5
| 14 = c7 c5
| 15 = b5 bxc6e.p.
| 16 = e8 Rxe5
| 17 = c6 cxb7
| 18 = d8 Qh4
Black Queen moves to attack.
| 19 = b7 bxc8=R+
| 20 = e5 Re8
| 21 = c8 Rxe8# 1–0
}}

=== Full game demo with collapsed notation ===
<pre style="display: inline-block">{{User:Fred Gandt/sandbox/chessDemo
| width = 400
| notation = collapsed
| notation = collapsed
| columns = 2
| columns = 2
Line 341: Line 272:
| 20 = e5 Re8
| 20 = e5 Re8
| 21 = c8 Rxe8# 1–0
| 21 = c8 Rxe8# 1–0
| initial = end
}}</pre>{{User:Fred Gandt/sandbox/chessDemo
}}</pre>{{User:Fred Gandt/sandbox/chessDemo
| width = 300
| fallback = chess game demo
| width = 400
| notation = collapsed
| notation = collapsed
| columns = 2
| columns = 2
Line 374: Line 305:
| 20 = e5 Re8
| 20 = e5 Re8
| 21 = c8 Rxe8# 1–0
| 21 = c8 Rxe8# 1–0
| initial = end
}}
}}


=== Full real game demo ===
=== Full real game demo with initial position before the first checking move ===
<pre style="display: inline-block">{{User:Fred_Gandt/sandbox/chessDemo
<pre style="display: inline-block">{{User:Fred_Gandt/sandbox/chessDemo
| width = 250
| width = 250
| notation = right
| notation = right
| columns = 3
| columns = 3
| title = [[Deep Blue versus Kasparov, 1996, Game 1]]
| title = [[Deep Blue versus Kasparov, 1996, Game 1]]
| information = The first game of the 1996 match was the first game to be won by a [[Computer chess|chess-playing computer]] against a reigning [[World Chess Championship|world champion]] under normal chess tournament conditions, and in particular, [[Glossary of chess#Classical|classical]] [[time control]]s. The game was played on February 10, 1996.
| information = The first game of the 1996 match was the first game to be won by a [[Computer chess|chess-playing computer]] against a reigning [[World Chess Championship|world champion]] under normal chess tournament conditions, and in particular, [[Glossary of chess#Classical|classical]] [[time control]]s.<br>The game was played on February 10, 1996.
| 1 = e2 e4 | 2 = c7 c5 | 3 = c2 c3 | 4 = d7 d5 | 5 = e4 exd5 | 6 = d8 Qxd5 | 7 = d2 d4 | 8 = g8 Nf6 | 9 = g1 Nf3 | 10 = c8 Bg4 | 11 = f1 Be2 | 12 = e7 e6 | 13 = h2 h3 | 14 = g4 Bh5 | 15 = e1 0-0 | 16 = b8 Nc6 | 17 = c1 Be3 | 18 = c5 cxd4 | 19 = c3 cxd4 | 20 = f8 Bb4 | 21 = a2 a3 | 22 = b4 Ba5 | 23 = b1 Nc3 | 24 = d5 Qd6 | 25 = c3 Nb5 | 26 = d6 Qe7 | 27 = f3 Ne5 | 28 = h5 Bxe2 | 29 = d1 Qxe2 | 30 = e8 0-0 | 31 = a1 Rac1 | 32 = a8 Rac8 | 33 = e3 Bg5 | 34 = a5 Bb6 | 35 = g5 Bxf6 | 36 = g7 gxf6 | 37 = e5 Nc4 | 38 = f8 Rfd8 | 39 = c4 Nxb6 | 40 = a7 axb6 | 41 = f1 Rfd1 | 42 = f6 f5 | 43 = e2 Qe3 | 44 = e7 Qf6 | 45 = d4 d5 | 46 = d8 Rxd5 | 47 = d1 Rxd5 | 48 = e6 exd5 | 49 = b2 b3 | 50 = g8 Kh8 | 51 = e3 Qxb6 | 52 = c8 Rg8 | 53 = b6 Qc5 | 54 = d5 d4 | 55 = b5 Nd6 | 56 = f5 f4 | 57 = d6 Nxb7 | 58 = c6 Ne5 | 59 = c5 Qd5 | 60 = f4 f3 | 61 = g2 g3 | 62 = e5 Nd3 | 63 = c1 Rc7 | 64 = g8 Re8 | 65 = b7 Nd6 | 66 = e8 Re1+ | 67 = g1 Kh2 | 68 = d3 Nxf2 | 69 = d6 Nxf7+ | 70 = h8 Kg7 | 71 = f7 Ng5+ | 72 = g7 Kh6 | 73 = c7 Rxh7+ 1–0
| 1 = e2 e4 | 2 = c7 c5 | 3 = c2 c3 | 4 = d7 d5 | 5 = e4 exd5 | 6 = d8 Qxd5 | 7 = d2 d4 | 8 = g8 Nf6 | 9 = g1 Nf3 | 10 = c8 Bg4
| 11 = f1 Be2 | 12 = e7 e6 | 13 = h2 h3 | 14 = g4 Bh5 | 15 = e1 0-0 | 16 = b8 Nc6 | 17 = c1 Be3 | 18 = c5 cxd4 | 19 = c3 cxd4 | 20 = f8 Bb4
| 21 = a2 a3 | 22 = b4 Ba5 | 23 = b1 Nc3 | 24 = d5 Qd6 | 25 = c3 Nb5 | 26 = d6 Qe7 | 27 = f3 Ne5 | 28 = h5 Bxe2 | 29 = d1 Qxe2 | 30 = e8 0-0
| 31 = a1 Rac1 | 32 = a8 Rac8 | 33 = e3 Bg5 | 34 = a5 Bb6 | 35 = g5 Bxf6 | 36 = g7 gxf6 | 37 = e5 Nc4 | 38 = f8 Rfd8 | 39 = c4 Nxb6 | 40 = a7 axb6
| 41 = f1 Rfd1 | 42 = f6 f5 | 43 = e2 Qe3 | 44 = e7 Qf6 | 45 = d4 d5 | 46 = d8 Rxd5 | 47 = d1 Rxd5 | 48 = e6 exd5 | 49 = b2 b3 | 50 = g8 Kh8
| 51 = e3 Qxb6 | 52 = c8 Rg8 | 53 = b6 Qc5 | 54 = d5 d4 | 55 = b5 Nd6 | 56 = f5 f4 | 57 = d6 Nxb7 | 58 = c6 Ne5 | 59 = c5 Qd5 | 60 = f4 f3
| 61 = g2 g3 | 62 = e5 Nd3 | 63 = c1 Rc7 | 64 = g8 Re8 | 65 = b7 Nd6 | 66 = e8 Re1+ | 67 = g1 Kh2 | 68 = d3 Nxf2 | 69 = d6 Nxf7+ | 70 = h8 Kg7
| 71 = f7 Ng5+ | 72 = g7 Kh6 | 73 = c7 Rxh7+ 1–0
| initial = 65
}}</pre>{{User:Fred_Gandt/sandbox/chessDemo
}}</pre>{{User:Fred_Gandt/sandbox/chessDemo
| width = 250
| width = 250
| notation = right
| notation = right
| columns = 3
| columns = 3
| title = [[Deep Blue versus Kasparov, 1996, Game 1]]
| title = [[Deep Blue versus Kasparov, 1996, Game 1]]
| information = The first game of the 1996 match was the first game to be won by a [[Computer chess|chess-playing computer]] against a reigning [[World Chess Championship|world champion]] under normal chess tournament conditions, and in particular, [[Glossary of chess#Classical|classical]] [[time control]]s. The game was played on February 10, 1996.
| information = The first game of the 1996 match was the first game to be won by a [[Computer chess|chess-playing computer]] against a reigning [[World Chess Championship|world champion]] under normal chess tournament conditions, and in particular, [[Glossary of chess#Classical|classical]] [[time control]]s.<br>The game was played on February 10, 1996.
| 1 = e2 e4 | 2 = c7 c5 | 3 = c2 c3 | 4 = d7 d5 | 5 = e4 exd5 | 6 = d8 Qxd5 | 7 = d2 d4 | 8 = g8 Nf6 | 9 = g1 Nf3 | 10 = c8 Bg4 | 11 = f1 Be2 | 12 = e7 e6 | 13 = h2 h3 | 14 = g4 Bh5 | 15 = e1 0-0 | 16 = b8 Nc6 | 17 = c1 Be3 | 18 = c5 cxd4 | 19 = c3 cxd4 | 20 = f8 Bb4 | 21 = a2 a3 | 22 = b4 Ba5 | 23 = b1 Nc3 | 24 = d5 Qd6 | 25 = c3 Nb5 | 26 = d6 Qe7 | 27 = f3 Ne5 | 28 = h5 Bxe2 | 29 = d1 Qxe2 | 30 = e8 0-0 | 31 = a1 Rac1 | 32 = a8 Rac8 | 33 = e3 Bg5 | 34 = a5 Bb6 | 35 = g5 Bxf6 | 36 = g7 gxf6 | 37 = e5 Nc4 | 38 = f8 Rfd8 | 39 = c4 Nxb6 | 40 = a7 axb6 | 41 = f1 Rfd1 | 42 = f6 f5 | 43 = e2 Qe3 | 44 = e7 Qf6 | 45 = d4 d5 | 46 = d8 Rxd5 | 47 = d1 Rxd5 | 48 = e6 exd5 | 49 = b2 b3 | 50 = g8 Kh8 | 51 = e3 Qxb6 | 52 = c8 Rg8 | 53 = b6 Qc5 | 54 = d5 d4 | 55 = b5 Nd6 | 56 = f5 f4 | 57 = d6 Nxb7 | 58 = c6 Ne5 | 59 = c5 Qd5 | 60 = f4 f3 | 61 = g2 g3 | 62 = e5 Nd3 | 63 = c1 Rc7 | 64 = g8 Re8 | 65 = b7 Nd6 | 66 = e8 Re1+ | 67 = g1 Kh2 | 68 = d3 Nxf2 | 69 = d6 Nxf7+ | 70 = h8 Kg7 | 71 = f7 Ng5+ | 72 = g7 Kh6 | 73 = c7 Rxh7+ 1–0
| 1 = e2 e4 | 2 = c7 c5 | 3 = c2 c3 | 4 = d7 d5 | 5 = e4 exd5 | 6 = d8 Qxd5 | 7 = d2 d4 | 8 = g8 Nf6 | 9 = g1 Nf3 | 10 = c8 Bg4
| 11 = f1 Be2 | 12 = e7 e6 | 13 = h2 h3 | 14 = g4 Bh5 | 15 = e1 0-0 | 16 = b8 Nc6 | 17 = c1 Be3 | 18 = c5 cxd4 | 19 = c3 cxd4 | 20 = f8 Bb4
| 21 = a2 a3 | 22 = b4 Ba5 | 23 = b1 Nc3 | 24 = d5 Qd6 | 25 = c3 Nb5 | 26 = d6 Qe7 | 27 = f3 Ne5 | 28 = h5 Bxe2 | 29 = d1 Qxe2 | 30 = e8 0-0
| 31 = a1 Rac1 | 32 = a8 Rac8 | 33 = e3 Bg5 | 34 = a5 Bb6 | 35 = g5 Bxf6 | 36 = g7 gxf6 | 37 = e5 Nc4 | 38 = f8 Rfd8 | 39 = c4 Nxb6 | 40 = a7 axb6
| 41 = f1 Rfd1 | 42 = f6 f5 | 43 = e2 Qe3 | 44 = e7 Qf6 | 45 = d4 d5 | 46 = d8 Rxd5 | 47 = d1 Rxd5 | 48 = e6 exd5 | 49 = b2 b3 | 50 = g8 Kh8
| 51 = e3 Qxb6 | 52 = c8 Rg8 | 53 = b6 Qc5 | 54 = d5 d4 | 55 = b5 Nd6 | 56 = f5 f4 | 57 = d6 Nxb7 | 58 = c6 Ne5 | 59 = c5 Qd5 | 60 = f4 f3
| 61 = g2 g3 | 62 = e5 Nd3 | 63 = c1 Rc7 | 64 = g8 Re8 | 65 = b7 Nd6 | 66 = e8 Re1+ | 67 = g1 Kh2 | 68 = d3 Nxf2 | 69 = d6 Nxf7+ | 70 = h8 Kg7
| 71 = f7 Ng5+ | 72 = g7 Kh6 | 73 = c7 Rxh7+ 1–0
| initial = 65
}}
}}{{clear}}

=== Example articles ===
Copies of current chess articles, with chessDemos used in place of {{tl|Chess diagram}}s.
* [[/Example article 1]]: A copy of [[Deep Blue versus Garry Kasparov]] (incomplete).
* [[/Example article 2]]: A copy of [[Deep Blue versus Kasparov, 1996, Game 1]].
* others to follow

}}</noinclude>
}}</noinclude>

Latest revision as of 16:38, 3 June 2023