Browser back button exits Single Page App despite pushState() on Chrome only

I’m working on a legacy single-page application that uses AJAX to load different internal views. After recent browser updates the Browser Back Button stopped behaving as expected.

The current problem:

When the user clicks the Back button in Firefox, everything works as intended — the app restores the previous in-app view without leaving the page.

In Chrome, the first Back click correctly restores the previous in-app view but the second Back click always kicks the user out of the app and back to the login screen.

I’m already using history.pushState and listening to popstate to restore the internal content and re-push guard states when needed.
It seems like Chrome doesn’t honor the guard state or simply navigates past it.
I’ve tried:
-Unique hash fragments for every state
-Replacing the base state
-Re-pushing guard states in popstate

None of it seem to make a difference in Chrome.

function sendAction(action, content) {
  // Capture current dynamic content
  const section = document.querySelector('.content section.rows');
  const html = section ? section.innerHTML : '';

  // Push in-app navigation state
  const newUrl = window.location.href.split('#')[0] + '#' + encodeURIComponent(content);
  history.pushState({ html, content }, null, newUrl);
  
  // (Ajax content loading happens here)
}

// Back button handling
window.addEventListener('popstate', function(event) {
  const section = document.querySelector('.content section.rows');

  if (event.state && event.state.html && section) {
    // Restore previous HTML content
    section.innerHTML = event.state.html;
    event.preventDefault();
    return;
  }

  // Prevent leaving the app
  history.pushState({ guard: true }, null, window.location.href);
  event.preventDefault();
});

// Initialize base history state
if (!history.state) {
  const section = document.querySelector('.content section.rows');
  history.replaceState(
    { initialized: true, html: section ? section.innerHTML : '' },
    null,
    window.location.href
  );
}

Apps Script Trigger Won’t Update My Function

I was trying to write a function to find the sum of a set of values in one list referencing a specified value in another list. Kind of like trying to find the total amount of an item bought in a table full of items bought chronologically.

The code seems to work when I first implement it, but whenever I try to apply and test a trigger, it gives the same error:

JavaScript runtime exited unexpectedly

I could really use some help. Let me know if you need any more info.

function myFunction(range1, range2, value) {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getActiveSheet();
  var value_list_1 = sheet.getRange(range1).getValues()
  var value_list_2 = sheet.getRange(range2).getValues()
  var new_value = 0
  var total_value = 0
  for (var i = 0; i < value_list_1.length; i++) {
    if (value_list_1[i] == value) {
      new_value = Number(value_list_2[i])
      total_value = total_value+new_value
    }
  }
  return(total_value)
} 

How do I change the rendering order for the SurfaceView element, so It won’t be rendered first on Android?

I am currently building an application that shows media files using expo-video, VideoView, these items has two states, a preview and an open state. When a video is opened the background is rendered on top of the video. This problem only occurs on android, on ios the video is rendered as intended. My goal is to have a little transparent black background behind the opened video.

<Modal
  visible={modalVisible}
  transparent
  animationType="fade"
  onRequestClose={closeModal}
>
  <View style={styles.openMediaBG}>
    <TouchableOpacity
      style={styles.closeButtonStyle}
      onPress={closeModal}
    >
      <Ionicons name="close" size={30} color="white" />
    </TouchableOpacity>

    <View style={styles.mediaContainer}>
      {isVideo && modalVideoPlayer ? (
        <TouchableOpacity
          style={styles.videoTouchable}
          onPress={handleVideoTap}
          activeOpacity={1}
        >
          <VideoView
            player={modalVideoPlayer}
            style={styles.modalVideo}
            allowsPictureInPicture={false}
            nativeControls={true}
            showsTimecodes={false}
            requiresLinearPlayback={false}
            contentFit="contain"
          />
        </TouchableOpacity>
      ) : (
        <Image
          source={typeof selectedMedia.uri === "string"
            ? { uri: selectedMedia.uri }
            : selectedMedia.uri
          }
          style={styles.modalImage}
          resizeMode="contain"
        />
      )}
    </View>

    <Text style={styles.timestampStyle}>
      {selectedMedia.timestamp
        ? new Date(selectedMedia.timestamp).toLocaleDateString()
        : "Unknown date"
      }
    </Text>
  </View>
</Modal>

I know this is caused by surfaceView being rendered differently on android, it is being rendered first then everything else gets rendered after. On expo’s documentation site textureView mentioned as a solution for rendering issues, so I have tried it, but with that the video wasn’t appearing at all. I have also tried some alternatives like rendering two VideoView, but one had a style that made it fully black, this gave the video a black background but cannot be made transparent and I fear this is a hardware heavy solution. Besides these approaches I couldn’t find more possible solutions.

How to replace a patterned string efficiently with PHP e.g. ((1)), ((2)) for footnotes

A website I have taken over uses footnotes in the form ((1)), ((2))((40)) etc. in the database. I am trying to programmatically replace these strings on the front-end templates with the following HTML on the fly, ideally using PHP, though I suppose a JavaScript / jQuery solution could work.

Replace ((1)) with:

<a href="#footnote-1" class="footnote-link"><sup>[1]</sup></a>

The number in brackets needs to be included both in the link target e.g. #footnote-1 but also in the superscript text e.g. <sup>[1]</sup>. Currently I am running through this with string replace. As follows:

$content = str_replace('((1))', '<a href="#footnote-1" class="footnote-link"><sup>[1]</sup></a>', $content);        
$content = str_replace('((2))', '<a href="#footnote-2" class="footnote-link"><sup>[2]</sup></a>', $content);
$content = str_replace('((3))', '<a href="#footnote-3" class="footnote-link"><sup>[3]</sup></a>', $content);

etc. x 40 

As we have up to forty footnotes this seems pretty inefficient, as the $content blocks of text can be long articles of thousands of words, and many may not have anything near 40 footnotes.

Is there a more efficient way to do this? Perhaps breaking out of the loop if the previous footnote doesn’t exist. I tried to look at RegEx but I am always baffled by the syntax and didn’t get very far. Any tips greatly appreciated.

KaTeX not formatting caret (^) for superscripts in mathematical expressions

I’m building a Q&A chat widget that uses marked.js for Markdown rendering and KaTeX for mathematical expressions. While most LaTeX expressions render properly, the caret (^) character for superscripts is not being formatted and displays as plain text.

Current Behavior:

Superscripts using ^ (like b^2, a^2, x^2) display as raw text instead of formatted superscripts. Most mathematical notation works fine

Example API Response:

json
{
    "success": true,
    "data": {
        "answer": "In the context of mathematics... the expression \( (a + b)^2 \) expands to: \[ a^2 + 2ab + b^2 \] ... Formulas can represent quadratic equations (e.g., \( ax^2 + bx + c = 0 \))."
    }
}

In this response, \( (a + b)^2 \) should render as (a+b)² but the caret remains unformatted.

Relevant Code:

HTML setup:

html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
JavaScript rendering:

javascript
function renderMath(element) {
  if (window.renderMathInElement) {
    renderMathInElement(element, {
      delimiters: [
        {left: '$$', right: '$$', display: true},
        {left: '$', right: '$', display: false},
        {left: '\[', right: '\]', display: true},
        {left: '\(', right: '\)', display: false},
        {left: '[ ', right: ' ]', display: true},
        {left: '[', right: ']', display: true}
      ],
      throwOnError: false,
      ignoredTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code'],
      processEscapes: true
    });
  }
}

function appendMessage(text, from) {
  const wrap = document.createElement("div");
  wrap.className = `message ${from}`;
  const bubble = document.createElement("div");
  
  if (from === "model") {
    bubble.className = "bubble";
    bubble.innerHTML = marked.parse(text);
    
    setTimeout(() => {
      renderMath(bubble);
    }, 10);
  } else {
    bubble.textContent = text;
  }
  
  wrap.appendChild(bubble);
  messagesEl.appendChild(wrap);
}

Expected Behavior:

  • b^2 should render as b² with proper superscript formatting
  • x^2 should render as x²
  • (a + b)^2 should render as (a+b)²
  • All caret-based superscripts and all mathematical expressions should be properly formatted.

I have not tested with other mathematical expressions like frac, etc. How can I ensure caret-based superscripts and all mathematical expressions are properly formatted?

How to hide / show slides?

I am trying to add a sideload add-in doing some automation in powerpoint.
I couldn’t find a command or property in the powerpoint office add-in to hide/show slides.

Does anyone know how to hide / show slides via javascript in powerpoint?

The command via VBA is:

ActivePresentation.Slides(1).SlideShowTransition.Hidden = True / False

Command via Javascript: ???

But there exists a method to delete slides:
slide.delete() exists, but no slide.hide()

Thanks, Florian

Puppeter: Error: Execution context was destroyed, most likely because of a navigation

I’m having a problem with this code. I’m using Puppeter, and it seems to be throwing the error: “Error: Execution context was destroyed, most likely because of a navigation.” Why could this happen? I’m attaching a fragment of my code where it seems to be failing.

export async function goTo(page: Page, target1: string, target2: string) {
    await common.click(page, '#nav-item-welcome');
    await common.waitTillHTMLRendered(page);

    await common.click(page, target1, { clickType: 'puppeteer' }); // clicktype puppeter or jquery
    await common.waitTillHTMLRendered(page);

    await common.click(page, target2, { clickType: 'puppeteer' });
    await common.waitTillHTMLRendered(page);
}

How can I simplify this dual filtering (by status & priority) logic in React using JavaScript array methods?

I’m building a small React app to manage tasks.
Each task has a status (true/false) and a priority (low/medium/high).

I have two filter buttons — one for status and one for priority — and I’m using the below handlers to update the displayed list (taskArray) based on what the user selects.

Here’s my working code:

const handleStatus = (e: React.MouseEvent<HTMLElement>) => {
    const label = e.currentTarget.innerText;
    setStatusLabel(label);
    setStatusActive(e.currentTarget.id);

    const priorityArray =
      priorityLabel === "All"
        ? allTasks
        : allTasks.filter((x) => x.priority === priorityLabel);

    if (label === "All") {
      setTaskArray(priorityArray);
    } else if (label === "Active") {
      setTaskArray(priorityArray.filter((x) => !x.status));
    } else if (label === "Complete") {
      setTaskArray(priorityArray.filter((x) => x.status));
    }
  };

  const handlePriority = (e: React.MouseEvent<HTMLElement>) => {
    const label = e.currentTarget.innerText;
    setPriorityLabel(label);
    setPriorityActive(e.currentTarget.id);

    const statusArray =
      statusLabel === "All"
        ? allTasks
        : statusLabel === "Active"
        ? allTasks.filter((x) => !x.status)
        : allTasks.filter((x) => x.status);

    setTaskArray(
      label === "All"
        ? statusArray
        : statusArray.filter((x) => x.priority === label)
    );
  };

It works, but I feel there might be a more concise or reusable way to achieve this using JavaScript array methods — maybe by combining both filters into one function or chaining them more elegantly.

Question:

How can I simplify or refactor this code to handle both filters more efficiently (while keeping readability)?

Using EXIF library to extract metadata from jpg media files causes an error that is not properly handled by try-catch

I’m writing a small JavaScript program that scans through the contents of a folder where hundreds or thousands of image files are stored, extracts some data items from each image file (like timestamp + GPS coordinates) and writes a text file with a JSON array of the form:

[{"File":"20250912_131538.jpg","Timestamp":"2025-09-12T13:15:22","GPS_Latitude":23.4544454,"GPS_Longitude":78.345428354},
 {"File":"20250912_131538.jpg","Timestamp":"2025-09-12T13:15:22","GPS_Latitude":23.4544411,"GPS_Longitude":78.345428301},
 ...
]

Everything works OK (meaning, tens of files are properly processed) till an error within the EXIF functionality causes the process to halt.

I tried placing the EXIF invocation within a try-catch block but the program still halts.

Since one of the possible reasons is asynchronous invocation, I added to printouts as follows:

try {
    console.log("----- Before invoking EXIF...")

    l_EXIF_Returned_Value = EXIF.getData(l_Thumb, function() {

    console.log("----- After invoking EXIF...")

    [rest of the code...]

Within the console:

----- Before invoking EXIF...
exif.js:742  Uncaught RangeError: Offset is outside the bounds of the DataView
...

So, the invocation is synchronic and still it appears that the exception is not caught by the try-catch structure.

Does anyone ever encountered such behavior (try-catch not working?

Any suggestion will be most appreciated.

Stacking on ansible centos [closed]

Swapping is like the OS moving things into the spare storage room when the main room RAM gets too full. It’s a memory management technique where the OS temporarily moves an entire process or some of its pages from main memory to a dedicated area on the secondary storage the hard drive, usually called swap space.

Backdrop filter not working after enabling View Transitions API and assigning view-transition-name

I’m implementing smooth page transitions using the View Transitions API in my svelte app.

Here’s the issue I’m facing: after setting a custom view transition root and giving view-transition-name to my main container and bottom navigation bar, the CSS backdrop-filter (and -webkit-backdrop-filter) on my bottom navigation stops working entirely.

It worked perfectly before adding the view-transition-name property.

before
enter image description here

after
enter image description here

 .main-container {
    position: relative;
    height: 100dvh;
    overflow: hidden;
    isolation: isolate;
    z-index: 2;
    view-transition-name: main;
  }
  .bottomBar_wrapper {
    position: relative;
    overflow: hidden;
    border-top: var(--theme-nav-border);
    isolation: isolate;
    z-index: 3;
    view-transition-name: bottom-navigation;
  }

  .bottomBar_wrapper::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    z-index: 1;
    isolation: isolate;
    background: var(--theme-bottom-navbar-background-before) !important;
    backdrop-filter: var(--theme-nav-backdrop-filter-blur) !important;
    -webkit-backdrop-filter: var(--theme-nav-backdrop-filter-blur) !important;
  }

  .bottomBar_wrapper::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    z-index: 100;
    isolation: isolate;
    background: var(--theme-bottom-navbar-background-after) !important;
  }
html:active-view-transition-type(forwards) {
  &::view-transition-old(main) {
    animation-name: slide-out-to-left;
  }
  &::view-transition-new(main) {
    animation-name: slide-in-from-right;
  }
}
html:active-view-transition-type(backwards) {
  &::view-transition-old(main) {
    animation-name: slide-out-to-right;
  }
  &::view-transition-new(main) {
    animation-name: slide-in-from-left;
  }
}

How to emulate aspect ratio change using CSS animation?

I’ve tried researching using a couple of sources, but none of them focused on my problem specifically. I want to use CSS, if possible, to get a border effect that emulates some aspect ratio changes, going from something like a 2.76:1 to 1.90:1.

Something like this: https://www.tiktok.com/@reeseirby/video/7535567446086864159?

I used some code from w3schools, but I only found animation that has both borders going in the same direction, while I’d like them to go in opposite directions. I’m new to this so there’s definitely something I’m missing, but I can’t find the necessary information. Code I’m currently using:

<!DOCTYPE html>
<html>
<head>
<style> 
#myDIV {
  width: 300px;
  height: 200px;
  border: 1px solid black;
  animation: mymove 5s infinite;
}

@keyframes mymove {
  50% {border-top-width: 15px;}
  50% {border-bottom-width: 15px;}
}
</style>
</head>
<body>

<h1>Animation of border-top-width</h1>

<p>Gradually change the border-top-width property from 1px to 15px, then back:<p>
<div id="myDIV"></div>

</body>
</html>

Thanks for any help!

Chart.JS overflowing labels

I am using the ChartJS library with a Vue Chart wrapper library.

Playground/Demo

My current issue is, when you open the playground, you can see the date labels on the X axis sort of “overflow” to the sides. This happens because there is too much of them. The goal is to make the labels not render past the red lines shown on the image:

Labels overflowing

I can’t find an optimal solution to prevent this from happening. Ideally, I want to find a way to automatically hide/resize/rotate/reposition labels, if they do not fit.

I’ve checked all configuration options of ChartJS and everything I could find had some drawbacks.