Input values are coming out as undefined?

I have a log in page that is asking for a username and a password. I want to check it against the local storage that adds and stores an object of user data (one object = username, full name, password, postcode, email, mobile). I have this so far that I want to try it out and test it, but I keep getting ‘undefined‘ when I get the console to print the username and password that the user has input into the log in screen. I can’t figure out why?

Here’s my js:

const loginForm = document.querySelector(".login-form");
    let usernameInput = document.getElementsByClassName(".lg-username").value;
    let passwordInput = document.getElementsByClassName(".lg-password").value;
    
    loginForm.addEventListener("submit", (e) => {
        e.preventDefault();
        if (localStorage.getItem("UserData")) {
            const data = JSON.parse(localStorage.getItem('UserData'))
            if(usernameInput === data.username && passwordInput === data.password) {
                console.log("ye");
            }else{
                console.log("ne");
            }
        }else{
            console.log("not regis");
        }
    
        console.log("not nice");
        console.log(localStorage);
        console.log(usernameInput);
        console.log(passwordInput);
    })
    <form class="login-form">
          <ul>
             <li><input type="text" name="username" class="lg-username" placeholder="Username" required></li>
        
             <li><input type="password" name="password" class="lg-password" placeholder="Password" required></li>
         </ul>
         <input type="submit">
         <div >
    </form>

Electron Uncaught Exception: TypeError: Cannot read properties of null (reading ‘on’)

The error appears only if i open a new window when the inspector is opened once. It does’nt appear for mainWindow.

enter image description here

// Detect maximize-unmaximize to change the maximize button's icon
app.on('browser-window-focus', (event, win) => {
  console.log('Focus: ' + win.webContents.id);
  BrowserWindow.fromId(win.webContents.id).on('ready-to-show', () => {
    BrowserWindow.fromId(win.webContents.id).on('maximize', () => {
      console.log("maximize detected", win.webContents.id);
      BrowserWindow.fromId(win.webContents.id).send('window-events', 'maximize');
    })
    BrowserWindow.fromId(win.webContents.id).on('unmaximize', () => {
      console.log("unmaximize detected", win.webContents.id);
      BrowserWindow.fromId(win.webContents.id).send('window-events', 'unmaximize');
    })
  })
})

UX: drop position indicator among tiles while reshuffle

I’m trying out a tile reshuffle experience in n * 2 grid. Taking reference of snapshot attached, the tile can be placed before tile 1 for putting it at starting position in row 1, or between tile 1 and tile 2 for cases where user wish to push it at position 1-2 in row 1.

For inserting a tile between tile 2 (in row 1) and tile 4 (in row 2), user can hover over after tile 2 in grid, or before tile 4 in row 2. Need to add dotted line as placeholder in both cases.

I’m thinking of two approaches –

  1. Adding placeholder divs as drop-zones, and when draggable tile appears there we try to insert at that position. I need to add intermediate divs with drop-zones which I feel can be avoided.
  2. Make tiles as drop-zones, and show dotted line when tile overlap is detected. With interact.js I could detect drag-enter and drag-leave events for tile overlap in and out, but there is issue for end of row. Let’s say we show placeholder “before” the tile on overlap, how would place it at the end of row 1.

I suspect this is solved issue with grid, I could not find any reference with UX libraries (ex: material-ui) for such in-place (with placeholder in-between tiles) draggable/swap tile/grid layouts. Any directions to think better can help.

Placeholder is shown as dotted vertical line

how put key when Array.from() inside a map method [duplicate]

I’m confused that I have an map method inside that method I put some different properties in their
span tag or div tag and I have to show star rate and for these element I used Array.from() , now I get a warning about I must use unique key , I don’t know how to delete this warning

const Rating = ({ratings}) => {
    return (
        <div>
         { ratings.map((li, index) => 
        <div className='ratings__item' key={index} >
           <h3>{li.name}</h3>
           <p>{li.content}</p>
              {Array.from({length:li.rate}, () => <span>&#9733;</span> )}
              {Array.from({length:5-li.rate}, () => <span>&#9734;</span> )}
        </div>
    )}
        </div>
    )
}

Is there a way to call a function in contextBridge, that won’t be read in renderer.js, from main.js in electron?

I hope you are having a good morning. I was wondering if there was a way to call a regular function in contextBridge in preload.js from main.js that will not be read by renderer.js. For example when wanting to call a regular function in contextBridge, not having to use ipcRenderer, you simply do window.preloader.functionName() in renderer.js.

I want to do the exact same thing except in main.js. I have tried doing win.webContents.functionName(); in main.js, however, I receive the error of TypeError: Cannot read properties of undefined (reading ‘functionName’)

Please let me know if you have a solution! Thanks.

Read More button in React

I’m using ReactReadMoreReadLess for implementing read more button in my react app. I want to break line in the content like some br tag between two paragraph after read more button is clicked. If I use br tag in datset through which data is mapped, it shows error as “TypeError: children.substr is not a function” .

How to get rid of this error and accomplish the above said task?
Thanks in Advance!

No data scraping a table using Apps Script

I’m trying to scrape the first table (FINRA TRACE Bond Market Activity) of this website using Google Apps Script and I’m getting no data.
https://finra-markets.morningstar.com/BondCenter/TRACEMarketAggregateStats.jsp
enter image description here

function myFunction() {

  const url = 'https://finra-markets.morningstar.com/BondCenter/TRACEMarketAggregateStats.jsp';
  const res = UrlFetchApp.fetch(url, { muteHttpExceptions: true }).getContentText();
  const $ = Cheerio.load(res);

  var data = $('table').first().text();
  Logger.log(data);
}

I have also tried from this page and I do not get any result.
https://finra-markets.morningstar.com/transferPage.jsp?path=http%3A%2F%2Fmuni-internal.morningstar.com%2Fpublic%2FMarketBreadth%2FC&_=1655503161665

I can’t find a solution on the web and I ask you for help.
Thanks in advance

Loaded fields are not initialized in the additional function

I use two functions to load some components for my page and save it in two fields representatives and allUsers. Then I try to use additional func subtractSets() to a little bit modify loaded data. My problem is that fields this.representatives and this.allUsers in this adittional function are still not initialized. What I can do to get loaded data in subtractSets()?

setup() {
     const representatives = ref([])
     const allUsers = ref([])
 data() {
   return { 
     representatives,
     users
   }
 }
},

methods(): {
   loadUsersRepresentatives() {
       axios.get('getRepresentatives').then(res => {
            this.representatives = res.data
        }).catch(() => {
            ...
            })
        });
     },
     loadAllUsers() {
         axios.get('/getAllUsers').then(res => {
         this.allUsers = res.data
         }).catch(() => {
             ...
             })
         });
    },
    subtractSets(obj1, obj2) {
            ...
    },
    showRepresentativesDialog(facultyID) {
          this.loadUsersRepresentatives(facultyID)
          this.loadAllUsers()
          this.subtractSets(this.representatives, this.allUsers)
          this.representativesDialog = true
      }
},
´´´

add dynamic useState

I see this link but didn’t get any answer for my question

in my component , I have a two selectbox and one txtarea that owned Specified state(define by use state).

so on click add button this form create again and again,
my question is how to define new state dynamicly to set it for new selectbox that dynamicly created.
my select box use react-select and code of them is here :

      <div className="mqContainer">
        {[...Array(mqCount)].map((x, i) => (
          <div key={i} className="newMqWrapper mt-4">
            <Row className="mt-4">
              <Col xs={3}>
                <span>milestone</span>
              </Col>
              <Col xs={6}>
                <Select
                  style={{ width: "100px !important" }}
                  defaultValue={mileStoneType}
                  onChange={setmileStoneType}
                  options={MileStoneTypeOption}
                  isMulti={true}
                />{" "}
              </Col>
            </Row>
            <Row className="mt-4">
              <Col xs={3}>
                <span>question text</span>
              </Col>
              <Col xs={8}>
                <Form.Group>
                  <Form.Control
                    placeholder="why so serious?"
                    className=" dirrtl"
                    as="textarea"
                    rows={3}
                  />
                </Form.Group>{" "}
              </Col>
            </Row>
            <Row className="mt-4">
              <Col xs={3}>
                <span>answer type</span>
              </Col>
              <Col xs={6} className="mb-4">
                <Select
                  defaultValue={mileStoneAnswerType}
                  onChange={setmileStoneAnswerType}
                  options={MqAnswerTypeOption}
                />{" "}
              </Col>
            </Row>
          </div>
        ))}
        <Row>
          <Col xs={12} className=" mb-4 mt-4">
            <Button
              onClick={() => setMqCount(mqCount + 1)}
              style={{ width: "100%" }}
              variant="outline-secondary"
            >
              +
            </Button>{" "}
          </Col>
        </Row>
      </div>

enter image description here

Button for the appearance of the SideBar

At the moment, I have the following structure on the site: SideBar (located on the left) and the main part of the site. I made it so that when the browser width is reduced, the Sidebar is hidden, leaving only the main part of the site (the code is presented below). And further, the SideBar appears only when the browser is expanded. It works.

But I’d like to add the following: When the browser is in a minimized state, add a button that, when clicked, will overlay the SideBar on the main menu (thus leaving the main body of the site behind).

For a demonstration, I will present https://catalog.onliner.by/tv (make the browser width minimal and click the “Фильтры” button)

And accordingly I would like to make a button to close the SideBar

I would be very grateful for any advice

WindowSize.jsx

export default function WindowSize () {
   const [windowSize, setWindowSize] = useState({
        width: undefined,
        height: undefined
    });

    useEffect(() => {
        if (typeof window !== "undefined") {
            function handleResize() {
                setWindowSize({
                    width: window.innerWidth,
                    height: window.innerHeight
                });
            }
            window.addEventListener("resize", handleResize);
            handleResize();
            return () => window.removeEventListener("resize", handleResize);
        }
    }, []); 
    return windowSize;
};

App.jsx

    return (
    <ThemeProvider theme={theme}>
        <BrowserRouter>
            <AppContext.Provider
                value={{ filters, setFilters}}>
                <div style={{display: 'flex'}}>
                {size.width > 600 && <Sidebar />}
                    <Routes>
                        <Route exact path='/devices/' element={<PockId />} />
                        <Route path="*" element={<Navigate to="/devices" replace />} />
                    </Routes>
                </div>
            </AppContext.Provider>
        </BrowserRouter>
    </ThemeProvider>
);

How can I export a CSV file with information from a JSON file?

I am writing a script that uses GET Api to receive message data from a messaging platform. I receive this data in a JSON file and eventually want to filter through it and export it as a CSV or use it for another Api request. I can see that the JSON values are pushed into the jsonArray successfully, but when the exportToCsv function is called at the end, it downloads as an empty csv file. I’m not sure why I can see the contents of jsonArray in the Chrome inspector console but not in the downloaded csv file. Am I not pushing the values in correctly?

var jsonArr = [];

    function getMessages(){
            fetch('https://webexapis.com/v1/messages, {
                method: 'GET',
                headers: {
                    'Content-type': 'application/json',
                    'Authorization': `Bearer ${token}`
                },
            })
            .then(function(res){
                return res.json();
            })
            .then(function(data){
                var status = document.getElementsByName("id")[0];

                for (var i = 0; i < data.items.length; i++) {
                    jsonArr.push([data.items[i].id, data.items[i].created]);

                }
            })
        }

        console.log("json is" , jsonArr);

        function exportToCsv(filename, rows) {
        var processRow = function (row) {
            var finalVal = '';
            for (var j = 0; j < row.length; j++) {
                var innerValue = row[j] === null ? '' : row[j].toString();
                if (row[j] instanceof Date) {
                    innerValue = row[j].toLocaleString();
                };
                var result = innerValue.replace(/"/g, '""');
                if (result.search(/("|,|n)/g) >= 0)
                    result = '"' + result + '"';
                if (j > 0)
                    finalVal += ',';
                finalVal += result;
            }
            return finalVal + 'n';
        };
        var csvFile = '';
        for (var i = 0; i < rows.length; i++) {
            csvFile += processRow(rows[i]);
        }
        var blob = new Blob([csvFile], { type: 'text/csv;charset=utf-8;' });
        if (navigator.msSaveBlob) { // IE 10+
            navigator.msSaveBlob(blob, filename);
        } else {
            var link = document.createElement("a");
            if (link.download !== undefined) { // feature detection
                // Browsers that support HTML5 download attribute
                var url = URL.createObjectURL(blob);
                link.setAttribute("href", url);
                link.setAttribute("download", filename);
                link.style.visibility = 'hidden';
                document.body.appendChild(link);
                link.click();
                document.body.removeChild(link);
            }
        }
    }