Javascript Minesweeper (yes, other): JS Beginner, fully functional, including HTML and CSS

//surpresses rightclick menu
window.oncontextmenu = (e) => {
    e.preventDefault();
}

var field = {
    cols: 0,
    rows: 0,
    mines: 10,
    markedMines: 0,
    bombArray: (),
    gameover: false
    

    //checks if every field with a mine is  flagged. if not, returns false
    , checkWin: function () {
        let check = true;
        for (let i = 1; i <= field.cols; i++) {
            for (let j = 1; j <= field.rows; j++) {
                let newId = parseInt(i);
                newId += "/";
                newId += parseInt(j);
                if (field.bombArray(i)(j) == "x" && document.getElementById(newId).style.backgroundColor != "red") check =
                    false;
            }
        }
        return check;
    }

    //injects the gamefield into html- td id = i/j - left click reveals a field, right click flags a field
    , printTable: function (cols, rows) {

        let html = '';
        let id = '';
        html += '';
        for (i = 1; i <= cols; i++) {
            html += '';
            for (j = 1; j <= rows; j++) {

                html += '';
            }
            html += '';
        }
        html += '
'; html += '
'; return html; } // functioncall with rightclick on , markABomb: function (id) { let x = id.substring(0, id.indexOf("/")); let y = id.substring((id.indexOf("/") + 1), (id.length + 1)); if (!this.gameover) { if (document.getElementById(id).style.backgroundColor != "yellow") { if (document.getElementById(id).style.backgroundColor == "red") { document.getElementById(id).style.backgroundColor = "blue"; field.markedMines--; field.mines++; } else { document.getElementById(id).style.backgroundColor = "red"; field.markedMines++; field.mines--; } } else { //if flagged mines on adjacant fields are equal to number on the field, reveal all adjacent fieds. put maybe into own funtion? if (this.bombArray(x)(y) === this.countRedNeighbours(x, y)) { for (let i = -1; i < 2; i++) { for (let j = -1; j < 2; j++) { let id = parseInt(parseInt(x) + parseInt(i)); id += "/"; id += parseInt(parseInt(y) + parseInt(j)); this.reveal(id); } } } } this.updateShowCounter(); if (this.mines == 0) { if (this.checkWin()) { alert("congratulations. You won!"); this.gameover = true; } else alert("somethings not quite right"); } } } , updateShowCounter: function () { document.getElementById("marked").innerHTML = ("

marked: " + this.markedMines + "

"); document.getElementById("minesLayed").innerHTML = ("

mines: " + this.mines + "

"); } //counts adjacent flagged mines. what a mess. , countRedNeighbours: function (x, y) { let counter = 0; for (let i = -1; i < 2; i++) { for (let j = -1; j < 2; j++) { let id = ""; id = parseInt(parseInt(x) + parseInt(i)); let ix = parseInt(parseInt(x) + parseInt(i)); id += "/"; id += parseInt(parseInt(y) + parseInt(j)); let yj = parseInt(parseInt(y) + parseInt(j)); let z = field.bombArray.length - 1; if (ix > 0 && yj > 0 && ix < field.bombArray.length - 1 && yj < this.bombArray(z).length - 1) { if (document.getElementById(id).style.backgroundColor == "red") counter++; } } } return counter; } , revealAllBombs: function (cols, rows) { for (let i = 0; i <= parseInt(cols); i++) { for (let j = 0; j <= (rows); j++) { if (field.bombArray(i)(j) == "x") { if (i < this.bombArray.length - 1 && j < this.bombArray(this.cols).length - 1) { let id = parseInt(i); id += "/"; id += parseInt(j); document.getElementById(id).innerHTML = "X"; document.getElementById(id).style.backgroundColor = "red"; } } } } } //functioncall from , left-click , reveal: function (id) { if (!this.gameover) { let x = id.substring(0, id.indexOf("/")); let y = id.substring((id.indexOf("/") + 1), (id.length + 1)); if (x > 0 && y > 0 && x < this.bombArray.length - 1 && y < this.bombArray(this.cols).length - 1) { if (document.getElementById(id).style.backgroundColor != "red") { if (field.bombArray(x)(y) == "x") { field.revealAllBombs(this.cols, this.rows); alert("lost"); this.gameover = true; } else if (field.bombArray(x)(y) == "0") { field.revealAll0(id); } else { document.getElementById(id).style.backgroundColor = "yellow"; document.getElementById(id).innerText = field.bombArray(x)(y); } } } } } , buildArray: function (cols, rows) { cols++; rows++; for (let i = 0; i <= parseInt(cols); i++) { field.bombArray(i) = (); for (let j = 0; j <= parseInt(rows); j++) { field.bombArray(i)(j) = ""; } } } , setMine: function (cols, rows) { let x = Math.floor((Math.random() * cols)); let y = Math.floor((Math.random() * rows)); x++; y++; field.bombArray(x)(y) = "x"; } , countMines: function (cols, rows) { let mineCounter = 0; for (let i = 1; i <= cols; i++) { for (let j = 1; j <= rows; j++) { if (field.bombArray(i)(j) == "x") mineCounter++; } } return mineCounter; } //counts all adajacent X and writes it in bpmbArray , countNeighbours: function (cols, rows) { for (let x = 1; x < cols + 1; x++) { for (let y = 1; y < rows + 1; y++) { let counter = 0; for (let i = -1; i < 2; i++) { for (let j = -1; j < 2; j++) { let xi = x + i; let yj = y + j; if (xi > 0 && yj > 0 && xi < this.bombArray.length && yj < this.bombArray(this.cols).length) if (this.bombArray(parseInt(x + i))(parseInt(y + j)) === "x") counter++; } } if (x > 0 && y > 0 && x < this.bombArray.length && y < this.bombArray(this.cols).length) if (field.bombArray(x)(y) != "x") field.bombArray(x)(y) = parseInt(counter); } } } // if a field with 0 mines next to it is revealed, all fields with 0 are revealed , revealAll0: function (id) { let listXY = (); listXY.push((parseInt(id.substring(0, id.indexOf("/"))), parseInt(id.substring((id.indexOf("/") + 1), (id.length + 1))))); while (listXY.length > 0) { let x = parseInt(listXY(0)(0)); let y = parseInt(listXY(0)(1)); for (let i = -1; i < 2; i++) { for (let j = -1; j < 2; j++) { if ((x + i != 0 && y + j != 0 && (x + i) <= document.getElementById("cols").value && (y + j) <= document .getElementById("rows").value)) { let newId = parseInt(x + i); newId += "/"; newId += parseInt(y + j); if (document.getElementById(newId).style.backgroundColor == "red") { field.mines++; field.markedMines--; this.updateShowCounter(); } if (field.bombArray(x + i)(y + j) != "x" && document.getElementById(newId).style.backgroundColor != "yellow") { document.getElementById(newId).style.backgroundColor = "yellow"; if (field.bombArray(x + i)(y + j) != 0) document.getElementById(newId).innerText = field.bombArray( x + i)(y + j); if (field.bombArray(x + i)(y + j) == 0) { listXY.push((x + i, y + j)) } } } } } listXY.shift(); } } } //-----------------------------------Object ends here--------------------------------------------------------------------------- function insertHTML(id, html) { let el = document.getElementById(id); el.innerHTML = html; } run = () => { field.gameover = false; let cols = document.getElementById("cols").value; field.cols = cols; let rows = document.getElementById("rows").value; field.rows = rows; field.mines = document.getElementById("mines").value; field.markedMines = 0; field.updateShowCounter(); if ((field.cols * field.rows < field.mines) || cols <= 1 || rows <= 1 || cols > 100 || rows > 100 || field.mines < 1) { alert("so nicht Kevin") field.gameover=true; } else { let html = field.printTable(cols, rows); field.buildArray(cols, rows); while (field.countMines(cols, rows) < field.mines) field.setMine(cols, rows); field.countNeighbours(cols, rows); insertHTML('table', html); } } // Run everything when the document loads. window.onload = run;
html {
    font-family: sans-serif;
  }

  .wrapper {
    display: grid;
    grid-template-columns: 200px, 8fr;
    grid-template-areas: 
    "....... header"
    "settings content";
    justify-content: left;
    grid-gap: 20px;
    white-space:nowrap;

  }
  .header {
      align-items: end;
      height: 10px;
      grid-area: header;
      color: white;
      margin-top: 10px;
  }
  .settings{
    grid-area: settings;
    position: absolut;
    white-space: nowrap;
    margin-top: 50px;
  }
  input {
    -moz-appearance: textfield;
    text-align: right;
    text-decoration: none;
    border: 0;
    background: black;
    border-bottom: 1px solid;
    color: #ffffff;
    width: 75px;
}

input(type=number)::-webkit-inner-spin-button,
input(type=number)::-webkit-outer-spin-button {
    opacity: 0;
}

  .content {
    grid-column-start: 2;
    grid-area: content;
    margin-top: 50px;
  }

  body {
    background: black;
  }
  #manual{
      color: white;
      font-size: small;
      opacity: 20%;
  }
  #manual:hover{
      opacity: 75%;
  }
 
  td {
    background: blue;
    height: 20px;
    width: 20px;

  }
  td:hover{
      background: rgba(0, 0, 255, 0.527);
  }
  h1{
      text-align: right;
  }

  p {
    color: white;
  }

  button {
    margin-top: 20px;

  }

  .marked {
    color: red;
    margin-top: 25px;
  }

  .minesLayed {
    color: red;
    margin-top: 25px;
  }
  


  
    Minesweeper

    

    
  

  
    

.Minesweeper

columns:

rows:

Mines:

Your goal is to mark all the mines. Left click on a blue square to reveal it.
Right click on a blue square to mark it. A quare flange is red. Right click on a red quare to uncheck it.
A number represents adjacent mines. If all adjacent mines are widened, right click to reveal their adjacent squares

Html + PHP payment

Good day,
I am creating a website for a school assignment where I need to create lists of products available in the database and I have the option of inserting them into the shopping cart.

So far it is working correctly, but when I click on "finish purchase" to save the purchase in the database, 2 mysqli errors appear.

Below is the part of the code I created for this:


Shopping cart

<? php echo "

There are no products in your shopping cart.

";?>
$ qty) { $ sql = "SELECT * FROM product WHERE code = & # 39; $ id & # 39;"; $ qr = mysqli_query ($ conn, $ sql) or die (mysqli_error ()); $ ln = mysqli_fetch_assoc ($ qr); $ code = $ ln (& # 39; code & # 39;); $ description = $ ln (& # 39; description & # 39;); $ value = $ ln (& # 39; value & # 39;); $ total = $ ln (& # 39; value & # 39;) * $ amount; $ subTotal + = $ total; echo & # 39;& # 39 ;; } }?> $ Amount): $ SqlInsertItems = mysqli_query ("Insert in sales items (SellId, ProductId, Qty) Values ​​(& # 39; $ SellId & # 39 ;, & # 39; $ ProdInsert & # 39 ;, & # 39; $ Qty & # 39; ) "); endforeach threw out ""; } ?>
Code Description Value Qntd R $ total Remove
& # 39 ;. $ code & # 39 ;. & # 39 ;. $ description. & # 39; & # 39 ;. $ value & # 39 ;. & # 39 ;. $ total. & # 39;
<? php echo & # 39;

Total: $ & # 39 ;. Format_number ($ subTotal, 2, ",", "."). & # 39;

& # 39;?>

And these are the two mistakes:

Warning: mysqli_insert_id () expects exactly 1 parameter, 0 given

Warning: mysqli_query () expects at least 2 parameters, 1 given in

If any part of the code is missing to help me, inform me here and I will send it, thanks in advance!

monitoring: registration of .html and .js files for a certain domain

In a local network, I would like to save / register all the files that any user requests and receives through http / https from a certain website.

Let's say user A accesses https://www.google.com through our Wi-Fi or cable connection and Google responds with .html and .js files, I would like to save these files!
(Similar to the Firefox Inspector, in Network).

I also have full access to all devices in case it is necessary to decrypt it! (SSL / TLS)

How can you get this?

How to put the header on the map in HTML CSS

I was wondering how I could make the header not overlap with the Google div map.
HTML:


    
    

CSS:

body {
    color: white;
    padding: 0;
    margin: 0;
}
html, body, #map {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

#lokal {
    background-image: linear-gradient(rgba(0, 1, 83, 0.5), rgba(0, 1, 83, 0.5));
}

#map {
    height: 100%;
    width: 100%;
    position: relative;
}

Here is a screenshot: http://prntscr.com/pwj4p3

html: Does the position of the Google Analytics snippet within the document header (before or after the scripts and css) affect the tracking data?

The MonsterInsights plugin puts the Google Analytics tracking code before other Java scripts and style sheets. I wanted to reduce the number of add-ons I'm using by one more, so I put the Google Analytics tracking code in "Add code to from your Divi theme options blog. What I've seen is that Divi puts the tracking code under the style sheets and some Java scripts.

Would it have any implication for data tracking?

html – How to remove inherited property by component?

When placing a side navigation icon, I noticed that a part of it "leaked" out of the expected, which made it behave visually uncomfortable in the animation. I put one background-color: red for easy viewing:

area of ​​the icon that escapes from the desired

But when inspecting the page element, I noticed that if I removed a CSS property from the tag It behaves as desired:

icon that behaves as you want
<img src = "https://i.stack.imgur.com/dF8Ww.png" alt = "property height unmarked”/>

but if I put height: 0 In my CSS, animation occurs in a strange way, in addition to the element that apparently no longer has "background":

strange behavior icon

How can I undo the behavior of a single property inherited from tags and higher classes in CSS Without losing others, which one can be useful?

html – Download video tag with jquerry or javascript

I need to have a video download button, I have no idea how I can do this.





and to download I am trying to download js but it doesn't work, does anyone know a better way to download the video?

function myFunction() {         
    var x=new XMLHttpRequest();
    x.open("GET", "https://pt.stackoverflow.com/", true);
    x.responseType = 'blob';
    x.onload=function(e){download(x.response, "dlBinAjax.mp4, video/mp4" ); }
    x.send();
}   

you need an html page created similar to the image

I need a simple html page created, based on this image

1 – MUST be verified by AMP
2- You should NOT use too many 1-2 scripts as jquery / bootstrap is fine.
3- CSS must be online

It's going to be a homepage, so I hope you understand how important it is to have speed, etc.
I have the email delivery code ready, just modify it according to the requirements. (will provide a sample of the way of working)
SEMrush

It shouldn't take more than 30 minutes for an experienced guy

You will pay 700 INR for it (around $ 10)
message only if you can do the job today in a couple of hours

Companies please excuse me
(IMG) "data-url =" https://newbioments.com/lp/hl.jpg

HTML form error with php

I am making a form to collect the data that reaches it from a local database.
The form is shown, so far so good. But wanting to send the data gives me an error, and I don't know what's going on. I have reviewed all the documents again and again and cannot find the fault. Let's see if you can help me.

index.html



    
        Formulario
        
    
    
        

Nombre


Correo


Mensaje




save.php

Volver";
    }
?>

show.php

";
    echo"";
    echo "Nombre";
    echo "Correo";
    echo "Mensaje";
    echo"";
    for($i=0; $i<$datos; $i++){
        echo"$datos(0)";
        echo"$datos(1)";
        echo"$datos(2)";
        echo"";
        $datos=mysqli_fetch_array($ejecutar);
    }
    echo"";
?>

The database is called "test", the "data" table, and they have the same variables.
When I save the data, I get a blank screen with "there was an error".

How to Duplicate The Generated Html table, but using the Array values ​​from Javascript?

I do not know if I am not inserting the array well but it does not throw the values ​​in the pd tables: I need 4 tables I do not know how to call the array

More specific question how to call or bring me specific array data from HTML

I attach work in Fiddle