1 // Load rules on variant page
2 Vue
.component('my-rules', {
15 // TODO: third button "see a sample game" (comp VS comp)
18 <div class="col-sm-12 col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
19 <div class="button-group">
20 <button @click="display='rules'">
23 <button @click="startComputerGame()">
27 <div v-show="display=='rules'" v-html="content" class="section-content"></div>
28 <my-game v-show="display=='computer'" :mycolor="mycolor" :settings="settings"
29 :allow-movelist="allowMovelist" :mode="mode" :fen="fen">
34 // AJAX request to get rules content (plain text, HTML)
35 ajax("/rules/" + variant
.name
, "GET", response
=> {
36 let replaceByDiag
= (match
, p1
, p2
) => {
37 const args
= this.parseFen(p2
);
38 return getDiagram(args
);
40 this.content
= response
.replace(/(fen:)([^:]*):/g, replaceByDiag
);
45 const fenParts
= fen
.split(" ");
47 position: fenParts
[0],
49 orientation: fenParts
[2],
53 startComputerGame: function() {
54 this.fen
= V
.GenRandInitFen();
55 this.display
= "computer";