//================================================== // Web-time Playing Board System for Renju // 2004/09/30~ // 2005/04/08~ // 2005/12/30~2006/12/02 // 2007/03/01~03/09 // 2007/03/23 Korean opening names //================================================== /*  */ var CURRENT_CALL = getCookie( "ID" ); var CALL_PLAYer = [ getCookie( "ID" ), "" ]; var HEAD_PLAYER = [ -1, -1 ]; var SORT_PLAYER = 'ID'; var ID_SPAN = 28; var TOTALs = 0; var FIND_COUNT = 0; var HAS_OPENed = false; var OTHER_AREA = []; var ACCESS_MESSAGE = ""; // var isNN = navigator.appName.indexOf( "Netscape" )!=-1; var RDFA_SPAN = 29; if( screen.height < 700 ){ RDFA_SPAN = 21; }else if( screen.height < 900 ){ RDFA_SPAN = 25; } RDFA_SPAN = 27; var MASK_NAME = "???"; var OPENing_FLAGs = {}; var ID_LIST = {}; var MINE_LIST = {}; var HEAD_HASH = [ {}, {} ]; var GAME_SERIAL = 0; var VIEW_SERIAL = 0; var FIND_COUNT = 0; var UNDO_LINE = ""; var CANNOT_SAME_OPENINGS = true; var WAIT_MESSAGE = "送信中です。\nしばらくお待ち下さい。"; var SERVER_CLOCK = 1714405464 - Math.floor( ( new Date() ).getTime() / 1000 ); var MY_OPENINGS = []; var GAME_LIST = { OPEN : {}, PLAY : {}, OVER : {} }; var GAME_HASH = []; var OPENing_FLAGs = { OPEN : { DIRECT : [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], INDIRECT : [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] }, RETURN : { DIRECT : [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], INDIRECT : [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] } }; var PLAYer_LIST = []; var HEAD = 0; var GAME_COUNT = 0; var OFFSET_HEAD = 0; var OFFSET_TAIL = 0; var GROUP_COUNT = 6; var CALL_GAME = []; //================================== // make object //================================== function player( nickName, ladderGrade, fromRegion ){ this.NICK = nickName; this.GRADE = ladderGrade; this.FROM = fromRegion; } //================================== // make tag command message //================================== function makeTagCommandMessage (){ return "
" + "
" + "" + "
"; } //================================== // command message //================================== function setCommandMessage( message, useButton ){ //--------------------------------- move command message box /* try{ with( isNN ? CATCH_AXIS : event ){ callFloatBox( 'COMMAND_MESSAGE', document.body.scrollLeft + x -20, document.body.scrollTop + y -20 ); } }catch( errorMSG ){ } */ with( document.getElementById( 'COMMAND_MESSAGE' ) ){ innerHTML = "

♠ " + message + "

" + ( useButton ? "" : "" ); style.display = 'block'; var boxWidth = clientWidth; } var Bobj = document.getElementById( 'COMMAND_MESSAGE' ).parentNode; // parent = FLOAT_HOME.COMMAND_MESSAGE = { // parent = X : Bobj.parentNode.parentNode.parentNode.offsetLeft + Bobj.offsetLeft, Y : Bobj.parentNode.parentNode.parentNode.offsetTop + Bobj.offsetTop }; FLOAT_HOME.COMMAND_MESSAGE.X += ( Bobj.clientWidth - boxWidth ) / 2; //--------------- standard function for FloatBox homeFloatBox( 'COMMAND_MESSAGE' ); location.hash = "#OPEN_LIST"; // document.getElementById( 'COMMAND_MESSAGE' ).style.display = 'block'; // location.hash = "#MESSAGE"; } function shutCommandMessage(){ document.getElementById( "COMMAND_MESSAGE" ).style.display = 'none'; } //================================== // submit by Ajax //================================== function submitWtPBS( searchString ){ setCommandMessage( sendingMessage( searchString.MODE ), false ); sendRequest( showRoom, searchString, "POST", "./WtPBSaccess.php", true, true ); } //================================== // show list //================================== function showRoom ( XRobj ){ try{ eval( XRobj.responseText ); }catch( errorMSG ){ } //----------------------------- nominated var hasOpenedBox = document.getElementById( 'HAS_OPENed' ); if( hasOpenedBox ){ hasOpenedBox.innerHTML = HAS_OPENed ? "
" : ""; } //----------------------------- other area var hasOtherAreaBox = document.getElementById( 'OTHER_AREA' ); if( hasOtherAreaBox ){ var tagString = ""; for( var AREAkey in OTHER_AREA ){ if( OTHER_AREA[ AREAkey ] ){ tagString += ""; tagString += ""; tagString += ""; } } hasOtherAreaBox.innerHTML = "
" + tagString + "
"; } document.getElementById( 'PLAYer_BOX1' ).innerHTML = makeTagPlayersSelecter( 0, 'PLAYER1' ); //---------------------------------- // set openings //---------------------------------- if( CANNOT_SAME_OPENINGS ){ setOpeningList(); } /* if( document.getElementById( 'PLAYER_NICK_BOX' ) ){ document.getElementById( 'PLAYER_SHOW_BOX' ).innerHTML = makeSelectPlayersTag( 'PLAY', 'PLAYER1', 'NICK', CALL_PLAYer[ 0 ] ); } if( document.getElementById( 'PLAYER_ID_BOX' ) ){ document.getElementById( 'PLAYER_ID_BOX' ).innerHTML = makeSelectPlayersTag( 'PLAY', 'PLAYER1', 'ID', CALL_PLAYer[ 0 ] ); } if( document.getElementById( 'PLAYER2_NICK_BOX' ) ){ document.getElementById( 'PLAYER2_SHOW_BOX' ).innerHTML = makeSelectPlayersTag( 'PLAY', 'PLAYER2', 'NICK', CALL_PLAYer[ 1 ] ); } if( document.getElementById( 'PLAYER2_ID_BOX' ) ){ document.getElementById( 'PLAYER2_ID_BOX' ).innerHTML = makeSelectPlayersTag( 'PLAY', 'PLAYER2', 'ID', CALL_PLAYer[ 1 ] ); } */ if( document.getElementById( 'TOTAL_GAMEs' ) ){ document.getElementById( 'TOTAL_GAMEs' ).innerHTML = TOTALs; } if( document.getElementById( 'SEARCH_GAMEs' ) ){ document.getElementById( 'SEARCH_GAMEs' ).innerHTML = FIND_COUNT; } try{ with( document.getElementById( 'FORM_PLAY' ) ){ setAttribute( 'WAITing', null ); // WAITing = false; MESSAGE.value = ""; } }catch( errorMSG ){ alert( errorMSG ); } GAME_HASH = []; for( var GMnum in GAME_LIST.PLAY ){ GAME_HASH = GAME_HASH.concat( [ parseInt( GMnum ) ] ); } var mineID = getCookie( 'ID' ); GAME_HASH.sort( function( Anum, Bnum ){ var Alist = GAME_LIST.PLAY[ Anum ]; var Blist = GAME_LIST.PLAY[ Bnum ]; var Aget = 0; var Bget = 0; with( Alist ){ Aget += ( getNextTurn( GEM_LINE ) ? BLACK : WHITE ) == mineID ? (STATUS == 'P' ? 100 : 50) : 0; Aget += GEM_LINE.match( /@\-/ ) ? 10 : 0; Aget += STATUS == 'P' ? 0 : 1; } with( Blist ){ Bget += ( getNextTurn( GEM_LINE ) ? BLACK : WHITE ) == mineID ? (STATUS == 'P' ? 100 : 50) : 0; Bget += GEM_LINE.match( /@\-/ ) ? 10 : 0; Bget += STATUS == 'P' ? 0 : 1; } if( Aget != Bget ){ return Aget < Bget ? 1 : -1; } return 0; } ); viewGame( 'PLAY', VIEW_SERIAL ? VIEW_SERIAL : GAME_HASH.length ? GAME_HASH[ 0 ] : 0 ); document.getElementById( 'GAME_TABLE' ).innerHTML = makeGameTable(); if( document.getElementById( 'GAME_SELECTER_BOX' ) ){ document.getElementById( 'GAME_SELECTER_BOX' ).innerHTML = makeTagGameSelecterTag( 'PLAY', 'GAMEs', 'NICK' ); } if( ACCESS_MESSAGE ){ setCommandMessage( ( ACCESS_MESSAGE ? accessMessage( ACCESS_MESSAGE ) : "You got it !" ), true ); }else{ if( WtPBS_COMMAND == 'view' ){ shutCommandMessage(); }else{ setCommandMessage( WtPBS_COMMAND, true ); } setTimeout( shutCommandMessage, 5000 ); } } //================================== // call by iframe // // mode: OPEN, JOIN, .... //================================== function callWtPBS( mode, gameSerial ){ VIEW_SERIAL = gameSerial; try{ var getGemLine = "" + document.applets[0].getGemLine(); }catch( errorMSG ){ status = "read applets error"; } var memo = 0; var searchObj = { AREA : "FengChu004", ROOM : "PLAY", PLAYER1 : CALL_PLAYer[ 0 ], PLAYER2 : CALL_PLAYer[ 1 ], HEAD_PLAYER_1 : HEAD_PLAYER[ 0 ], HEAD_PLAYER_2 : HEAD_PLAYER[ 1 ] }; try{ var FOobj = document.getElementById( 'FORM_OPEN' ); var FPobj = document.getElementById( 'FORM_PLAY' ); var FVobj = document.getElementById( 'FORM_OVER' ); var FGobj = document.getElementById( 'FORM_GTB' ); if( GAME_LIST.PLAY && GAME_LIST.PLAY[ gameSerial ] ){ searchObj.GEM_LINE = GAME_LIST.PLAY[ gameSerial ].GEM_LINE; }else{ searchObj.GEM_LINE = ""; } if( mode == 'view' ){ searchObj.MODE = 'view'; searchObj.SERIAL = 0; if( document.getElementById( 'VIEW_NAME_NICK' ).checked ){ searchObj.SORT_PLAYER = "NICK"; }else{ searchObj.SORT_PLAYER = "ID"; } submitWtPBS( searchObj ); } //--------------------------------------- open new game if( mode == 'open' ){ searchObj.MODE = 'new'; with( FOobj ){ searchObj.FLAGs = ""; if( STATUS_UNDO.checked ){ searchObj.FLAGs += "U"; } if( STATUS_EXTRA.checked ){ searchObj.FLAGs += "E"; } if( STATUS_VIEW.checked ){ searchObj.FLAGs += "V"; } for( var Onum=0; Onum" : callFrom ); } //=================================== // make Players Selecter tag //=================================== function setPlayers( Sobj ){ var IDkey = Sobj.value; var PIobj = document.getElementById( 'PLAYER_INFOMATION' ); if( IDkey == '*' ){ PIobj.innerHTML = "ここに、指名者の情報が出ます"; }else if( ID_LIST[ IDkey ] ){ with( ID_LIST[ IDkey ] ){ PIobj.innerHTML = "
" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + ""; } }else{ Sobj.blur(); HEAD_PLAYER[ 0 ] = IDkey; callWtPBS( 'view', 0 ); } } //================================ // change search //================================ function changeSearch ( key2val ) { var getSearch = location.search; getSearch = getSearch.replace( /^(\?|&)/, "" ) + "&"; with( key2val ){ for( var KEYnum in key2val ){ getSearch = getSearch.replace( new RegExp( KEYnum + "=[^&]*&", "g" ), "" ) + KEYnum + "=" + key2val[ KEYnum ] + "&"; } } location.search = "?" + getSearch.replace( /&$/, "" ); } //================================== // call player //================================== function callPlayer( playerNumber, Sobj ){ var IDkey = Sobj.value; Sobj.blur(); if( IDkey == '*' ){ HEAD_PLAYER[ playerNumber ] = -1; CALL_PLAYer[ playerNumber ] = '*'; }else if( ID_LIST[ IDkey ] ){ HEAD_PLAYER[ playerNumber ] = ID_LIST[ IDkey ].HEAD; CALL_PLAYer[ playerNumber ] = IDkey; }else{ HEAD_PLAYER[ playerNumber ] = IDkey; } callWtPBS( 'view', 0 ); } //================================== // next player //================================== function nextPlayer( playerNumber, Sobj ){ var IDkey = Sobj.value; if( IDkey == '*' ){ HEAD_PLAYER[ playerNumber ] = -1; }else if( ID_LIST[ IDkey ] ){ for( var HHnum in HEAD_HASH[ playerNumber ] ){ if( IDkey == HEAD_HASH[ playerNumber ][ HHnum ] ){ HEAD_PLAYER[ playerNumber ] = parseInt( HHnum ); break; } } }else{ Sobj.blur(); HEAD_PLAYER[ playerNumber ] = IDkey; callWtPBS( 'over', 0 ); } } /* submitWtPBS( { MODE : 'view', AREA : "FengChu004", ROOM : "PLAY", LANGUAGE : "JPN", PLAYER1 : IDkey } ); */ //=================================== // make tag Players Selecter // // SORT_PLAYER : ID/NICK/GRADE // TOTAL_MEMBERs // HEAD_PLAYER //=================================== function makeTagPlayersSelecter( hashNumber, CGIkey ){ var isMainShow = SORT_PLAYER == 'NICK'; var tagString = ""; return tagString; } //================================== // set Opening //================================== function setOpening ( OpeningGemLine ){ var getBoard = document.applets[0].getGemLine()+""; if( !getBoard.match( /a4/ ) && !getBoard.match( /A0[a-o][A-O]/ ) ){ document.applets[0].setGemLineString( OpeningGemLine ); } } //======================================================================================================= // set Opening selecter used color // // OPENing_FLAGs /* OPENing_FLAGs.OPEN.DIRECT = [ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 ]; OPENing_FLAGs.OPEN.INDIRECT = [ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0 ]; OPENing_FLAGs.RETURN.DIRECT = [ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0 ]; OPENing_FLAGs.RETURN.INDIRECT = [ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0 ]; OPENINGs_LIST.INDIRECT[ 26 ].TITLE = '大彗星'; OPENINGs_LIST.DIRECT[ 1 ].SHAPE = 'A1HHa2HGA3HF'; */ //======================================================================================================= function setOpeningList(){ with( document.getElementById( 'MY_OPENINGs' ) ){ for( var Onum = 0; Onum < 13; Onum ++ ){ options[ Onum + 13 * 0 ].style.backgroundColor = OPENing_FLAGs.OPEN.DIRECT[ Onum ] ? "orange" : "transparent"; options[ Onum + 13 * 1 ].style.backgroundColor = OPENing_FLAGs.OPEN.INDIRECT[ Onum ] ? "orange" : "transparent"; options[ Onum + 13 * 2 ].style.backgroundColor = OPENing_FLAGs.OPEN.DIRECT[ Onum + 13 ] ? "orange" : "transparent"; options[ Onum + 13 * 3 ].style.backgroundColor = OPENing_FLAGs.OPEN.INDIRECT[ Onum + 13 ] ? "orange" : "transparent"; } } } //======================================================================================================= // make Opening selecter tag // // OPENing_FLAGs //======================================================================================================= function makeTagOpeningSelecter(){ var makeTag = ""; return makeTag; } //======================================= // is right opening //======================================= function isRightOpening( OpeningGemLine ){ //------------------ opener if( !OpeningGemLine || getLastMove( OpeningGemLine ) < 3 ){ return( "珠型を打って下さい。" ); } //------------------ set gem line var thisOpeningNumber = getOpeningNumber( OpeningGemLine ); var thisOpeningName = getOpeningName( OpeningGemLine ); var errorOpening = null; if( thisOpeningNumber ){ if( CANNOT_SAME_OPENINGS && OPENing_FLAGs.OPEN[ 0 < thisOpeningNumber ? "DIRECT" : "INDIRECT" ][ Math.abs( thisOpeningNumber ) - 1 ] ){ errorOpening = "この珠型は既に使われています。\n26珠型を使い切らないと同じ珠型を提示できません。"; } if( !OpeningGemLine.match( /A0[A-O]{2}/ ) ){ errorOpening = "題数分のベタ珠を打って下さい。"; } }else{ errorOpening = "未知の珠型は提示できません。"; } return( errorOpening ); } //=================================================================================================== // draw game table // REG_ID is impossible // [70,'LLIO','',1096915601,'0V',60,['*',0,0,0],['LLIO',0,0,0],'A1HH!---',[[0,'8^-^8']]], // mode = 0:Open/1:Play/2:Hold/3:Over //=================================================================================================== function makeGameTable(){ var mineID = ''; var tagString = ""; //--------------------------- draw table tagString += "
NICK" + NICK + "段級" + makeTitleText( TITLE ) + "
ID" + IDkey + "グレード" + ( GRADE + 1 ) + "
来自" + makeFromFlagTag( FROM ) + "
"; tagString += "" + "" + "" + ""; tagString += ""; //--------------------------- header tag var headerString = ""; headerString += ""; headerString += ""; headerString += ""; /* headerString += ""; */ headerString += ""; headerString += ""; headerString += ""; headerString += ""; /* headerString += ""; */ headerString += ""; var buttonList = { cancel : { TITLE : "取消", CONFIRM : "取消 ?" }, join : { TITLE : "参加", CONFIRM : "参加 ?" }, call : { TITLE : getShowName( mineID ), CONFIRM : "参加 ?" } /* "指名" */ }; var linePos = 0; var joinableList = []; for( var Gpos in GAME_HASH ){ var Gnum = GAME_HASH[ Gpos ]; var pickUpGame = GAME_LIST.PLAY[ Gnum ]; //---------------------------- header if( linePos % 10 == 0 ){ tagString += headerString; } //---------------------------- header tagString += ""; //----------------------------------------------- // game number [OPEN:rare/PLAY:button] //----------------------------------------------- tagString += ""; with( pickUpGame ){ var thisOpeningNumber = getOpeningNumber( GEM_LINE ); var thisOpeningName = getOpeningName( GEM_LINE ); var ImOWNer = mineID == OWNer; // var isRandom = BLACK != '*' && !GEM_LINE.match( /A1HH/ ); var gameInfomation = ""; if( thisOpeningNumber ){ // %2b%2bAA gameInfomation += "
"; } if( FLAGs.match( /L/ ) ){ gameInfomation += makeTagGameStatus( 'L', false, 'width:1em;height:1em;margin:0px 0.2ex;' ); } //----------------------------------------------- // access button //----------------------------------------------- var ButtonName = "view"; var turnColor = getTurnColor( pickUpGame, mineID ); //------------------ names tagString += ""; tagString += ""; tagString += ""; tagString += ""; //---------- status tagString += ""; tagString += ""; tagString += ""; // tagString += ""; //---------- limit tagString += ""; /* //---------- open date or last move if( isOpen ){ with( new Date( pickUpGame.DATE_OPEN * 1000 ) ){ tagString += ""; } }else{ tagString += ""; } */ //---------- message var getMessage = "
" + new Date( DATE_OPEN * 1000 ).toLocaleString() + "
"; if( MESSAGE_LIST[ Gnum ] && MESSAGE_LIST[ Gnum ].length ){ with( MESSAGE_LIST[ Gnum ][ MESSAGE_LIST[ Gnum ].length - 1 ] ){ if( pickUpGame.DATE_LAST < POST_DATE ){ getMessage = ID + " [" + MOVE + "] " + MESSAGE; } } } tagString += ""; //---------------------------- close tagString += ""; //----------------------------------------------- // 2nd stair // opening/random //----------------------------------------------- tagString += ""; if( gameInfomation ){ tagString += ""; }else{ tagString += ""; tagString += ""; } tagString += ""; } //---------------------------- count up linePos ++; } tagString += "
No. "; headerString += " "; headerString += "設定"+( isOpen ? "開局日" : "最終珠" ) + "一言
情報持日数
" + "" + "" + getShowName( BLACK ) + "  " + getShowName( WHITE ) + "" + ( FLAGs.match( /U/ ) ? makeTagGameStatus( 'U', false, 'width:1em;height:1em;' ) : ' ' ) + "" + ( FLAGs.match( /E/ ) ? makeTagGameStatus( 'E', false, 'width:1em;height:1em;' ) : ' ' ) + "" + ( FLAGs.match( /V/ ) ? ' ' : makeTagGameStatus( 'H', false, 'width:1em;height:1em;' ) ) + "" + ( FLAGs.match( /([ML])/ ) ? makeTagGameStatus( RegExp.$1, false, 'width:1em;height:1em;' ) : ' ' ) + "" + ( pickUpGame.LIMIT ? pickUpGame.LIMIT : "無制限" ) + "" + toLocaleDateString() + "" + getLastMove( pickUpGame.GEM_LINE ) + "" + getMessage + "
"; tagString += gameInfomation; tagString += "  
"; return( tagString ); } //============================================== // get NICK_NAME or ID //============================================== function getShowName( IDkey ){ return( ID_LIST[ IDkey ] && ID_LIST[ IDkey ].NICK ? ID_LIST[ IDkey ].NICK : "(" + IDkey + ")" ); } //============================== // make title text //============================== function makeTitleText ( titleKey ){ return [ '9級','8級','7級','6級','5級','4級','3級','2級','1級','無級','初段','二段','三段','四段','五段','六段','七段','八段','九段' ][ 9 + titleKey ]; } //============================================== // make turn color string //============================================== function getTurnColor( pickUpGame, mineID ){ with( { WINner : "#aaf", DReW : "#9f9", // palegreen MY_TURN : "#f66", IS_TURN : "#f90", // UNDO_COLOR : "yellow", NONE : "transparent" } ){ if( pickUpGame.STATUS == 'P' ){ var isTurn = getLastMove( pickUpGame.GEM_LINE ) & 1; var retColor = ( pickUpGame.GEM_LINE.match( /@\-/ ) ? [ pickUpGame[ isTurn ? "WHITE" : "BLACK" ] == mineID ? MY_TURN : IS_TURN, pickUpGame[ isTurn ? "BLACK" : "WHITE" ] == mineID ? MY_TURN : IS_TURN ] : [ pickUpGame[ isTurn ? "WHITE" : "BLACK" ] == mineID ? MY_TURN : IS_TURN, NONE ] ); if( isTurn ){ retColor.reverse(); } return { BLACK : retColor[ 0 ], WHITE : retColor[ 1 ] }; }else if( pickUpGame.STATUS.match( /B/i ) ){ return { BLACK : WINner, WHITE : NONE }; }else if( pickUpGame.STATUS == 'W' || pickUpGame.STATUS == 'w' ){ return { BLACK : NONE, WHITE : WINner }; }else if( pickUpGame.STATUS == 'D' ){ return { BLACK : DReW, WHITE : DReW }; } return { BLACK : NONE, WHITE : NONE }; } } //============================================== // trans gem line for send //============================================== function replaceNumberlessGems ( GemLine ){ GemLine = GemLine.replace( /A0n./g, "" ); //---------------------------------- A0 to couner var newGemLine = ""; var gem5th = 0; for( var pos=0; pos" : "
"; tagString += "" + // "onclick='try{ document.getElementById( \"GAME_SELECTER_BOX\" ).innerHTML = " + // "makeTagGameSelecterTag( \"PLAY\", \"GAMEs\", \"ID\" ); }catch( errorMSG ){}'>" + ""; tagString += "" + // "onclick='try{ document.getElementById( \"GAME_SELECTER_BOX\" ).innerHTML = " + // "makeTagGameSelecterTag( \"PLAY\", \"GAMEs\", \"NICK\" ); }catch( errorMSG ){}'>" + ""; tagString += useForm ? "" : "
"; return tagString; } //************************************************************************************************ //************************************************************************************************ //************************************************************************************************ //=============================== // game selecter tag //=============================== function makeTagGameSelecterTag( roomType, formID, showType ){ showType = SORT_PLAYER == 'NICK' ? 'NICK' : 'ID'; var tagKey = formID + ( showType == 'NICK' ? "_NICK" : "" ); var tagKey = formID; var makeTag = ""; return( hasGame ? makeTag : "
no games
" ); } function viewGame ( roomType, valueNumber ){ var mineID = getCookie( 'ID' ); var gameSerial = valueNumber; if( roomType == 'OVER' ){ if( !HEAD_LIST[ valueNumber ] && 0 < FIND_COUNT ){ if( FIND_COUNT <= valueNumber ){ valueNumber = 0; } callWtPBS( 'over', Math.min( FIND_COUNT, valueNumber ) ); return; } gameSerial = HEAD_LIST[ valueNumber ]; } if( isNaN( gameSerial ) || gameSerial == 0 ){ clearBoard (); return 0; } //--------------------------- get game data var getGame = GAME_LIST[ roomType ][ gameSerial ]; if( getGame == null ){ clearBoard (); return; } GAME_SERIAL = gameSerial; //----------------- set names var turnColor = getTurnColor( getGame, mineID ); var nameBlack = getGame.BLACK; var nameWhite = getGame.WHITE; with( document ){ with( getElementById( 'BLACK_ID' ) ){ innerHTML = nameBlack; style.backgroundColor = turnColor.BLACK; } with( getElementById( 'WHITE_ID' ) ){ innerHTML = nameWhite; style.backgroundColor = turnColor.WHITE; } with( getElementById( 'BLACK_NICK' ) ){ innerHTML = getShowName( nameBlack ); style.backgroundColor = turnColor.BLACK; } with( getElementById( 'WHITE_NICK' ) ){ innerHTML = getShowName( nameWhite ); style.backgroundColor = turnColor.WHITE; } } //---------------------------------- time [ add last time ] var Bsec = getGame.TIME_BLACK; var Wsec = getGame.TIME_WHITE; if( getGame.STATUS == 'P' ){ // var addClock = Math.floor( ( new Date () ).getTime() / 1000 ) + SERVER_CLOCK - getGame.DATE_LAST; var addClock = getAddTime( getGame.DATE_LAST ); if( getNextTurn( getGame.GEM_LINE ) ){ Bsec += addClock; }else{ Wsec += addClock; } } with( document ){ // getElementById( 'BLACK_TIME' ).innerHTML = makeUseTimeString( getGame.TIME_BLACK ) + "
" + makeUseTimeString( Bsec ); // getElementById( 'WHITE_TIME' ).innerHTML = makeUseTimeString( getGame.TIME_WHITE ) + "
" + makeUseTimeString( Wsec ); getElementById( 'BLACK_TIME' ).innerHTML = makeUseTimeString( Bsec ); getElementById( 'WHITE_TIME' ).innerHTML = makeUseTimeString( Wsec ); } var formNumber = 0; //------------------- status var statusString = ""; with( getGame.FLAGs ){ if( match( /U/ ) ){ statusString += makeTagGameStatus( 'U', true, 'margin:0.5ex;' ); } if( match( /E/ ) ){ statusString += makeTagGameStatus( 'E', true, 'margin:0.5ex;' ); } if( match( /M/ ) ){ statusString += makeTagGameStatus( 'M', true, 'margin:0.5ex;' ); } if( match( /L/ ) ){ statusString += makeTagGameStatus( 'L', true, 'margin:0.5ex;' ); } if( match( /R/ ) ){ statusString += makeTagGameStatus( 'R', true, 'margin:0.5ex;' ); } if( !match( /V/ ) ){ statusString += makeTagGameStatus( 'H', true, 'margin:0.5ex;' ); } } document.getElementById( 'STATUS_BOX' ).innerHTML = statusString; //------------------- days limit document.getElementById( 'DAYs_LIMIT' ).innerHTML = ( getGame.LIMIT ? ( getGame.LIMIT + "日" ) : "無制限" ); //------------------- turns var viewGemLine = getGame.GEM_LINE; var lastMove = getLastMove( viewGemLine ); var hasSwap = viewGemLine.match( /\$[X|=]/ ); var openTurnList = [ [ "示", "#ccc" ], [ "択", "transparent" ] ]; if( hasSwap ){ openTurnList.reverse(); } with( document ){ with( getElementById( 'OPEN_BLACK' ) ){ innerHTML = openTurnList[ 0 ][ 0 ]; style.backgroundColor = openTurnList[ 0 ][ 1 ]; } with( getElementById( 'OPEN_WHITE' ) ){ innerHTML = openTurnList[ 1 ][ 0 ]; style.backgroundColor = openTurnList[ 1 ][ 1 ]; } if( ( hasSwap ? 2 : 3 ) < lastMove ){ with( getElementById( 'TURN_BLACK' ) ){ style.backgroundColor = "black"; style.color = "white"; innerHTML = "黒"; } with( getElementById( 'TURN_WHITE' ) ){ style.backgroundColor = "white"; style.color = "black"; innerHTML = "白"; } }else{ with( getElementById( 'TURN_BLACK' ) ){ innerHTML = "-"; style.backgroundColor = "white"; style.color = "black"; } with( getElementById( 'TURN_WHITE' ) ){ innerHTML = "-"; style.backgroundColor = "white"; style.color = "black"; } } } //------------------- set RDFA var appletNumber = 0; with( getGame ){ if( FLAGs.match( /L/ ) && ( lastMove == 4 || ( lastMove == 3 && hasSwap ) ) ){ var gradePlus = Math.floor( GRADE / 10 ) - GRADE % 10; if( 0 < gradePlus ){ viewGemLine = viewGemLine.replace( /(A0n.)*A0oO/, "A0nOA0nNA0nMA0nL".substr( 0, gradePlus * 4 ) + "A0oO" ); GEM_LINE = viewGemLine; } } } // document.applets[ appletNumber ].setGemLineString( viewGemLine ); document.applets[ appletNumber ].setGemLineString( viewGemLine + ( roomType == 'OVER' ? getGame.UNDO : "" ) ); //------------------------------- show caption if( roomType == 'PLAY' ){ document.getElementById( 'PROMPT' ).innerHTML = makeCaption( getGame ); } //------------------------------- show caption with( document.getElementById( 'MESSAGE_BOX' ) ){ scrollTop = 0; innerHTML = makeMessage( GAME_SERIAL, getGame, 'fore' ) + "
" + "
最終着手: " + ( new Date( getGame.DATE_LAST * 1000 ) ).toLocaleString() + "
" + makeMessage( GAME_SERIAL, getGame, 'hind' ); //---------------------------------- box slide to bottom !!!! (2004/10/05) // scrollTop = scrollHeight; // scrollTop = memoPosition; } setTimeout( "with( document.getElementById( 'MESSAGE_BOX' ) ){ scrollTop = scrollHeight; }", 1000 ); //------------------- game selecter with( document ){ if( getElementById( 'GAMEs' ) ){ getElementById( 'GAMEs' ).value = valueNumber; } if( getElementById( 'GAMEs_SHOW' ) ){ getElementById( 'GAMEs_SHOW' ).value = valueNumber; } getElementById( 'GAME_NUMBER' ).innerHTML = "対局 No." + GAME_SERIAL + ""; } } //=========================================== // get add time //=========================================== function getAddTime( lastTime ){ return Math.floor( new Date().getTime() / 1000 ) + SERVER_CLOCK - lastTime; } //=========================================== // clear board //=========================================== function clearBoard (){ //----------------- set names with( document ){ with( getElementById( 'BLACK_ID' ) ){ innerHTML = "-"; style.backgroundColor = "transparent"; } with( getElementById( 'WHITE_ID' ) ){ innerHTML = "-"; style.backgroundColor = "transparent"; } with( getElementById( 'BLACK_NICK' ) ){ innerHTML = "8^-^8"; style.backgroundColor = "transparent"; } with( getElementById( 'WHITE_NICK' ) ){ innerHTML = "8^-^8"; style.backgroundColor = "transparent"; } //---------------------------------- time [ add last time ] getElementById( 'BLACK_TIME' ).innerHTML = "0"; getElementById( 'WHITE_TIME' ).innerHTML = "0"; //------------------- game status getElementById( 'STATUS_BOX' ).innerHTML = "?"; //------------------- days limit getElementById( 'DAYs_LIMIT' ).innerHTML = "0"; //------------------- turns with( getElementById( 'OPEN_BLACK' ) ){ innerHTML = "-"; style.backgroundColor = "transparent"; } with( getElementById( 'OPEN_WHITE' ) ){ innerHTML = "-"; style.backgroundColor = "transparent"; } with( getElementById( 'TURN_BLACK' ) ){ innerHTML = "-"; style.backgroundColor = "white"; style.color = "black"; } with( getElementById( 'TURN_WHITE' ) ){ innerHTML = "-"; style.backgroundColor = "white"; style.color = "black"; } //------------------------------- show caption getElementById( 'MESSAGE_BOX' ).innerHTML = "no games"; if( getElementById( 'PROMPT' ) ){ getElementById( 'PROMPT' ).innerHTML = "8^-^8"; } //------------------- game selecter getElementById( 'GAME_NUMBER' ).innerHTML = "対局 No.?"; //------------------- set RDFA var appletNumber = 0; applets[ appletNumber ].setGemLineString( "$8FH$^GH$-HH$^IH$8JH" ); } } //=========================================== // clear board //=========================================== function resetBoard ( gameSerial ){ try{ document.applets[ 0 ].setGemLineString( GAME_LIST[ 'OVER' ][ gameSerial ].GEM_LINE ); }catch( errorMSG ){ } /* if( isNaN( gameSerial ) || gameSerial == 0 ){ return; } //--------------------------- get game data var getGame = GAME_LIST[ 'OVER' ][ gameSerial ]; if( getGame == null ){ return; } document.applets[ appletNumber ].setGemLineString( viewGemLine ); */ } //================================= // message open //================================= function openMessage( roomType, serial ){ Wobj = window.open( "./Message.html","WtPBS_MESSAGEs","width=500,height=600,dependent=yes,directories=no,personalbar=no,location=no,menubar=no,toolbar=no,status=no,resizable=yes,scrollbars=yes"); if( Wobj ){ with( Wobj.document ){ open(); write( makeMessage( serial, GAME_LIST[ roomType ][ serial ], 'fore' ), makeMessage( serial, GAME_LIST[ roomType ][ serial ], 'hind' ) ); close(); title = "Game No." + serial; with( body ){ scrollTop = scrollHeight; } focus(); } } } //================================= // make use time string //================================= function makeUseTimeString ( showSec ){ var showDays = Math.floor( showSec / ( 3600 * 24 ) ); with( new Date( showSec % ( 3600 * 24 ) * 1000 ) ){ return( ( showDays ? showDays + "日 " : "" ) + ( showDays || getUTCHours() ? ( getUTCHours() < 10 ? "0" : "" ) + getUTCHours() + ":" : "" ) + ( showDays || getUTCHours() || getUTCMinutes() ? ( getUTCMinutes() < 10 ? "0" : "" ) + getUTCMinutes() + ":" : "" ) + ( getUTCSeconds() < 10 ? "0" : "" ) + getUTCSeconds() + "" ); } } //================================= // make message string //================================= function makeMessage ( gameNumber, getGame, requestFore ){ var IDblack = getGame.BLACK; var IDwhite = getGame.WHITE; var lastDate = getGame.DATE_LAST; //--------------- message set var tagString = ""; var gameMessage = MESSAGE_LIST[ gameNumber ]; if( !gameMessage ){ return requestFore == 'fore' ? "
no message
" : ""; } for( var Mnum in gameMessage ){ var moveList = gameMessage[ Mnum ]; with( moveList ){ if( requestFore == 'fore' ? ( lastDate <= POST_DATE ) : ( POST_DATE < lastDate ) ){ continue; } var showName = getShowName( ID ); var backColor = "transparent"; if( ID == IDblack ){ backColor = "cyan"; }else if( ID == IDwhite ){ backColor = "palegreen"; } tagString += "
"; tagString += "[" + MOVE + "] " + showName + "> "; if( MESSAGE.match( /^\{.*MODE.+\}$/ ) ){ try{ eval( "var MSGobj = " + MESSAGE ); if( MSGobj.MODE ){ with( MSGobj ){ if( MODE == 'time' ){ tagString += "
" + "last move = " + new Date( LAST_TIME * 1000 ).toLocaleString() + "
" + "black time = " + makeUseTimeString( BLACK_TIME ) + "
" + "white time = " + makeUseTimeString( WHITE_TIME ) + "
"; } } } }catch( errorMSG ){ tagString += "error data"; } }else{ tagString += MESSAGE; } tagString += "
" + ( new Date( POST_DATE * 1000 ) ).toLocaleString() + "
"; tagString += "
"; } } return tagString; } //=============================== // make game status //=============================== function makeTagGameStatus( gameStatus, size, styleString ){ with( { U : { GIF : 'Undo', ALT : "待った" }, E : { GIF : 'Extra', ALT : "代打ち" }, H : { GIF : 'Hide', ALT : "密局w" }, R : { GIF : 'Random', ALT : "示択握り" }, M : { GIF : 'Mask', ALT : "覆面打ち" }, L : { GIF : 'Ladder', ALT : "梯子打ち" } }[ gameStatus ] ){ return( "" + ALT + "" ); } } //=============================== // get Last Move //=============================== function getLastMove ( GemLine ){ if( GemLine.match( /@_/ ) && !GemLine.match( /A5/ ) ){ return 5; } var Gnum = GemLine.indexOf("!---"); if( Gnum == -1 ){ Gnum = GemLine.length; } while( Gnum ){ Gnum -= 4; // var gn = GemLine.charAt(Gnum).toUpperCase(); var gn = GemLine.substr(Gnum,1).toUpperCase(); var xp = GemLine.charAt(Gnum+2); if(gn<'A' || 'Z'" + Lkey + ""; } tagString += ""; var doronString = "document.getElementById(\"FLOAT_MENU\").style.display=\"none\";"; var lineString = ""; for( var Lkey in linkList ){ lineString += ""+ "●" + linkList[ Lkey ].TITLE + ""+ ""; } tagString += ""; document.write( tagString ); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // window double click //_________________________________________ document.ondblclick = function() { try{ document.getElementById( "FLOAT_MENU" ).style.display = "block"; with( isNN ? CATCH_AXIS : event ){ callFloatBox( "FLOAT_MENU", document.body.scrollLeft + x -20, document.body.scrollTop + y -20 ); } }catch( errorMSG ){ } }