Route params are not rendering inside Vue components when using Vue Router

I’ve got Vue router running with these routes:

const routes = [
  {
    path: '/',
    name: 'home',
    params: {
      label: 'Home page'
    },
    component: Home
  },
  {
    path: '/group1',
    name: 'group1',
    params: {
      label: 'Group One'
    },
    redirect: { name: 'subgroup1' },
    children: [
      {
        path: 'subgroup1',
        name: 'subgroup1',
        params: { label: 'Sub Group One' },
        component: SubGroup1,
      },
      {
        path: 'subgroup2',
        name: 'subgroup2',
        params: { label: 'Sub Group Two' },
        component: SubGroup2,
      }
    ]
  }
]

I want to render the label param inside a component, but it isn’t working. Here is an example of my component:

<template>
  <div>
    {{ $route.params.label}}
  </div>
</template>

What am I doing wrong? How do I get this to work?

Refused to load the script ‘https://www.googletagmanager.com/gtag/js?l=dataLayer&

I am working on a chrome extension with React but keep getting this error after unpacking into chrome


Refused to load the script 'https://www.googletagmanager.com/gtag/js?l=dataLayer&id=G-FEDZ04DLF7' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

Does anyone know what could be the possible issue?

I have tried reloading and creating a new build but still get the same error

ASP.NET Razor Pages, passing data from the front-end script to the back-end

I am working on a project where I am using a map and need to send feedback to the backend with the current zoom level. The problem is that the page only returns a 400 Bad Request error along with “Error: SyntaxError: Unexpected end of JSON input.”

.cshtml:

map.on('zoomend', function () {
    var zoomLevel = map.getZoom();

    // Enviar el nivel de zoom al backend
    fetch('@Url.Page("/Map", "UpdateZoom")', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json'
        },
        body: JSON.stringify(zoomLevel)
    })
        .then(response => response.json())
        .then(data => console.log(data))
        .catch(error => console.error('Error:', error));
});

.cs:

public IActionResult OnPostUpdateZoom([FromBody] string zoom)
{
    ZoomLevel = JsonSerializer.Deserialize<int>(zoom);

    int valorCapturado = ZoomLevel;


    return new JsonResult(new { success = true, receivedValue = valorCapturado });
}

Upon inspection with breakpoints, I realized that the OnPostUpdateZoom method in the backend is never being triggered. I have also verified that @Url.Page(“/Map”, “UpdateZoom”) is generating the correct URL.

Bootstrap Collapse on unordered list doesn’t react on first click

I have created a filetree page on a website and added some bootstrap collapse stuff which basically does all I want. The list of files and folders is shown with all tree branches uncollapsed initially. But when I click on a folder symbol (button) in order to collapse the relevant folder content, it doesn’t work but for the second click.

I guess I have to initialize some JavaScript stuff but have no idea where to look for the right spot in my included .js files.

This is the page: https://www.cirp.org/filetree.php

Any help is appreciated.

simingly unlinked CSS changes impact value of window.innerWidth and window.innerHeight on chrome

Everything works fine on a regular chrome page on a computer, but as soon as I toggle the device toolbar and preview my website from let’s say an iphone 12 (any device in portrait mode works), the value given by window.innerWidth and window.innerHeight are (although at the correct ratio) bigger than the intended resolution, which weirdly doesn’t happen on devices in landscape mode (such as a nest hub for example),but also works fine in portrait mode when I go back to preview my website on a normal chrome window.

Here is a minimal HTML page that reproduces the bug:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        html,
        body {
            font-family: "Helvetica";
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100%;
            overflow: hidden;
        }

        input {
            z-index: 1;
            position: absolute;
            top: 50%;
            left: 50%;
            margin: 0;
            background: none;
            outline: none;
            border: none;
            color: white;
            font-size: 48px;
            font-weight: bolder;
            text-align: center;
            transform: translateX(-50%) translateY(-50%);
            mix-blend-mode: difference;
        }

        #canvas {
            position: absolute;
            top: 0;
            left: 0;
            padding: 0%;
            margin: 0%;
            z-index: -1;
        }
    </style>
</head>
<body>
    <canvas id="canvas"></canvas>
    <input id="input" value="Hello, World!"></input>
    <script>
        let canvas = document.getElementById('canvas');
        // set canvas resolution
        canvas.width = window.innerWidth;
        canvas.height = window.innerHeight;
        console.log(window.innerWidth, window.innerHeight);
        // fill canvas with black
        let ctx = canvas.getContext('2d');
        ctx.fillStyle = 'black';
        ctx.fillRect(0, 0, canvas.width, canvas.height);
    </script>
</body>
</html>

For some reasons, removing the font-size: 48px line removes the issue; why is some CSS affecting stuff from javascript?? This doesn’t happen in firefox and the correct value is always given, although you can still scroll in the page like you can on the bigger canvas created in chrome.

My swiper slider is not loading javascript properly

I have been having an annoying issue with my swiper slider in my project. I am trying to create a slider with a scrollbar at the bottom that contains 3 slides per view. I laid out my html pretty much exactly like the swiper docs and included the tags in both my head and script section in my document. I also stylized my slider with scss and added the javascript code, however it is still not working properly. The slidesPerView is not working correctly and the scrollbar is not appearing. I really do not understand why the code is not working the way it should and have no idea what I am missing. Here is my html.

<section class="artists">

  <div class="artists_box">
    
    <div class="swiper">
      <ul class="swiper-wrapper">
        <li class="swiper-slide">
          <img src="" alt="" class="" height="250" width="150">
          <h4>Vinxed Lynn</h4>
          <div class="artist_box_slider_stats">
            <div class="artist_box_slider_stats_followers">
              <h5>Followers:</h5>
              <h5>100k</h5>
            </div>
            <div class="artist_box_slider_stats_class">
              <h5>Class:</h5>
              <h5>Platinum</h5>
            </div>
          </div>
        </li>

        <li class="swiper-slide">
          <img src="" alt="" class="" height="250" width="150">
          <h4>Vinxed Lynn</h4>
          <div class="artist_box_slider_stats">
            <div class="artist_box_slider_stats_followers">
              <h5>Followers:</h5>
              <h5>100k</h5>
            </div>
            <div class="artist_box_slider_stats_class">
              <h5>Class:</h5>
              <h5>Platinum</h5>
            </div>
          </div>
        </li>

        <li class="swiper-slide">
          <img src="" alt="" class="" height="250" width="150">
          <h4>Vinxed Lynn</h4>
          <div class="artist_box_slider_stats">
            <div class="artist_box_slider_stats_followers">
              <h5>Followers:</h5>
              <h5>100k</h5>
            </div>
            <div class="artist_box_slider_stats_class">
              <h5>Class:</h5>
              <h5>Platinum</h5>
            </div>
          </div>
        </li>

        <li class="swiper-slide">
          <img src="" alt="" class="" height="250" width="150">
          <h4>Vinxed Lynn</h4>
          <div class="artist_box_slider_stats">
            <div class="artist_box_slider_stats_followers">
              <h5>Followers:</h5>
              <h5>100k</h5>
            </div>
            <div class="artist_box_slider_stats_class">
              <h5>Class:</h5>
              <h5>Platinum</h5>
            </div>
          </div>
        </li>

        <li class="swiper-slide">
          <img src="" alt="" class="" height="250" width="150">
          <h4>Vinxed Lynn</h4>
          <div class="artist_box_slider_stats">
            <div class="artist_box_slider_stats_followers">
              <h5>Followers:</h5>
              <h5>100k</h5>
            </div>
            <div class="artist_box_slider_stats_class">
              <h5>Class:</h5>
              <h5>Platinum</h5>
            </div>
          </div>
        </li>

        <li class="swiper-slide">
          <img src="" alt="" class="" height="250" width="150">
          <h4>Vinxed Lynn</h4>
          <div class="artist_box_slider_stats">
            <div class="artist_box_slider_stats_followers">
              <h5>Followers:</h5>
              <h5>100k</h5>
            </div>
            <div class="artist_box_slider_stats_class">
              <h5>Class:</h5>
              <h5>Platinum</h5>
            </div>
          </div>
        </li>

        <li class="swiper-slide">
          <img src="" alt="" class="" height="250" width="150">
          <h4>Vinxed Lynn</h4>
          <div class="artist_box_slider_stats">
            <div class="artist_box_slider_stats_followers">
              <h5>Followers:</h5>
              <h5>100k</h5>
            </div>
            <div class="artist_box_slider_stats_class">
              <h5>Class:</h5>
              <h5>Platinum</h5>
            </div>
          </div>
        </li>

        <li class="swiper-slide">
          <img src="" alt="" class="" height="250" width="150">
          <h4>Vinxed Lynn</h4>
          <div class="artist_box_slider_stats">
            <div class="artist_box_slider_stats_followers">
              <h5>Followers:</h5>
              <h5>100k</h5>
            </div>
            <div class="artist_box_slider_stats_class">
              <h5>Class:</h5>
              <h5>Platinum</h5>
            </div>
          </div>
        </li>

      </ul>
      <div class="swiper-scrollbar"></div>
    </div>
  </div>
</section>


<script src="https://kit.fontawesome.com/f103464ccf.js"></script>
<script src="JS/FeaturedNews.js"></script>
<script src="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js"></script>

Here is my scss main module file.

 @use 'base';

.artists{
 width:100%;
 margin:0 auto;

.artists_box{
    width:90%;
    margin:0 auto;

    .swiper{
        width:90%;
        height:100%;

        .swiper-slide{
            width: 10rem;
            height:20rem;
            overflow:hidden;

            h4{
                @include base.fjFontStyle;
                text-align:center;
            }

            h5{
                @include base.osFontStyle;
            }

            .artist_box_slider_stats{
                display:flex;
                gap:1rem;
            }
         }
      }
   }
 }

And here is my javascript file.

 var swiper = new Swiper(".swiper", {
   slidesPerView:6,
   slidesPerGroup:6,
   spaceBetween:50,

 scrollbar: {
   el: ".swiper-scrollbar",
   hide: true,
 },
})

Thank you in advance!

I attempted to delete the tags and paste them again and nothing happened. I have also attempted to try different swiper demos to see if the issue was strictly with my own slider and the issue was still there. I even deleted the files and started over again and nothing changed.

how to change one word’s font in track_list js?

firstly i have no idea how js works i’m sorry, i’m trying to learn how to change the font of a track name in a js playlist. sorry if it is a simple or stupid question.

here is the code i have now:

let track_list = [
            
            {
                name:"title - artist",
                path:"/"
            },

it would be preferable to change one word in the name, but i don’t know if i can use the replace method here, or how i would that. i tried searching online but i don’t know how to incorporate the methods with the code i have, since they don’t say how to do it in a track list name and i’m new to js. thank you in advance.

Trouble with Date, change the format of the input string [duplicate]

I have a string with a date like this ’12/07/2024 7:14′ and I want to create a Date with that. The problem is that the new Date assume that is in united states format -> ‘mm/dd/yyyy’ and I want it in the format ‘dd/mm/yyyy’.

const dateAsString = '12/07/2024 7:14';
const date = new Date(dateAsString);
consol.log({date});

Output expected:

date: '12/07/2024 7:14'

12 / July / 2024

Result of the operation:

date: '07/12/2024 7:14'

7 / December / 2024

Make Bootstrap non-closable modal closable again

I’m using this code to make a Bootstrap 3.4.1 modal non-closable — to not allow the user to click outside the modal or use Esc to close it, while still allowing the normal .modal("hide") and data-dismiss="modal" to work:

$('#myModal').removeData('bs.modal')
    .modal({
        backdrop: 'static',
        keyboard: false
    });

This is from this comment on an answer: Disallow Twitter Bootstrap modal window from closing

However, I’m struggling to reverse the above. Just passing in the opposite options won’t work; the modal remains non-closable:

$("#myModal").modal({
    backdrop: true,
    keyboard: true
});

With help from the SO JavaScript chat (thanks @matt), I also tried using the hide.bs.modal handler, wherein I’d read a data-allow-close attribute within to determine if I should allow closing via keyboard/mouse:

attachNonClosableModalHideHandler: function() {
    const $self = $(this);
    $("#myModal").on("hide.bs.modal", $self.handleNonClosableModalHide);
},

handleNonClosableModalHide: function () {
    return $(this).data("allow-close");
}

Here’s the modal’s main DIV tag:

<div id="myModal" class="modal default fade" tabindex="-1" 
     role="dialog" data-allow-close="true">...</div>

However, the above handler prevents calls to $("#myModal").modal("hide") from working because I now need to set the allow-close data attribute before doing so. Also, the data-dismiss="modal" buttons within the modal won’t work for the same reason.

I created this jQuery plugin to call as a wrapper for hiding the modal but it’s all becoming cumbersome:

$.fn.hideNonClosableModal = function () {
    const $self = $(this);
    const hasClass = $self.hasClass("modal");
    const hasRole = $self.attr("role") === "dialog";
    if (!hasClass || !hasRole) {
        return this;
    }

    $self.data("allow-close", true);
    $self.modal("hide");

    return this;
};

It shouldn’t be this difficult to make a modal closable again. What am I doing wrong? Thanks.

doPost not working when a google form is sent

I am trying to automate my mail management.

I created a google form to add new participants on my mailing list. The form code is the following :

var formFile = DriveApp.getFileById('MyId');
var folder = formFile.getParents().next();

function testLog() {
  appendToLogFile("test");
}

function appendToLogFile(content) {
  var logFileName = "logFormNewParticipant.txt";

  // Get the files in the folder with the specified name
  //get full date second for printing the timestamp in log
  var date = new Date();
  var prettyDate = Utilities.formatDate(date, "GMT+2", "dd-MM-YYYY HH:mm:ss");

  var files = folder.getFilesByName(logFileName);
  var logFile;

  // Check if the log file exists
  if (files.hasNext()) {
    logFile = files.next(); // Get the existing log file
  } else {
    logFile = folder.createFile(logFileName, ""); // Create a new log file if it does not exist
  }

  // Read the current content of the log file
  var currentContent = logFile.getBlob().getDataAsString();

  // Append the new content to the existing content
  var updatedContent = currentContent + prettyDate + "   " + content + "n";

  // Overwrite the log file with the updated content
  logFile.setContent(updatedContent);
}

function onFormSubmit(e) {
  appendToLogFile("TestForm");
    // Log the event object to understand what data is being received
  Logger.log('Event object: ' + JSON.stringify(e));
  appendToLogFile('Event object: ' + JSON.stringify(e));

 var response = e.response;
  var itemResponses = response.getItemResponses();
  var responses = {};

  itemResponses.forEach(itemResponses => {
    var itemTitle = itemResponses.getItem().getTitle();
    var value = itemResponses.getResponse();
    responses[itemTitle] = value;
  });
  appendToLogFile("Answer submitted: " + JSON.stringify(formResponse));

  // Log named values to debug form responses
  var responses = e.namedValues;
  Logger.log('Named values: ' + JSON.stringify(responses));
  appendToLogFile('Named values: ' + JSON.stringify(responses));

  // Safely extract form responses, handling missing fields gracefully
  var prenom = responses['Prénom'] ? responses['Prénom'][0] : "Unknown";
  Logger.log('Prénom: ' + prenom);
  appendToLogFile('Prénom: ' + prenom);

  var nomDeFamille = responses['Nom de famille (optionnel)'] ? responses['Nom de famille (optionnel)'][0] : "";
  Logger.log('Nom de famille: ' + nomDeFamille);
  appendToLogFile('Nom de famille: ' + nomDeFamille);

  var nom = prenom + " " + nomDeFamille;
  Logger.log('Nom: ' + nom);
  appendToLogFile('Nom: ' + nom);

  var email = responses['Email'] ? responses['Email'][0] : "Unknown";
  Logger.log('Email: ' + email);
  appendToLogFile('Email: ' + email);

  appendToLogFile("Processed form data: " + nom + ", " + email);

  var action = "newParticipant";
  var url = "my-url"; 

  var payload = {
    'nom': nom,
    'email': email,
    'action': action
  };

  var options = {
    'method': 'post',
    'payload': payload
  };

  try {
    var response = UrlFetchApp.fetch(url, options);
    appendToLogFile("Form sent for " + nom + " " + email);
    Logger.log(response.getContentText()); // Log response from the web app for debugging
  } catch (fetchError) {
    appendToLogFile("Error sending form for " + nom + " " + email + ": " + fetchError.toString());
    Logger.log("Error sending form for " + nom + " " + email + ": " + fetchError.toString());
  }
}


function setupTrigger() {
  var form = FormApp.openById('1a3b0MLg8USO2ypWxhVwzk3w_pdaA_6AN18VlIoLkI_U'); // Replace with your form ID
  ScriptApp.newTrigger('onFormSubmit')
    .forForm(form)
    .onFormSubmit()
    .create();
  appendToLogFile('Trigger setup complete'); // Log for debugging
}

It seems that the formAnswer I get is empty (log :Event object: {“authMode”:”FULL”,”response”:{},”source”:{},”triggerUid”:”43217120″})

I’ve been trying for hours but I just don’t understand what is going on. I verified the authorization, it seems not to be the problem.

Any help would be appreciated.

could not find react-redux context value using react-native

I am trying to implement Redux-toolkit in my React Native app. I wrapped the index with the provider, but I am facing the ‘Could not find context’ error on the home page. It works normally on the other pages when I try to access states using the useSelector() hook (FirstPage, etc.). I checked the component tree, and everything is indeed present as a child of the index. Any ideas on how to fix this ?

enter image description here

import { Provider } from "react-redux";
import { store } from "../redux/store";
import RootNavigator from "./navigation/RootNavigator";

export default function Index() {
  return (
    <Provider store={store}>
      <RootNavigator />
    </Provider>
  );
}

Nextjs api is not updated

I have uploaded my Nextjs project to Vercel, but I have the following problem, my api route is not updating automatically. When new entries are added to the database, they are not fetched by the api.

Here is the api:

import { NextResponse } from "next/server";
import mysql from 'mysql2/promise';

export async function GET() {


    const connection = await mysql.createConnection({
        host: 'placeholder',
        user: 'placeholder',
        password: 'placeholder',
        database: 'placeholder',
    });
    try {
        const query = 'SELECT * FROM orders';
        const [data] = await connection.execute(query);
       
        return NextResponse.json(data);
    } catch (error) {
        console.error('Fehler', error);
        return NextResponse.json({
            error: 'Datenbankabfrage fehlgeschlagen'
        }, { status: 500 });
    }
}

I have already tried it with useRouter(), but it could also be that I have used it incorrectly, otherwise I have not found anything about it so far

CKEditor 5 mini version

the last time i used ckeditor was i think 1 year ago. it was like this.

  1. go to their site.
  2. select what you want.
  3. change toolbar order.
  4. select langauge.
  5. download zip and use it in your project.

now is not like that. it’s just give me code to imports those i want and use it in my project.
old way was 500KB~2MB based on plugins.
now is 22MB wow.

now i want to know what should i do?

i searched a lot in stackoverflow and other sites and can’t find any solution.
so forgive me if it’s very very simple question i don’t know what to do.

Unable to access properties of object in react

I am unable to access the properties of user_daily_status.
This var contains an object which is displayed as below…

However, when i am trying to access user_daily_status._id I am getting error as TypeError: Cannot read properties of undefined (reading '_id')

function getUserStatus(username) {
    const status = dailyStatus.find(function (ds) {
      if (ds.username === username) {
        console.log(ds);
        return ds;
      }
      // return ds.username == username;
    });
    return status;
  }

Code Snippet :

{users.map((user, index) => {
        console.log(user);
        let user_daily_status = getUserStatus(user);
        console.log(user_daily_status._id);

        return (
          <tr>
            <td>{user}</td>
            <td>{console.log(user_daily_status)}</td>
          </tr>
        );
      })}

user_daily_status = {
        "_id": "669d3c92fd117c2db8492d4d",
        "username": "test",
        "date": "21/7/2024",
        "status": [
            {
                "tag": "tag1",
                "status": "test333",
                "_id": "669d3c92fd117c2db8492d4e"
            },
            {
                "tag": "tag2",
                "status": "11",
                "_id": "669d3c92fd117c2db8492d4f"
            },
            {
                "tag": "tag3",
                "status": "sbbbd",
                "_id": "669d3c92fd117c2db8492d50"
            },
            {
                "tag": "tag4",
                "status": "sssss",
                "_id": "669d3c92fd117c2db8492d51"
            },
            {
                "tag": "tag5",
                "status": "sss",
                "_id": "669d3c92fd117c2db8492d52"
            }
        ],
        "__v": 0
    }

How do I scroll to the bottom of the page using tampermonkey?

I’m trying to create a simple tampermonkey script to scroll to the very bottom of the page in discord after switching the channel, I can’t seem to get it to scroll at all

the code currently does nothing, what I want it to do is scroll to the very bottom of the page

here’s the code I’ve tried

(function() {
    'use strict';

    function scrollToBottom() {
        const scroller = document.querySelector('div[class*="scrollerContent-"]');
        if (scroller) {
            scroller.scrollTop = scroller.scrollHeight;
        }
    }

    function setupURLChangeObserver() {
        window.addEventListener('popstate', () => {
            setTimeout(scrollToBottom, 500);  // Delay to allow content to load
        });
    }

    setupURLChangeObserver();
})();
(function() {
    'use strict';

    function simulateMouseScroll() {
        const scroller = document.querySelector('div[class*="scrollerContent-"]');
        if (scroller) {
            for (let i = 0; i < 100; i++) {
                scroller.dispatchEvent(new WheelEvent('wheel', { deltaY: 100, bubbles: true }));
            }
        }
    }

    function setupURLChangeObserver() {
        window.addEventListener('popstate', () => {
            setTimeout(simulateMouseScroll, 500);  // Delay to allow content to load
        });
    }

    setupURLChangeObserver();
})();

I’ve also tried scroller.scrollTo(0, maxScrollTop);