Google Apps Scripts URL throwing Error 404

By following the instructions on this page — https://developers.google.com/apps-script/api/reference/rest/v1/scripts/run#http-request, I tried the URL, i.e.,

https://script.googleapis.com/v1/scripts/{scriptId}:run

After replacing {scriptId} with the actual script ID, the link was throwing Error 404.
I was trying to submit a HTML form to Google Forms, and I thought this script is necessary to do so, can you please advise other ways to submit forms to Google forms from HTML forms?

NodeJS pass captcha with tesseract.js

I’m having a problem solving the capcha on a site.

The system works like this, first I go to the site with the pupeter and fill in the necessary information, and I save the screenshot of that part with the pupeter to solve the captcha there.

Then I try to read it with the tesseract.js module, but the result I want does not appear here.

import puppeteer from "puppeteer";
import { createWorker } from "tesseract.js";
const worker = createWorker();

const start = async function () {
  let launchOptions = { headless: false, args: ["--start-maximized"] };

  const browser = await puppeteer.launch(launchOptions);
  const page = await browser.newPage();

  await page.setViewport({ width: 1366, height: 768 });
  await page.setUserAgent(
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36"
  );

  await page.goto(
    "https://webihlaltakip.kgm.gov.tr/WebIhlalSorgulama/Sayfalar/Sorgulama"
  );

  await page.type('input[title="Plaka"]', "AA" as string);

  const logo = (await page.$(
    "#pnlUpdate > table > tbody > tr:nth-child(2) > td:nth-child(1) > table > tbody > tr:nth-child(2) > td"
  )) as any; 
  await logo.screenshot({
    path: "captchaImage.png",
  });

  setTimeout(() => {
    (async () => {
      await worker.load();
      await worker.loadLanguage("eng");
      await worker.initialize("eng");
      const {
        data: { text },
      } = await worker.recognize("./captchaImage");
      console.log(text);
      await worker.terminate();
    })();
  }, 2000);
};

start();

For example, the code written in the captcha picture is 5000 then result is very different.

How to stop the child to inheriting the parents filter property?

If I use the css filter property on the parent then It affecting the child too. I want to stop the child to not effect when I set the propert filter in parent.

article {
  width: 300px;
  height: 300px;
  
  position: relative;
}

article:hover {
  filter: contrast(110%);
}

img {
  width: 300px;
  height: 300px;
}

div {
  width: 200px;
  height: 50px;
  background: #FCDBA3;
  
  position: absolute;
  bottom:0;
}
<article>
  <img src="https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885_960_720.jpg" />
  
  <div></div>
</article>

If you noticed carefully! You can see when I hover over the article then the div tag also affecting because of the filter property. But I don’t want the div to get affected when I hover over the article.

How can I achieve it?

React globalThis reverting to initial value

I have an element that I create through a visitor pattern:

public Create(): void {
    ...
    globalThis.pinConfiguration.parts.push({type: this.element.localName, id: this.element.id, top: 0 , left: 0 });

    const arr1: string[] = [this.elementID+":A", "pin:10"];
    const arr2: string[] = [this.elementID+":C", "pin:GND"];

    globalThis.pinConfiguration.connections.push(arr1, arr2); 
    ...
    Drag(this.element);
    ...
}

The Drag method looks like this

export function Drag(element: HTMLElement) {


    const simulation = document.getElementById('simulation--simulationArea');

    element.onmousedown = (e) => {
      simulation!.addEventListener('mousemove', handler);
      dragStart(e);
    }

    element.onmouseup = (e) => {
      simulation!.removeEventListener('mousemove', handler);
      simulation?.dispatchEvent(new Event('change'));
      dragEnd(e);
    }

    let xdiff: number = 0;
    let ydiff: number = 0;
    let isDragging: boolean = false;

    const dragStart = (e: any) => {
      xdiff = (e.screenX - element.getBoundingClientRect().left);
      ydiff = (e.screenY - element.getBoundingClientRect().top);
      isDragging = true;
    };

    const dragging = (e: any) => {
        if (isDragging) {
            var left = e.screenX - xdiff - simulation!.getBoundingClientRect().left;
            var top = e.screenY - ydiff - simulation!.getBoundingClientRect().top;
            element.style.top = (top + "px").toString();
            element.style.left = (left + "px").toString();
            globalThis.pinConfiguration.parts.find(part => part.id === element.id)!.top = top;
            globalThis.pinConfiguration.parts.find(part => part.id === element.id)!.left = left;
        }
    };

    const handler = (e: any) => {
        dragging(e);
    };

    const dragEnd = (e: any) => {
        isDragging = false;
    };
}

The problem is that the entire created object seems to remember the initial globalThis.pinConfiguration state and when I later change the global variable elsewhere (connect to different pins for instance) and then try to drag the created component, the global values are back to the ones with which the element was created.

// This works
function handleConnectionsChange(newValue: string) {

  try {
    globalThis.pinConfiguration = JSON.parse(newValue);
    setEditorContext(newValue);
    console.log('handleConnectionsChange');
    console.log(globalThis.pinConfiguration);
  }
  catch (err) {
      console.error(err);
  }
}

Is there a way to use a pointers/references in react? It seems to me that the global variable gets just duplicated to a different place in the memory during element creation and that this is the root of the entire problem.

Has anyone ever encountered and solved this? I’m not a web developer, perhaps the problem will be glaringly obvious to you. Thank you.

how to make [ifrarme tag more adjustable]

I want to make my iframe wipers and works behind the text but it seems that I couldn’t do it , if someone can help

tell me more about what’s wrong with my code and how to improve it
and I wanna know if someone is free to help me with the rest of the project

here’s my code:

    
    <!-- language: lang-html -->
    
        <section id="hero" class="d-flex justify-content-center align-items-center">
          <div class="container position-relative" data-aos="zoom-in" data-aos-delay="100">
            <div class="row">
              <div class="col-md-6">
                <h1>Let's <span style="color:#37D7BB;">Connect</span> you,<br>An Educator that works with you</h1>
                <h2>Learn easily with better person and grow for yourself</h2>
                <a href="#" class="btn-get-started">Get Started</a>
              </div>
              <div class="col-md-6 mydots">
                <iframe src='https://my.spline.design/interactivespherescopy-ff4fb574865b5c4be7dac5a0faa9d13f/' frameborder='0' width='100%' height='100%'></iframe>
              </div>
            </div>
          </div>
        </section>

Auto convert all html char to readable text

I scraped webpage but it has a lot of special characters, for example,

“a +ΔS” turns into: “a +ΔS”

“→” turns into: “→”

“<−>” turns into: “<−>”

When I display it to my website.

I tried to change it manually to html numbers like “→” to “& rarr ;”, but I feel like I am wasting my time because of too many occurences.

Why does his website reads “→” without converting to “& rarr ;”?

I tried this but did not work Thanks:

replace(/[u00A0-u9999<>&]/g, function(i) {
   document.write('&#'+i.charCodeAt(0)+';');
});

location.href not working when preceded by document.cookie

i’m trying to redirect users after i getting some informations but the location.href does’nt work when she proceded by document.cookie after i cancled it the program redirect but with no informations
here is the code

document.getElementById('envoyer').onclick=function k()
{

var numfilieres=[];
for(let i=0;i<8;i++){
    

numfilieres.push(document.getElementById(i).value);

        }

numfilieres=numfilieres.join('');

// document.cookie='num'= + numfilieres;

window.location.href="confirm.php";

}

JQuery won’t fire an action from modal

I have the following form in a Bootstrap modal window

            <form id="formCsv" class="row gy-2" enctype="multipart/form-data">
              <div class="col-md-5 ">
                <input class="form-control" type="file" id="file" name="file">    
              </div>
                <div class="col-md-3">
                <button type="submit" id="csvBtn"class="btn btn-primary" name="something"> Upload </button>
              </div>
              <div id="loading" class="clearfix col-md-2">
                <div class="spinner-border text-primary float-right" role="status"></div>
              </div>
              <div class="col-md-2">
                <button type="button" id="export-btn" class="btn btn-primary" disabled>Export CSV</button>
              </div>
            </form>

JQuery file

console.log("Works");

$(document).ready( function() {
    // Submit form data via Ajax
    $("#formCsv").on('submit', function(e)
    {
        alert("test");
        e.preventDefault();
        var form_data = new FormData($(this)[0]); 

        $.ajax({
            type: 'POST',
            url: 'src/positionen/getCsvData.php',
            data: form_data,
            contentType: false,
            cache: false,
            processData:false,
            success: function(response)
            {
                console.log(response);
                var json = JSON.parse(response);                
                addToTable(json);
            },
        });
    });
});

The console.log() works.
The alert() within is not triggered and no errors are thrown.

Any ideas why it is like this?

Without a the form in a modal it just works fine.

JavaScript code doesn’t work, no errors or stops

I am new to JavaScript and I try to write a decoder to caesar cipher. But my code doesn’t work, and there is no errors shown and it doesn’t stop.

let word = "привет";
let shift = 3;
let result = "";
for (let i = 0; i < word.legth; i++){
    if ('А'.charCodeAt(0) <= word[i].charCodeAt(0) <= 'Я'.charCodeAt(0)) {
        let char = ((word[i].charCodeAt(0) + shift - 'А'.charCodeAt(0)) % 32) + 'А'.charCodeAt(0)
        result = result + String.fromCharCode(char);
    }
    else if ('а'.charCodeAt(0) <= word[i].charCodeAt(0) <= 'я'.charCodeAt(0)) {
        let char = ((word[i].charCodeAt(0) + shift - 'а'.charCodeAt(0)) % 32) + 'а'.charCodeAt(0)
        result = result + String.fromCharCode(char);
    }
    else {
        result = result + word[i];
    }
}
console.log(result)

Axios is not loading List Content in Unit Test => Empty Array

I have this list in my frontend

<ul>
  <li v-for="department in departments" :key="department.DepartmentId" data-test="department">
        {{ department.DepartmentName }}
  </li>
</ul>

and this action

methods: {
        async refreshData() {
            axios.get("http://localhost:49146/api/department").then((response) => {
                this.departments = response.data
            }).catch( error => console.log( 'error: ' + error ) );
        },

and this Unit Test

import axios from 'axios';
import DepartmentForm from '../../src/components/DepartmentForm.vue'
import { mount, flushPromises } from '@vue/test-utils'

const mockList = [
    { DepartmentId: 1, DepartmentName: 'Support'},
    { DepartmentId: 2, DepartmentName: 'IT'}
]

// Following lines tell Jest to mock any call to `axios.get`and to return `mockPostList` instead
jest.spyOn(axios, 'get').mockResolvedValue(mockList)

describe('DepartmentForm.vue', () => {
    const wrapper = mount(DepartmentForm)

    it('Does a wrapper exist', () => {
        expect(wrapper.exists()).toBe(true)
    })

    it('Has a department table', () => {
        expect(wrapper.find('table').exists()).toBe(true)
    })

    it('Refreshes departments on mount', async () => {
        // Let's assert that we've called axios.get the right amount of times and
        // with the right parameters.
        expect(axios.get).toHaveBeenCalledTimes(1)
        expect(axios.get).toHaveBeenCalledWith('http://localhost:49146/api/department')

        // Wait until the DOM updates.
        await flushPromises()

        // Finally, we make sure we've rendered the content from the API.
        const departments = (wrapper.findAll('[data-test="department"]'))        

        expect(departments).toHaveLength(2)
        expect(departments[0].text()).toContain('Support')
        expect(departments[1].text()).toContain('IT')
    })
})    

On my localhost everything is working. But my UnitTest is faulty, because apparently the departments list is empty.

Unit Test Fail

How can I fix this issue?

NextJS Error while using react-router-dom

I am Using Nextjs with React-router-dom, I am getting reference errors and I don’t know why.

my index.js

import Head from "next/head";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import Landing from "./Landing";

export default function Home() {
  return (
    <div>
      <Head>
        <title>Jobify</title>
        <meta name="description" content="Generated by create next app" />
        <link rel="icon" href="/favicon.ico" />
      </Head>
      <BrowserRouter>
        <Routes>
          <Route exact path="/" element={<div>Dashboard</div>} />
          <Route exact path="/register" element={<div>Register</div>} />
          <Route exact path="/landing" element={<div><Landing/></div>} />
          <Route path="/" element={<h1>Error</h1>} />
        </Routes>
      </BrowserRouter>
    </div>
  );
}

Error:
Server Error
ReferenceError: document is not defined

ng2-pdf-viewer issue: 403 when rendering the pdf, even if file is already stored in memory

I’m trying to use ng2 pdf viewer to render a blob that is already saved in memory, but I keep getting a 403 error when trying to render the pdf despite the file being available in memory in a variable (I also have a download button that uses the same variable to download the file locally and that works fine).

This error only happens on our development server. When running my application on localhost everyone is working perfectly fine.

After doing some testing, I seem to have discovered that the pdf viewer module does another backend call to render the PDF, despite the fact that I refer to a variable that holds the file, and this second call is what causes the 403 error. Is this possible?

The chain of events seems to be:

  • My pdf gets loaded through a call to the backend, in the subscribe I
    put the pdf blob in a file variable
  • the pdf-viewer component is rendered visible since the ng-if is set
    to true
  • A second call seems to happen to my backend despite the HTML src
    property referring through an in memory blob. Is this normal behavior
    or am I minsterpreting what is happening? Can this be avoided? I’m
    pretty sure this is what is causing my issue.

My typescript method is the following:

downloadFile(observable: Observable<any>) { observable.subscribe((document: any) => { console.log(document) this.file = document; console.log(this.file) if (!this.isFilePdF()) { this.isLoading = false; } }) }

And my HTML is:

<pdf-viewer (error)="logError($event)" [zoom]="zoomRatio" [hidden]="isLoading" *ngIf="isFilePdF()" (after-load-complete)="finishLoading($event)" [(page)]="currentPage" [src]="file" [original-size]="false" [class.height]="!isLoading" style=" width: 100%; background-color:whitesmoke"> </pdf-viewer>

A screenshot of my error:
As you see, the first download downloads the file perfectly fine and saves it in the parameter. The second download is causing the error, and I have no idea why the second download is happening since I didn't do anything in my code for it.

As you see, the first download downloads the file perfectly fine and saves it in the parameter. The second download is causing the error, and I have no idea why the second download is happening since I didn’t do anything in my code for it.

If there is a way to just use the blob variable from the first download, and not having the second one happen, I’m sure my issue would be resolved.

Does anyone know how to fix the issue I am having?

REACTJS how to make an invisible navigation bar that when scrolling down it shows with a transition effect?

My fixed navigation bar on scrolling doesn’t work, I’m trying that once when entering the page the navigation bar is invisible, and when I scroll down it appears with a transition effect, like could do it? I feel that I am doing everything right, but something is wrong, I can’t find the place, for a moment with the code as it was, the nav I want was working, I don’t know what could have changed

[Navbar.js]

import React, { useEffect } from "react";
import { Link } from "react-router-dom";
import "./Navbar.scss";

const Navbar = () => {
  
  useEffect(() => {
    window.addEventListener("scroll", isSticky);
    return () => {
      window.removeEventListener("scroll", isSticky);
    };
  });

  const isSticky = (e) => {
    const header = document.querySelector(".header-section");
    const scrollTop = window.scrollY;
    scrollTop >= 250
      ? header.classList.add("is-sticky")
      : header.classList.remove("is-sticky");
  };

  return (
    <>
      <section className="section-1">
        <header className="header-section d-none d-xl-block">
          <nav className="navbar">
            <div className="navbar__menu">
              <ul className="navbar__ul">
                <li className="navbar__li">
                  <Link to="/mens">MENS</Link>
                </li>
                <li className="navbar__li">
                  <Link to="/womens">WOMENS</Link>
                </li>

                <li className="navbar__li">
                  <Link to="/make-product">SPREAD YOUR PRODUCT</Link>
                </li>
              </ul>
              <div className="navbar__logo">
                <h1 className="navbar__title">
                  <Link
                    style={{
                      textDecoration: "none",
                      color: "black",
                      fontWeight: "bold",
                      letterSpacing: ".7px",
                      fontSize: "2rem",
                      marginRight: "264px",
                    }}
                    to="/"
                  >
                    <span
                      style={{
                        fontSize: "2rem",
                      }}
                    >
                      1
                    </span>
                    COMFORT
                  </Link>
                </h1>
              </div>
              <ul className="navbar__ul">
                <li className="navbar__li">
                  <Link to="/">SEARCH</Link>
                </li>
                <li className="navbar__li">
                  <Link to="/sign-in">SIGN IN</Link>
                </li>
                <li className="navbar__li">
                  <Link to="/cart">CART</Link>
                </li>
              </ul>
            </div>
          </nav>
        </header>
      </section>
    </>
  );
};

export default Navbar;

[Navbar.scss]

.section-1 {
  background-color: #3b0000;
  background-position: center;
  height: 100vh;
  background-size: cover;
  width: 100%;
}

header {
  display: flex;
  padding: 30px;
  align-items: center;
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  width: 100%;
  transition: 500ms;
}

.navbar__title {
  flex: 1;
  font-size: 1.5rem;
  font-weight: bold;
  color: #fff;
  text-align: center;
  text-transform: uppercase;
}

.navbar {
  background-color: white;
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  width: 100%;
  z-index: 1;
}
.none {
  display: none;
}

.navbar__menu {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
}

.navbar__ul {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.navbar__li {
  display: inline-block;
  margin: 0 0.7rem;
}

.navbar__li a {
  color: black;
  text-decoration: none;
  font-size: 0.9rem;

  &:hover {
    text-decoration: underline;
    transition: all 2.3s ease-in-out;
  }
}

.is-sticky {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 999;
  box-shadow: 0 2px 24px 0 rgb(0 0 0 / 15%);
  background-color: #ffffff !important;
  animation: 500ms ease-in-out 0s normal none 1 running fadeInDown;
  padding-top: 0px;
  padding-bottom: 0px;
}

How to get image & text value on click in JavaScript?

I have a list and I want to get image and text value using JavaScript how can i do that? right now i’m getting only selected li id.

My Code:-

function reply_click()
{
    console.log(event.target.id);
}
ul.coinList{ margin:0px; padding:0px;}
ul.coinList li{ list-style:none; border:1px solid #ccc; padding:10px; display:flex; margin-bottom:20px; display:block;}
<ul class="coinList">

<li id="1" onClick="reply_click();">
<img src="https://via.placeholder.com/140x100" />
<span class="coinText">one</span>
</li>

<li id="2" onClick="reply_click();">
<img src="https://via.placeholder.com/140x100" />
<span class="coinText">two</span>
</li>

</ul>

Thanks for your efforts!