React Bootstrap Cards are Overlapping

I am trying to create a react bootstrap card view, Where all cards should have some space between each other, But my created react bootstrap cards do not have the expected space between them.

I have tried to achieve the above mentioned design, here is my App.js Code

import './App.css';
import HeaderComponent from './HeaderComponent';
import FooterComponent from './FooterComponent';
import BootstrapPractice from './BootstrapPractice';
function App() {
  let name = "Absar Ahmad"
  let testArray = [10, 20, 30, 40];
  let myObject = {
    'name': "Object In JXS",
    'cName': "MERN",
    'Desc': "React JS Learning"
  }

  let status = true;
  return (
    <div className='main' >
      <HeaderComponent />
      <h1 className='text-danger'>{name}</h1>
      {
        testArray.map((arrayValues, i) => {
          return (
            <div key={i}>
              {arrayValues}
            </div>
          )
        })
      }

      <div>{myObject.name}</div>
      <div>{myObject.cName}</div>
      <div>{myObject.Desc}</div>
      <div>Sum of 10 and 20= {10 + 20}</div>

      {
        status ? <h1 style={{ color: "red", backgroundColor: "yellow" }}>Welcome to Ternary Operator</h1> : ""
      }


      <div className='row'>
        <CardExample />
        <CardExample />
        <CardExample />
        <CardExample />
        <CardExample />
        <CardExample />
        <CardExample />
      </div>


      <BootstrapPractice />

      <FooterComponent />

    </div>
  );
}

export default App;


function CardExample() {
  return (
    <div className='cardItems'>Card Div</div>
  )
}

Here is my BootstrapPractice.js Code:

import Card from 'react-bootstrap/Card';
import { Col, Container, Row, Button } from 'react-bootstrap'

function BootstrapPractice() {
    return (
        <Container fluid>
            <Container>
                <Row>
                    <Col className='col-12 text-center py-4'>
                        <h1>Our Courses</h1>
                    </Col>
                </Row>
                <Row>
                    <Col lg="3" md="6">
                        <Card style={{ width: '18rem' }}>
                            <Card.Body>
                                <Card.Title>Card Title</Card.Title>
                                <Card.Text>
                                    Some quick example text to build on the card title and make up the
                                    bulk of the card's content.
                                </Card.Text>
                                <Button variant="primary">Go somewhere</Button>
                            </Card.Body>
                        </Card>
                    </Col>

                    <Col lg="3" md="6">
                        <Card style={{ width: '18rem' }}>
                            <Card.Body>
                                <Card.Title>Card Title</Card.Title>
                                <Card.Text>
                                    Some quick example text to build on the card title and make up the
                                    bulk of the card's content.
                                </Card.Text>
                                <Button variant="primary">Go somewhere</Button>
                            </Card.Body>
                        </Card>
                    </Col>
                    <Col lg="3" md="6">
                        <Card style={{ width: '18rem' }}>
                            <Card.Body>
                                <Card.Title>Card Title</Card.Title>
                                <Card.Text>
                                    Some quick example text to build on the card title and make up the
                                    bulk of the card's content.
                                </Card.Text>
                                <Button variant="primary">Go somewhere</Button>
                            </Card.Body>
                        </Card>
                    </Col>
                    <Col lg="3" md="6">
                        <Card style={{ width: '18rem' }}>
                            <Card.Body>
                                <Card.Title>Card Title</Card.Title>
                                <Card.Text>
                                    Some quick example text to build on the card title and make up the
                                    bulk of the card's content.
                                </Card.Text>
                                <Button variant="primary">Go somewhere</Button>
                            </Card.Body>
                        </Card>
                    </Col>
                    <Col lg="3" md="6">
                        <Card style={{ width: '18rem' }}>
                            <Card.Body>
                                <Card.Title>Card Title</Card.Title>
                                <Card.Text>
                                    Some quick example text to build on the card title and make up the
                                    bulk of the card's content.
                                </Card.Text>
                                <Button variant="primary">Go somewhere</Button>
                            </Card.Body>
                        </Card>
                    </Col>
                    <Col lg="3" md="6">
                        <Card style={{ width: '18rem' }}>
                            <Card.Body>
                                <Card.Title>Card Title</Card.Title>
                                <Card.Text>
                                    Some quick example text to build on the card title and make up the
                                    bulk of the card's content.
                                </Card.Text>
                                <Button variant="primary">Go somewhere</Button>
                            </Card.Body>
                        </Card>
                    </Col>
                </Row>
            </Container>
        </Container>
    )
}


export default BootstrapPractice;

Here is my App.css Code:

.row{
  max-width: 1320px;
  margin: auto;
  flex-wrap: wrap;
  display: flex;
}

.cardItems{
  flex-basis: 23%;
  margin: 1%;
  height: 200px;
  background-color: brown;
}

.main{
  max-width: 1320px;
  margin: auto;
  background-color: antiquewhite;
}

Here is my HeaderComponent.js

import React from 'react'

export default function HeaderComponent() {
    return (
        <div>
            <h1>HeaderComponent</h1>
        </div>
    )
}

And here is my FooterComponent.js Code

import React from 'react'

export default function FooterComponent() {
  return (
    <h1>Footer  Component</h1>
  )
}

Here is the output of my code: My Tried Card View Design

Here is what i expected it to look like
Expected Output

How to efficiently stream and visualize real-time neural network training metrics in a web dashboard without blocking the UI?

You’re building a web application that monitors machine learning model training in real-time. The backend sends training metrics (loss, accuracy, gradient norms) every few seconds via WebSocket, but you’re experiencing performance issues when updating multiple charts simultaneously. The browser becomes unresponsive during heavy data updates, especially when displaying loss curves for multiple epochs

Disabling Bootstrap event delegation for specific DOM elements

Environment

  • Bootstrap version: 5.3.3
  • Browser: Chrome (latest)
  • Framework: Vue.js 3 with Phaser 3.87.0

Problem Description

I’m developing a game using Phaser 3 within a Vue.js application that uses Bootstrap 5 for UI components.
I’ve encountered a performance issue: whenever a user clicks to move a piece in the game, a Bootstrap click event is being triggered and processed, causing frame drops.

Using Chrome’s performance profiler [screenshot], I can see that:

  1. Every click on the game canvas triggers a Bootstrap event handler
  2. These handlers take considerable time to process
  3. The game logic is handled by Phaser, not Bootstrap
  4. Removing bootstrap.min.js import increases frame rate

What I’ve Tried

I’ve attempted several approaches to prevent Bootstrap from handling events on the game container:

  1. Stop event in Vue.js. Result: disable both bootstrap and phaser event handling:
// In mounted() method
this.$refs.gameContainer.addEventListener('click', this.stopEvent, true);
this.$refs.gameContainer.addEventListener('mousedown', this.stopEvent, true);
// Same for mouseup, touchstart, touchend, touchmove

stopEvent: function(event) {
    event.stopPropagation();
    event.preventDefault();
}

  1. Selective event stop in Vue.js. Result: nothing changes:
stopEvent: function(event) {
    if (this.$refs.gameContainer && this.$refs.gameContainer.contains(event.target)) {
      const isBootstrapEvent = new Error().stack.includes('bootstrap');
      if (isBootstrapEvent) {
        event.stopPropagation();
        event.preventDefault();
      }
    }
}
  1. Stop event in Phaser.js. Result: nothing changes:
this.input.on("pointerdown", this.stopEvent, this);
this.input.on("pointerup", this.stopEvent, this);

stopEvent(pointer) {
    const event = pointer.event;
    event.stopPropagation();
    event.preventDefault();
}
  1. Using data-bs-no-jquery attribute. Result: nothing changes:
<div id="game-container" ref="gameContainer" data-bs-no-jquery="true"/>
  1. CSS pointer-events modifications. Result: disable both bootstrap and phaser event handling:
.bootstrap-element {
  pointer-events: none;
}

#game-container {
  pointer-events: auto;
}

Unfortunately, these solutions either:

  • Block all events (including those needed by Phaser)
  • Don’t effectively prevent Bootstrap from processing the events

Questions

  1. Is there an official way to tell Bootstrap to ignore events on specific DOM elements or containers?

  2. Is there a way to configure Bootstrap’s event delegation system to exclude certain elements from event processing?

  3. Are there any known conflicts between Bootstrap’s event handling and canvas-based libraries like Phaser, and any recommended solutions?

Any guidance would be greatly appreciated. Thank you!

Force Scrollbar to Appear For Mac Sequoia Users

I have a complaint from a user that they cannot scroll my website because they are using Mac OS Sequoia. I have a specific place on my app where there is a div with only a scrollbar in it. That div appears to allow the user to scroll several containers simultaneously in sync. It has been working fine for years until Mac OS Sequoia. Suddenly, those users cannot see the scrollbar and therefore cannot scroll horizontally. I cannot control my user’s computers or their settings so please don’t tell me to change their computer setting. I would like a CSS or JS way of forcing the scrollbar to always be visible. I tested this in BrowserStack using both Safari 18.4 and Chrome 137. I also tested it in BrowserStack with Mac Sonoma and didn’t have the issue so it is new to Sequoia. I have also tried these settings:

/// <reference path="_colors" />
/// <reference path="_mixins" />
/// <reference path="maincss" />

::-webkit-scrollbar-corner {
    background: $light-gray;
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-bar-color, $medium-gray) var(--scroll-bar-bg-color, $light-gray);
}

/* Works on Chrome, Edge, and Safari */
*::-webkit-scrollbar {
    width: 12px;
    height: 12px;
    -webkit-appearance: none;
}

*::-webkit-scrollbar-track {
    background: var(--scroll-bar-bg-color, $light-gray);
}

*::-webkit-scrollbar-thumb {
    background-color: var(--scroll-bar-color, $medium-gray);
    border-radius: 20px;
    border: 3px solid var(--scroll-bar-bg-color, $light-gray);
}

.scrollbar-container {
    display: none;
    width: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch; /* optional for smooth scroll on iOS */
}

My HTML:

    <div id="scrollable-block"></div>
    <div class="scrollbar-container" style="width: 1036px;">
        <div class="scrollbar-details" style="width: 1393px;">&nbsp;</div>
    </div>

Drag-and-Drop files from VS Code to Firefox/Chome drags filenames on macOS

When dragging files from VS Code to my JS application in Firefox or Chrome I get several string items (e.dataTransfer.items has several strings but 0 files and e.dataTransfer.files has 0 files). Each string has the absolute path of the file or other info about the file.

Things that do work:

  • Finder to Firefox/Chrome
  • VS Code to/from Finder
  • VS Code to Safari (although Safari has other issues with my JS app)

Things that do not work:

  • VS Code to Firefox – get 3 strings: two file:/// URIs and 1 ‘regular’ absolute path
  • VS Code to Chrome – get 6 strings: ‘regular’ absolute path, file:/// URI, JSON array with ‘regular’ absolute path, JSON array file:/// URI, JSON array with an object with a bunch of file information (path, how many lines, view state, language, encoding), and an empty string.

Things I haven’t tested:

  • Other operating systems (Windows or Linux)
  • Other programs with draggable files

I am implementing drag-and-drop using elem.addEventListener("drop", (e) => {...}) and rootElem.addEventListener("dragover", (e) => { e.preventDefault(); });

Is there any way to work around this rather large issue?

  • Access the files based on their local absolute paths? I find this hard to believe as possible due to typical browser security restrictions.
  • Implement drag-and-drop differently like using a <input type=file>?
  • Change a setting in VS Code?

Working between VS Code and non-Safari on macOS is important due to a closed environment. However, we can control settings in VS Code.

How to handle back navigation between route groups in Expo Router?

I’m using Expo Router with file-based routing, and my app is organized into multiple route groups, like this:

app/
  (main)/
    _layout.tsx       // Contains a Tabs layout
    index.tsx         // Default screen when entering (main)
    screenA.tsx
    screenB.tsx
  (modals)/
    modalA.tsx
    modalB.tsx

From a screen in the (main) group (e.g. screenA), I navigate to modalA. Then from modalA, I navigate to modalB. The navigation flow looks like:

(main)/screenA → (modals)/modalA → (modals)/modalB

In (modals)/_layout.tsx, I use a shared HeaderBackButton to handle back navigation across all modals.

Main Layout Code ((main)/_layout.tsx)

export default function MainLayout() {
  return (
    <Tabs screenOptions={{ headerShown: false }}>
      <Tabs.Screen name="index" />
      <Tabs.Screen name="screenA" />
      <Tabs.Screen name="screenB" />
    </Tabs>
  );
}

Modal Layout Code ((modals)/_layout.tsx)

import { Stack } from 'expo-router';
import { HeaderBackButton } from '@react-navigation/elements';
import { useRouter } from 'expo-router';

export default function ModalLayout() {
  const router = useRouter();

  return (
    <Stack
      screenOptions={{
        headerLeft: () => (
          <HeaderBackButton
            onPress={() => {
              router.back();
            }}
          />
        ),
      }}
    />
  );
}

Current behavior

  • Pressing back from modalB correctly returns to modalA
  • But pressing back from modalA goes to /index in the (main) group, instead of back to screenA, which originally opened the modal

So the modal-to-modal navigation works, but the connection between the modal and the originating screen is lost.

What I’m trying to achieve

  • Back from modalB → modalA
  • Back from modalA → the screen that opened it (screenA)
  • Without manually passing a returnTo param or tracking state
  • Back navigation should behave like a normal stack even across route groups

Questions

  1. How does navigation history work across route groups in Expo Router?
  2. Why does router.back() from modalA go to (main)/index instead of screenA?
  3. Is there a recommended way to preserve stack behavior across route groups (e.g. from tab screens to modals)?
  4. Do route groups isolate navigation history, and if so, how can I work around that for modal flows?

Any guidance or best practices would be appreciated.

How can I correctly guide a character through a map using if-else movement logic in p5.js?

I’m working on a detective game assignment using p5.js (as part of a “Sleuth” case study). The detective character moves through a city map based on if…else if conditions that adjust speedX and speedY.

Here’s a simplified version of my directional logic inside the draw() function:

The detective starts at (199, 10) and needs to follow a maze-like road toward the perp at (763, 696). However, in my current implementation, the character either stops moving or goes off-road at some point.

I’ve been trying to fix this by tweaking the coordinates in each condition, but something is still off — especially during transitions between horizontal and vertical movement.

How can I improve the logic or structure of my if…else if blocks to make sure the character follows the intended route without getting stuck or going off-road?

Any help or code structuring tips would be greatly appreciated!

if (det.locationY < 135 && det.locationX < 210) {
    det.speedX = 0;
    det.speedY = 1;
}
else if (det.locationY >= 135 && det.locationY < 138 && det.locationX < 702) {
    det.speedX = 1;
    det.speedY = 0;
}
else if (det.locationX >= 702 && det.locationY < 260) {
    det.speedX = 0;
    det.speedY = 1;
}
else if (det.locationY >= 260 && det.locationX > 268) {
    det.speedX = -1;
    det.speedY = 0;
}
else if (det.locationX <= 268 && det.locationY < 448) {
    det.speedX = 0;
    det.speedY = 1;
}
else if (det.locationY >= 448 && det.locationY <= 450 && det.locationX < 827) {
    det.speedX = 1;
    det.speedY = 0;
}
else if (det.locationX >= 827 && det.locationY < 670) {
    det.speedX = 0;
    det.speedY = 1;
}
else if (det.locationY >= 670 && det.locationX < 763) {
    det.speedX = 1;
    det.speedY = 0;
}
else if (det.locationX >= 763 && det.locationY < 696) {
    det.speedX = 0;
    det.speedY = 1;
}

enter code here

JavaScript/CSS Smooth “Iris” Scroll Transition: Circle Grows but Won’t Shrink on Scroll-Up

I have a one-page site with five fullscreen “Problem” cards (#problems) and a fixed “Solution time” section (#solutions).
When the user scrolls past Problem 5 a circular mask should grow from the center (radius 0 → full viewport) revealing #solutions. Scroll-down works perfectly.

Issue
When the circle reaches full size and I scroll back up, the page instantly jumps to Problem 5 and the circle snaps closed—there’s no smooth, proportional shrinking on scroll-up.

Expected

  • Scroll-down: circle grows 0 → max, revealing “Solution time”.
  • Scroll-up: circle should shrink max → 0, smoothly revealing Problem 5 again (no jump).

Reproduction

  1. Save the three files below in one folder.
  2. Open index.html.
  3. Scroll down past Problem 5 → circle grows (OK).
  4. Scroll up → circle does not shrink, jumps instead.

script.js

(() => {
  // Get the two sections: the problems you scroll past and the solutions you reveal
  const problems = document.getElementById('problems');
  const solutions = document.getElementById('solutions');
  const body = document.body;
  const html = document.documentElement;

  /* -------- Robust way to read the current vertical scroll position -------- */
  const getScrollY = () =>
    window.pageYOffset ||
    html.scrollTop ||
    body.scrollTop ||
    window.visualViewport?.offsetTop ||
    0;

  /* -------- Calculate the vertical boundaries where the clip animation starts/ends -------- */
  let viewportHeight = window.innerHeight;
  // The top position of the solutions section
  let topOfSolutions = problems.offsetTop + problems.offsetHeight;
  // When to start revealing solutions: one viewportHeight before the section
  let startReveal = topOfSolutions - viewportHeight;
  // When to be fully revealed
  let endReveal = topOfSolutions;

  let revealRatio = 0;    // Will go from 0 (hidden) to 1 (fully revealed)
  let isLocked = false;   // Are we locking the page scroll to control the reveal?

  /* Maximum radius for the circular clip: half the diagonal of the viewport */
  const maxRadius = () => Math.hypot(window.innerWidth / 2, window.innerHeight / 2);

  /* Apply the circular clip with given radius (in pixels) */
  const setRadius = (r) => {
    const clip = `circle(${r}px at 50% 50%)`;
    solutions.style.clipPath = clip;
    solutions.style.webkitClipPath = clip;
  };

  /* -------- Functions to lock/unlock the normal page scroll -------- */
  const lockScroll = (yPos) => {
    isLocked = true;
    body.style.overflow = 'hidden';
    window.scrollTo(0, yPos);
  };
  const unlockScroll = (yPos) => {
    isLocked = false;
    body.style.overflow = 'auto';
    window.scrollTo({ top: yPos, behavior: 'auto' });
  };

  /* ---------- Main scroll handler: controls the clip during scrolling ---------- */
  window.addEventListener('scroll', () => {
    if (isLocked) return; // if we're locked, ignore normal scroll events

    const currentY = getScrollY();

    if (currentY < startReveal) {
      // Above the start zone: keep circle closed
      revealRatio = 0;
      setRadius(0);
      return;
    }
    if (currentY > endReveal) {
      // Below the end zone: circle fully open
      revealRatio = 1;
      setRadius(maxRadius());
      return;
    }

    // Inside the transition zone: compute how far we are in it
    revealRatio = (currentY - startReveal) / (endReveal - startReveal);
    setRadius(revealRatio * maxRadius());

    // Lock the scroll so we can use wheel/touch to drive the reveal
    // Decide which edge to snap to if the user reverses direction
    const midpoint = (startReveal + endReveal) / 2;
    lockScroll(currentY < midpoint ? startReveal : endReveal);
  }, { passive: true });

  /* ---------- Helper to advance the reveal by a delta, then release lock if done ---------- */
  const advanceReveal = (deltaY) => {
    // convert delta scroll into a change in ratio
    revealRatio = Math.max(0, Math.min(1, revealRatio + deltaY / viewportHeight));
    setRadius(revealRatio * maxRadius());

    if (revealRatio === 1) unlockScroll(endReveal);    // fully revealed → resume normal scroll down
    if (revealRatio === 0) unlockScroll(startReveal);  // fully hidden → resume normal scroll up
  };

  /* ---------- Mouse wheel while locked: drive the reveal ---------- */
  window.addEventListener('wheel', (e) => {
    if (!isLocked) return;    // only intercept if we're in the locked state
    e.preventDefault();       // prevent the page from scrolling
    advanceReveal(e.deltaY);
  }, { passive: false });

  /* ---------- Touch drag while locked: similar to wheel ---------- */
  window.addEventListener('touchmove', (e) => {
    if (!isLocked) return;
    e.preventDefault();
    const touch = e.touches[0];
    if (touch._prevY === undefined) {
      touch._prevY = touch.clientY;
    }
    const dy = touch._prevY - touch.clientY;
    touch._prevY = touch.clientY;
    advanceReveal(dy);
  }, { passive: false });

  /* ---------- Recalculate dimensions on resize ---------- */
  window.addEventListener('resize', () => {
    viewportHeight = window.innerHeight;
    topOfSolutions = problems.offsetTop + problems.offsetHeight;
    startReveal = topOfSolutions - viewportHeight;
    endReveal = topOfSolutions;
    if (!isLocked) {
      // update current clip if not locked
      setRadius(revealRatio * maxRadius());
    }
  });
})();

index.html

<!DOCTYPE html>
<html lang="de">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>Iris Demo</title>
  <link rel="stylesheet" href="style.css" />
</head>
<body>

  <section id="problems">
    <h1>Do you know these problems?</h1>
    <article class="card">Problem 1</article>
    <article class="card">Problem 2</article>
    <article class="card">Problem 3</article>
    <article class="card">Problem 4</article>
    <article class="card">Problem 5</article>
  </section>

  <!-- fixed layer revealed by the circle -->
  <section id="solutions">
    <h2>Solution</h2>
  </section>

  <script src="script.js"></script>
</body>
</html>

style.css

html,body{height:100%;margin:0;font-family:sans-serif}

/* Problems */
#problems{scroll-snap-type:y mandatory;position:relative}
#problems h1{position:sticky;top:0;background:#fff;padding:1rem;text-align:center;z-index:1}
.card{height:100vh;scroll-snap-align:start;display:flex;align-items:center;justify-content:center;font-size:2rem;color:#fff}
.card:nth-child(2){background:#90caf9}
.card:nth-child(3){background:#a5d6a7}
.card:nth-child(4){background:#ce93d8}
.card:nth-child(5){background:#ffcc80}

/* Solutions (masked) */
#solutions{
  position:fixed;inset:0;
  background:#000;color:#fff;
  display:flex;align-items:center;justify-content:center;
  font-size:2rem;
  clip-path:circle(0px at 50% 50%);
  -webkit-clip-path:circle(0px at 50% 50%);
  pointer-events:none;
  z-index:50;
}

How to enable horizontal scrolling without showing scrollbar on desktop

I am trying to create an “ecommerce website” and I added product cards in a row and the cards that overflow I want to be converted into horizontal scrollable style.

I have tried using “overflow-x: scroll;” but it shows the scrollbar that looks ugly and if I make its width zero. It only works on mobile and not on desktop.

Here is the view https://baabi.netlify.app/

can anyone provide a solution to it.

.top-products {
  display: flex;
  justify-content: flex-start;
  gap: 20px;
  overflow-x: scroll;
  padding: 20px;
  position: relative;
  cursor: grab
}

It is the code of container that I tried to enable horizontal scroll but facing issue on desktop screen. It works well as I scroll easily on mobile device but when it comes to scroll on desktop. it does not work, I do not want to use javaScript if it is possible with CSS

javascript code doesn’t work, even when proen in another application [closed]

i have a javascript program that i’m working on. i’ve tested it line by line. when the program doesn’t work i know the most recently (added) line is the problem. however, when i delete that line and try to re-run the program, it fails. i can remove ALL the code from the offending function (all that’s left are the ‘{‘ and ‘}’) and it still fails. i close the browser down, erase the cache, and try to rerun it with the offending code removed. it still usually fails. i have to literally save the program to a different name and add code line-by-line like it’s a new function entirely, building from the {} line-by-line, even the code that had proven to work previously. it is beyond frustrating and exceeds my expertise. what gives?

like, this fails sometimes in the above scenario. makes absolutely no sense!!!

function getList() {
let sngMin;
let sngMax;
let sngTemp;
let strTemp;
}

String to Datetime in Jinja2

I tried {{datetime_var.strftime(‘%Y-%m-%d’)}} but this gives error:
jinja2 error

I want to make it clear: I don’t want to convert the datetime in datetime string format on the backend because I want the datetime to be displayed according to the user’s timezone on the user’s machine. So please don’t suggest doing it on the backend because backend obviously doesn’t know the tz of a user.

Example:

  • Datetime is stored in UTC timezone in database like : 2025-06-16 05:00:25 +00:00
  • Datetime is sent directly to user side exactly the same.
  • I want the datetime to be accurate as per the timezone of the machine. Like I am in India so the datetime displayed should be: 2025-06-16 10:30:25

I hope this example makes it clear what I am trying to do. It is easy with JavaScript, I just have to use new Date(datetime_var) and I am done. How to achieve the same thing in Jinja2?

SUM of column with same Title in CSR JS [duplicate]

I have js csr code run in sharepoint 2013.

| Title    | Paid     |            OutPut
| -------- | -------- |
| A        | 2        |
| B        | 100      |           A    22
| A        | 20       |           B    110
| B        | 10       |

If I enter any third value (paid) in A or B than NAN shows

| Title    | Paid     |            OutPut
| -------- | -------- |
| A        | 2        |
| B        | 100      |           A    22
| A        | 20       |           B    NAN
| B        | 10       |
| B        | 10       |

code image attach
Sum CSR

I want more than two values with same Title entered and sum answer shown.

I want more than two values with same Title entered and sum answer shown.

| Title    | Paid     |            OutPut
| -------- | -------- |
| A        | 2        |
| B        | 100      |           A    22
| A        | 20       |           B    120
| B        | 10       |
| B        | 10       |

Update Current Time Automatically And Update Database via ajax php mysql after video fully watched

Currently I am using following code to check video is fully watched or not. (Taken from This Stackoverflow Question)

  1. I want to update watchtime/playtime updated per seconds. Currently it is getting updated on clicking pause button.

  2. Many times total video duration not get captured on first page load but works when page reloaded. Specially when video is of big / large size. How to fix it ?

  3. Want to update mysql database via ajax php after watching full video only (without fast forward / moving seekbar to end)…

  4. Can we hide seekbar of video in video.js

Current Code :

<video id="video" class="video-js" controls preload="none" width="640" height="264" poster="../assets/img/poster-for-video.jpg" data-setup="{}">
<source src="<?php echo $video_url;?>" type="video/mp4"></source>


    <p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="https://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p>
 </video>

<div id="status" class="incomplete">
  <span>Play status: </span>
  <span class="status complete">COMPLETE</span>
  <span class="status incomplete">INCOMPLETE</span>
  <br />
</div>
<div>
  <span id="played">0</span> seconds out of 
  <span id="duration"></span> seconds. (only updates when the video pauses)
</div>

JS code :

<script src="js/jquery2.0.3.min.js"></script>
<link href="src/plugins/video-js/video-js.css" rel="stylesheet">
<script src="src/plugins/video-js/video.js"></script>

<script type="text/javascript" defer="defer">
 $(document).ready(function() {
   var video = document.getElementById("video")
   var timeStarted = -1
   var timePlayed = 0
   var duration = 0

 // If video metadata is laoded get duration
  if (video.readyState > 0) getDuration.call(video)
//If metadata not loaded, use event to get it
  else {
    video.addEventListener("loadedmetadata", getDuration)
 }

  // remember time user started the video
   function videoStartedPlaying() {
     timeStarted = new Date().getTime() / 1000
   }
   function videoStoppedPlaying(event) {
       // Start time less then zero means stop event was fired vidout start event
    if (timeStarted > 0) {
       var playedFor = new Date().getTime() / 1000 - timeStarted
       timeStarted = -1
       // add the new ammount of seconds played
        timePlayed += playedFor
    }
    
    document.getElementById("played").innerHTML = Math.round(timePlayed) + ""
     // Count as complete only if end of video was reached
    if (timePlayed >= duration && event.type == "ended") {
        document.getElementById("status").className = "complete"
    }
   }

   function getDuration() {
     duration = video.duration
     document.getElementById("duration").appendChild(new Text(Math.round(duration) + ""))
         console.log("Duration: ", duration)
    }

   video.addEventListener("play", videoStartedPlaying)
   video.addEventListener("playing", videoStartedPlaying)

   video.addEventListener("ended", videoStoppedPlaying)
   video.addEventListener("pause", videoStoppedPlaying)

  });
 </script>

If metadata not loaded, use event to get it – video.addEventListener(“loadedmetadata”, getDuration) is not working…..

Where can I put Ajax function to update database after video watched fully..

              var datastring = {member_uid: <?php echo $member_uid;?>, video_uid: <?php echo $video_uid;?>}, // php values set at top of this script page
              $.ajax({                      
                type: "POST",
                url: "videos-watched-ajax.php",
                data: dataString,
                cache: false,
                success: function(html){
                    alert ('database updated successfully');
                }
                });