Creating a responsive Gomoku board with clickable squares

I am trying to create a gomoku board where users can click on the line intersections. I created this in Vue playground which works fine on a large screen size. However, when I shrink the width of the screen the squares suddenly no longer fit to the parent. I tried all kind of things with aspect ratios on a cell and on the grid parent but it just messed up the shape all together.

Basically I have 2 questions:

  1. How can I make this grid look good on all screen sizes (down to say around 275px width of the board at least)?
  2. Is there a simpler solution of doing this?

Protected Route not routing react-router-dom

I am using react-router-dom for Routing in my react app. I now want to create a protected route so you can access certain pages only if you are logged in. But at the moment I can still access the protected pages and dont get redirected from the login page to the dashboard after loggin in

index.js

import React from 'react';
import ReactDOM from 'react-dom/client';
import {
    BrowserRouter as Router,
    Routes,
    Route,
    Navigate,
} from 'react-router-dom';
import axios from 'axios';
import { UserContextProvider } from './context/userContext';
import { ToastProvider } from './context/toastContext';
import { DialogProvider } from './context/dialogContext';
import ProtectedRoute from './components/protectedRoute';
import Register from './pages/auth/register';
import Profile from './pages/profile';
import Friends from './pages/friends';
import Notifications from './pages/notifications';
import Landingpage from './pages/landingpage';
import Dashboard from './pages/dashboard';
import Login from './pages/auth/login';
import './index.css';

const routes = [
    { path: '/home', element: Landingpage },
    { path: '/dashboard', element: Dashboard, protected: true },
    { path: '/login', element: Login },
    { path: '/register', element: Register },
    { path: '/profile', element: Profile, protected: true },
    { path: '/friends', element: Friends, protected: true },
    { path: '/notifications', element: Notifications, protected: true },
    { path: '/', element: Navigate, to: '/home' },
];

axios.defaults.baseURL = 'http://localhost:8000';
axios.defaults.withCredentials = true;

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
    <UserContextProvider>
        <ToastProvider>
            <DialogProvider>
                <Router>
                    <Routes>
                        {routes.map((route, index) => {
                            if (route.protected) {
                                return (
                                    <Route
                                        key={index}
                                        path={route.path}
                                        element={
                                            <ProtectedRoute
                                                element={route.element}
                                            />
                                        }
                                    />
                                );
                            }
                            return (
                                <Route
                                    key={index}
                                    path={route.path}
                                    element={<route.element to={route.to} />}
                                />
                            );
                        })}
                    </Routes>
                </Router>
            </DialogProvider>
        </ToastProvider>
    </UserContextProvider>
);

protectedRoute.jsx

import React, { useContext } from 'react';
import { Navigate } from 'react-router-dom';
import { UserContext } from '../context/userContext';
import { Loader } from 'lucide-react';

const ProtectedRoute = ({ element: Component, ...rest }) => {
    const { user, loading } = useContext(UserContext);

    if (loading) {
        return (
            <div className='flex items-center justify-center py-4'>
                <Loader className='animate-spin mr-2' />
                <span>Lädt...</span>
            </div>
        );
    }

    if (!user) {
        return <Navigate to='/login' />;
    }

    return <Component {...rest} />;
};

export default ProtectedRoute;

How to have Popup between selected and inactive markers in react-leaflet


I’ve been at it for a while now and I just can’t seem to get the Popup between the selected marker (which should be in front. It’s 3 in the image) and the inactive ones.

enter image description here

I’ve tried changing the z-index, but all the markers seem to be in entirely different divs as the popup. Setting the selected marker to absolute doesn’t do anything either.

enter image description here

The only option I think I’m left with is placing a copy of the marker within the popup, but this makes my skin crawl :(.

Adapt a multi input with JavasScript and Alpine JS

I have a multi input made with alpine js, is not mine, I search for one on Google and like this one. So, the problem is that 3 inputs on my form needs to be multi-options available, but the first input options repeat for all inputs (They should be different for each input).

I know is because that the input was implemented for 1 multi input per form, but I need to adapt it and I don’t know have any idea of what to do. (I’m a Django dev, I don’t have knowledge in alpine js at all and my knowledge of JavaScript is pretty basic).

If a pure soul can help me to adapt it or, at least, guide me how to do it, it would help. Thanks.

Dependencies: Tailwind (lasted stable), Alpine JS (lasted stable)

  <section class="w-full">
    <select x-cloak id="select" style="display:none" class="text-gray-400">
      <option value="Preescolar">Preescolar</option>
      <option value="Educ. Básica">Educ. Básica</option>
      <option value="Educ. Media">Educ. Media</option>
    </select>

    <label class="w-full text-sm">
      <span class="text-gray-700 dark:text-gray-400">Nivel/es</span>
      <div x-data="dropdown()" x-init="loadOptions()" class="h-fit w-full flex flex-col items-center mx-auto">
        <input name="values" type="hidden" x-bind:value="selectedValues()" readonly="readonly">
        <div class="inline-block relative w-full">
          <div class="flex flex-col items-center relative">
            <div x-on:click="open" class="w-full svelte-1l8159u">
              <div class="mt-1 p-2 flex rounded border dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-400 dark:focus:shadow-outline-gray svelte-1l8159u">
                <div class="flex flex-auto flex-wrap grow gap-1">
                  <template x-for="(option,index) in selected" :key="options[option].value">
                    <div
                      class="flex justify-center gap-1 items-center font-medium pl-1 pr-0.5 rounded text-purple-700 bg-purple-100 border border-purple-300">
                      <div class="text-xs font-normal leading-none max-w-full flex-initial" x-model="options[option]" x-text="options[option].text"></div>
                      <div class="flex flex-auto flex-row-reverse">
                        <div x-on:click="remove(index,option)">
                          <svg xmlns="http://www.w3.org/2000/svg" role="button" viewBox="0 0 20 20" fill="currentColor" class="size-4 fill-current">
                            <path d="M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z" />
                          </svg>
                        </div>
                      </div>
                    </div>
                  </template>
                  <div x-show="selected.length == 0" class="flex-1">
                    <input placeholder="..."
                      class="bg-transparent p-0 border-none appearance-none outline-none h-full w-full text-gray-400 text-sm"
                      x-bind:value="selectedValues()" readonly="readonly">
                  </div>
                </div>
                <div
                  class="w-fit pl-2 border-l flex items-center border-gray-600 svelte-1l8159u">
                  <button type="button" x-show="isOpen() === true" x-on:click="open"
                    class="cursor-pointer outline-none focus:outline-none">
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="size-5 cursor-pointer outline-none focus:outline-none">
                      <path fill-rule="evenodd" d="M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd" />
                    </svg>
                  </button>
                  <button type="button" x-show="isOpen() === false" @click="close"
                    class="cursor-pointer outline-none focus:outline-none">
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="size-5 cursor-pointer outline-none focus:outline-none">
                      <path fill-rule="evenodd" d="M9.47 6.47a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 1 1-1.06 1.06L10 8.06l-3.72 3.72a.75.75 0 0 1-1.06-1.06l4.25-4.25Z" clip-rule="evenodd" />
                    </svg>  
                  </button>
                </div>
              </div>
            </div>
            <div class="w-full px-4">
              <div x-show.transition.origin.top="isOpen()"
                class="absolute shadow top-100 text-gray-400 bg-gray-700 z-40 w-full left-0 rounded max-h-select overflow-y-auto svelte-5uyqqj"
                x-on:click.away="close">
                <div class="flex flex-col w-full">
                  <template x-for="(option,index) in options" :key="option">
                    <div>
                      <div class="cursor-pointer w-full border-gray-600 rounded-b border-b hover:bg-purple-700"
                        @click="select(index,$event)">
                        <div x-bind:class="option.selected ? 'border-purple-600' : ''"
                          class="flex w-full items-center p-2 pl-2 hover:text-gray-100 relative">
                          <div class="w-full items-center flex">
                            <div class="mx-2 leading-6" x-model="option" x-text="option.text"></div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </template>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </label>
  </section>

  <section class="w-full">
    <select x-cloak id="select" style="display:none" class="text-gray-400">
      {% for course in courses %}
      <option value="1">{{course.grade}}</option>
      {% endfor %}
    </select>

    <label class="w-full text-sm">
      <span class="text-gray-700 dark:text-gray-400">Sección/es</span>
      <div x-data="dropdown()" x-init="loadOptions()" class="h-fit w-full flex flex-col items-center mx-auto">
        <input name="values" type="hidden" x-bind:value="selectedValues()">
        <div class="inline-block relative w-full">
          <div class="flex flex-col items-center relative">
            <div x-on:click="open" class="w-full svelte-1l8159u">
              <div class="mt-1 p-2 flex rounded border dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-400 dark:focus:shadow-outline-gray svelte-1l8159u">
                <div class="flex flex-auto flex-wrap grow gap-1">
                  <template x-for="(option,index) in selected" :key="options[option].value">
                    <div
                      class="flex justify-center gap-1 items-center font-medium pl-1 pr-0.5 rounded text-purple-700 bg-purple-100 border border-purple-300">
                      <div class="text-xs font-normal leading-none max-w-full flex-initial" x-model="options[option]" x-text="options[option].text"></div>
                      <div class="flex flex-auto flex-row-reverse">
                        <div x-on:click="remove(index,option)">
                          <svg xmlns="http://www.w3.org/2000/svg" role="button" viewBox="0 0 20 20" fill="currentColor" class="size-4 fill-current">
                            <path d="M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z" />
                          </svg>
                        </div>
                      </div>
                    </div>
                  </template>
                  <div x-show="selected.length == 0" class="flex-1">
                    <input placeholder="..."
                      class="bg-transparent p-0 border-none appearance-none outline-none h-full w-full text-gray-400 text-sm"
                      x-bind:value="selectedValues()">
                  </div>
                </div>
                <div
                  class="w-fit pl-2 border-l flex items-center border-gray-600 svelte-1l8159u">
                  <button type="button" x-show="isOpen() === true" x-on:click="open"
                    class="cursor-pointer outline-none focus:outline-none">
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="size-5 cursor-pointer outline-none focus:outline-none">
                      <path fill-rule="evenodd" d="M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd" />
                    </svg>
                  </button>
                  <button type="button" x-show="isOpen() === false" @click="close"
                    class="cursor-pointer outline-none focus:outline-none">
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="size-5 cursor-pointer outline-none focus:outline-none">
                      <path fill-rule="evenodd" d="M9.47 6.47a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 1 1-1.06 1.06L10 8.06l-3.72 3.72a.75.75 0 0 1-1.06-1.06l4.25-4.25Z" clip-rule="evenodd" />
                    </svg>  
                  </button>
                </div>
              </div>
            </div>
            <div class="w-full px-4">
              <div x-show.transition.origin.top="isOpen()"
                class="absolute shadow top-100 text-gray-400 bg-gray-700 z-40 w-full left-0 rounded max-h-select overflow-y-auto svelte-5uyqqj"
                x-on:click.away="close">
                <div class="flex flex-col w-full">
                  <template x-for="(option,index) in options" :key="option">
                    <div>
                      <div class="cursor-pointer w-full border-gray-600 rounded-b border-b hover:bg-purple-700"
                        @click="select(index,$event)">
                        <div x-bind:class="option.selected ? 'border-purple-600' : ''"
                          class="flex w-full items-center p-2 pl-2 hover:text-gray-100 relative">
                          <div class="w-full items-center flex">
                            <div class="mx-2 leading-6" x-model="option" x-text="option.text"></div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </template>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </label>
  </section>

  <section class="w-full">
    <select x-cloak id="select" style="display:none" class="text-gray-400">
      <option value="1">Option 2</option>
      <option value="2">Option 3</option>
      <option value="3">Option 4</option>
      <option value="4">Option 5</option>
    </select>

    <label class="w-full text-sm">
      <span class="text-gray-700 dark:text-gray-400">Materia/s</span>
      <div x-data="dropdown()" x-init="loadOptions()" class="h-fit w-full flex flex-col items-center mx-auto">
        <input name="values" type="hidden" x-bind:value="selectedValues()">
        <div class="inline-block relative w-full">
          <div class="flex flex-col items-center relative">
            <div x-on:click="open" class="w-full svelte-1l8159u">
              <div class="mt-1 p-2 flex rounded border dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-400 dark:focus:shadow-outline-gray svelte-1l8159u">
                <div class="flex flex-auto flex-wrap grow gap-1">
                  <template x-for="(option,index) in selected" :key="options[option].value">
                    <div
                      class="flex justify-center gap-1 items-center font-medium pl-1 pr-0.5 rounded text-purple-700 bg-purple-100 border border-purple-300">
                      <div class="text-xs font-normal leading-none max-w-full flex-initial" x-model="options[option]" x-text="options[option].text"></div>
                      <div class="flex flex-auto flex-row-reverse">
                        <div x-on:click="remove(index,option)">
                          <svg xmlns="http://www.w3.org/2000/svg" role="button" viewBox="0 0 20 20" fill="currentColor" class="size-4 fill-current">
                            <path d="M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z" />
                          </svg>
                        </div>
                      </div>
                    </div>
                  </template>
                  <div x-show="selected.length == 0" class="flex-1">
                    <input placeholder="..."
                      class="bg-transparent p-0 border-none appearance-none outline-none h-full w-full text-gray-400 text-sm"
                      x-bind:value="selectedValues()">
                  </div>
                </div>
                <div
                  class="w-fit pl-2 border-l flex items-center border-gray-600 svelte-1l8159u">
                  <button type="button" x-show="isOpen() === true" x-on:click="open"
                    class="cursor-pointer outline-none focus:outline-none">
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="size-5 cursor-pointer outline-none focus:outline-none">
                      <path fill-rule="evenodd" d="M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd" />
                    </svg>
                  </button>
                  <button type="button" x-show="isOpen() === false" @click="close"
                    class="cursor-pointer outline-none focus:outline-none">
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="size-5 cursor-pointer outline-none focus:outline-none">
                      <path fill-rule="evenodd" d="M9.47 6.47a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 1 1-1.06 1.06L10 8.06l-3.72 3.72a.75.75 0 0 1-1.06-1.06l4.25-4.25Z" clip-rule="evenodd" />
                    </svg>  
                  </button>
                </div>
              </div>
            </div>
            <div class="w-full px-4">
              <div x-show.transition.origin.top="isOpen()"
                class="absolute shadow top-100 text-gray-400 bg-gray-700 z-40 w-full left-0 rounded max-h-select overflow-y-auto svelte-5uyqqj"
                x-on:click.away="close">
                <div class="flex flex-col w-full">
                  <template x-for="(option,index) in options" :key="option">
                    <div>
                      <div class="cursor-pointer w-full border-gray-600 rounded-b border-b hover:bg-purple-700"
                        @click="select(index,$event)">
                        <div x-bind:class="option.selected ? 'border-purple-600' : ''"
                          class="flex w-full items-center p-2 pl-2 hover:text-gray-100 relative">
                          <div class="w-full items-center flex">
                            <div class="mx-2 leading-6" x-model="option" x-text="option.text"></div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </template>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </label>
  </section>

<script>
function dropdown() {
  return {
    options: [],
    selected: [],
    show: false,
    open() { this.show = true },
    close() { this.show = false },
    isOpen() { return this.show === true },
    select(index, event) {

      if (!this.options[index].selected) {

        this.options[index].selected = true;
        this.options[index].element = event.target;
        this.selected.push(index);

      } else {
        this.selected.splice(this.selected.lastIndexOf(index), 1);
        this.options[index].selected = false
      }
    },
    remove(index, option) {
      this.options[option].selected = false;
      this.selected.splice(index, 1);
    },
    loadOptions() {
      const options = document.getElementById('select').options;
      for (let i = 0; i < options.length; i++) {
        this.options.push({
          value: options[i].value,
          text: options[i].innerText,
          selected: options[i].getAttribute('selected') != null ? options[i].getAttribute('selected') : false
        });
      }
    },
    selectedValues() {
      return this.selected.map((option) => {
        return this.options[option].value;
      })
    }
  }
}
</script>

Stripe Money Transfers from Merchant Accounts to Platform Account

I’m working on a project where merchants integrate their Stripe API keys into my system, allowing me to access their analytics and provide consulting on their sales performance. I want to automate charging a consulting fee under specific conditions. Here’s the setup:

If a merchant makes sales over $5000 in a day, I want to charge a flat $10 consultation fee from their account and transfer it to my Stripe account.
Merchants have requested that these charges happen once daily rather than multiple times.
I’m new to Stripe and have looked into Stripe Connect, but I’m having difficulty understanding how to implement this setup, especially when it comes to charging fees on behalf of other accounts.

Specific Questions:

Is it possible to automate these charges directly from the merchant’s account to mine using just their API key?
How should I be using Stripe Connect (if applicable) to facilitate these fee transfers?

Flask-SocketIO with Blueprint &Name space Issue

Iam New to use falsk-ScocketIo to make chat,i have an issue with meet events and printing data and no customer event sent it seam to be an issue for server side I don’t Know ,
there are connection between socit and server as attached image
terminal data

and if i need to print data in terminal or log no data loged or printed ,i think thre are an issue with Bluebrint or Name space as when i removed Bluprint and code dirictly it working Fine i serached more and more and i didnt find solution . here is my code
my socketioController.py :-


    # Import necessary modules and libraries
    from flask import render_template,url_for,flash,redirect,request,Blueprint,request,json,jsonify,session,Response,Flask
    from flask_login import login_user, current_user, logout_user, login_required
    from myproject import db
    from myproject import app
    from myproject.models import User ,Presentaions,PresntaionImages,PresntaionVideos,Settings,Colors,Hand,PresnterFrameMode,SlidingMode
    from myproject.users.dataValidator import *
    from myproject.handler import *
    import datetime 
    from sqlalchemy import func 
    from sqlalchemy.sql import text
    import cv2
    from flask_socketio import SocketIO, join_room, leave_room, send,emit
    from app import socketio 
 
    
    # Define a Flask Blueprint named 'streaming'
    socketio_blueprint = Blueprint('socketio_blueprint', __name__) 
    # 
    
    @socketio_blueprint.route('/soket/show', methods=['GET','POST'])
    @login_required
    def show():
        pagetitle = "Presenter X | Streaming Details"
        return render_template('socit_template/show.html')
    
    @socketio.on('connect')
    def test_connect():
        print('Client connected')
        emit('custom-event', 'Connected to server!')
    
    @socketio.on('message')
    def handle_message(data):
        print(f'Message received: {data}')
        emit('custom-event', f'Server got your message: {data}')

my html code and Js :-

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Flask-SocketIO Test</title>
    <script src="https://cdn.socket.io/4.0.1/socket.io.min.js"></script>
</head>
<body>
    <h1>Flask-SocketIO WebSocket Test</h1>
    
    <script>
        const socket = io.connect(`${location.protocol}//${document.domain}:${location.port}`);

       

        socket.on('connect', () => {
            console.log('WebSocket connected');
            socket.send('Hello, Server!');
        });

        socket.on('custom-event', data => {
            console.log(`Custom event received: ${data}`);
        });
        
        

        socket.on('message', data => {
            console.log(`Message from server: ${data}`);
        });
        
        socket.on('connect_error', (error) => {
            console.error(`Connection error: ${error}`);
        });
    </script>
</body>
</html>

here my app.py code :-


    from myproject import app
    from flask_socketio import SocketIO
    #socketio = SocketIO(app)
    
    
    socketio = SocketIO(app, cors_allowed_origins="*", async_mode=None)  # Ensure proper initialization
    
    if __name__ == '__main__':
        #app.run(debug=True)
        socketio.run(app,debug=True)

 here my init.py code:

    from flask import Flask
    from flask_sqlalchemy import SQLAlchemy
    from flask_migrate import Migrate
    from flask_login import LoginManager
    import pymysql
    from myproject.config import *
    from flask_mail import Mail
    from flask_socketio import SocketIO
    
    # Initialize the Flask app
    app = Flask(__name__)
    
    # Configure Mail
    app.config["MAIL_SERVER"] = "smtp.googlemail.com"
    app.config["MAIL_PORT"] = 587
    app.config["MAIL_USE_TLS"] = True
    app.config["MAIL_USERNAME"] = os.environ.get("EMAIL_USER")
    app.config["MAIL_PASSWORD"] = os.environ.get("EMAIL_PASS")
    mail = Mail(app)
    
    # Initialize the login manager
    login_manager = LoginManager()
    login_manager.init_app(app)
    login_manager.login_view = "users.login"
    login_manager.login_message_category = "info"
    login_manager.login_message = ''
    
    # Initialize database and migrations
    db = SQLAlchemy(app)
    migrate = Migrate(app, db)
    
    # Initialize SocketIO (ensure it's done after app is created)
    socketio = SocketIO(app, cors_allowed_origins="*", async_mode=None)
    
    # Import the blueprints AFTER initializing the app, db, and login manager
    from myproject.core.coreController import core
    from myproject.errors.errorhandlers import errors
    from myproject.users.userController import users
    from myproject.setting.settingController import setting
    from myproject.color.colorController import colors
    from myproject.slidingmode.slidingController import slidingmode
    from myproject.hand.handController import hand
    from myproject.presentaion.presentationController import presentation
    from myproject.presnterframemode.presnterframemodeController import presnterframemode
    from myproject.streaming.streamingController import streaming
    from myproject.socketio.socketioController import socketio_blueprint
    
    # Register blueprints
    app.register_blueprint(core)
    app.register_blueprint(errors)
    app.register_blueprint(users)
    app.register_blueprint(colors)
    app.register_blueprint(setting)
    app.register_blueprint(slidingmode)
    app.register_blueprint(hand)
    app.register_blueprint(presnterframemode)
    app.register_blueprint(streaming)
    app.register_blueprint(presentation)
    app.register_blueprint(socketio_blueprint)

it seem to be no reply from server side , i dont Know hopping any one help me may be issue is name sapace .
thanks

How to pre-load images so that they are displayed instantly?

I sat for a long time solving the problem of pre-loading pictures. What’s the problem? I have a page with a loader. I need to be redirected to the main page when all the pictures of the main page are loaded.

I found an interesting solution in the internet with the hook usePreloadImages here is its code:

import { useEffect, useState } from 'react'

function preloadImage(src: string) {
    return new Promise((resolve, reject) => {
        const img = new Image()
        img.src = src
        img.onload = function () {
            resolve(img)
        }
        img.onerror = img.onabort = function () {
            reject(src)
        }
    })
}

export default function useImagePreloader(imageList: string[]) {
    const [imagesPreloaded, setImagesPreloaded] = useState<boolean>(false)

    useEffect(() => {
        let isCancelled = false

        async function effect() {
            if (isCancelled) {
                return
            }

            const imagesPromiseList: Promise<any>[] = []
            for (const i of imageList) {
                imagesPromiseList.push(preloadImage(i))
            }

            await Promise.all(imagesPromiseList)

            if (isCancelled) {
                return
            }

            setImagesPreloaded(true)
        }

        effect()

        return () => {
            isCancelled = true
        }
    }, [imageList])

    return { imagesPreloaded }
}

This solution seems to work, but when loading all the pictures I am redirected to the main page and the pictures are re-loaded. The images to be loaded are in the public folder if it matters

Network devtools before redirect to main page:

Network devtools after redirect to main page:

chrome dev tools showing event listeners been leaked

New javascript dev, and only started dipping my toes into the webdev world.
I feel like I’m getting gaslit by chrome dev tools or I’m misunderstanding completely how removeEventListener works.

Is this a known issue or have i done something wrong?

Screenshot of chrome tools

What i’ve done is click 5~6 times and then press the collect garbage button (broom icon) next to memory which results in a saw like pattern. But the net number of event listener’s keeps increasing.

Here’s the code I’ve used to produce this.

<!doctype html>
<html>
  <head>
    <script>
      function handleClick(e) {
        console.log("click");
        document.removeEventListener("click", handleClick);
        document.addEventListener("click", handleClick);
      }
      document.addEventListener("click", handleClick);
    </script>
  </head>
  <body></body>
</html>

There are 2 other instances in stack overflow reporting similar things but neither of them seem properly answered.

JavaScript listeners keep increasing
Listeners in Chrome dev tools’ performance profiling results

When the page is fully loaded, the visibility of the content is cut-off

In the first option – page loading mode – this is if you interrupt it at the loading stage and not completely.
The page is not completely loaded.
In this case – option – all the content is displayed in the browser – the content that has time to load is loaded accordingly – which had time to load before the interruption.

In the second option – page loading – this is if you do not interrupt the loading and the loading is complete.
All the content on the page is completely loaded.
But at the moment – immediately upon complete loading – there is a cut-off – a reduction in the visibility of the content – you cannot fully view the – seemingly fully loaded page.
The content is cut-off.

It is possible that something is not working somewhere.
Could this be – is it because of the side menu?

I’m trying to create a shell for Django Python. And I have a strange thing – visibility – content availability is limited. Although everything seems to load when loading – but then when fully loaded for some reason – there is a limitation – there is no scrolling of all the contents. Maybe you can find out why this is happening to me.

When the page is fully loaded, the visibility of the content is cut-off.

Help please.

This code after the page is fully loaded – limits part of the page – template.

The effect of this code is to limit access to content and does not allow viewing content beyond what is visible on the screenshot – as if it is cut off and there is nothing beyond one diagram – although a lot of things are loaded during loading – and at the end there is a limitation of cutting.

When it is removed, everything loads normally – but the button for activating the menu call is not active – at the top left.

https://fomantic-ui.com/modules/sidebar.html#/examples

This code after the page is fully loaded – limits part of the page – template.

      // using context
      $('.ui.sidebar')
        .sidebar({
          context: $('.bottom.segment')
        })
        .sidebar('attach events', '.ui.top.attached.demo.menu .item')
      ;

index.html

{% load static %}
{% load widget_tweaks %}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Sidebar Menu | Side Navigation Bar</title>
    <!-- CSS -->
    <!-- You MUST include jQuery 3.4+ before Fomantic -->
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/semantic.min.css">
  </head>
  <body hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'>
    <div class="ui top attached demo menu">
      <a class="item">
        <i class="sidebar icon"></i>
        Menu
      </a>
    </div>
    <div class="ui bottom attached segment">
      <div class="ui labeled icon left inline vertical demo sidebar menu">
        <a class="item">
          <i class="home icon"></i>
          Home
        </a>
        <a class="item">
          <i class="block layout icon"></i>
          Мониторинг
        </a>
        <a class="item">
          <i class="smile icon"></i>
          Анализ архива
        </a>
        <a class="item">
          <i class="calendar icon"></i>
          History
        </a>
      </div>
      <div class="pusher">
        <div class="ui basic segment">
          <h3 class="ui header">Application Content</h3>
          <p></p>
          <p></p>
          <p></p>
          <p></p>
          <div class="ui grid">
            <div class="six wide column">
              Menu Text
              <div class="ui hidden divider"></div>
              <div class="ui vertical menu">
                <div class="item">
                  <div class="ui input"><input type="text" placeholder="Search..."></div>
                </div>
                <div class="item">
                  Home
                  <div class="menu">
                    <a class="active item">Search</a>
                    <a class="item">Add</a>
                    <a class="item">Remove</a>
                  </div>
                </div>
                <a class="item">
                  <i class="grid layout icon"></i> Browse
                </a>
                <a class="item">
                  Messages
                </a>
                <div class="ui dropdown item">
                  More
                  <i class="dropdown icon"></i>
                  <div class="menu" id="courses_id">
                    <a class="item"><i class="edit icon"></i> Edit Profile</a>
                    <a class="item"><i class="globe icon"></i> Choose Language</a>
                    <a class="item"><i class="settings icon"></i> Account Settings</a>
                  </div>
                </div>
              </div>
            </div>
            <div class="ten wide column" style="text-align: center;">
              Content Text
              <div class="ui hidden divider"></div>
              <div class="ui fluid selection dropdown">
                <input type="hidden" name="user">
                <i class="dropdown icon"></i>
                <div class="default text">Select Friend</div>
                <div class="menu">
                  <div class="item">
                    Jenny Hess
                  </div>
                  <div class="item">
                    Elliot Fu
                  </div>
                  <div class="item">
                    Stevie Feliciano
                  </div>
                  <div class="item">
                    Christian
                  </div>
                  <div class="item">
                    Matt
                  </div>
                </div>
              </div>
              <div class="ui hidden divider"></div>
              {% block content %}

              {% endblock %}
            </div>
          </div>
        </div>
      </div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/semantic.min.js"></script>
    <script>
      // using context
      $('.ui.sidebar')
        .sidebar({
          context: $('.bottom.segment')
        })
        .sidebar('attach events', '.ui.top.attached.demo.menu .item')
      ;
      $('.ui.dropdown').dropdown();
      $('.ui.selection.dropdown')
        .dropdown({
          clearable: true
        })
      ;
    </script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
  </body>
</html>

content.html

{% extends "realnost/index.html" %}

{% block content %}
    <h5 class="ui grey header">Мониторинг систем теплоснабжения</h5>
    <h5 class="ui grey header">Режимные характеристики котельной</h5>
    <h5 class="ui grey header">Режимные характеристики котла №1</h5>
    <div class="ui segment">
        <p>Выработка котлом №1</p>
        {{ chart1k1|safe }}
    </div>
    <div class="ui hidden divider"></div>
    <div class="ui segment">
        <p>Удельный расход условного топлива на выработку котла №1</p>
        {{ chart2k1|safe }}
    </div>
    <div class="ui hidden divider"></div>
    <div class="ui segment">
        <p>КПД котла №1</p>
        {{ chart3k1|safe }}
    </div>
    <div class="ui hidden divider"></div>
    <div class="ui segment">
        <p>Температура уходящих газов за котлом №1</p>
        {{ chart4k1|safe }}
    </div>
    <div class="ui hidden divider"></div>
    <div class="ui segment">
        <p>Таблица среднесуточных значений режимных показателей котла №3</p>
        <table class="ui small table">
            <thead>
                <tr>
                    {% for col in tablek3.columns %}
                    <th>
                        {{ col }}
                    </th>
                    {% endfor %}
                </tr>
            </thead>
            {% for index, row in tablek3.iterrows %}
            <tr>
                {% for cell in row %}
                <td>
                    {{ cell }}
                </td>
                {% endfor %}
            </tr>
            {% endfor %}
        </table>    
    </div>
{% endblock %}

Scren 1

Scren 2

Scren 3

On the first screenshot you can see – that I can’t scroll further – to see the content.

I can’t see the content – scroll the scroll on the right side – something is limiting the displayed content on the page.

On the right – you can see the scroll – on the screenshots – you can see the difference between what the content should be – it should all be visible.

But on the first screenshot you can see – what the page display actually is – what it is in fact now.

Can a key in a key:value pair have a non-row type in?

I argued with my mentor that the key in the key: value pair can be not only a string. On my side there is VS Code in which you can put a number in a key and then get the value using this key. On his side there are various articles and notes where it is written that the key can only be a string. Someone can either credibly argue my side, or if I’m wrong, his side.

Attaching a photo from VS Code:enter image description here

I want a formatter for VSCode which preseves the number of lines on save and only changes the tabs and indentations

As te title says. I could not find a way to just do that. The formatter are either pretty aggressive and change the number of lines to their liking or actually do nothing and not even fix the tabs and indentations.

I changed a bunch of prettier settings none of them helped for doing exactly what I wanted. for example in .prettierrc:

{
  "proseWrap": "preserve",
  "printWidth": 160,
  "bracketSameLine": true,
  "singleAttributePerLine": false
}

How to search in autocomplete with typeahead as false

I previously used the vuetify which has combobox. Basically in the combobox we can add items manually by typing in the field and also it allows to search through the existing items list as well.

I want to replicate the same thing using prime vue.

Here i am able to add the manual items but not able to search through the list. Is there any way to search through the list as well?

<AutoComplete v-model="value" dropdown multiple :suggestions="items" :typeahead="false" @complete="search" />
import { ref } from "vue";

const value = ref("");
const items = ref([]);

const search = (event) => {
    items.value = ['1','abc efg txt','3']
    if (event.query) {
        items.value = items.value.filter(function (item) {
            return item.search(event.query) >= 0
        })
    }
}
</script>

Pan to selection in InDesign

I’m writing a script to find short streaks of different formatting (an italicized comma in a non-italicized sentence, etc.). I have a dialog to jump between found instances, and I would like the view to follow in the same way that it does when searching with the built-in Find/Change tool. The instances get selected but I haven’t been able to figure out how to pan the view to selection.

Modal Fields Not Clearing on Close in Bootstrap

I’m currently working on a web application using Bootstrap modals and jQuery, and I am having trouble clearing the input fields and other elements in my modal when it is closed.

I have two modals in my application: one for adding a new category and another for editing an existing category. Here’s a snippet of the HTML for the new category modal:

<div class="modal-dialog modal-lg" role="document">
    <form id="new_category_form" method="POST" action="{% url 'add_category' %}" enctype="multipart/form-data">
      {% csrf_token %}
      <div class="modal-content">
        <div class="modal-header">
          <h4 class="modal-title">New Category</h4>
          <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>
        <div class="modal-body">
          <div class="input-group mb-3">
            <input type="text" class="form-control" placeholder="Enter category name" name="new_name" id="new_name" required>
          </div>
          <div class="input-group">
            <div class="col-md-12 p-0">
              <input type="file" class="form-control w-100" accept="image/*" name="new_image" id="new_image" placeholder="Category Image" required>
              <img class="row" id="preview" src="" width="200" style="float:left; margin-top: 10px;">
            </div>
          </div>
          <div class="d-block">
            <div class="form-check form-check-inline">
              <input id="is_free-pre" type="radio" name="is_paid" value="0" class="form-check-input" required>
              <label for="is_free-pre" class="form-check-label">Free</label>
            </div>
            <div class="form-check form-check-inline">
              <input id="is_paid-pre" type="radio" name="is_paid" value="1" class="form-check-input" required>
              <label for="is_paid-pre" class="form-check-label">Paid</label>
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <button type="submit" id="btn_new_category" class="btn btn-primary">Save</button>
        </div>
      </div>
    </form>
  </div>
</div>

Here’s the jQuery code I’m using to handle the modal:

$(document).ready(function() {
    $('#newCategoryModal').on('hidden.bs.modal', function() {
        $('#new_name').val(''); 
        $('#preview').attr('src', '').css('display', 'none'); 
        $('#is_paid-pre').prop('checked', false); 
        $('#is_free-pre').prop('checked', false); 
    });
    
    document.getElementById('new_image').addEventListener('change', function(event) {
        const file = event.target.files[0]; 
        const preview = document.getElementById('preview'); 
        
        if (file) {
            const reader = new FileReader(); 
            reader.onload = function(e) {
                preview.src = e.target.result; 
                preview.style.display = 'block'; 
            }
            reader.readAsDataURL(file); 
        } else {
            preview.style.display = 'none'; 
        }
    });
});

I implemented a jQuery event listener for the modal’s hidden.bs.modal event to clear the input fields and reset the image preview whenever the modal is closed. Specifically, I tried:

Setting the value of the category name input field to an empty string.
Setting the image preview’s src attribute to an empty string and hiding it.
Unchecking both radio buttons for the payment type (Free/Paid).

I expected that when I closed the modal, all input fields, including the text input for the category name, the image preview, and the radio buttons, would be reset to their default states, allowing for a fresh start the next time the modal is opened.

When I closed the modal, the input fields and the image preview did not clear as intended. The input field still contained the previous value, the image preview remained visible, and the radio buttons retained their checked state. It seems that the jQuery code responsible for clearing these fields is executing, but the fields do not reset as expected.

Unable to Include HTML Partial in Main HTML Files Using html-loader in Webpack

I’m a beginner, learning some frontend staff. I’m trying to include HTML partials into my main HTML files using html-loader in my Webpack configuration. Despite following various tutorials and solutions, I keep encountering issues. I tried this also but can’t figure out. If you help me to get rid of this I’ll be thankful.

I tried this, still not getting any solution.
Is there a way to include partial using html-webpack-plugin?

Here is my webpack.config.js file

const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const ImageMinimizerPlugin = require("image-minimizer-webpack-plugin");
const webpack = require("webpack");
const glob = require("glob");

module.exports = ({ mode }) => {
  const isProduction = mode === "production";

  return {
    entry: "./src/js/app.js",
    output: {
      path: path.resolve(__dirname, "dist"),
      filename: "js/app.bundle.js",
      clean: true,
    },
    devServer: {
      static: {
        directory: path.join(__dirname, "dist"),
      },
      compress: true,
      port: 3000,
      open: true,
      hot: true,
    },
    module: {
      rules: [
        {
          test: /.(s[ac]ss|css)$/i,
          use: [
            isProduction ? MiniCssExtractPlugin.loader : "style-loader",
            "css-loader",
            "postcss-loader",
            "sass-loader",
          ],
        },
        {
          test: /.html$/i,
          loader: "html-loader",
        },
        {
          test: /.(png|jpe?g|gif|svg|ico|eot|ttf|woff)$/i,
          type: "asset",
          generator: {
            filename: "images/[name][ext]",
          },
        },
        {
          test: /.m?js$/,
          exclude: /node_modules/,
          use: {
            loader: "babel-loader",
            options: {
              presets: ["@babel/preset-env"],
            },
          },
        },
      ],
    },
    resolve: {
      extensions: [".js"],
    },
    plugins: [
      ...glob.sync("./src/pages/**/*.html").map((file) => {
        return new HtmlWebpackPlugin({
          template: file,
          filename: path.basename(file),
          chunks: ["main"],
        });
      }),
      new webpack.ProvidePlugin({
        $: "jquery",
        jQuery: "jquery",
      }),
      ...(isProduction
        ? [
            new MiniCssExtractPlugin({
              filename: "css/[name].css",
            }),
            new ImageMinimizerPlugin({
              minimizer: {
                implementation: ImageMinimizerPlugin.imageminMinify,
                options: {
                  plugins: [
                    ["mozjpeg", { quality: 75 }],
                    ["pngquant", { quality: [0.65, 0.9], speed: 4 }],
                    ["svgo", { removeViewBox: false }],
                    ["gifsicle", { interlaced: true }],
                  ],
                },
              },
            }),
          ]
        : []),
    ],
    mode: isProduction ? "production" : "development",
  };
};

I write this in my index.html and other html pages, but when I run npm run dev or npm run build I got this <%= require(‘html-loader!./partial/header.html’).default %>.

<%= require('html-loader!./partial/header.html').default %>

Please help me to solve this. If you need more info let me know please.
Thanks in advance.