How to open about:blank with html code in the page when clicked on link

I’m Tyler!

I need help on making working HTML code when you click on a link, it goes to about:blank with code in it.

I did the following code below, but it redirects it automatically and the link doesn’t work when I click it.

<body style="background-color: purple;"><script>
const w = window.open() // access the "about:blank" window you've opened
w.document.body.innerHTML = "<p style='Subscribe to NothingButTyler on YouTube!</p><iframe src='https://1v1.lol'></iframe>"
// or access other parts to add more JS or CSS
const style = w.document.createElement("link")
link.href = "LINK_THAT_I_WANNA_GO_TO"
link.rel = "stylesheet"
w.document.head.appendChild(style)
</script>
<h1>Learn the Coding Experience!</h1>
<p>Click <a href="LINK_THAT_I_WANNA_GO_TO" id="link" target="_blank">here</a> to see the ultimate coding experience.</p>

Is there any way to fix this? Thank you very much!

(Please note this question is not the same as mine! Mine includes a link and not redirected in a way.)

Programatically altering CSS Grid item position mysteriously scrolls page. Why? Can I stop this behaviour?

Good evening,

I’m attempting to create a grid system where the items in the grid can be moved programatically. When moving a grid item on the Y axis (by updating its grid-row property), the document scrolls to keep the item in the same visual location on in the viewport.

This is both undesirable and confusing. I would like the page to remain in its current location and only move the item down on the page.

I have made a very minimal example of this behaviour. If you scroll the viewport down slightly so that the top is within the grid, then press upon the + next to Y:, you will likely experience this issue. Curiously the page does not scroll horizontally when increasing the X position.

(It might be a good idea to run the snippet below in full screen to experience the issue)

let y = 0;
let x = 0;
const item = document.getElementById("item");
const plusY = document.getElementById("plusY");
const minusY = document.getElementById("minusY");
const plusX = document.getElementById("plusX");
const minusX = document.getElementById("minusX");
const updatePosition = (newY, newX) => {
  if (newY < 0) {
    newY = 9;
  }
  y = Math.abs(newY) % 10;
  if (newX < 0) {
    newX = 9;
  }
  x = Math.abs(newX) % 10;
  item.style = `grid-column: ${x + 1} / span 1; grid-row: ${y + 1} / span 1`;
};
plusY.addEventListener("click", () => {
  updatePosition(y + 1, x);
});
minusY.addEventListener("click", () => {
  updatePosition(y - 1, x);
});
plusX.addEventListener("click", () => {
  updatePosition(y, x + 1);
});
minusX.addEventListener("click", () => {
  updatePosition(y, x - 1);
});
*,
*:before,
*:after {
  box-sizing: border-box;
}
body {
  background-color: black;
  color: white;
}
#grid {
  padding: 20px;
  background-color: white;
  display: grid;
  width: 885px;
  height: 885px;
  gap: 5px;
  grid-template-columns: repeat(10, 80px);
  grid-template-rows: repeat(10, 80px);
}
#item {
  border: 1px solid black;
  grid-column: 1 / span 1;
  grid-row: 1 / span 1;
  color: black;
}
.buttons {
  display: flex;
  justify-content: center;
  width: 800px;
}
<html>
  <body>
    <div id="grid">
      <div id="item">Test</div>
    </div>
    <div class="buttons">
      Y:
      <button id="plusY">+</button>
      <button id="minusY">-</button>
    </div>
    <div class="buttons">
      X:
      <button id="plusX">+</button>
      <button id="minusX">-</button>
    </div>
    <div style="width: 4000px; height: 2000px"></div>
  </body>
</html>

This issue occurs in both Chrome and Firefox, but strangely not within Edge.

Can this issue be quashed, have I misconfigured CSS grid in some manner, or have I come across a strange browser bug?

Assistance would be much appreciated, I’m incredibly stumped and use of CSS grid was to be a very important part of the project that I was working on when I came across this issue.

Thanks.

Is it possible to pass a location to the Google Custom Search API while querying it?

I’m working on integrating Google’s Custom Search API into my application, and I’ve run into an issue with retrieving location-specific search results using the gl (geolocation) parameter.

What I’m Trying to Achieve:
I want to retrieve search results tailored to a specific country (e.g., Nigeria, Thailand, United States, etc.) based on the user’s input. For this, I am using the gl parameter to specify the location in my API request.

My Setup:
Here’s an example of the API request I’m making:

https://www.googleapis.com/customsearch/v1
  ?key=MyAPIKey
  &cx=MySearchEngineID
  &hl=en
  &q=writing agency
  &gl=ng
  &num=10
  &start=1

Observations:

  1. The gl parameter appears to be correctly appended to the API request.
  2. Despite specifying gl=ng (Nigeria), the results do not seem to reflect a location-specific ranking.
  3. I’ve verified that without the gl parameter, the API works as expected but defaults to global search results.
  4. The requested URL and parameters are logged correctly, and there are no errors in the response from the API.

What I’ve Tried:

  1. Double-checked the API documentation to confirm that the gl parameter is supported for location-specific results.
  2. Tested with different location codes (e.g., gl=us for the United States), but the results are always global.
  3. Ensured the key, cx, and other parameters are valid and functional.
  4. Normalized URLs and compared them against the target to ensure accuracy.

The Issue:
The search results are not ranking URLs based on the specified location, and I consistently receive “no ranking” for queries I know should work in the specified country (e.g., Nigeria). However, when I manually search on Google, the URL I’m targeting ranks on the first page for the same keyword in the same location.

My Question:
Why might the gl parameter not be affecting the search results as expected? Is there a limitation or nuance in the Google Custom Search API that could cause this behavior? Are there additional parameters I need to include for location-specific results to work properly?

Any insights or suggestions would be greatly appreciated!

Below is a snippet of me making the API request with the parameters.

try {
    while (currentPage <= maxPages) {
      console.log(`Querying page ${currentPage}, startIndex: ${startIndex}`);

      // Construct the API request URL
      const params = {
        key: process.env.GOOGLE_API_KEY,
        cx: process.env.SEARCH_ENGINE_ID,
        hl: "en", // Language
        q: keyword, // Search query
        gl: validatedCountry, // Geolocation
        num: 10, // Results per page
        start: startIndex, // Start index
      };

      const apiUrl = `https://www.googleapis.com/customsearch/v1?${qs.stringify(params)}`;
      console.log("Constructed API Request URL:", apiUrl);

const response = await axios.get(apiUrl);
      console.log("API Response Request:", response.data.queries.request[0]);
      const searchResults = response.data.items || [];

Problem with gsap on mobile version when deployed

I have concern with gsap animations on mobile version(s).

More specifically:

  • Local, the code works perfectly on both destop and mobile version(s)

  • When deployed, the code still works on desktop and on the responsive simulator that desktop chrome proposes.
    But the gsap animations do no work on mobile versions.

I tried the different methods to link gsap and my code, and the results are always those described above.

Does someone have an idea to help me?
Thanks in advance!

Didier

How to Achieve Consistent Auto-Scrolling Between ASCIIMath Input and LaTeX Rendered Output?

I’m building a calculator web application where users type ASCIIMath expressions, which are then rendered into LaTeX using ASCIIMathML. One challenge I’m facing is ensuring that when users type or move the cursor in the input field, the scroll position aligns correctly with the corresponding position in the rendered LaTeX output.

The main issue is that the relationship between the length of the ASCIIMath input and the width of the rendered LaTeX is non-linear and unpredictable. For example:

  • A short ASCIIMath string can expand significantly when rendered as LaTeX.
  • Cursor positions in the ASCIIMath input don’t directly map to positions in the rendered LaTeX.

Currently, my implementation uses simple arithmetic to estimate the cursor position in the LaTeX render, but this is inconsistent because:

  1. The rendered output width doesn’t directly relate to the input length.
  2. Small inputs and long outputs make this approach unreliable.

Here is my current code snippet for handling scrolling:

const cursorPosition = keyinputs.selectionStart;
const isTypingAtEnd = cursorPosition === input.length;
const simplebarContentWrapper = document.querySelector('.simplebar-content-wrapper'); // latex is stored in here

if (isTypingAtEnd) {
    simplebarContentWrapper.scrollLeft = simplebarContentWrapper.scrollWidth;
    showScrollbarTemporarily();
} else {
    const currentScrollPosition = simplebarContentWrapper.scrollLeft;
    const contentWidth = simplebarContentWrapper.scrollWidth;
    const displayWidth = simplebarContentWrapper.clientWidth;    
    if (contentWidth > displayWidth) {
        const threshold = displayWidth * 0.05;
        const estimatedCursorPosition = (cursorPosition / input.length) * contentWidth;
        const cursorViewPosition = estimatedCursorPosition - currentScrollPosition;
        if (cursorViewPosition < threshold) {
            const targetScrollPosition = Math.max(0, estimatedCursorPosition - threshold);
            simplebarContentWrapper.scrollTo({
                left: targetScrollPosition,
                behavior: 'auto'
            });
        } else if (cursorViewPosition > displayWidth - threshold) {
            const targetScrollPosition = Math.min(contentWidth - displayWidth, estimatedCursorPosition + threshold);
            simplebarContentWrapper.scrollTo({
                left: targetScrollPosition,
                behavior: 'auto'
            });
        }
    }
}     

This works in some cases, but it doesn’t guarantee accuracy when:

  • The user types in the middle of the input.
  • The rendered LaTeX is significantly longer or shorter than the ASCIIMath input.

I want to improve this algorithm to ensure scrolling always aligns the input cursor with the correct position in the rendered LaTeX. I’ve thought about tokenizing the ASCIIMath input or precomputing mappings between input positions and LaTeX positions, but I’m unsure how to implement these efficiently.


My Questions (Mainly looking for advice not necessarily direct fixes to my code):

  1. How can I accurately map ASCIIMath input positions to LaTeX output positions without tokenizing the input?
  2. If tokenizing is necessary, what’s the best way to track cursor positions in both the input and rendered output?
  3. Are there better techniques or libraries for handling this type of auto-scrolling in real-time or just matching behavior between input and output in general?

Why is my proxy displaying, “Connect to the Internet?”

So I’m hosting a live server with VSC, and I built a proxy server; currently, I can display the HTML/CSS response from Google or whatever link I inputted, but am having trouble with the interactive JS part. For some reason, if you input something like an input URL on live server and click something, it says, “Connect to the Internet, you are not connected to the Internet.” I have no idea why, although I think it could be because I’m displaying the information within an iFrame. Here’s my code (if it helps to host a live server on your end (if necessary)):
Index.js:

let tabCount = 1;

function showTab(tabId) {
  const tabs = document.querySelectorAll('.tab-content');
  tabs.forEach(tab => tab.classList.remove('active'));
  document.getElementById(tabId).classList.add('active');

  const tabElements = document.querySelectorAll('.tab');
  tabElements.forEach(tab => tab.classList.remove('active'));
  event.target.classList.add('active');
}

function addNewTab() {
  tabCount++;
  const newTabId = `tab${tabCount}`;
  const newTab = document.createElement('div');
  newTab.className = 'tab';
  newTab.textContent = `Tab ${tabCount}`;
  newTab.setAttribute('onclick', `showTab('${newTabId}')`);
  document.querySelector('.add-tab').before(newTab);

  const newTabContent = document.createElement('div');
  newTabContent.id = newTabId;
  newTabContent.className = 'tab-content';
  newTabContent.innerHTML = `
    <img src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" alt="Google Logo" class="logo">
    <div class="search-box">
      <input type="text" id="${newTabId}-search-input" placeholder="Search Google or type a URL">
      <button onclick="browse('${newTabId}')">&#x1F50D;</button>
    </div>
    <div class="buttons">
      <button onclick="browse('${newTabId}')">Google Search</button>
    </div>
    <div class="search-results">
      <iframe id="${newTabId}-iframe" class="search-iframe" style="width: 100%; height: 80vh;" frameborder="0"></iframe>
    </div>
  `;
  document.body.appendChild(newTabContent);
}

function browse(tabId) {
  const searchInput = document.getElementById(`${tabId}-search-input`);
  const iframe = document.getElementById(`${tabId}-iframe`);
  const inputValue = searchInput.value.trim();

  if (!inputValue) return;

  const isUrl = /^https?:///i.test(inputValue);
  const fetchUrl = isUrl ? `/urls?url=${encodeURIComponent(inputValue)}` : `/search?q=${encodeURIComponent(inputValue)}`;

  iframe.style.display = 'block'; // Show iframe
  iframe.src = fetchUrl; // Dynamically load the content
}

document.addEventListener("keydown", function (event) {
  if (event.key === "Enter") {
    const activeTab = document.querySelector('.tab-content.active');
    const activeTabId = activeTab.id;
    browse(activeTabId);
  }
});

Server.js:

const express = require('express');
const https = require('https');
const http = require('http');
const app = express();
const port = 5507;

app.use(express.static('public'));

const rewriteUrls = (html, baseUrl) => {
    return html.replace(/(href|src)="([^"]*)"/g, (match, attr, url) => {
        const absoluteUrl = new URL(url, baseUrl).toString();
        return `${attr}="/proxy?url=${encodeURIComponent(absoluteUrl)}"`;
    });
};

app.get('/search', (req, res) => {
    const query = req.query.q;
    const googleSearchUrl = `https://www.google.com/search?q=${encodeURIComponent(query)}`;
    https.get(googleSearchUrl, (response) => {
        let data = '';
        response.on('data', chunk => {
            data += chunk;
        });
        response.on('end', () => {
            const rewrittenData = rewriteUrls(data, googleSearchUrl);
            res.send(rewrittenData);
        });
    }).on('error', (err) => {
        res.status(500).send('Error: ' + err.message);
    });
});

app.get('/urls', (req, res) => {
  let targetUrl = req.query.url;
  const client = targetUrl.startsWith('https://') ? https : http;

  client.get(targetUrl, (response) => {
    let data = '';
    response.on('data', (chunk) => {
        console.log('Sending URL results back');
      data += chunk;
    });
    response.on('end', () => {
      res.send(data);
    });
  }).on('error', (err) => {
    res.status(500).send('Error: ' + err.message);
  });
});

app.listen(port, () => {
  console.log(`Server is running at http://localhost:${port}`);
});

Index.html:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Thing</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      margin: 0;
      padding: 0;
      background-color: #f1f3f4;
    }
    .tabs {
      display: flex;
      justify-content: center;
      align-items: center;
      background-color: white;
      border-bottom: 1px solid #ccc;
      box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
      padding: 10px 0;
      position: sticky;
      top: 0;
      z-index: 10;
    }
    .tab {
      padding: 10px 20px;
      margin: 0 5px;
      cursor: pointer;
      font-size: 16px;
      color: #5f6368;
      border-bottom: 3px solid transparent;
      transition: border-color 0.3s;
    }
    .tab:hover {
      color: #202124;
    }
    .tab.active {
      color: #1a73e8;
      border-bottom: 3px solid #1a73e8;
    }
    .add-tab {
      font-size: 24px;
      font-weight: bold;
      cursor: pointer;
      color: #5f6368;
      padding: 0 10px;
      transition: color 0.3s;
    }
    .add-tab:hover {
      color: #202124;
    }
    .tab-content {
      display: none;
    }
    .tab-content.active {
      display: block;
      text-align: center;
      margin-top: 50px;
    }
    .logo {
      margin: 20px auto;
    }
    .search-box {
      margin: 20px auto;
      width: 60%;
      display: flex;
      align-items: center;
      border: 1px solid #dfe1e5;
      border-radius: 24px;
      background-color: white;
      padding: 5px 15px;
      box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    }
    .search-box input {
      flex: 1;
      border: none;
      outline: none;
      font-size: 16px;
      padding: 10px;
    }
    .search-box button {
      background: none;
      border: none;
      cursor: pointer;
      color: #5f6368;
      font-size: 18px;
    }
    .buttons {
      margin: 20px auto;
    }
    .buttons button {
      margin: 5px;
      padding: 10px 20px;
      font-size: 14px;
      color: white;
      background-color: #1a73e8;
      border: none;
      border-radius: 4px;
      cursor: pointer;
      transition: background-color 0.3s;
    }
    .buttons button:hover {
      background-color: #1669c1;
    }
  </style>
</head>
<body>
  <div class="tabs">
    <div class="tab active" onclick="showTab('tab1')">Tab 1</div>
    <div class="add-tab" onclick="addNewTab()">+</div>
  </div>
  <div id="tab1" class="tab-content active">
    <img src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" alt="Google Logo" class="logo">
    <div class="search-box">
        <input id="tab1-search-input" type="text" placeholder="Search Google or type a URL">
        <button onclick="browse('tab1')">&#x1F50D;</button>
    </div>
    <div class="buttons">
        <button onclick="browse('tab1')">Google Search</button>
    </div>
    <div class="search-results">
        <iframe id="tab1-iframe" class="search-iframe" style="width: 100%; height: 80vh;" frameborder="0"></iframe>
    </div>
  </div>
  <script src="index.js"></script>
</body>
</html>

My only issue is the, “Connect to the Internet” issue. Thank you to anyone that can help me!

OnPress function not working as expected when changing the height attribute on neighbouring view in React Native Screen

I have a sidebar view which has a button which when pressed should navigate to another page in my app. However if I remove the height attribute from a neighbouring view the button is not pressable. If I add a height attribute to my wikiView styles the button then works. I am beside myself on how changing a neighbouring view’s height attribute can make an another views pressable button work/not work.

MainSideBarWeb.js

import React, { useState, Component, useEffect } from "react";
import {
  StyleSheet,
  Text,
  View,
  ScrollView,
  Image,
  TextInput,
  Button,
  Alert,
  TouchableOpacity,
  Modal,
  Pressable,
  StatusBar
} from "react-native";
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';
import { useIsFocused } from "@react-navigation/native";
import { registerRootComponent } from 'expo';
import {NavigationContainer} from '@react-navigation/native';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import { useNavigation } from '@react-navigation/native';
import constants from './Constants.js';
import { styles } from './CommonStylesWeb.js';
import RNPickerSelect from 'react-native-picker-select';

const STYLES = ['default', 'dark-content', 'light-content'];
const TRANSITIONS = ['fade', 'slide', 'none'];

const MainSideBarWeb = () => {
  const [hidden, setHidden] = useState(false);
  const [sideBarContent, setSideBarContent] = useState('');
  const [statusBarStyle, setStatusBarStyle] = useState(STYLES[0]);
  const [statusBarTransition, setStatusBarTransition] = useState(
    TRANSITIONS[0],
  );
  const changeStatusBarVisibility = () => {
    setHidden(!hidden);
    if(hidden) {
        setSideBarContent('')
    }
    else {
        setSideBarContent("Cancer Types n Cancer Drugs n Cancer Genes")
    }
  };

    const changeStatusBarStyle = () => {
      const styleId = STYLES.indexOf(statusBarStyle) + 1;
      if (styleId === STYLES.length) {
        setStatusBarStyle(STYLES[0]);
      } else {
        setStatusBarStyle(STYLES[styleId]);
      }
    };

    const changeStatusBarTransition = () => {
      const transition = TRANSITIONS.indexOf(statusBarTransition) + 1;
      if (transition === TRANSITIONS.length) {
        setStatusBarTransition(TRANSITIONS[0]);
      } else {
        setStatusBarTransition(TRANSITIONS[transition]);
      }
    };

    return (
        <SafeAreaProvider>
          <SafeAreaView style={styles.sideBar}>
            <StatusBar
              animated={true}
              backgroundColor="#61dafb"
              barStyle={statusBarStyle}
              showHideTransition={statusBarTransition}
              hidden={hidden}
            />
            <View style={styles.buttonContainer}>
              <Button style={styles.buttonContainer}
                title="Toggle StatusBar"
                onPress={changeStatusBarVisibility}
              />
            </View>
            {hidden &&
            <View style={[
              styles.sideBar,
              {
                // Try setting `flexDirection` to `"row"`.
                flexDirection: 'column',
              },
            ]}>
               <TouchableOpacity style={{backgroundColor: "red", padding: 20}} onPress={()=> {
                   console.log('does not work');
                   }
                 }>
                 <Text>Press Me</Text>
               </TouchableOpacity>
            </View>
            }

          </SafeAreaView>
        </SafeAreaProvider>
   );
};

export { MainSideBarWeb };

CancerHomepageWeb.js

import { StatusBar } from "expo-status-bar";
import React, { useState, Component, useEffect } from "react";
import {
  StyleSheet,
  Text,
  View,
  ScrollView,
  Image,
  TextInput,
  Button,
  Alert,
  TouchableOpacity,
  Modal,
  Pressable
} from "react-native";
import { useIsFocused } from "@react-navigation/native";
import { registerRootComponent } from 'expo';
import {NavigationContainer} from '@react-navigation/native';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import { useNavigation } from '@react-navigation/native';
import constants from './Constants.js';
import { styles } from './CommonStylesWeb.js';
import RNPickerSelect from 'react-native-picker-select';
import { MainSideBarWeb } from './MainSideBarWeb'

const CancerHomepageWeb = ({navigation}) => {
    const [cancerWiki, setCancerWiki] = useState("");
    const [cancerType, setCancerType] = useState("");
    const [selectedValue, setSelectedValue] = useState(null);
    const [selectedLabel, setSelectedLabel] = useState(null);
    const [options, setOptions] = useState([]);
    const [cancerWikiContent, setCancerWikiContent] = useState("");
    //const navigation = useNavigation();
    console.log("navigation ", navigation);
    useEffect(() => {
        const getData = async () => {

            var urlCancerWiki = await constants.getServerURL() + 'cancers_wiki';
            console.warn(urlCancerWiki);
            let resultCancerWiki = await fetch(urlCancerWiki, {
                method: "GET", mode: 'cors'
                }).then(response => response.json())
                    .then(response => {
                        if (response) {
                            console.warn(response)
                            setCancerWiki(response)
                        }
                });
        };
        getData();
    }, []);
    async function handleChangeCancer(value, index) {
      console.warn("CANCER HAS CHANGED");
      setSelectedValue(value);
      console.warn(value)
      if(index > 0) {
          indexOffset = index - 1;
          console.warn(options[indexOffset].label);
          setSelectedLabel(options[indexOffset].label);

          const url = await constants.getServerURL() + 'cancer_wiki';
          console.warn(url);
          let result = fetch(url, {
             method: 'POST',
             headers: { 'Content-Type': 'application/json' },
             body: JSON.stringify({ id: value}),
             mode: 'cors'
           }).then(response => response.json())
             .then(response => {
                if (response) {
                    setCancerWikiContent(response)
                    setCancerWiki("")
                }
           });

      }
    };
    const searchCancers = async() => {
        const url = await constants.getServerURL() + 'cancer_name';
        console.warn(url);
        console.warn(cancerType);
        if (cancerType.length >= 3) {
            let result = fetch(url, {
               method: 'POST',
               headers: { 'Content-Type': 'application/json' },
               body: JSON.stringify({ cancer_type: cancerType}),
               mode: 'cors'
             }).then(response => response.json())
               .then(response => {
               setOptions([]);
               optionsTemp = [];
               console.warn("GETTING CANCER RESPONSE")
               console.warn(response)
               if (response) {
                    //setCancer = response.cancers
                    console.warn("VALID CANCER RESPONSE")
                    response.map( (cancer) => {
                        optionsTemp.push(new Object({label:cancer.name , value: cancer.id}));
                    });
                    console.warn(optionsTemp)
                    setOptions(optionsTemp);
               } else {
                   console.warn("Error retrieving Cancer");
                   //setErrorMessage("Error Getting Cancers!");
                   //setErrorVisible(true);
               }
              });
        }
    }
    return (

    <View style={styles.sideBar}>
        <MainSideBarWeb />
        <StatusBar style="auto" />
        <View style={styles.container}>
            <TextInput
              style={styles.TextInput}
              placeholder="Cancers"
              placeholderTextColor="#003f5c"
              onChangeText={(cancerType) => setCancerType(cancerType)}
              onKeyPress={searchCancers}
            />
        </View>
        <View style={styles.selectBox}>
            <Text>Select Cancer</Text>
            <RNPickerSelect
              style={styles.container}
              items={options}
              onValueChange={(value, index)  =>
                handleChangeCancer(value,index)}
              value={selectedValue}
            />
            {selectedValue && <Text>Selected: {selectedLabel}</Text>}
        </View>
        <ScrollView>
             <View style={styles.wikiView}>
                 <Text>{cancerWikiContent}</Text>
                 <Text>{cancerWiki}</Text>
             </View>
        </ScrollView>
    </View>
);
}



export { CancerHomepageWeb };

CommonStylesWeb.js (where if wikiView’s height is set MainSideBarWeb’s button works, if it is not, button does not work.

import {
  StyleSheet,
  Text,
  View,
  Image,
  TextInput,
  Button,
  Alert,
  TouchableOpacity,
} from "react-native";

const styles = StyleSheet.create({
  container: {
    flex: 1,
    flexDirection:'column',
    backgroundColor: 'white',
    alignItems: "center",
    justifyContent: "center",
  },
  container1: {
      flex: 1,
      flexDirection:'column',
      backgroundColor: 'white',
      alignItems: "left",
      justifyContent: "left",
  },
  container2: {
      flex: 2,
      flexDirection:'column',
      backgroundColor: 'white',
      alignItems: "left",
      justifyContent: "left",
    },
    container3: {
        flex: 3,
        flexDirection:'column',
        backgroundColor: 'white',
        alignItems: "left",
        justifyContent: "left",
      },
  selectBox: {
      backgroundColor: 'white',
      alignItems: "center",
      justifyContent: "center",
      marginLeft: 400,
      marginRight: 400,

  },
  wikiView: {
    backgroundColor: "#94C93D",
    borderRadius: 30,
    width: 1000,
    height: 300,
    marginBottom: 20,
    alignItems: "center",
    justifyContent: "center",
    marginLeft: 300,
    marginRight: 250,
  },
  TextInput: {
    backgroundColor: "#94C93D",
    width: 1000,
    flex: 1,
    padding: 10,
    marginLeft: 20,
    alignItems: "center",
    justifyContent: "center",
  },
    backButton: {
        alignItems: 'left',
        justifyContent: 'left',
        paddingVertical: 12,
        paddingHorizontal: 32,
        borderRadius: 4,
        elevation: 3,
        backgroundColor: '#2196F3',
    },

    scrollView: {
        marginHorizontal: 20,
        height: 500,
    },
    sideBar: {
        flex: 1,
        flexDirection:'column',
        backgroundColor: 'white',
        alignItems: "left",
        justifyContent: "left",
        backgroundColor: '#ECF0F1',
    },
    buttonOpen: {
      backgroundColor: '#F194FF',
    },
    buttonClose: {
      backgroundColor: '#2196F3',
    },
    buttonContainer: {
      backgroundColor: 'white',
      width: 100
    }
});

export { styles };

SpreadJS 16v refresh from new every time

I’m trying to retrieve user data into the modified spreadsheet but it refreshes from new every time, I’m currently using 16v, this wasn’t with 13v.
After calling the function essIFrame.postMessage(message, ESSurl); the data is wiped out

I also tried to copy the info into a different input, even bring it from database but the spreadsheet keeps refreshing from new.
I’m expecting to reload the modification that the user does, for example if I write anything into a cell, I’m expecting to see that content but instead I see a new empty spreadsheet

How can I create a comma-separated string in JavaScript using a for loop without adding a trailing comma?

I’m learning JavaScript and practicing string manipulation using for loops. I’m trying to build a string that repeats a word multiple times, separated by commas, but without leaving an extra comma at the end.

Here’s an example:

  • Input: "hello", 3
  • Expected Output: "hello,hello,hello"

This is the code I’ve written so far:

function repeatWord(word, times) {
  let result = "";
  for (let i = 0; i < times; i++) {
    result += word + ",";
  }
  return result; // This adds an extra comma at the end. How can I fix this?
}

What I’ve Tried

  1. Using a for loop to add the word and a comma on each iteration. However, I haven’t figured out how to prevent the extra comma from being added after the final word.
  2. I’ve researched string manipulation techniques and found that methods like Array.join() could handle this easily:
Array(times).fill(word).join(",");

But I specifically want to use a for loop to improve my understanding of loops and conditionally appending characters.

  1. I’ve reviewed the MDN for loop documentation and beginner tutorials, but most focus on basic iteration or adding fixed patterns without addressing how to exclude trailing characters.

My goal is to modify my code to:

  • Repeat a word multiple times.
  • Add commas between each repetition.
  • Avoid adding a trailing comma after the last word.

This exercise is helping me learn how to use loops effectively for string building, so I’d appreciate an explanation focused on using for loops rather than alternative methods.

Error: cannot estimate gas; transaction may fail or may require manual gas limit (Sepolia test Network)

I will summarise my question.
I have first deployed successfully the smart contract from my account address in Sepolia test network. Then, when I wanted to call a function of that deployed contract, I have this error:
“cannot estimate gas; transaction may fail or may require manual gas limit”. “UNPREDICTABLE_GAS_LIMIT”
The parameter of the function that I want to call is a deployed contract address that implement a Interface.

I have tried to fix this problem on my own searching on the internet, but I couldn’t. I have tried to add a gas limit manually to the transection, but it did not work. I used Hardhat for this project and maybe something is wrong with the configuration.
Please, help!

“Deploy.js” file:

const hre = require("hardhat");
const ethers = hre.ethers;

async function main() {
 // The address of the winner contract that we want to call
  const winnerContractAddress = "0xcF469d3BEB3Fc24cEe979eFf83BE33ed50988502";
  // Get the EventWinner contract factory from the hardhat config
  const EventWinner = await hre.ethers.getContractFactory("EventWinner");
  // Deploy the EventWinner contract to the blockchain
  const eventWinner = await EventWinner.deploy();

  // Wait for the contract to be deployed
  await eventWinner.deployed();

  // Log the address of the deployed contract to the console
  console.log(`contract is deployed to ${eventWinner.address}`);

  // Call the callWinner function of the EventWinner contract and pass in the address of the winner contract
 
  const tx = await eventWinner.callWinner(winnerContractAddress);
 
  // Wait for the transaction to be confirmed on the blockchain
  await tx.wait();
}

// Call the main function and catch any errors
main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

“Contract.sol” file:

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.27;

interface ContractWinner{
    function attempt()external;
}

contract EventWinner{
    // Function to call the attempt function on the ContractWinner instance at the given address
    function callWinner(address winnerContractAddress) external{
        ContractWinner(winnerContractAddress).attempt();
    }
}

“hardhat.config.js” file:

require("dotenv").config();
require("@nomicfoundation/hardhat-toolbox");
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  
  solidity: "0.8.27",
  networks: {
    sepolia: {
      url: process.env.RPC_URL,
      accounts: [process.env.PRIVATE_KEY]
    },
  },
  etherscan: {
    apiKey: {
      sepolia: process.env.ETHERSCAN_API_KEY,
    },
  },
};

Problems hitting a localhost API

I am using React with Remix.run and I am using fetch to call an API that runs in my localhost (developed with C# and .NET 8).
The ports of my React application and web API are different but both run in localhost.

The code runs in a Remix (on server-side, i.e. node.js) and is the following:

response = await fetch(apiURL, {
  method: "GET",
  headers: { "Content-Type": "application/json" },
});

I would say that normally there is a problem with the API (an HTTP 500 error) but here the API is not being called.
Any ideas on how to solve this?

If I use axios, I get an error saying “self signed certificate” and a huge stack trace but with no additional details.

The axios code I tried is:

get = async <T>(
  url: string,
  config?: AxiosRequestConfig<any> | undefined
) => {
  try {
    const res = await this.api.get<T>(url, {
      ...config,
    });
    return res.data;
  } catch (err) {
    console.log("Error:" + JSON.stringify(err));
    if (axios.isAxiosError(err) && err.response) {
      console.log("Error:" + JSON.stringify(err.response));
      const error = (err.response.data?.detail && {
        cause: {
          status: err.response.status,
          detail: err.response.data?.detail,
        },
      }) || {
        cause: err.response.status,
      };
      throw new Error(
        error.detail || "Something went wrong: " + err.toString()
      );
    }
    throw new Error("Something went wrong");
  }
};

Recursion Inconsistency in Javascript

I have written some short recursive code to try to find the minimal path sum through a 2D array in Javascript, only moving right or down from top-left to bottom-right. The code seems good to me, but basically it seems to get confused about the output of stacked function calls…

a=[
  [ 3, 8, 8 ],
  [ 1, 4, 7 ],
  [ 8, 7, 1 ]
]
w=a[0].length-1
h=a.length-1
f=(s,x,y)=>{s+=a[y][x]
console.error([s,x,y,x<w,y<h])
if(x==w&&y==h)return s
r=x<w?f(0,x+1,y):9999
d=y<h?f(0,x,y+1):9999
console.error([s,x,y,r,d,r<d?s+r:s+d])
return r<d?s+r:s+d}
console.log(f(0,0,0))

For this array, it outputs 11 instead of 16. Attempt this online!

Looking closer the problem occurs at (1,1) where it tests the paths 4+7+1 (right, down) and 4+7+1 (down, right). Changing the last line to console.log(f(4,1,1)) makes this easier to see. You get a return value of 9 and the below error output:

[ 8, 1, 1, true, true ]
[ 7, 2, 1, false, true ]
[ 1, 2, 2, false, false ]
[ 7, 2, 1, 9999, 1, 8 ]
[ 7, 1, 2, true, false ]
[ 1, 2, 2, false, false ]
[ 7, 1, 2, 1, 9999, 8 ]
[ 8, 1, 1, 1, 8, 9 ]

Both the (2, 1) and the (1, 2) paths correctly evaluate their path sums to 8 (7+1). But then when we fall back to the (1, 1) node in the tree, it seems to think the right path evaluated to 1 instead of 8, so it consistently underestimates the path length by 7. I can’t seem to understand why this is happening. I’m new to JavaScript. Can someone please explain what’s going wrong here?

Simulate js click event on Gtok HTML element

I’m trying to write JS test code for Gettr social site & I have problem with simulating a JS click() event on Gettr GTok video player

Sample link (take any)

https://gettr.com/gtok/p3e65qa96a2

I’m trying to click on the arrow down element

It can be found using this query

document.querySelector("a[href*='/gtok/']:nth-child(2)")

But click(); doesn’t work

document.querySelector("a[href*='/gtok/']:nth-child(2)").click()

nothing happens.

I’ve tried to trigger mouse events:


function simulateMouseClick(targetNode) {
    function triggerMouseEvent(targetNode, eventType) {
        var clickEvent = document.createEvent('MouseEvents');
        clickEvent.initEvent(eventType, true, true);
        targetNode.dispatchEvent(clickEvent);
    }
    ["mouseover", "mousedown", "mouseup", "click"].forEach(function(eventType) { 
        triggerMouseEvent(targetNode, eventType);
    });
}

simulateMouseClick(document.querySelector("a[href*='/gtok/']:nth-child(2)"))

Doesn’t work too…

The app is based on React, I never had any issue with writing tests for React apps but this one just refuses to be clicked on 😀

I suspected it might check for ‘isTrusted’ in onclick event, but I couldn’t find any references to this string in JS files…

I’ve tried to fire ‘keydown’ event on this item

function fireDownKey(el)
{
    var key = 40;
    if(document.createEventObject)
    {
        var eventObj = document.createEventObject();
        eventObj.keyCode = key;
        el.fireEvent("onkeydown", eventObj);   
    }else if(document.createEvent)
    {
        var eventObj = document.createEvent("Events");
        eventObj.initEvent("keydown", true, true);
        eventObj.which = key;
        el.dispatchEvent(eventObj);
    }
} 

fireDownKey(document.querySelector("a[href*='/gtok/']:nth-child(2)"))

Still nothing! Stubborn element to click on…