Minimize browser navigation bar on page load – mobile browsers

I am trying to create a “full-screen” interactive experience for a website I am building and I would like to hide the browser navigation on page load. The nav bar typically minimises when you scroll so I imagine there might be some javascript to request this?

I am specifically trying to achieve this on mobile across both andriod and iOS typical browsers. I’ve attached an image of what I mean.

mark-up of the nav bar I am trying to hide on page load. Screen shot taken on Chrome iOS

Some research revealed that this might not be possible on recent browser updates due to security restricitons.

Javascript library to draw actigraph

I would like to dar an actigraph like the one below (double plotted signal with light overlaid).
There doesn’t seem to be an off-the shelf solution. Ideally, it would be good to use an existing library (D3, plotly, chart.js, etc). Does anyone have experience with this or know how to do it?

enter image description here

I need help making a database that allows users to insert rows into columns, remove rows, modify rows. Also allowing them to traverse the database [closed]

I want to make the following website work as follows. The user should be able to Insert new rows into any table within the datbase. I.e. there should be three text input fields one for Table name, the other for columns names, and lastly values. Then there should be an insert button that when clicked inserts this new row into the specified table. Lastly, the database should update automatically after the insert is presses. So that the user can then go up to the database search text field and see the cahanges they have made to the database within the website. Note that for some columns the primitive type will change. I.e. some will be strings and some will be integers. Usually just those.

This is what I have so far: index.html:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>DBFinal</title>
        <style>
            body {
                font-family: Arial, sans-serif;
                margin: 0;
                padding: 0;
                /* overflow: hidden; */
                background: #F1F2B5; /* fallback for old browsers */
                background: -webkit-linear-gradient(
                    to right,
                    #135058,
                    #F1F2B5
                ); /* Chrome 10-25, Safari 5.1-6 */
                background: linear-gradient(
                    to right,
                    #135058,
                    #F1F2B5
                ); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
                overflow-y: scroll;
            }

            h1 {
                text-align: center;
                margin-top: 50px;
            }

            form {
                text-align: center;
                margin-top: 50px;
                display: flex;
                justify-content: center;
                align-items: center;
            }

            label {
                font-size: 18px;
                font-weight: bold;
                color: wheat;
                text-transform: uppercase;
                text-decoration: wavy;
                margin-right: 10px;
            }

            input[type="text"] {
                padding: 10px;
                font-size: 16px;
                border-radius: 5px;
                border: none;
                box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
                margin-right: 10px;
            }

            button {
                padding: 10px;
                font-size: 16px;
                border-radius: 5px;
                border: none;
                background-color: #4CAF50;
                color: white;
                box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
                cursor: pointer;
            }

            table {
                margin: 50px auto;
                border-collapse: collapse;
                width: 50%;
                border: 1px solid #ddd;
                font-size: 18px;
            }

            th,
            td {
                text-align: left;
                padding: 12px;
            }

            th {
                background-color: #4CAF50;
                color: white;
            }

            tr:nth-child(even) {
                background-color: #f2f2f2;
            }

            .container {
                background-color: white;
                border-radius: 10px;
                box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;
                padding: 10px;
                margin: 25px auto;
                width: 50%;
                text-align: center;
            }

            .search-container {
                display: flex;
                justify-content: center;
                align-items: center;
                margin-top: 50px;
            }

            nav {
                display: flex;
                justify-content: space-between;
                align-items: center;
                padding: 0px 40px;
                background: #d9da9f; /* fallback for old browsers */
                background: -webkit-linear-gradient(
                    to right,
                    #0f474f,
                    #e5e6a2
                ); /* Chrome 10-25, Safari 5.1-6 */
                background: linear-gradient(
                    to right,
                    #0d4148,
                    #e0e19a
                ); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
                position: fixed;
                top: 0;
                right: 0;
                left: 0;
                z-index: 9999;
            }

            nav .logo {
                font-size: 30px;
                text-decoration: none;
                color: rgb(205, 200, 200);
                padding: 10px;
            }

            .hamburger-menu {
                position: relative;
                width: 30px;
                height: 22.5px;
                cursor: pointer;
                margin-right: 10px;
            }

            .hamburger-menu span {
                position: absolute;
                width: 100%;
                height: 3px;
                background-color: black;
                transition: all 0.3s ease-in-out;
            }

            .hamburger-menu span:nth-child(1) {
                top: 0;
            }

            .hamburger-menu span:nth-child(2) {
                top: 50%;
                transform: translateY(-50%);
            }

            .hamburger-menu span:nth-child(3) {
                bottom: 0;
            }

            .menu {
                position: absolute;
                top: 100%;
                right: 0;
                background-color: white;
                border-radius: 5px;
                box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
                display: none;
                padding: 10px;
                margin-top: 5px;
                margin-right: 20px;
            }

            .menu.active {
                display: block;
            }

            .menu a {
                display: block;
                padding: 10px;
                /* padding-left: 20px; */
                font-size: 16px;
                text-align: center;
                text-decoration: none;
                color: black;
                margin-right: 20px;
            }

            .menu a:hover {
                background-color: #f2f2f2;
            }
        </style>
    </head>
    <body>
        <nav>
            <a href="#" class="logo">Simple</a>
            <div class="hamburger-menu" onclick="toggleMenu()">
                <span></span>
                <span></span>
                <span></span>
            </div>
            <div class="menu">
                <a href="#">Info</a>
                <a href="#">DB Explained</a>
            </div>
        </nav>
        <script>
            function toggleMenu()
            {
                const menu = document.querySelector('.menu');
                menu.classList.toggle('active');
            }
        </script>

        <div class="container">
            <h1>Insert Into Table in DB</h1>
        </div>
        <div class="insert-container">
            <label for="table-name">Table Name:</label>
            <input type="text" id="table-name" /><br />
            <label for="columns">Columns:</label>
            <input type="text" id="columns" /><br />
            <label for="values">Values:</label>
            <input type="text" id="values" /><br />
            <button id="insert-button">Insert</button>
        </div>

        <div class="search-container">
            <label for="inputtedSearch">Search Table Name:</label>
            <input type="text" id="inputtedSearch" />
            <button id="buttonSearch">Search</button>
        </div>
        <table id="resultantTable"></table>

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
        <script src="index.js"></script>
    </body>
</html>

Index.js:

jQuery(function () {
    jQuery("#buttonSearch").on("click", function () {
        var theTableName = jQuery("#inputtedSearch").val();
        jQuery.ajax({
            url: "/getTableDB",
            type: "POST",
            data: { theTableName: theTableName },
            success: function (data) {
                var headerVals = Object.keys(data[0]);
                var htmlHeaderVal = "";
                headerVals.forEach(function (i) {
                    htmlHeaderVal += "<th>" + i + "</th>";
                });
                jQuery("#resultantTable").html(
                    "<tr>" + htmlHeaderVal + "</tr>"
                );

                var htmlRowPlaceholder = "";
                data.forEach(function (rows) {
                    var htmlRow = "";
                    headerVals.forEach(function (cols) {
                        htmlRow += "<td>" + rows[cols] + "</td>";
                    });
                    htmlRowPlaceholder += "<tr>" + htmlRow + "</tr>";
                });
                jQuery("#resultantTable").append(htmlRowPlaceholder);
            },
            error: function (jqXHR, textStatus, errorThrown) {
                console.log("Error:", errorThrown);
            },
        });
    });

    jQuery("#insert-button").on("click", function () {
        var tableName = jQuery("#table-name").val();
        var columns = jQuery("#columns").val().split(",");
        var values = jQuery("#values").val().split(",");

        var data = {};
        for (var i = 0; i < columns.length; i++) {
            data[columns[i].trim()] = values[i].trim();
        }

        jQuery.ajax({
            url: "/insertIntoTable",
            type: "POST",
            data: { tableName: tableName, data: data },
            success: function () {
                // Update the search results table
                jQuery("#buttonSearch").click();
            },
            error: function (jqXHR, textStatus, errorThrown) {
                console.log("Error:", errorThrown);
            },
        });
    });
});

And lastly server.js:

const path = require("path");
const express = require("express");
const sqlite3 = require("sqlite3").verbose();
const bodyParser = require("body-parser");
const { data } = require("jquery");

const openPort = 5000;

const app = express();

// Serve static files in the 'public' directory
app.use(express.static(path.join(__dirname, "public")));

// Parses incoming request bodies in a middleware before our handlers, available under the req.body property.
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

// Here we define a route that serves to handle Post to /getTableDB
app.post("/getTableDB", (req, res) => {
    // Garners the name of the table from the request body
    const theTableName = req.body.theTableName;

    // Opens the database connection
    const database = new sqlite3.Database("UNBDB.db", (err) => {
        if (err) {
            console.error(err.message);
            return res
                .status(500)
                .send("Error in the servers internal component");
        }
        console.log("Successful connection to database.");
    });

    // Retreive data from table
    database.all(`SELECT * FROM ${theTableName}`, [], (err, rows) => {
        if (err) {
            console.error(err.message);
            return res
                .status(500)
                .send("Error in the servers internal component");
        }
        res.send(rows);
        // Close ongoing connection to database
        database.close((err) => {
            if (err) {
                console.error(err.message);
            }
            console.log("Database connection closed");
        });
    });
});

app.post("/insertIntoTable", (req, res) => {
    const tableName = req.body.tableName;
    const data = req.body.data;

    const database = new sqlite3.Database("UNBDB.db", (err) => {
        if (err) {
            console.error(err.message);
            return res
                .status(500)
                .send("Error in the servers internal component");
        }
        console.log("Successful connection to database.");
    });

    const columns = Object.keys(data).join(", ");
    const values = Object.values(data)
        .map((value) => {
            if (isNaN(value)) {
                return "'" + value + "'";
            } else {
                return value;
            }
        })
        .join(", ");

    database.run(
        `INSERT INTO ${tableName} (${columns}) VALUES (${values})`,
        (err) => {
            if (err) {
                console.error(err.message);
                return res
                    .status(500)
                    .send("Error in the servers internal component");
            }
            res.sendStatus(200);
            database.close((err) => {
                if (err) {
                    console.error(err.message);
                }
                console.log("Database connection closed");
            });
        }
    );
});

// Serves the index.html file and index.js file when the root path is requested
app.get("/", function (req, res) {
    res.sendFile(path.join(__dirname + "/index.html"));
});

app.get("/index.js", function (req, res) {
    res.sendFile(path.join(__dirname + "/index.js"));
});

// Starts the server
app.listen(openPort, () => {
    console.log(`Server started at http://localhost:${openPort}`);
});

Using jQGrid How Can I Prevent a Container from Being Disabled

Using jqGrid 4.15.6-pre – free

I open an Add form to add a new row.
I one of the cells I have click dataEvent that calls the folowing:

function accessBudgetView(){
        
$('.rma-miscdisplay2-zoom600995').load("/QMSWebApp/RMAControllerServlet",
{lifecycle:"accessRMAMONumberRequestBudgetLayout",
nextMONumberRequestIndex:nextMONumberRequestIndex,
recseq:0}, function(){$('.rma-miscdisplay2-zoom600995').show("slide", { direction: "right" }, 
1000);});
                    
}

This is my container code:

<div class="rmaMainBody"></div>
<div class="rma-miscdisplay"></div>
<div class="rma-miscdisplay2"></div>
<div class="rma-miscdisplay2-zoom600995"></div>
<div class="rma-miscdisplay3"></div>

My problem is the called container is disabled even though I have the z-index set higher than the addForm z-index.

When custom implementing JavaScript objects and their methods,. should I be using be functions or classes?

To improve my JavaScript, I am custom implementing objects and their methods, beginning with Arrays. Should be I be doing this with functions or classes? My programming knowledge started with Java, which is much more rigid. The looseness of JavaScript can sometimes be confusing and I want to make sure I am on the right path here. For example, here is how I have started implementing a custom JavaScript Array:

function QuaideArray () {
    let array = Object.create(QuaideArray.prototype)
    array.length = 0

    Object.defineProperty(array, 'length', {
        value: 0,
        enumerable: false,
        writable: true,
      })

    for (key in arguments) {
        array[key] = arguments[key] //arguments passed to function, array-like object
        array.length += 1
    }
    

    return array
}

QuaideArray.prototype.isArray = function(value) {
    return (value instanceof QuaideArray)
}

QuaideArray.prototype.push = function (element) {
    this[this.length] = element
    this.length++
    return this.length
}

QuaideArray.prototype.pop = function () {
    if(this.length === 0) {
        return undefined
    }
    else{
        const element = this[this.length - 1]
        delete this[this.length] 
        this.length--
        return element
    }
}

Am I heading in the right direction? Or should I be implementing QuaideArray as a class? That’s what I would expect that I should be doing but the research I have found is pointing me in the direction of setting it up as a function while manipulating prototype.

ACH payments Stripe

Until now I was using automatic_payments_on in my javascript/php integration for Stripe. It auto creates payment methods i enabled in Stripe dashboard and they look pretty cool. Due to my personal processing reasons I want to separate card and ach us payments.

before my code looked like this (automatic payments on)

elements = stripe.elements({
clientSecret: data.client_secret
});
const paymentElement = elements.create('payment');
paymentElement.mount("#payment-element"); 

Since I want to separately create elements for card and ach payment, If I use StripeAPI method for collecting. Will this auto generate design to match one from paymentElement (when using automatic payments on), where user can pick bank and everything looks nice? How to seperate it but keep the same design?

I tried this to separate :

createACHPElement(clientSecret) {
    const elements = this.stripe.elements({
        clientSecret: clientSecret
    });

    const paymentElement = elements.create('payment', {
        paymentMethodTypes: ['ach_credit_transfer']
    });

    paymentElement.mount("#ach-element");
    return paymentElement;
}

But it’s generating me and mounting a CARD payment. In php backend i’m not doing anything “crazy”, just creating a normal payment intent. note: i dont want to use any 3rd party like plaid. Maybe i’m just missing something obvious…

Replace exponential values in a table by normal float values

I have a table in my html file:

<table class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th>timestamp</th>
      <th>cid1</th>
      <th>cid2</th>
      <th>cid3</th>
      <th>cid4</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>2023-04-08 15:39:21</td>
      <td>1.0</td>
      <td>55.560000</td>
      <td>5.123143e+06</td>
    </tr>
    <tr>
      <td>2023-04-08 15:39:21</td>
      <td>1.0</td>
      <td>27913.540000</td>
      <td>4.653931e+04</td>
    </tr>
  </tbody>
</table>

As we can see there is many float values in cells with exponential form or with many zero in the end. Now I wrote a calc in a head of file:

<form onsubmit="return false;"oninput="document.getElementById('rez_float').innerHTML= 
parseFloat(document.getElementById('expo').value).toFixed(20).replace(/.?0+$/,'')">
<input id="expo" value="Paste exponential" onfocus="if (this.value === 'Paste exponential') this.value=''">  
<br>float = <output id="rez_float"></output>
</form>

This calc return me 2572962000 if I put 2.572962e+09.

But I want to find in the table all cells contained exponential values and replace it by normalize float values with function toFixed(20).replace(/.?0+$/,''). And may be remove excessed zeros for values like to 27913.540000.

How to make it with JS? I’m pythonist and I have beginner JS level. Help me please!

why is console.log(items); running twice

 Item.find()
    .then(function (items) {
      if (items.length === 0) {
        Item.insertMany(defaultItems)
        .then(function () {
          console.log("Successfully Saved");
        })
        .catch(function (err) {
          console.log(err);
        });
      } else {
        res.render("list", { listTitle: "Today", newListItems: items });
        console.log(items);
      }
    })
    .catch(function (err) {
      console.log(err);
    });

just inserted defaultItems if no elements were present in database.
If elements were already present then simply print them on console.

increment does not work correctly in my expo project

I’m coding a quiz with the expo framework, in a certain part of the code I make a comparison of each answer chosen by the user. It works for all questions except the first one. The part that compares is down below:

const verificarResposta = (opMarcada, opCorreta) => {
    console.log("choosen: ", opMarcada, " correct: ", opCorreta)
    // compares the choosen option with the right value
    if (opMarcada == opCorreta) {
      setAcertos(acertos => acertos+1)
      console.log("correct! ", acertos)
    } else {
      setErros(erros => erros+1)
      console.log("wrong! ", erros)
    }
    proximaQuestao()
  }

I tried to increase both the number of hits and misses, for all it works with the exception of the first increment. hope it works for all comparisons.

How can I use the background color of a cell in an if-statement driven formula in Google Sheets?

I am facing a big challenge in extracting a cell’s background color and using it as a conditional in Google Sheets. The idea is to write a custom formula in Apss Script and execute it in an if-statement so that when the background color of a cell turns blue it returns 1; otherwise, it returns 0.

Also, at some point, the code was working when editing the cell value, but later it did not update. Is there any way to use this code with a constant update of the background color?

In case it is easier to imagine, the background color will serve as a toggle, indicating to the user when a payment was made and eliminating the amount in a table.

Thank you very much in advance.

Cheers,

JB

So far, I have written/ modified this code

function ColoredCells(countRange) {
  var activeRange = SpreadsheetApp.getActiveRange();
  var activeSheet = activeRange.getSheet();
  var formula = activeRange.getFormula();
  
  var colorCellA1Notation = formula.match(/,(.*))/).pop();
  var colorCell = activeSheet.getRange(colorCellA1Notation);
  var color = colorCell.getBackground();

  return color;
};

`

While the formula is:

if(ColoredCells(E2)="#00ff00",1,0)

This result should be 1, and when changing the background color to “red”, it should return 0.

I want to write the formula with the selected cell as an argument, but I do not know how. Can you please also give me a hand with an explanation or book where I can look into for more information? I highly appreciate it. =)

getEngineFactories() returns an empty list

I need to execute JS code in Java (JDK 18). To do this, I want to use the ScriptEngine class with the engine “Nashorn” (or any other capable of executing Javascript) using the constructor new ScriptEngineManager().getEngineByName(“nashorn”).

The problem is that this code returns null, the same happens for the name “js”. Then I decided to go through the list of all possible engines with new ScriptEngineManager().getEngineFactories(), but it returns…an empty list. After a little digging, I also found out that Nashorn seems to have been removed from JDK15, so another question: what to use?

Remove all routes from a map with mapbox

I have code with a structure similar to this one that I put in Codepen and I want to create a function to remove all the routes drawn on the map. But I can’t remove the route in blue, which is the last one tested by mapbox.

codepen: https://codepen.io/lucasthaynan/pen/ZEqGYqM

Script done but unable to remove the route in blue:


function removeRoutes(map) {

  if (map.getSource("theRoute")) {
    map.removeLayer("theRoute");
    map.removeSource("theRoute");
  }
  if (map.getSource("theBox")) {
    map.removeLayer("theBox");
    map.removeSource("theBox");
  }
  if (map.getSource("clearances")) {
    map.removeLayer("clearances");
    map.removeSource("clearances");
  }
  if (map.getSource("route")) {
    map.removeLayer("route");
    map.removeSource("route");
  }
  if (map.getSource("load")) {
    map.removeLayer("load");
    map.removeSource("load");
  }

}

Javascript Giving Random Number Of Input Text Length

I cant seem to get my js code properly functioning. I looped through
the elements that are in a list and printed out their text length (elements are inputs)
and it just gave me the same random numbers (4, 5, 8)

function OnCreation() {
  let X = {
    User: document.getElementsByClassName("Username").value,
    Gmail: document.getElementsByClassName("Gmail").value,
    Password: document.getElementsByClassName("Password").value
  }
  for (var Y in X) {
    console.log(Y.length)
  }
}

send message to iframe from main page in localhost

I am trying to send a message between two files that are in the same folder in localhost, main.php and iframe.php, but the iframe does not listen to it, I have tried to use many target origin like this:

mainpage.php

const iframe = document.querySelector('.iframe');
        
iframe.contentWindow.postMessage("message sent from localhost/mainpage.php","http://localhost/iframe.php");

and inside the iframe.php to listen to the message i use

window.onmessage = function(event) {

    alert(event.data);
}