2009年11月26日木曜日

More.

このエントリーをブックマークに追加 このエントリーを含むはてなブックマーク
I implemented some parsing code. Now if you gives it


<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1.3.2");
</script>
<script type="text/javascript" src="../src/jsboard.js">
</script>

<div>Script understands Copy and Paste from gnubg
<div class="jsboard" width="400" height="300">
Position ID: sGfwgAPbuIEDIA
Match ID: cIkqAAAAAAAA
1. Cubeful 2-ply 24/22 13/9 Eq.: -0.151
0.425 0.125 0.005 - 0.575 0.192 0.009
2-ply cubeful prune [world class]
2. Cubeful 2-ply 8/4 6/4 Eq.: -0.208 ( -0.057)
0.396 0.133 0.006 - 0.604 0.204 0.015
2-ply cubeful prune [world class]
</div>
</div>


it gives you:

So far done today

このエントリーをブックマークに追加 このエントリーを含むはてなブックマーク
Well,

  • I started jQuery.

  • dynamically inserting figure and handlers


need to

  • JavaScript

    • pick up value of alt attribute from div (root) and generates url for image

    • handlers to tell server what is action.

  • server side

    • generating map coords.

    • api which returns next position id for the pair of current position and action.



50 lines of JavaScript let me to generate:


from:


<html>
<head>
<title>editor test</sample>
<!--
Copyright 2009 Noriyuki Hosaka bgnori@gmail.com
-->
</head>
<body>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1.3.2");
</script>
<script type="text/javascript" src="../src/jsboard.js">
</script>

<script>
</script>
<div class="jsboard" ">initial position</div>
<div class="jsboard" alt="4PPgAQPgc+QBIg:cAl7AAAAAAAA">another position</div>
<div class="jsboard" alt="4PPgAQPgc+QBIg:cAl7AAAAAAAA" width="400" height="300">yet another position with size</div>
</body>
</html>

Using jQuery to build ajax board with backgammonbase

このエントリーをブックマークに追加 このエントリーを含むはてなブックマーク
Okay, the core idea is replacing image with DOM manipulation via JavaScript when user changes some thing. Such as...

  • Moving chequer

  • Picking up dice

  • Doubling

  • Take/Pass on Cube

  • Placing chequers to set up position


jQuery helps me a lot.




<html>
<head>
<title>sample</sample>
</head>
<body>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1.3.2");
</script>
<script type="text/javascript">
<!--
$(document).ready(function(){
$('#debug').val('debugger ready!\n');
$('#jsboard area').mousedown(function(){
$('#debug').val('mousedown at ' + $(this).attr("alt") + ' \n');
})
});
-->
</script>

<div>
<img src="http://image.backgammonbase.com/image?gnubgid=4PPgAQPgc%2BQBIg%3AcAl7AAAAAAAA&height=262&width=341&css=nature&format=png" alt="4PPgAQPgc+QBIg:cAl7AAAAAAAA"
usemap="#jsboard" width="341" height="262">

<!--
point {width: 18; height:88}
-->

<map name="jsboard" id="jsboard">
<!--
point:data(13) {x: 25 ; y: 5 ; flip: True }
-->
<area id="13pt" shape="rect" coords="25,5,43,93" nohref="nohref" alt="13pt">

<!--
point:data(7) { x: 115 ; y: 139 }
-->
<area id="7pt" shape="rect" coords="115,139,133,227" nohref="nohref" alt="7pt">

<!--
bar {width: 25; height: 112; background: #583017}
bar[player=you] {x:133; y:116}
bar[player=you] chequer{x:137; y:135 ;y_offset: 18; max_count:4}
-->
<area id="yourbar" shape="rect" coords="133,116,158,228" nohref="nohref" alt="yourbar">

</map>

</div>
<div>
<form>
<textarea cols="40" rows="10" id="debug">
</textarea>
</form>
</div>

</body>
</html>