coreui – How do I create a Logout link (with icon) at the footer of the sidebar properly ? (in React)

In coreui, How do I create a Logout link (with icon) at the footer of the sidebar properly ? (in React)

https://github.com/coreui/coreui-free-react-admin-template <– this is the template I’m using.

I tried the following:

  <CSidebarFooter className="border-top d-none d-lg-flex">
    
  <CNavItem customClassName="nav-icon">
    <CNavLink to='/logout'>
      <CIcon icon={cilAccountLogout} className="me-2" />
      Logout
    </CNavLink>
  </CNavItem>
  
    <CSidebarToggler
      onClick={() => dispatch({ type: 'set', sidebarUnfoldable: !unfoldable })}
    />
  </CSidebarFooter>

But if you check out the screenshots. There is a dot and when the sidebar is contracted, the word “Logout” doesnt disappear.


How to let mouse hover effect apply to two overlayed images?

I have two images in the same div, one over another. I want the mouse hover effect to apply to both images when I move mouse over the image, and the background image will display to have the zoom effect. But I found only the one on the top will react to the hover. Is there anyway to let both images change simultaneously?

<div class="overlay transparent" onmousemove="zoom(event)"
  style="background-image: url(https://i.pinimg.com/originals/2b/de/de/2bdede0647e3cdf75b44ea33723201d9.jpg)">
  <img src="https://i.pinimg.com/originals/2b/de/de/2bdede0647e3cdf75b44ea33723201d9.jpg" />
  <img src="https://media.nomadicmatt.com/2023/tropicalislandsfeature.jpg" />
</div>

<style>
  div.transparent {
    height: 150px;
    width: 250px;
    overflow: hidden;
    cursor: zoom-in;
  }

  div.transparent img:hover {
    opacity: 0;
  }

  div.transparent img {
    transition: opacity 0.5s;
    display: block;
    width: 100%;
  }

  div.overlay {
    position: relative;
    display: inline-block;
  }

  div.overlay img:nth-child(1) {
    position: relative;
    object-fit: contain;
    z-index: 1;
  }

  div.overlay img:nth-child(2) {
    position: absolute;
    object-fit: contain;
    top: 0;
    left: 0;
    z-index: 2;
  }
</style>

<script>
 function zoom(e) {
            var zoomer = e.currentTarget;
            e.offsetX ? offsetX = e.offsetX : offsetX = e.touches[0].pageX
            e.offsetY ? offsetY = e.offsetY : offsetX = e.touches[0].pageX
            x = offsetX / zoomer.offsetWidth * 100
            y = offsetY / zoomer.offsetHeight * 100
            zoomer.style.backgroundPosition = x + '% ' + y + '%';
        }
</script>

Is there any way to capture whole Wikipedia links

I’m developing a tool for Wikipedia that fixes mistakes and replaces incorrect words in the text of Urdu language. Right now, it’s replacing words everywhere, even in links and templates. But I want to avoid changing links and templates to prevent breaking them. I’ve tried different ways to do this, but it’s not working. How can I make sure the tool doesn’t change any text inside double square brackets or double curly braces?

Here’s the code for the function that fixes words. It’s already skipping text like “[[JavaScript]]” and “{{JavaScript}}”, but I need it to skip entire links or those links which includea incorrect words like “[[source codes of JavaScript software]]” and “{{source codes of JavaScript software}}”. Specifically, I want the tool to ignore all text inside double square brackets or double curly braces.

async function imla(imlaWords) {
try {
    const pageTitle = mw.config.get('wgTitle');
    let pageContent = await loadPage(pageTitle);
    const originalContent = pageContent;

    // Regex patterns for wiki links and words between curly braces
    const wikiLinkRegex = /[[(.*?)(|.*?)?]]/g; // Regex for wiki links
    const curlyBracesRegex = /{{(.*?)(|.*?)?}}/g; // Regex for words between curly braces

    imlaWords.forEach(([incorrectWord, correctWord]) => {
        const regex = new RegExp(incorrectWord, 'g');
        pageContent = pageContent.replace(regex, (match) => {
            // Check if the matched word is within square brackets or curly braces
            const isWithinSquareBrackets = wikiLinkRegex.test(match);
            const isWithinCurlyBraces = curlyBracesRegex.test(match);
            if (isWithinSquareBrackets || isWithinCurlyBraces) {
                // If within square brackets or curly braces, don't replace
                return match;
            } else {
                // Otherwise, replace with the correct word
                return correctWord;
            }
        });
    });

    const imlaCorrected = originalContent !== pageContent;

    if (imlaCorrected) {
        // اصلاحات کو صفحہ میں محفوظ کیا جا رہا ہے
        await savePage(pageTitle, pageContent);
        openDiffPage(pageTitle); // اصلاحات کے بعد فرق صفحہ کھولنے کے لیے
    } else {
        // اگر اصلاح کی ضرورت نہ ہو تو
        mw.notify('اِس صفحہ میں اصلاح کی ضرورت محسوس نہیں ہوئی۔');
    }
} catch (error) {
    mw.notify(error.message);
}

}

Is there a way to fix this blank page?

I’m trying to make a book using HTML, CSS, and JS. Everything works except the last page; for some reason it is broken like having a extra page even though it’s not supposed to.

I tried replacing all the files but it is not working. The site is supposed to not add a blank page after “Answer Questions”.

How to make html2canvas faster when generating a PDF using HTML tables in my angular application using jsPDF?

I have a Angular application which presents a paginated table to the user. My user needs to be able to create a PDF report with each paginated table per page, scaled to fit 1 table per page.

Currently I have this implementation using JSPDF:

  async downloadCustomTablePdf() {

    const pdf = new jsPDF('l', 'mm', 'a4');


    let temp = [];
    let count = 1;

    for (let i in this.fData) {

      if (count > 18) {
        count = 1
        this.fDataReport = temp;

        const table: any = document.getElementById('myTable');
        table.style.width = '100%';

        await html2canvas(table).then(async (canvas) => {
          const imageData = canvas.toDataURL('image/jpeg', 0.5);

          const imgWidth = pdf.internal.pageSize.getWidth() - 20; 
          const imgHeight = canvas.height * imgWidth / canvas.width;

          pdf.addImage(imageData, 'PNG', 10, 10, imgWidth, imgHeight);
          temp = [];

          pdf.addPage('l');

        });

      }

      if (count <= 18) {
        temp.push(this.fData[i]);
        count++
      }

    }

    pdf.save('table.pdf');
  }

essentially the current code loops through by data object and populates the Table and every 18 rows a “screenshot” is taken and added to the PDF page.
But it seems that for each page it takes about 1 second to process. Wondering if there is faster way of doing this? Potentially without the image method. Its imperative that each tabled is scaled to fit on only 1 page.

Thanks for any help on this.

Any alternatives to function like iframe? Something like a web browser inside the page

I have an HTML page (let’s call it A) on my own domain that displays content I want the user to see, and below this content, I have an iframe of another page (let’s call it B). Page B isn’t mine; it is a platform where the user must sign in to their account. However, the platform of page B apparently doesn’t allow its users to log in from another domain. So when the user signs in through the iframe, the account instantly logs out. They use something like Cloudflare captcha.

Is there any alternative to an iframe that could work for me? Something like opening a mini browser inside the page so that platform B will only recognize that the user is logging into their account via a normal browser and not from another domain. Or perhaps something that doesn’t allow platform B to detect that the account was logged in from another domain.

Thanks!

The html page and the iframe is working perfectly but the only problem is the automatic logout

Glow following cursor in html or css

I have this example website here: https://jars.vexyhost.com/
And i want to ask what is called this glow that follow cursor when you hover cards from page?

And on second example here: https://www.areacs.ro/
The web following cursor…
What is that called?
If possible to help with how to do it too is ok, if not at least with the name of thing and i can look on google. Thank you!

I tried look on google for something similar but i couldnt find it at all

Show Splash Screen on Cache Miss to CanvasKit

I want to display a splash screen only if canvaskit.wasm is not available locally. I am fine using heuristics that are not always perfect.

The other option is to always show a splash screen, but I found it suboptimal because the splash screen gets discarded almost immediately and it gives a weird UI.

Can’t view an ejs file using the a tag to link to it

I am trying to make a blog web app using node.js and express. I am trying to link to ejs files that were created in a blog-files directory using an a tag. I am quite new to programming (2-3 consistent months practice) so I’m finding backend difficult to understand. I should be able to view the files created from within the index.ejs file but it keeps showing an error such as:
Cannot GET /blog-files/2024-04-06_09-22-51.ejs

Index.ejs code

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Cooper's Blog</title>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
    <link rel="stylesheet" href="styles/main.css">
</head>

<body>
    <%- include("form-create.ejs") %>

        <h3>Recent Blog Posts</h3>
        <ul>
            <% files.forEach((file)=> { %>
                <li><a href="/blog-files/<%= file %>">
                        <%=file%>
                    </a>

                </li>
                <% }); %>
        </ul>

</body>

</html>

app.js code

import express from "express";
import bodyParser from "body-parser";
import fs from "fs";
import { v4 as uuidv4 } from "uuid";

const app = express();
const port = 3000;

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

app.use(express.urlencoded({ extended: true }));

app.get("/", (req, res) => {
    const blogDirectory = "./views/blog-files";
    fs.readdir(blogDirectory, (err, files) => {
        if (err) {
            console.log(`Error reading directory:`, err);
            res.status(500).send("Error reading directory");
            return;
        } else {
            res.render("index.ejs", { files });
        }
    });
});

app.post("/submit", (req, res) => {
    //Assign title and content
    const title = req.body["post-title"];
    const content = req.body["post-content"];

    //Assign file content
    let fileContent = `<!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>
            ${title}
        </title>
    </head>
    
    <body>
        <h3>
            ${title}
        </h3>
        <p>
            ${content}
        </p>
    </body>
    
    </html>`;

    //Generate file name based on current date and time
    const curDate = new Date();
    const fileName = `./views/blog-files/${curDate.getFullYear()}-${(
        curDate.getMonth() + 1
    )
        .toString()
        .padStart(2, "0")}-${curDate
        .getDate()
        .toString()
        .padStart(2, "0")}_${curDate
        .getHours()
        .toString()
        .padStart(2, "0")}-${curDate
        .getMinutes()
        .toString()
        .padStart(2, "0")}-${curDate
        .getSeconds()
        .toString()
        .padStart(2, "0")}.ejs`;

    //Write the file content to an ejs file
    fs.writeFile(fileName, fileContent, (err) => {
        if (err) {
            console.log(`Error writing file: ${err}`);
            res.status(500).send("Error writing file");
            return;
        } else {
            console.log(`File written successfully: ${fileName}`);

            res.render("template.ejs", { title, content });
        }
    });
});

app.listen(port, () => {
    console.log(`Listening on port: ${port}`);
});

How to give styles to certain words that the user enters in a contenteditable

enter image description here
What I want to do is know what the user is writing and depending on what they write, see if certain words exist and add them to the contenteditable as span and with styles, as shown in the image

Try to see if there are certain words in all the text that is entered and if there is, add them to the contenteditable but several problems happen and the span is added with the text but the same text remains in the div and the same word appears twice I also tried after adding the span to eliminate the text that is not in labels and it worked but it blurred the contenteditable and that was another problem. That’s a summary of the problems I face.

Uncaught TypeError: Cannot set properties of null [closed]

Why am I getting this error
Uncaught TypeError: Cannot set properties of null (setting ‘textContent’)
at HTMLButtonElement. (app.js:11:27)

When running this code?
It should be adding +1 to h1 span id=p1Display every time p1Buttom is clicked

const p1Button = document.querySelector('#p1Button');
const p2Button = document.querySelector('#p2Button');
const p1Display = document.querySelector('#p1Dispaly');
const p2Display = document.querySelector('#p2Dispaly');

let p1Score = 0;

p1Button.addEventListener('click', function() {
    p1Score += 1;
    p1Display.textContent = p1Score;

})
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Score Keeper</title>
</head>

<body>
    <h1><span id="p1Display">0</span> to <span id="p2Display">0</span></h1>
    <button id="p1Button">+1 Player One</button>
    <button id="p2Button">+1 Player Two</button>
    <button id="reset">Reset</button>

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

</html>

Coloring charts

first of all, sorry for my English, I don’t know if I can explain what I would like to do…
I have this: https://jsfiddle.net/rp6b40ak/

            plotOptions: {
                areaspline: {
                    zones: [
                        {
                            value: -99.9,
                            color: '#be00be'
                        },
                        {
                            value: -40.0,
                            color: '#dc00dc'
                        },
                        {
                            value: -30.9,
                            color: '#e600ff'
                        }, etc.

I would like to make the chart area have the same color as the line above it. Currently, these are “stairs”. If the value of 20 degrees is yellow, I would like the entire graph to be yellow at that point, green at 9 degrees, and so on.
Second thing, I would like the chart to gradually lose its opacity, the further down, the lower the opacity, like here: https://www.highcharts.com/demo/highcharts/line-time-series
like the weather on MSN.

I even tried to use AI, but without success, please help.

TypeError: Cannot read properties of undefined (reading ‘startsWith’) error

TypeError: Cannot read properties of undefined (reading ‘startsWith’)
at connectionStringHasValidScheme (d:getPlacednode_modulesmongodb-connection-string-urllibindex.js:9:30)
at new ConnectionString (d:getPlacednode_modulesmongodb-connection-string-urllibindex.js:85:34)
at parseOptions (d:getPlacednode_modulesmongodblibconnection_string.js:192:17)
at new MongoClient (d:getPlacednode_modulesmongodblibmongo_client.js:52:63)
at Object. (d:getPlaceddb.js:4:16)
at Module._compile (node:internal/modules/cjs/loader:1369:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
at Module.load (node:internal/modules/cjs/loader:1206:32)
at Module._load (node:internal/modules/cjs/loader:1022:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)

cause ANND SOLUTION FOR THIS ERROR

Server responds differently to browser and fetch

I’m trying to fetch a download link from a server that has Cloudflare set up.

When I make a request with my browser it responds just fine (downloading the file), but when fetching with fetch() it responds with an HTML page.

I’ve already tried mimicking the request from the browser but it still responds with the HTML

fetch(url, {
        method: "GET",
        mode: "cors",
        credentials: "include",
        headers: {
          "User-Agent":
            "Mozilla/5.0 ...",
          Accept:
            "text/html,application/xhtml+xml,application/xml ...",
          ...
        },
      })

Inspecting the HTML I found an inline function that aparently loads the data from the desired website:

<script>(function(){window._cf_chl_opt={cvId: '3',cZone: "...", cUPMDTk:"... .m3u8?"}()</script>

But my browser prevents this load of data:
Firefox error Message

Do you have any idea of what I can do to get the actual download from the link?