From: hayao Date: Sat, 7 Aug 2021 03:11:57 +0000 (+0900) Subject: [fix] : Use attribute instead of dataset X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=5b36cd85e8e0ffeead72ad9b7767822feab3a04d;p=alterlinux%2Fhayao.fascode.net.git [fix] : Use attribute instead of dataset --- diff --git a/sanmoku/script/init.js b/sanmoku/script/init.js index b911e2d..070a719 100644 --- a/sanmoku/script/init.js +++ b/sanmoku/script/init.js @@ -13,13 +13,15 @@ var InitilizeTable = function() { // ボックスの設定 td.innerText = InitialStr; // ボックスの文字を初期化する(空白に設定する) - td.dataset.clicked = false; // ボックスの状態を「クリックされていない」にする + //td.dataset.clicked = false; // ボックスの状態を「クリックされていない」にする + td.setAttribute("data-clicked", false); // ボックスの状態を「クリックされていない」にする // 座標を設定 - td.dataset.x = x; // X軸方向が同じグループを作成 - td.dataset.y = y; // Y軸方向が同じグループを作成 - var id = x+ "," + y - td.setAttribute("id", id) // ボックスIDを座標名で設定 + //td.dataset.x = x; // X軸方向が同じグループを作成 + //td.dataset.y = y; // Y軸方向が同じグループを作成 + td.setAttribute("data-x", x) + td.setAttribute("data-y", y) + td.setAttribute("id", x+ "," + y) // ボックスIDを座標名で設定 // ボックスを表示 td.addEventListener("click", ClickedBox) //ボックスがクリックされた時「ClickedBox」関数を実行する diff --git a/sanmoku/script/judgement.js b/sanmoku/script/judgement.js index aed1beb..79490d6 100644 --- a/sanmoku/script/judgement.js +++ b/sanmoku/script/judgement.js @@ -36,11 +36,15 @@ var Judgement =function() { //elements.forEach(function(e) { for(i=0; i -1; x--){ var y = TableXNumber - x - 1; var e = document.getElementById(x + "," + y); - if (e.dataset.clicked == "true" && e.dataset.player == p){ + if (e.getAttribute("data-clicked") == "true" && e.getAttribute("data-player") == p){ CheckedbyCurrentPlayerD.push(x + "," + y); } } diff --git a/sanmoku/script/main.js b/sanmoku/script/main.js index 6f85228..243ee29 100644 --- a/sanmoku/script/main.js +++ b/sanmoku/script/main.js @@ -9,15 +9,19 @@ var ClickedBox = function (e) { var MySelf = e.target // クリックされたボックスを取得する if (! GameEnded){ //もしゲームの状態が「終了」でなければ - - if (MySelf.dataset.clicked != "true"){ + if (MySelf.getAttribute("data-clicked") != "true"){ // クリックされたボックスの設定 MySelf.innerText = PlayerMarks[CurrentPlayer]; //クリックされたボックスのテキストをクリックしたプレーヤーの記号にする - MySelf.dataset.clicked = "true"; //ボックスの状態を「クリック済み」にする - MySelf.dataset.player = CurrentPlayer; // チェックしたプレーヤーのIDをボックスに書き込む + + //MySelf.dataset.clicked = "true"; //ボックスの状態を「クリック済み」にする + //MySelf.dataset.player = CurrentPlayer; // チェックしたプレーヤーのIDをボックスに書き込む + + MySelf.setAttribute("data-clicked", true) //ボックスの状態を「クリック済み」にする + MySelf.setAttribute("data-player", CurrentPlayer) // チェックしたプレーヤーのIDをボックスに書き込む // ログ - console.log(CurrentPlayer + "が " + MySelf.dataset.x + "," + MySelf.dataset.y + " をクリックしました") + //console.log(CurrentPlayer + "が " + MySelf.dataset.x + "," + MySelf.dataset.y + " をクリックしました") + console.log(CurrentPlayer + "が " + MySelf.getAttribute("data-x") + "," + MySelf.getAttribute("data-y") + " をクリックしました") // プレイヤーを変更する ChangePlayer();