(function(WGo, undefined){ "use strict"; var prepare_dom = function() { this.box = document.createElement("div"); this.box.className = "wgo-box-wrapper wgo-comments-wrapper"; this.element.appendChild(this.box); this.comments_title = document.createElement("div"); this.comments_title.className = "wgo-box-title"; this.comments_title.innerHTML = WGo.t("comments"); this.box.appendChild(this.comments_title); this.comments = document.createElement("div"); this.comments.className = "wgo-comments-content"; this.box.appendChild(this.comments); this.help = document.createElement("div"); this.help.className = "wgo-help"; this.help.style.display = "none"; this.comments.appendChild(this.help); this.notification = document.createElement("div"); this.notification.className = "wgo-notification"; this.notification.style.display = "none"; this.comments.appendChild(this.notification); this.comment_text = document.createElement("div"); this.comment_text.className = "wgo-comment-text"; this.comments.appendChild(this.comment_text); } var mark = function(move) { var x,y; x = move.charCodeAt(0)-'a'.charCodeAt(0); if(x < 0) x += 'a'.charCodeAt(0)-'A'.charCodeAt(0); if(x > 7) x--; y = (move.charCodeAt(1)-'0'.charCodeAt(0)); if(move.length > 2) y = y*10+(move.charCodeAt(2)-'0'.charCodeAt(0)); y = this.kifuReader.game.size-y; this._tmp_mark = {type:'MA', x:x, y:y}; this.board.addObject(this._tmp_mark); } var unmark = function() { this.board.removeObject(this._tmp_mark); delete this._tmp_mark; } var search_nodes = function(nodes, player) { for(var i in nodes) { if(nodes[i].className && nodes[i].className == "wgo-move-link") { nodes[i].addEventListener("mouseover", mark.bind(player, nodes[i].innerHTML)); nodes[i].addEventListener("mouseout", unmark.bind(player)); } else if(nodes[i].childNodes && nodes[i].childNodes.length) search_nodes(nodes[i].childNodes, player); } } var format_info = function(info, title) { var ret = '
"+WGo.filterHTML(comment).replace(/\n/g, "
")+"
"; if(formatNicks) comm = comm.replace(/()([^:]{3,}:)\s/g, '
$2 '); if(formatMoves) comm = comm.replace(/\b[a-zA-Z]1?\d\b/g, '$&'); return comm; } return ""; }; /** * Adding 2 configuration to BasicPlayer: * * - formatNicks: tries to highlight nicknames in comments (default: true) * - formatMoves: tries to highlight coordinates in comments (default: true) */ WGo.BasicPlayer.default.formatNicks = true; WGo.BasicPlayer.default.formatMoves = true; WGo.BasicPlayer.attributes["data-wgo-formatnicks"] = function(value) { if(value.toLowerCase() == "false") this.formatNicks = false; } WGo.BasicPlayer.attributes["data-wgo-formatmoves"] = function(value) { if(value.toLowerCase() == "false") this.formatMoves = false; } WGo.BasicPlayer.layouts["right_top"].right.push("CommentBox"); WGo.BasicPlayer.layouts["right"].right.push("CommentBox"); WGo.BasicPlayer.layouts["one_column"].bottom.push("CommentBox"); WGo.i18n.en["comments"] = "Comments"; WGo.i18n.en["gameinfo"] = "Game info"; WGo.BasicPlayer.component.CommentBox = CommentBox })(WGo);