casino's People
casino's Issues
Right Click Issues
Figured a bit out, right clicking works when I don't have my Chrome inspector open...it doesn't work when I have the Chrome inspector open. I have no idea why, but if it's a bug with Chrome and not my code I'm fine with leaving it. I'm keeping this open in case it's something that I'm doing incorrectly with my code.
I've been trying to implement right clicking for flagging and it is not working. I've tried pretty much every method described that I've seen so it must be how I'm setting things up. The context menu still appears and the right click function is not called.
function createBoard(playerOne) {
populateMines(playerOne);
let grid = document.createElement('table');
let gameBoard = document.getElementById('game-board');
grid.className = 'grid';
gameBoard.appendChild(grid);
let elementArr = new Object(playerOne.size);
for (let i = 0; i < playerOne.size; i++) {
let tr = grid.appendChild(document.createElement('tr'));
elementArr[i] = new Object(playerOne.size);
for (let k = 0; k < playerOne.size; k++) {
elementArr[i][k] = addSquare(i, k, tr, playerOne);
}
}
playerOne.elementArr = elementArr;
}
function addSquare(i, k, tr, playerOne) {
let cell = tr.appendChild(document.createElement('td'));
let spaceElement = document.createElement('img');
spaceElement.setAttribute('data-id', playerOne.mineArr[i][k].value);
spaceElement.setAttribute('src', 'images/MinesweeperImages/Minesweeper_0.png');
spaceElement.setAttribute('locX', i);
spaceElement.setAttribute('locY', k);
spaceElement.addEventListener('contextmenu', function() {event.preventDefault(); rightClick(event, playerOne)});
spaceElement.addEventListener('mouseup', function() {clickFunction(event, playerOne)});
cell.appendChild(spaceElement);
return spaceElement;
}
function rightClick(e, playerOne) {
document.getElementById('')
console.log(e.target.matches('img'));
if (e.target.matches('data-id *')) {
e.stopPropagation();
let xLoc = e.target.getAttribute('locX');
let yLoc = e.target.getAttribute('locY');
if (playerOne.mineArr[xLoc][yLoc].status != 'open') {
playerOne.elementArr[xLoc][yLoc].setAttribute('src', 'images/MinesweeperiIages/Minesweeper_flagged.png');
}
}
console.log('Right Click');
}
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.