Some more traces... (+ fix lastMove when exit analyze)
[vchess.git] / client / src / components / BaseGame.vue
1 <template lang="pug">
2 div#baseGame
3 input#modalEog.modal(type="checkbox")
4 div#eogDiv(
5 role="dialog"
6 data-checkbox="modalEog"
7 )
8 .card.text-center
9 label.modal-close(for="modalEog")
10 h3.section {{ endgameMessage }}
11 #gameContainer
12 #boardContainer
13 Board(
14 ref="board"
15 :vr="vr"
16 :last-move="lastMove"
17 :analyze="mode=='analyze'"
18 :score="game.score"
19 :user-color="game.mycolor"
20 :orientation="orientation"
21 :vname="game.vname"
22 :incheck="incheck"
23 @play-move="play"
24 @click-square="clickSquare"
25 )
26 #turnIndicator(v-if="showTurn") {{ turn }}
27 #controls.button-group
28 button(@click="gotoBegin()")
29 img.inline(src="/images/icons/fast-forward_rev.svg")
30 button(@click="undo()")
31 img.inline(src="/images/icons/play_rev.svg")
32 button(v-if="canFlip" @click="flip()")
33 img.inline(src="/images/icons/flip.svg")
34 button(
35 @click="runAutoplay()"
36 :class="{'in-autoplay': autoplay}"
37 )
38 img.inline(src="/images/icons/autoplay.svg")
39 button(@click="play()")
40 img.inline(src="/images/icons/play.svg")
41 button(@click="gotoEnd()")
42 img.inline(src="/images/icons/fast-forward.svg")
43 p(v-show="showFen") {{ (!!vr ? vr.getFen() : "") }}
44 #movesList
45 MoveList(
46 :show="showMoves"
47 :canAnalyze="canAnalyze"
48 :canDownload="allowDownloadPGN"
49 :score="game.score"
50 :message="game.scoreMsg"
51 :firstNum="firstMoveNumber"
52 :moves="moves"
53 :cursor="cursor"
54 @download="download"
55 @showrules="showRules"
56 @analyze="toggleAnalyze"
57 @goto-move="gotoMove"
58 @reset-arrows="resetArrows"
59 )
60 .clearer
61 </template>
62
63 <script>
64 import Board from "@/components/Board.vue";
65 import MoveList from "@/components/MoveList.vue";
66 import params from "@/parameters";
67 import { store } from "@/store";
68 import { getSquareId } from "@/utils/squareId";
69 import { getDate } from "@/utils/datetime";
70 import { processModalClick } from "@/utils/modalClick";
71 import { getScoreMessage } from "@/utils/scoring";
72 import { getFullNotation } from "@/utils/notation";
73 import { undoMove } from "@/utils/playUndo";
74 export default {
75 name: "my-base-game",
76 components: {
77 Board,
78 MoveList
79 },
80 props: ["game"],
81 data: function() {
82 return {
83 st: store.state,
84 // NOTE: all following variables must be reset at the beginning of a game
85 vr: null, //VariantRules object, game state
86 endgameMessage: "",
87 orientation: "w",
88 mode: "",
89 score: "*", //'*' means 'unfinished'
90 moves: [],
91 cursor: -1, //index of the move just played
92 lastMove: null,
93 firstMoveNumber: 0, //for printing
94 incheck: [], //for Board
95 inMultimove: false,
96 autoplay: false,
97 autoplayLoop: null,
98 inPlay: false,
99 stackToPlay: []
100 };
101 },
102 computed: {
103 turn: function() {
104 if (!this.vr) return "";
105 if (this.vr.showMoves != "all") {
106 return this.st.tr[
107 (this.vr.turn == 'w' ? "White" : "Black") + " to move"];
108 }
109 // Cannot flip: racing king or circular chess
110 return (
111 this.vr.movesCount == 0 && this.game.mycolor == "w"
112 ? this.st.tr["It's your turn!"]
113 : ""
114 );
115 },
116 showFen: function() {
117 return (
118 this.mode == "analyze" &&
119 this.$router.currentRoute.path.indexOf("/analyse") === -1
120 );
121 },
122 // TODO: is it OK to pass "computed" as properties?
123 // Also, some are seemingly not recomputed when vr is initialized.
124 showMoves: function() {
125 return this.game.score != "*"
126 ? "all"
127 : (!!this.vr ? this.vr.showMoves : "none");
128 },
129 showTurn: function() {
130 return (
131 this.game.score == '*' &&
132 !!this.vr && (this.vr.showMoves != "all" || !this.vr.canFlip)
133 );
134 },
135 canAnalyze: function() {
136 return (
137 this.game.mode != "analyze" &&
138 !!this.vr && this.vr.canAnalyze
139 );
140 },
141 canFlip: function() {
142 return !!this.vr && this.vr.canFlip;
143 },
144 allowDownloadPGN: function() {
145 return (
146 this.game.score != "*" ||
147 (!!this.vr && this.vr.showMoves == "all")
148 );
149 }
150 },
151 created: function() {
152 if (!!this.game.fenStart) this.re_setVariables();
153 },
154 mounted: function() {
155 if (!("ontouchstart" in window)) {
156 // Desktop browser:
157 const baseGameDiv = document.getElementById("baseGame");
158 baseGameDiv.tabIndex = 0;
159 baseGameDiv.addEventListener("click", this.focusBg);
160 baseGameDiv.addEventListener("keydown", this.handleKeys);
161 baseGameDiv.addEventListener("wheel", this.handleScroll);
162 }
163 document.getElementById("eogDiv")
164 .addEventListener("click", processModalClick);
165 },
166 beforeDestroy: function() {
167 if (!!this.autoplayLoop) clearInterval(this.autoplayLoop);
168 },
169 methods: {
170 focusBg: function() {
171 document.getElementById("baseGame").focus();
172 },
173 handleKeys: function(e) {
174 if ([32, 37, 38, 39, 40].includes(e.keyCode)) e.preventDefault();
175 switch (e.keyCode) {
176 case 37:
177 this.undo();
178 break;
179 case 39:
180 this.play();
181 break;
182 case 38:
183 this.gotoBegin();
184 break;
185 case 40:
186 this.gotoEnd();
187 break;
188 case 32:
189 this.flip();
190 break;
191 }
192 },
193 handleScroll: function(e) {
194 e.preventDefault();
195 if (e.deltaY < 0) this.undo();
196 else if (e.deltaY > 0) this.play();
197 },
198 resetArrows: function() {
199 // TODO: make arrows scale with board, and remove this
200 this.$refs["board"].cancelResetArrows();
201 },
202 showRules: function() {
203 // The button is here only on Game page:
204 document.getElementById("modalRules").checked = true;
205 },
206 re_setVariables: function(game) {
207 if (!game) game = this.game; //in case of...
208 this.endgameMessage = "";
209 // "w": default orientation for observed games
210 this.orientation = game.mycolor || "w";
211 this.mode = game.mode || game.type; //TODO: merge...
212 this.moves = JSON.parse(JSON.stringify(game.moves || []));
213 // Post-processing: decorate each move with notation and FEN
214 this.vr = new V(game.fenStart);
215 const parsedFen = V.ParseFen(game.fenStart);
216 const firstMoveColor = parsedFen.turn;
217 this.firstMoveNumber = Math.floor(parsedFen.movesCount / 2) + 1;
218 let L = this.moves.length;
219 this.moves.forEach((move,idx) => {
220 // Strategy working also for multi-moves:
221 if (!Array.isArray(move)) move = [move];
222 const Lm = move.length;
223 move.forEach((m,idxM) => {
224 m.notation = this.vr.getNotation(m);
225 m.unambiguous = V.GetUnambiguousNotation(m);
226 this.vr.play(m);
227 const checkSquares = this.vr.getCheckSquares();
228 if (checkSquares.length > 0) m.notation += "+";
229 if (idxM == Lm - 1) m.fen = this.vr.getFen();
230 if (idx == L - 1 && idxM == Lm - 1) {
231 this.incheck = checkSquares;
232 const score = this.vr.getCurrentScore();
233 if (["1-0", "0-1"].includes(score)) m.notation += "#";
234 }
235 });
236 });
237 if (firstMoveColor == "b") {
238 // 'start' & 'end' is required for Board component
239 this.moves.unshift({
240 notation: "...",
241 unambiguous: "...",
242 start: { x: -1, y: -1 },
243 end: { x: -1, y: -1 },
244 fen: game.fenStart
245 });
246 L++;
247 }
248 this.positionCursorTo(L - 1);
249 },
250 positionCursorTo: function(index) {
251 this.cursor = index;
252 // Note: last move in moves array might be a multi-move
253 if (index >= 0) this.lastMove = this.moves[index];
254 else this.lastMove = null;
255 },
256 toggleAnalyze: function() {
257 if (this.mode != "analyze") {
258 // Enter analyze mode:
259 this.gameMode = this.mode; //was not 'analyze'
260 this.mode = "analyze";
261 this.gameCursor = this.cursor;
262 this.gameMoves = JSON.parse(JSON.stringify(this.moves));
263 document.getElementById("analyzeBtn").classList.add("active");
264 }
265 else {
266 // Exit analyze mode:
267 this.mode = this.gameMode ;
268 this.cursor = this.gameCursor;
269 this.moves = this.gameMoves;
270 let fen = this.game.fenStart;
271 if (this.cursor >= 0) {
272 let mv = this.moves[this.cursor];
273 if (!Array.isArray(mv)) mv = [mv];
274 fen = mv[mv.length-1].fen;
275 }
276 this.vr = new V(fen);
277 this.incheck = this.vr.getCheckSquares();
278 if (this.cursor >= 0) this.lastMove = this.moves[this.cursor];
279 else this.lastMove = null;
280 document.getElementById("analyzeBtn").classList.remove("active");
281 }
282 },
283 download: function() {
284 const content = this.getPgn();
285 // Prepare and trigger download link
286 let downloadAnchor = document.getElementById("download");
287 downloadAnchor.setAttribute("download", "game.pgn");
288 downloadAnchor.href =
289 "data:text/plain;charset=utf-8," + encodeURIComponent(content);
290 downloadAnchor.click();
291 },
292 getPgn: function() {
293 let pgn = "";
294 pgn += '[Site "vchess.club"]\n';
295 pgn += '[Variant "' + this.game.vname + '"]\n';
296 const gdt = getDate(new Date(this.game.created || Date.now()));
297 pgn += '[Date "' + gdt + '"]\n';
298 pgn += '[White "' + this.game.players[0].name + '"]\n';
299 pgn += '[Black "' + this.game.players[1].name + '"]\n';
300 pgn += '[Fen "' + this.game.fenStart + '"]\n';
301 pgn += '[Result "' + this.game.score + '"]\n';
302 if (!!this.game.id)
303 pgn += '[Url "' + params.serverUrl + '/game/' + this.game.id + '"]\n';
304 if (!!this.game.cadence)
305 pgn += '[Cadence "' + this.game.cadence + '"]\n';
306 pgn += '\n';
307 for (let i = 0; i < this.moves.length; i += 2) {
308 if (i > 0) pgn += " ";
309 // Adjust dots notation for a better display:
310 let fullNotation = getFullNotation(this.moves[i]);
311 if (fullNotation == "...") fullNotation = "..";
312 pgn += (i / 2 + this.firstMoveNumber) + "." + fullNotation;
313 if (i+1 < this.moves.length)
314 pgn += " " + getFullNotation(this.moves[i+1]);
315 }
316 pgn += "\n\n";
317 for (let i = 0; i < this.moves.length; i += 2) {
318 const moveNumber = i / 2 + this.firstMoveNumber;
319 // Skip "dots move", useless for machine reading:
320 if (this.moves[i].notation != "...") {
321 pgn += moveNumber + ".w " +
322 getFullNotation(this.moves[i], "unambiguous") + "\n";
323 }
324 if (i+1 < this.moves.length) {
325 pgn += moveNumber + ".b " +
326 getFullNotation(this.moves[i+1], "unambiguous") + "\n";
327 }
328 }
329 return pgn;
330 },
331 showEndgameMsg: function(message) {
332 this.endgameMessage = message;
333 document.getElementById("modalEog").checked = true;
334 },
335 runAutoplay: function() {
336 const infinitePlay = () => {
337 if (this.cursor == this.moves.length - 1) {
338 clearInterval(this.autoplayLoop);
339 this.autoplayLoop = null;
340 this.autoplay = false;
341 return;
342 }
343 if (this.inPlay || this.inMultimove)
344 // Wait next tick
345 return;
346 this.play();
347 };
348 if (this.autoplay) {
349 this.autoplay = false;
350 clearInterval(this.autoplayLoop);
351 this.autoplayLoop = null;
352 } else {
353 this.autoplay = true;
354 setTimeout(
355 () => {
356 infinitePlay();
357 this.autoplayLoop = setInterval(infinitePlay, 1500);
358 },
359 // Small delay otherwise the first move is played too fast
360 500
361 );
362 }
363 },
364 // Animate an elementary move
365 animateMove: function(move, callback) {
366 let startSquare = document.getElementById(getSquareId(move.start));
367 if (!startSquare) return; //shouldn't happen but...
368 let endSquare = document.getElementById(getSquareId(move.end));
369 let rectStart = startSquare.getBoundingClientRect();
370 let rectEnd = endSquare.getBoundingClientRect();
371 let translation = {
372 x: rectEnd.x - rectStart.x,
373 y: rectEnd.y - rectStart.y
374 };
375 let movingPiece = document.querySelector(
376 "#" + getSquareId(move.start) + " > img.piece"
377 );
378 // For some unknown reasons Opera get "movingPiece == null" error
379 // TODO: is it calling 'animate()' twice ? One extra time ?
380 if (!movingPiece) return;
381 const squares = document.getElementsByClassName("board");
382 for (let i = 0; i < squares.length; i++) {
383 let square = squares.item(i);
384 if (square.id != getSquareId(move.start))
385 // HACK for animation:
386 // (with positive translate, image slides "under background")
387 square.style.zIndex = "-1";
388 }
389 movingPiece.style.transform =
390 "translate(" + translation.x + "px," + translation.y + "px)";
391 movingPiece.style.transitionDuration = "0.25s";
392 movingPiece.style.zIndex = "3000";
393 setTimeout(() => {
394 for (let i = 0; i < squares.length; i++)
395 squares.item(i).style.zIndex = "auto";
396 movingPiece.style = {}; //required e.g. for 0-0 with KR swap
397 callback();
398 }, 250);
399 },
400 // For Analyse mode:
401 emitFenIfAnalyze: function() {
402 if (this.game.mode == "analyze") {
403 let fen = this.game.fenStart;
404 if (!!this.lastMove) {
405 if (Array.isArray(this.lastMove)) {
406 const L = this.lastMove.length;
407 fen = this.lastMove[L-1].fen;
408 }
409 else fen = this.lastMove.fen;
410 }
411 this.$emit("fenchange", fen);
412 }
413 },
414 clickSquare: function(square) {
415 // Some variants make use of a single click at specific times:
416 const move = this.vr.doClick(square);
417 if (!!move) this.play(move);
418 },
419 // "light": if gotoMove() or gotoEnd()
420 play: function(move, received, light, noemit) {
421 // Freeze while choices are shown:
422 if (this.$refs["board"].choices.length > 0) return;
423 const navigate = !move;
424 // Forbid playing outside analyze mode, except if move is received.
425 // Sufficient condition because Board already knows which turn it is.
426 if (
427 this.mode != "analyze" &&
428 !navigate &&
429 !received &&
430 (this.game.score != "*" || this.cursor < this.moves.length - 1)
431 ) {
432 return;
433 }
434 if (!!received) {
435
436 if (this.mode == "analyze") { console.log("received move");
437 console.log(move); }
438
439 if (this.mode == "analyze") this.toggleAnalyze();
440 if (this.cursor < this.moves.length - 1)
441 // To play a received move, cursor must be at the end of the game:
442 this.gotoEnd();
443 }
444 if (!!noemit) {
445 if (this.inPlay) {
446 // Received moves in observed games can arrive too fast:
447 this.stackToPlay.unshift(move);
448 return;
449 }
450 this.inPlay = true;
451 }
452 // The board may show some the possible moves: (TODO: bad solution)
453 this.$refs["board"].resetCurrentAttempt();
454 const playSubmove = (smove) => {
455 smove.notation = this.vr.getNotation(smove);
456 smove.unambiguous = V.GetUnambiguousNotation(smove);
457 this.vr.play(smove);
458 if (this.inMultimove && !!this.lastMove) {
459 if (!Array.isArray(this.lastMove))
460 this.lastMove = [this.lastMove, smove];
461 else this.lastMove.push(smove);
462 }
463 // Is opponent (or me) in check?
464 this.incheck = this.vr.getCheckSquares();
465 if (this.incheck.length > 0) smove.notation += "+";
466 if (!this.inMultimove) {
467 // First sub-move:
468 this.lastMove = smove;
469 // Condition is "!navigate" but we mean "!this.autoplay"
470 if (!navigate) {
471 if (this.cursor < this.moves.length - 1)
472 this.moves = this.moves.slice(0, this.cursor + 1);
473 this.moves.push(smove);
474 }
475 this.inMultimove = true; //potentially
476 this.cursor++;
477 } else if (!navigate) {
478 // Already in the middle of a multi-move
479 const L = this.moves.length;
480 if (!Array.isArray(this.moves[L-1]))
481 this.$set(this.moves, L-1, [this.moves[L-1], smove]);
482 else this.moves[L-1].push(smove);
483 }
484 };
485 const playMove = () => {
486 const animate = (
487 ["all", "highlight"].includes(V.ShowMoves) &&
488 (this.autoplay || !!received)
489 );
490 if (!Array.isArray(move)) move = [move];
491 let moveIdx = 0;
492 let self = this;
493 const initurn = this.vr.turn;
494 (function executeMove() {
495 console.log("execute move " + move.length);
496 const smove = move[moveIdx++];
497
498 console.log(smove);
499 console.log(animate + " " + smove.start.x);
500
501
502 // NOTE: condition "smove.start.x >= 0" required for Dynamo,
503 // because second move may be empty.
504 if (animate && smove.start.x >= 0) {
505 self.animateMove(smove, () => {
506 playSubmove(smove);
507
508 console.log(moveIdx + " " + move.length);
509
510 if (moveIdx < move.length)
511 setTimeout(executeMove, 500);
512 else afterMove(smove, initurn);
513 });
514 } else {
515 playSubmove(smove);
516 if (moveIdx < move.length) executeMove();
517 else afterMove(smove, initurn);
518 }
519 })();
520 };
521 const computeScore = () => {
522 const score = this.vr.getCurrentScore();
523 if (!navigate) {
524 if (["1-0","0-1"].includes(score)) {
525 if (Array.isArray(this.lastMove)) {
526 const L = this.lastMove.length;
527 this.lastMove[L - 1].notation += "#";
528 }
529 else this.lastMove.notation += "#";
530 }
531 }
532 if (score != "*" && this.mode == "analyze") {
533 const message = getScoreMessage(score);
534 // Just show score on screen (allow undo)
535 this.showEndgameMsg(score + " . " + this.st.tr[message]);
536 }
537 return score;
538 };
539 const afterMove = (smove, initurn) => {
540 if (this.vr.turn != initurn) {
541
542 console.log(smove);
543
544 // Turn has changed: move is complete
545 if (!smove.fen)
546 // NOTE: only FEN of last sub-move is required (=> setting it here)
547 smove.fen = this.vr.getFen();
548 this.emitFenIfAnalyze();
549 this.inMultimove = false;
550 this.score = computeScore();
551 if (this.mode != "analyze" && !navigate) {
552 if (!noemit && this.mode != "analyze") {
553 // Post-processing (e.g. computer play).
554 const L = this.moves.length;
555 // NOTE: always emit the score, even in unfinished,
556 // to tell Game::processMove() that it's not a received move.
557 this.$emit("newmove", this.moves[L-1], { score: this.score });
558 } else {
559 this.inPlay = false;
560 if (this.stackToPlay.length > 0)
561 // Move(s) arrived in-between
562 this.play(this.stackToPlay.pop(), received, light, noemit);
563 }
564 }
565 }
566 };
567 // NOTE: navigate and received are mutually exclusive
568 if (navigate) {
569 // The move to navigate to is necessarily full:
570 if (this.cursor == this.moves.length - 1) return; //no more moves
571 move = this.moves[this.cursor + 1];
572 if (!this.autoplay) {
573 // Just play the move:
574 if (!Array.isArray(move)) move = [move];
575 for (let i=0; i < move.length; i++) this.vr.play(move[i]);
576 if (!light) {
577 this.lastMove = move;
578 this.incheck = this.vr.getCheckSquares();
579 this.score = computeScore();
580 this.emitFenIfAnalyze();
581 }
582 this.cursor++;
583 return;
584 }
585 }
586 playMove();
587 },
588 cancelCurrentMultimove: function() {
589 const L = this.moves.length;
590 let move = this.moves[L-1];
591 if (!Array.isArray(move)) move = [move];
592 for (let i = move.length - 1; i >= 0; i--) this.vr.undo(move[i]);
593 this.moves.pop();
594 this.cursor--;
595 this.inMultimove = false;
596 },
597 cancelLastMove: function() {
598 // The last played move was canceled (corr game)
599 this.undo();
600 this.moves.pop();
601 },
602 // "light": if gotoMove() or gotoBegin()
603 undo: function(move, light) {
604 // Freeze while choices are shown:
605 if (this.$refs["board"].choices.length > 0) return;
606 this.$refs["board"].resetCurrentAttempt();
607 if (this.inMultimove) {
608 this.cancelCurrentMultimove();
609 this.incheck = this.vr.getCheckSquares();
610 } else {
611 if (!move) {
612 const minCursor =
613 this.moves.length > 0 && this.moves[0].notation == "..."
614 ? 1
615 : 0;
616 if (this.cursor < minCursor) return; //no more moves
617 move = this.moves[this.cursor];
618 }
619 this.$refs["board"].resetCurrentAttempt();
620 undoMove(move, this.vr);
621 if (light) this.cursor--;
622 else {
623 this.positionCursorTo(this.cursor - 1);
624 this.incheck = this.vr.getCheckSquares();
625 this.emitFenIfAnalyze();
626 }
627 }
628 },
629 gotoMove: function(index) {
630 if (this.$refs["board"].choices.length > 0) return;
631 this.$refs["board"].resetCurrentAttempt();
632 if (this.inMultimove) this.cancelCurrentMultimove();
633 if (index == this.cursor) return;
634 if (index < this.cursor) {
635 while (this.cursor > index)
636 this.undo(null, null, "light");
637 }
638 else {
639 // index > this.cursor)
640 while (this.cursor < index)
641 this.play(null, null, "light");
642 }
643 // NOTE: next line also re-assign cursor, but it's very light
644 this.positionCursorTo(index);
645 this.incheck = this.vr.getCheckSquares();
646 this.emitFenIfAnalyze();
647 },
648 gotoBegin: function() {
649 if (this.$refs["board"].choices.length > 0) return;
650 this.$refs["board"].resetCurrentAttempt();
651 if (this.inMultimove) this.cancelCurrentMultimove();
652 const minCursor =
653 this.moves.length > 0 && this.moves[0].notation == "..."
654 ? 1
655 : 0;
656 while (this.cursor >= minCursor) this.undo(null, null, "light");
657 this.lastMove = (minCursor == 1 ? this.moves[0] : null);
658 this.incheck = this.vr.getCheckSquares();
659 this.emitFenIfAnalyze();
660 },
661 gotoEnd: function() {
662 if (this.$refs["board"].choices.length > 0) return;
663 this.$refs["board"].resetCurrentAttempt();
664 if (this.cursor == this.moves.length - 1) return;
665 this.gotoMove(this.moves.length - 1);
666 this.emitFenIfAnalyze();
667 },
668 flip: function() {
669 if (this.$refs["board"].choices.length > 0) return;
670 this.orientation = V.GetOppCol(this.orientation);
671 }
672 }
673 };
674 </script>
675
676 <style lang="sass" scoped>
677 [type="checkbox"]#modalEog+div .card
678 min-height: 45px
679
680 #baseGame
681 width: 100%
682 &:focus
683 outline: none
684
685 #gameContainer
686 margin-left: auto
687 margin-right: auto
688
689 #downloadDiv
690 display: inline-block
691
692 #controls
693 user-select: none
694 button
695 border: none
696 margin: 0
697 padding-top: 5px
698 padding-bottom: 5px
699
700 .in-autoplay
701 background-color: #FACF8C
702
703 img.inline
704 height: 22px
705 padding-top: 5px
706 @media screen and (max-width: 767px)
707 height: 18px
708
709 #turnIndicator
710 text-align: center
711 font-weight: bold
712
713 #boardContainer
714 float: left
715 // TODO: later, maybe, allow movesList of variable width
716 // or e.g. between 250 and 350px (but more complicated)
717
718 #movesList
719 width: 280px
720 float: left
721
722 @media screen and (max-width: 767px)
723 #movesList
724 width: 100%
725 float: none
726 clear: both
727 </style>