vendredi 30 avril 2021

Showing 'TypeError: Failed to fetch' while creating contact form for my charity

I'm getting the message while creating contact form for my website.The Follwing error is showing !

Here is the HTML code for contact form in index.html -

<div class="col-lg-6">
        <form action="forms/contact.php" method="post" class="php-email-form">
          <div class="row gy-4">

            <div class="col-md-6">
              <input type="text" name="name" class="form-control" placeholder="Your Name" required>
            </div>

            <div class="col-md-6 ">
              <input type="email" class="form-control" name="email" placeholder="Your Email" required>
            </div>

            <div class="col-md-12">
              <input type="text" class="form-control" name="subject" placeholder="Subject" required>
            </div>

            <div class="col-md-12">
              <textarea class="form-control" name="message" rows="6" placeholder="Message" required></textarea>
            </div>

            <div class="col-md-12 text-center">
              <div class="loading">Loading</div>
              <div class="error-message"></div>
              <div class="sent-message">Your message has been sent. Thank you!</div>

              <button type="submit">Send Message</button>
            </div>

          </div>
        </form>

      </div>

Next here is the code for contact.php -

     <?php
  
  $receiving_email_address = 'arkajyotichakraborty99@gmail.com';

  if( file_exists($php_email_form = '../assets/vendor/php-email-form/php-email-form.php' )) {
    include( $php_email_form );
  } else {
    die( 'Unable to load the "PHP Email Form" Library!');
  }

  $contact = new PHP_Email_Form;
  $contact->ajax = true;
  
  $contact->to = $receiving_email_address;
  $contact->from_name = $_POST['name'];
  $contact->from_email = $_POST['email'];
  $contact->subject = $_POST['subject'];

  

  $contact->add_message( $_POST['name'], 'From');
  $contact->add_message( $_POST['email'], 'Email');
  $contact->add_message( $_POST['message'], 'Message', 10);

  echo $contact->send();
?>

Please help me to solve this problem. A big Thank you in advance :)




Student card with web application

I am a begginer student for my project i want to develop web application to print : (a student card, diploma, school certificate) with the simple method (Php & MySQL), but I do not know with which tool I can generate the student card or how for printing and dimensions, could you give me advices how to start or what i should search for in Google, i'am limited in time which is the fast method?




Best and easiest search engine for webpage?

Hello im going to develop a lesson Archiver i just wondering what kind od search engine i should use in search the content of web page for example. Im going to search for lesson chapter 3 and the web page should give a result if their is a lesson chapter 3. Like that thankyou in advance and any idea/answers will be appreciated thankyou!




What can java do except web? [closed]

I`m a developer using Java. I develop web application for javaee, but now my company start using server less. I feel that JAVAEE programmers may be unemployed




How do I make a website with a map that detects the user's current location, asks a question, and sets a marker on that location?

I want to make a website that asks for the user's current location, asks a question, and based on the response, it sets a marker on the map. How would I go about doing this?




Use different PHP filter styles on different languages

i using gettext filter to translate strings on my website , because there is some plugin can't translate full website ,and i have multi language on my website , can i use gettext filter to translate deffirent language like the trick HTML html[lang="en_US"]

enter image description here




How can i google something into my browser through python script? [duplicate]

How do i make my script google something in my default browser

Example:

a = input("What to google? ")
google(a)
#this should google the input in default browser

Thanx in advance!




Hello hope all of you are well i want to select motherboard on the basis of socket and chipset supported by CPU but it can fetch all motherboard

  1. **basically, i want to develop a website like pc part picker in Django I want to select a motherboard on the basis of socket and chipset supported by CPU problem is it can fetch all motherboard I want to select only those motherboard having the same socket and chipset stored in session problem in build_mobo

    **here are models****
    
    
    
    
    
    
    class vendor(models.Model):
            vendor_name=models.CharField(max_length=250)
    
        def __str__(self):
            return self.vendor_name
    
    class socket(models.Model):
        socket_type = models.CharField(max_length=250)
        def __str__(self):
            return self.socket_type
    
    class chipset(models.Model):
        cpu_chipset=models.CharField(max_length=250)
        def __str__(self):
            return self.cpu_chipset
    
    class CPU(models.Model):
        image = models.ImageField(upload_to="uploads/product/")
        vendor = models.ForeignKey(vendor , on_delete=models.CASCADE)
        cpu_name=models.CharField(max_length=250)
        cpu_price = models.CharField(max_length=250 , default="")
        generation = models.CharField(max_length=250)
        socket= models.ForeignKey(socket ,on_delete=models.CASCADE)
        chipset =models.ManyToManyField(chipset)
    
        def __str__(self):
            return self.cpu_name
    
    
    class Motherboard(models.Model):
        mobo_name= models.CharField(max_length=250)
        chipset = models.ForeignKey(chipset , on_delete=models.CASCADE)
        socket = models.ForeignKey(socket ,on_delete=models.CASCADE)
        vendor = models.ForeignKey(vendor , on_delete=models.CASCADE)
        DIMM_sockets  = models.CharField(max_length=250 ,default="single", choices=(("dual","dual"), ("single","single"),("4","4")))
        Supported_ram= models.CharField(max_length=250 ,default="ddr3", choices=(("ddr3","ddr3"), ("ddr4","ddr4")))
        Onboard_Graphics= models.CharField(max_length=250,blank=True,null=True)
        Expensions_socket_version= models.CharField(max_length=250 ,default="version 1", choices=(("version 1","version 1"), ("version 2","version 2"), ("version 3","version 3")))
        Audio =models.CharField(max_length=250,blank=True,null=True)
        LAN =models.CharField(max_length=250 ,blank=True,null=True)
        Storage_Interface =models.TextField(max_length=250 ,blank=True,null=True)
        USB =models.TextField(max_length=250 ,blank=True,null=True)
        def __str__(self):
            return self.mobo_name
    

    my view is :

    def build_cpu(request):
        data = CPU.objects.all()
        d = {'data1': data}
        return render(request, 'build/cpu.html', d)
    
    
    def build_home(request):
        if request.method == 'POST':
            cpu_id = request.POST['cid']
            cpu_nam = request.POST['nammm']
            dat = CPU.objects.get(cpu_name=cpu_nam)
            chip = dat.chipset.all()
    
    
            request.session['socket'] = dat.socket.socket_type
            request.session['cpuname'] = dat.cpu_name
    
            li = []
            for d in chip:
                li.append(d.cpu_chipset)
    
            request.session['listt'] = li
    
        return render(request, 'shop/build.html')
    
    
    def build_mobo(request):
        data = Motherboard.objects.all()
        request.session.get('socket')
    
        print("xxxxxxxxxxxxxxxxx")
        x = request.session['listt']
        y = request.session.get('socket')
        print(x)
        print(y)
        xxi = Motherboard.objects.filter(Q(socket__socket_type=y) & Q(chipset__cpu_chipset__icontains=x))
        print(xxi.query)
        d = {'data1': data}
        return render(request, 'build/mobo.html', d)
    



Is there any way In which I can transfer files from laptop to laptop if they are not in Lan using python?

Hello I Am building an app and what now i need is that the files or the client data should be saved in the server(which is my laptop). I want to ask if there any way to do that using python




How to Setup base Authentication on the Website?

I have a Drupal Website Deployed on Linux Server, It doesn't have any base authentication, How can i setup this. It is. For Example, If somebody visit the site, It needs to input credentials to visit site.




What existing platforms/services can I use to build an app-based subscription service? (without in-app purchase)

I want to build a mobile app with a login screen and a registration website to subscribe for the app. For subscription, I do not wan't users to pay through the app store but instead register/pay through an exterior website like Spotify and Adobe.

If building the website from scratch, I believe the development process would become complicated in order to safely handle customer information, manage recurring payments, manage reregistration, etc. Therefore it would save a lot of time if I could use existing platforms such as Shopify to build the website and somehow connect it to the server (for login authentication).

Do you know any platforms/services I can use to build a website like this?




How to verify text entered in a textbox is valid YAML or not in javascript

I am having a textbox that data will be entered by user, before saving that I have to verify data entered is valid YAM or not in Java script.




How to Make OG Url result t o PlayStore App

Hi All
In My Website I have placed this OG text for getting thumbnail from whatsapp.

             <meta property="og:title" content="Fooya Fit Food Fun " />
             <meta property="og:description" content="How to change the Food Habit " />
             <meta property="og:url" content="https://www.smywebsiteite.com" />
             <meta property="og:image" content="https://www.msywebsiteite./comF/oWatsapp.png" />

The Image is displaying well. But when the user is clicked my website link . I have to open my app in the playstore app.

OHow can i do it. How can i change the og:url to open my app in the playstore.

Thank s and Regards




How can I add alarm for the new listted items on a website?

There is a website with a list of items and I want to know about the new listted items instantly without refreshing and monitoring the page all the time. So can I make a vb.net and android app to give me alarm every time the website adds a new item to the list. Please can you help me with the code?




Is it possible to install more than one wordpress website on the same email?

I have one email And I have installed WordPress Then I want to install another site with the same email Is that possible?




Javascript Framework for a drawing/painting application

I am a noob javascript dev, but I have a project that I intend to provide. It is basically a drawing application.

I already made a first version in native canvas and react: https://github.com/201flaviosilva/Rupestre

For a second version I would like to use a framework that simplifies development, I've been testing with fabricjs, but it didn't seem to have many specific features for my goal, I would like to know if you know any lib / framework that could be useful in this idea of mine ?

(Sorry, for my English) :)




Prevent access to a site from a server

I am actually in internship and have an app to create for my structure. It will be an intern app which will allow crud dashboard actions with some data provided by the use of an API of one of the structure partner and make a correspondance to data contained in a private database. Since it's an intern app, I thought about Electron.js for a desktop app because I did a lot of web with Laravel and the structure goes more for desktop app. But it will be my first occasion working with this tech if I choose this solution. Otherwise I'll will go for a web app with Laravel.

My main question is, in case I choose a web app, what can I do about the access issue. Are there some things to do allow access only to the structure members ?

Thanks




How to fix the unable to load local resources issue in vuejs

So I have an application written in the MEVN stack and I split it into two folders, one for frontend and one for backend, I have a computer vision script that creates images in the backend that I want to access and show in the frontend. I wrote an API to store the files in an array and call that API in the vuejs page but for some reason even though I receive the files in the frontend, I think since its in the backend directory which is outside the parent directory of the frontend, It gives me an "unable to load local resources error" which I know is a security measure but for the testing purpose I would like to access these files. I am sorry that this question is wordy but I can provide code if explicitly asked. This is the error I am getting in the console : "Not allowed to load local resource: file:///E:/neos-backend/it_came/maskrcnn_segmentation_0.png" The Browser I am using is Edge




how many AJAX requests are reasonable per second?

I'm writing a web application that has to be as fast as possible, and i'd like to send about 1 ajax request every 200ms because it should be a very simple real time game and requirements that have been assigned to me preclude me from using WebSocket, so i was wondering if could be applicable to send so much ajax request, even if use GET insted POST, and data to send is very short




Using recursion to return the sum of the first n elements of an array arr

I'm trying to learn some JavaScript from freecodecamp.org and I stumbled upon a recursion problem which I can't wrap my head around:

Instructions: Write a recursive function, sum(arr, n), that returns the sum of the first n elements of an array arr.

function sum(arr, n) {
 if(n <= 0) {
    return 0;
 } else {
    return sum(arr, n - 1) + arr[n - 1];
}
}

I understand the second part: arr[n -1] adding the item value

But I don't understand what the first part(sum(arr, n-1)) does, and how the arr parameter reacts.

Can anyone help?

Any help is appreciated!




How do I fix red and green blocks with CSS ?

everyone Would like to ask at present I am making a version when the web page to slide up the red and green block to be fixed, only the yellow block can slide! The current treatment on the green side is using

 position:sticky;
 right:0px;
 top:100px;

The grammar keeps him fixed there, but there's a problem because if you don't give height it looks like it's position:sticky; I want his height to be customizable, so I give him a height of 200px; As a result, when the content is too much or in RWD mode, it goes out of the green zone.

Is there a better way to fix the red and green blocks?

Here's what I'm trying to do so far. https://codepen.io/hong-wei/pen/wvgbbye?editors=1100




how save parameters in domain wih redirect on htaccess?

i have problem with redirects in my domain

when i go to www.example.com - my doman redirect me to example.com - its ok! but,

when i go to www.example.com/test - my domain redirect me to example.com without /test... why? somebody help me?

code:

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews -Indexes
</IfModule>

RewriteEngine On

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]



jeudi 29 avril 2021

my vs code is working perfect but files are not working on localhost

I have coded a landing page in vs code which is perfectly running on vs code live server but when I run it on the browser or on localhost it doesn't work properly what could be the possible issue




What is the best folders hierarchy for a website built with pure PHP?

I wanted to know how to structure my folders for building a PHP website. it would be awesome if you could share with me the method used in big companies like Google, Facebook, etc... I want my project to be clean and comprehensive.

Thanks in advance. Have a good day.




How to fill a regulator's form using sql database with JS and JSON?

In my company, employees use a SQL database to enter the information manually in the regulator's website. Is it possible to automate this process so that the data automatically inputs in the fields. As of now, this process is very long as the employees have to manually input 100s of fields from the database.




How to get an unique ID from every user visiting my web page without the need of login in?

I want to have a Web page and identify every visitor somehow. Maybe using their MAC address. Is it possible to get the MAC address of visitors in my web page? or is there any other way to get what I want?

I don't want to make a login form because I hate when web pages ask me to log or to create an account, It would be better if the page just identify the device used on each case.

Thank you.




trying to find people to build projects

Hey m farouk and I'm 18 years old, first sorry my English is not that good, so I 'v been learning web development ( front end ) for like 1 year just by myself but to be honest I don't feel like I'm going good, I don't know why I feel kinda bad now cs I don't know if I'm on the right way or not I don't have friends to work with or something I wish if I can find a team to build projects and advance my skills, so if someone is interested in that we can do it, and thanks y'all.




How to make a button using html that will cause a zip file to be downloaded

On my website I have a downloads page and I want to know how to make a button that will cause the user to download a zip file.




CSFR token to limit AJAX requests

We received a lot of requests on an Ajax call. It was likely a DDOS, indeed it saturated our infrastructure for more than 1 hour. We implemented the throttling on the API called by this Ajax call but we'd like to block the users doing this action.

Can the implementation of CSFR tokens limiting these requests? As far as I know, it could work but I know this is not the "best" solution to do that or the solution at all.

Do you have some advice? It's a normal website with some ajax calls in the backend.

Thanks




How to fix scrollbar not being height of text size HTML

so I'm learning HTML and CSS, I made a container and within that container I have a div that is scrollable, but the scrollbar is the height of the div (looks more like it's a border-right than a scrollbar), why is that? (Don't mind my comments, it's just so I know what stuff does)

This is how it looks: here

HTML:

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Flexbox funsies</title>
    <link rel="stylesheet" href="./style.css">
    </link>
    <script src="./script.js"></script>
</head> <!-- I need to remember this;
the head is basically like importing modules and setting variables except this is HTML so we only set our meta(data) tags, import our script & css and also can set the title of our page !-->

<body>
    <main>
        <div class="container"> <!-- Here I made a container, containers are for... containing stuff, so if you make a div that's 50vh and 50vw, and then put something IN the div, it will be positioned in the div !-->
            <div class="inContainer">
                <div>Hello cruel world!</div>
                <div>This is another div!</div>
                <div>And could we do another one?</div>
                <div class="scrollbarHere">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras elementum. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Fusce tellus. Nam quis nulla. Nullam sit amet magna in magna gravida vehicula. Nulla accumsan, elit sit amet varius semper, nulla mauris mollis quam, tempor suscipit diam nulla vel leo. Fusce wisi. Aenean fermentum risus id tortor. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam dapibus fermentum ipsum. Nulla turpis magna, cursus sit amet, suscipit a, interdum id, felis. Integer tempor. Duis bibendum, lectus ut viverra rhoncus, dolor nunc faucibus libero, eget facilisis enim ipsum id lacus. Etiam sapien elit, consequat eget, tristique non, venenatis quis, ante.

Nullam sit amet magna in magna gravida vehicula. Nam quis nulla. Aliquam id dolor. Proin mattis lacinia justo. Fusce wisi. Nulla pulvinar eleifend sem. Suspendisse nisl. Duis pulvinar. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam sapien sem, ornare ac, nonummy non, lobortis a enim. Etiam sapien elit, consequat eget, tristique non, venenatis quis, ante. Et harum quidem rerum facilis est et expedita distinctio.</div>
                <div id="toChange">Flexbox is so awesome!</div>
            </div>
            <div class="inContainer2">
                <div>Hey nice world!</div>
                <button type="button" onclick="changeDivText()" class="basicButton">Click me!</button>
            </div>
        </div>
    </main>
</body>

</html>

CSS

/* To change something by ID, use # ex.: #my2ndDiv
To change sonething by class, use . ex.: .container
To change something by the DOM, use its name ex.: button */

* { /* sets these things for every element */
    font-family: "./Lekton-Bold.ttf", monospace; /* for some reason you have to pass in the type of the font? */
    color: #A6ADB8; /* text color */
    margin: 0; /* these two reset some stuff for other browsers i dont really know */
    padding: 0;
    box-sizing: border-box; 
}

main {
    min-height: 100vh; /* vh is view-height so basically what is visible on the screen :) */
    display: flex; /* makes our main a flexbox so that we can have things aligned easily */
    align-items: center; /* will not work without display: flex; */
    justify-content: center; /* will not work without display: flex; */
    text-align: center; /* will not work without display: flex; */
    background-color: #050A12;
}

.container {
    background: linear-gradient(
      to bottom left,
      rgba(185, 181, 199, 0.05), /* rgba stands for Red Green Blue Alpha, which means that the last number, from 0 to 1 is the alpha (opacity) of the color */
      rgba(185, 181, 199, 0.12)
    ); /* linear gradient, you did gfx you know what that is. */
    min-height: 80vh; /* sets the minimum height to 80 view-height */
    min-width: 80vw; /* sets the minimum width to 80 view-width */
    border-radius: 2rem; /* round things = better */
    display: flex; /* covered on line 11 */
    align-items: center; /* ^^^^ */
    justify-content: center;
    text-align: center;
}

.inContainer {
    display: flex; /* line 11 */
    flex: 1; /* we set our 'flex' to be 1 so that means if something next to it has 'flex' 2 then the width of this container will be 33% and the other thing next to it would have 66%, just get me... */
    flex-direction: column; /* makes it so that stuff inside the container is displayed vertically instead of horizontally */
    min-width: 30vw;
    min-height: 80vh; /* ^^ blablabla talked about it before */
    align-items: center;
    justify-content: space-evenly; /* speaks for itself */
    text-align: center;
    background: linear-gradient(
      to right bottom,
      rgba(185, 181, 199, 0.1),
      rgba(185, 181, 199, 0.2)
    );
    border-radius: 2rem;
    box-shadow: 16px 0 12px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.15); /* makes a shadow just on the right side of the container */
}

.inContainer2 {
    display: flex;
    flex: 1.5;
    flex-direction: column;
    min-width: 30vw;
    min-height: 80vh;
    align-items: center;
    justify-content: space-evenly;
    text-align: center;
}

.basicButton {
    font-size: 125%; /* here i have set the font size of the button text to 125%, 100% is the default size, by increasing font size, button size also increases */
    border-radius: 0.25rem;
    border-style: none; /* i remove the ugly default style it gives it */
    padding-top: 5px; /* makes a 5px space between text of the button and the top of the button */
    padding-bottom: 5px; /* makes a 5px space between text of the button and the bottom of the button */
    padding-left: 5px; /* makes a 5px space between text of the button and the left side of the button */
    padding-right: 5px; /* makes a 5px space between text of the button and the right side of the button */
    background: linear-gradient(
      to right bottom,
      rgba(185, 181, 199, 0.1),
      rgba(185, 181, 199, 0.3)
    );
    box-shadow: 16px 0 12px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.15);
}

.scrollbarHere {
    min-height: 20vh;
    max-height: 20vh;
    min-width: 20vw;
    max-width: 20vw;
    overflow-y: scroll;
    word-break: break-all;
}

::-webkit-scrollbar {
    background-color: red; /* This is just so I know where the scrollbar is */
}



{Beginner} Why Variable - 1 return original variable value of the variable. Why it does not decrement

I know its a very beginner question Here is scenario

Let number = 5; 
number - 1;
console.log(number);

it shows 5, why it does not show 4;

I want to understand this below recursion. Here times-1 is passed each time function is called. How it reaches to zero? And how each time decremented value is passed.

 if(times < 0) 
   return "";
 if(times === 1) 
   return string;
 else 
   return string + repeatStringNumTimes(string, times - 1);
}
repeatStringNumTimes("abc", 3);```



Shipping option is making my paypal not work

I was able to connect Paypal payment to my wordpress website and the payment process was working fine, however, when I added the shipping option to the website, Paypal is not working anymore and its showing me this message, Please help.

enter image description here




Uncaught TypeError: Converting circular structure to JSON --> starting at object with constructor 'FiberNode'

This is the error I am getting.

```
**EventList.js:70 Uncaught TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'FiberNode'
    |     property 'stateNode' -> object with constructor 'HTMLInputElement'
    --- property '__reactInternalInstance$rpowr4rh70f' closes the circle
    at JSON.stringify (<anonymous>)
    at Object.addEvent (EventList.js:70)
    at handleSave (AddEvent.js:34)
    at HTMLUnknownElement.callCallback (react-dom.development.js:336)**
```
  • It looks like the issue is with EventList line 70 and AddEvent line 34 which is here.

    EventList line 70

     ```
    //Add New Event
     addEvent(event) {
         const proxyurl = " https://secret-ocean-49799.herokuapp.com/";
         const url = SERVER_URL + '/api/v1/event';
         fetch(proxyurl + url,
             {
                 method: 'POST',
                 headers: {
                     'Content-Type': 'application/json',
                 },
                 body: JSON.stringify(event) {/*<-- Line 70*/}
             })
             .then(res => this.fetchEvents())
             .catch(err => console.error(err))
    

    }

     AddEvent line 34
import React, { useState } from 'react';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogTitle from '@material-ui/core/DialogTitle';
import Button from '@material-ui/core/Button';

const AddEvent = (props) => {
    const [open, setOpen] = useState(false);
    const [event, setEvent] = useState({
        id: '',
        title: '',
        subTitle: '',
        startDate: '',
        displayUntilDate: '',
        location: '',
        description: '',
        infoLink: ''
    });

    const handleClickOpen = () => {
        setOpen(true);
    };

    const handleClose = () => {
        setOpen(false);
    };

    const handleChange = (event) => {
        setEvent({ ...event, [event.target.name]: event.target.value });
    }

    const handleSave = () => {
        props.addEvent(event); {/*<-- Line 34 for Add Event*/}
        handleClose();
    }

    return (
        <div>
            <br />
            <button class="" variant="outlined" color="primary" onClick={handleClickOpen}
            >Add New Event
            </button>
            

            <Dialog open={open} onClose={handleClose}>
                <DialogTitle>New Event</DialogTitle>
                <DialogContent>
                    <input type="text" placeholder="Id" name="id"
                        value={event.id} onChange={handleChange} /><br />
                    <input placeholder="Title" name="title"
                        value={event.title} onChange={handleChange} /><br />
                    <input type="text" placeholder="Sub Title" name="subTitle"
                        value={event.subTitle} onChange={handleChange} /><br />
                    <input type="date" placeholder="Start Date" name="startDate"
                        value={event.startDate} onChange={handleChange} /><br />
                    <input type="date" placeholder="Display Until Date" name="displayUntilDate"
                        value={event.displayUntilDate} onChange={handleChange} /><br />
                    <input type="text" placeholder="Location" name="location"
                        value={event.location} onChange={handleChange} /><br />
                    <input type="text" placeholder="Description" name="description"
                        value={event.description} onChange={handleChange} /><br />
                    <input type="text" placeholder="Info Link" name="infoLink"
                        value={event.infoLink} onChange={handleChange} /><br />
                </DialogContent>
                <DialogActions>
                    <button onClick={handleClose}>Cancel</button>
                    <button onClick={handleSave}>Save</button>
                </DialogActions>
            </Dialog>
        </div>
    );
};

export default AddEvent;
```

From what I understand Circular Data occurs when you have an object that references some other parent object and if JSON.stringify printed the circular data, the string would be infinity.

So, it looks like the Stringify function is causing the issue but, I do not see how it is referencing a parent object.

At first I though it was because of the id value that is included but, also auto serialized as new objects are added. I removed the parts of code that interacted with the Id information but, that did not work.




Why is my published website looks bigger than the one which i open on my computer [closed]

Why is the pictures and menu items looks bigger in the piblished website? Because i open it from my computer, with VisualStudioCode live server, and it looks perfectly sized. Then i want to go to my page (siteofbarney.com), and some of the things looks bigger and goes through the right side. Please visit my page and then try to figure out why is this happening?




I have a challenge adding labels on chart js

When I apply labels using label-plugin on a single pie chart, it applies effect to all charts on the page including adding it on bar Charts




Using Python request, registrate on a website

I need to register new account on the site using request, but i dont know how to do it and i cant find information about it in the web.

So, help to register on the site, or push me on the right path, I will be grateful!




Website breaks when I change to PHP 7.4 from PHP 7.0 . Help please:)

Cant upgrade from PHP 7.0 to 7.4 without website breaking.HELP please:)

I am using the latest version of JOOMLA 3.9.26 I am using this template called ELOS purchased from themeforest. https://themeforest.net/item/elos-responsive-multipurpose-joomla-theme/8643058

I have all plugins updated. When I change my PHP setting to 7.4 on my hosting panel I get the message below:

0 - Using $this when not in object context

My website only works when I revert it back to PHP 7.0

I have attached a screenshot and listing of errors when I change it to 7.4. My website is www.connormaguire.com

Any help greatly appreciated. Thanks:)

*[0 - Using $this when not in object context You may not be able to visit this page because of: an out-of-date bookmark/favourite a search engine that has an out-of-date listing for this site a mistyped address you have no access to this page The requested resource was not found. An error has occurred while processing your request. Please try one of the following pages: Home Page If difficulties persist, please contact the System Administrator of this site and report the error below.. Using $this when not in object context Call stack

Function Location

1 () JROOT/libraries/src/Application/CMSApplication.php:390 2 Joomla\CMS\Application\CMSApplication::getMenu() JROOT/libraries/src/Application/SiteApplication.php:275 3 Joomla\CMS\Application\SiteApplication::getMenu() JROOT/templates/elos/preset/index_default.php:13 4 require() JROOT/templates/elos/index.php:15 5 require() JROOT/libraries/src/Document/HtmlDocument.php:668 6 Joomla\CMS\Document\HtmlDocument->_loadTemplate() JROOT/libraries/src/Document/HtmlDocument.php:730 7 Joomla\CMS\Document\HtmlDocument->_fetchTemplate() JROOT/libraries/src/Document/HtmlDocument.php:545 8 Joomla\CMS\Document\HtmlDocument->parse() JROOT/libraries/src/Application/CMSApplication.php:1076 9 Joomla\CMS\Application\CMSApplication->render() JROOT/libraries/src/Application/SiteApplication.php:778 10 Joomla\CMS\Application\SiteApplication->render() JROOT/libraries/src/Application/CMSApplication.php:209 11 Joomla\CMS\Application\CMSApplication->execute() JROOT/index.php:51]1*




bash curl | grep a specific website content

I'm trying to extract a specific piece of information from a website, but the content seems to be included in the class definition:

<div class= "some_div_class">
  <strong content="999" itemprop="price" class="strong_class">
      999
  </strong>
</div>

I'm targeting the "999", which I can if I do:

curl -s url |grep -zPo '<strong content="999" itemprop="price" class="strong_class">\s*\K.*?(?=\s*</strong>)'

If the "999" is in the content though, and it changes, grep would become invalid. Wildcards wouldn't return anything




How can I set up AOS (Animation on Scroll) on my website using npm method? [closed]

I have installed aos using npm install aos@next -save, but I don't know how to configure it into my website. Can someone help me out with this? Thank you.




Laravel multiple foreach in blade problem

I have segments. There are categories that segments have. Each segment consists of 3 categories and the middle segment is the main segment. How can I show them on the blade?enter image description here

I write code like this.

    $seg = DB::table('segments')->get();
        $categories = DB::table('categories')
            ->join('category_translations', 'category_translations.category_id', 'categories.id')
            ->select('categories.id', 'category_translations.category_name')
            ->where('language_id', $lan->id)
            ->get();
        $seg_cat = DB::table('segment_categories')->get();


@foreach($seg as $segment)
    <section class="news-block">

        <div class="container">
            <div class="row">
                @foreach($seg_cat as $segment_categories)
                    @if($segment->id == $segment_categories->segment_id)
                        @foreach($categories as $cat)
                            @if($cat->id == $segment_categories->category_id)
                <div class="col-lg-3">
                    
                </div>
                <div class="col-lg-6">
                    </div>
                </div>
                <div class="col-lg-3">
                </div>
                            @endif
                        @endforeach
                    @endif
                @endforeach

And this gives me like this enter image description here




Export data from HTML form into a .csv file [closed]

I'm creating a form here that catch some informations like: name, id, email, phone...

I need to export this data from a .txt or .csv file, how can I do this? It's possible to do using PHP? (I'm beginner on Web Development).

Thanks




GTmetrix and PageSpeed indicate my files don't get compressed

I've been working on performance profiling recently. PageSpeed suggests enabling text compression, in the Waterfall of GTmetrix, the file is also in uncompressed size. However, when I check the resource from Chrome DevTool, it's well compressed. (size is as expected and the response headers contain gzip settings) On the other hand, running on WebPageTest is perfectly okay.

Don't know if anyone encountered this situation before, thanks




uploading laravel-8 project in 000webhost error

I am trying to upload my laravel-8 project in 000webhost.com but my Public folder and resources and storage and routes and tests and vendor folder not uploading. I make my whole project in a zip folder and upload it public_html and extract my project than those folders not showing. but in my zip file, those folders and files are present what can I do?




How to fill elements automatically with css(css grid)?

How to create this mode automatically with css grid?

Because their number is not known and each time may be different

I want the other ones to fill Josh if the forgiveness was empty (like the picture)

enter image description here

enter image description here

.tests {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
}

.tests .test {
    font-weight: 900;
    background-color: rgb(172, 172, 172);
    margin: 3px;
    cursor: pointer;
    border-radius: 10px;
    padding: 5px;
    text-align: center;
}
<div class="tests">
    <span class="test">1</span>
    <span class="test">2</span>
    <span class="test">3</span>
    <span class="test">4</span>
    <span class="test">5</span>
</div>



Onclick "run a function" using external javascript

I created a simple project in which I click on a button then another button should be created(button 2) and the previous button should be disappeared and this works fine. But when I click on button 2 then a particular function should be executed. I am stuck here.

It says cannot set property to null.
function myFunction1() {
  var x = document.createElement("BUTTON");
  var t = document.createTextNode("button 2");
x.setAttribute('id','bt2');
  x.appendChild(t);
  document.body.appendChild(x);

var a= document.getElementById('bt1');  
a.style.display='none';

}
var item = document.getElementById('bt2');
item.onclick = myFunction;
function myFunction() {
  document.getElementsByTagName("BODY")[0].style.backgroundColor = "lime";
    }
<button id= 'bt1' onclick="myFunction1();">
 button 1
</button>



Can I use Full screen iframe in my webpage of my other website?

I have hosted a website on GitHub but I cant share that url as it's too long.

So, I have created a webpage from blogger with custom url and set my GitHub website into the full screened

If have to display Google ads in that website, will it be legal, as Google may think that the GitHub website used in iframe is not mine? Will Google see the code of my website before approving it?




Run Php Script using access code which has a lifetime of 30 days [closed]

I have a php script that users can run when they enter a correct and active access code. My idea is to pass the necessary parameters (access code, etc) from a start page to my PHP script using the GET method. When isset($_GET[]) is executed I would like to check if the access code is correct and active, if so a function should be called. How could I implement such a query of an access code, which remains active for 30 days after the first execution?

In summary: -How can I check the 30 days validity of keys stored in a file or something similar? -How to start such a timer when using a key for the first time?

I don't need a detailed description but just some hints for the implementation.

I hope someone can help me.

Thanks




I want to mention group the user either admin or customer while register(programmatically) in Django. I am new to Django

enter image description here

From the admin panel I can group the user either customer or admin. How do to programmatically? This my function register in views.py.

@unauthenticated_user
def register(request):    
    form = CreateUserForm()    
    if request.method == 'POST':
        form = CreateUserForm(request.POST)
        if form.is_valid():
            form.save()
            profile = form.save(commit=False) 
            profile.save()
            user = form.cleaned_data.get('username')
            us1 =  User.objects.filter(username=user).first()
            us1.is_staff = True 
            us1.is_superuser = False 
            
            us1.save()
            messages.success(request, 'Account was created for ' + user)
            return redirect('loginpage')
        

    context = {'form':form}
    return render(request, 'register.html', context)



mercredi 28 avril 2021

What is the best way of making an authentication system from a python script to a web server?

I'm having trouble of finding a good answer how to make an authentication system that would send a request from a python script with a hardware id to a server and check if that value exists in the database. I'm really new in the web development so I'm not sure what is the best and secure way to approach it.




How to convert image to text?

Hello im just wondering if I can covert or read a text in an image after upload . In web based , im actually want to upload photo where if I upload it it automatically read or check and image if their is a text or not. For example I upload a picture of ID and It will identify if it is a School ID, Voters ID and Etc.

Thankyou so much any answer will be appreciated Thankyouu!




Returning Empty list while getting text from span tag (Web scrapping)

import requests
from bs4 import BeautifulSoup

headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'}

html_text=requests.get('https://www.daraz.com.np/televisions/?spm=a2a0e.11779170.cate_3.1.287d2d2bmERvcc',headers=headers).content

soup=BeautifulSoup(html_text, 'lxml')
#soup = BeautifulSoup(html_text, 'html5lib')

string1=soup.find('span',class_='c13VH6')
print(soup.find('span', class_='c13VH6'))
print(string1)

its printing none value.




How to mimic a browser which can refresh itself using Python request

Whenever we open up a webpage using web browser (Chrome), for example Wall Street journal https://www.wsj.com/. I can see that the webpage can refresh itself: sometime the headline automatically change, the stock index got update or get an ad push.

I am wondering how can the web browser realize such an "listen" state? If I also want to mimic that behavior in Python, how would I do?

Something I know so far:

  1. sending request every 1 seconds to scrape for any update.
  2. if there is a web socket, I can subscribe and keep running ws.recv() in a while loop



Making a website for a school project - backend problem

So, for my school project I have to make a website using HTML and CSS for the frontend and node.js for the backend side. I was thinking about making a website that will stream online movies (it would be a website just for that project, I am aware that it's illegal to host movies for free). The problem is, I don't know where to start. I have about 20movies downloaded on my laptop so I was thinking about making a database (we have to make one too) with the file locaton of the movies, and then make my own server that will comunicate with that database and enable users to watch my movies when they want to (when the server on my laptop is running). My question is: does this idea make any sense or you would suggest me to make something else?




How can i make multi-language site? [closed]

I've got a question. How can I create a site in multiple languages? Actually I am building a site in EJS and am going to make it multilingual.

I would like the system to work on the principle that after selecting the language it changes:

  • Flag in the selection menu,
  • Country name or prefix in the selection menu,
  • Full page content in each language.

I would also like to change the language on each subpage the user navigates to after selecting the language.




How to convert an old wordpress website into a new one on godaddy?

So I have been given a zip folder with all the necessary files to for the website made on WordPress, however the person who owns the site had died and we lost there login details, so we had to make a new site on WordPress using godaddy. Does anyone know how i can convert the files to a AWordPressSite. I have provided the image of the content I have rn. Thanks!

The files i have access too




Safari Focuses Incorrect Input Field for Saved Passwords

I have a simple login form that includes username and password fields. When user save login credentials in Safari Desktop, it automatically focuses wrong input while typing password. For example, I show a captcha area when password's length reaches 4. digit. In that scenario, it focuses username field again. I wonder if there is anyone faced with same problem before with Safari Desktop.




Fabric JS Polyline points update issue

I'm having issue with the update of Polyline points.

I want to be able to move my arrow, and also to change two points of it.

When I move my arrow (left, top), the points doesn't update. So I update them manually, and the issue comes here.

For me, maybe I'm wrong, my point calculation is good, but fabric displays me the opposite.

I've made a jsfiddle which reproduces the issue: https://jsfiddle.net/7k6oyuL4/1/


    const calcNewAngle = ({ x1, y1, x2, y2 }) => {
      const width = Math.abs(Math.max(x1, x2) - Math.min(x1, x2));
      const height = Math.abs(Math.max(y1, y2) - Math.min(y1, y2));
      let theta;
      if (x1 < x2 && y1 < y2) {
        theta = Math.atan(height / width);
      } else if (x1 < x2 && y1 >= y2) {
        theta = Math.atan(-height / width);
      } else if (x1 >= x2 && y1 < y2) {
        theta = Math.abs(Math.atan(height / width) - Math.PI);
      } else {
        theta = Math.abs(Math.atan(-height / width) - Math.PI);
      }
      return theta;
    };
    
    const setArrowPoints = ({x1, y1, x2, y2}) => {
      const angle = calcNewAngle({x1, y1, x2, y2});
      const headlen = 8;
      return [
        {
          x: x1,
          y: y1
        },
        {
          x: x2,
          y: y2
        },
        {
          x: x2 - headlen * Math.cos(angle - Math.PI / 2),
          y: y2 - headlen * Math.sin(angle - Math.PI / 2)
        },
        {
          x: x2 + headlen * Math.cos(angle),
          y: y2 + headlen * Math.sin(angle)
        },
        {
          x: x2 - headlen * Math.cos(angle + Math.PI / 2),
          y: y2 - headlen * Math.sin(angle + Math.PI / 2)
        },
        {
          x: x2,
          y: y2
        }
      ];
    }
    
    const getX1Y1X2Y2 = points => {
        return {
        x1: points[0].x,
        y1: points[0].y,
        x2: points[1].x,
        y2: points[1].y
      }
    }
    
    const updateArrow = (e, canvas, arrow, index) => {
        const mousePos = canvas.getPointer(e);
      const {points} = arrow;
      points[index].x = mousePos.x;
      points[index].y = mousePos.y;
      arrow.set('points', setArrowPoints(getX1Y1X2Y2(points)))
    }
    
    const createControl = ({canvas, index, arrow}) => {
        const left = arrow.points[index].x;
      const top = arrow.points[index].y;
      const control = new fabric.Circle({
        index,
        left, 
        top,
        radius: 5,
        strokeWidth: 1,
        hasBorders: false,
        stroke: 'rgba(0,0,255,1)',
        fill: 'rgba(255,255,255,1)',
        originX: 'center',
        originY: 'center'
      });
      control.setControlsVisibility({
        bl: false,
        br: false,
        mb: false,
        ml: false,
        mr: false,
        mt: false,
        tl: false,
        tr: false,
        mtr: false
      });
      control.on('moving', e => updateArrow(e, canvas, arrow, index));
      return control;
    }
    
    const handleMoving = (e, canvas, controls) => {
      const {target} = e.transform;
      if (!target.alreadyLogged) {
        target.alreadyLogged = true;
        console.log('handleMoving', target.points);
      controls.forEach(control => control.set('visible', false))
      }
    }
    
    const handleMoved = (e, canvas, controls) => {
      console.log('###### handleMoved ######')
      const {target, transform} = e;
      const {left: originLeft, top: originTop} = transform.original;
      const {left: newLeft, top: newTop, points} = target;
      const leftDiff = newLeft - originLeft;
      const topDiff = newTop - originTop;
      console.log({originLeft, newLeft, leftDiff, originTop, newTop, topDiff});
      console.log('pointsBeforeManualUpdate', getX1Y1X2Y2(points))
      const x1 = points[0].x + leftDiff;
      const y1 = points[0].y + topDiff;
      const x2 = points[1].x + leftDiff;
      const y2 = points[1].y + topDiff;
      target.set('points', setArrowPoints({x1, y1, x2, y2}))
      console.log('pointsAfterManualUpdate', getX1Y1X2Y2(target.points))
      controls.forEach(control => {
        const {index} = control;
        const leftControl = target.points[index].x;
        const topControl = target.points[index].y;
        control.set({
            visible: true,
            left: leftControl, 
          top: topControl
        })
      })
        target.alreadyLogged = false;
    }
      
    const createArrow = ({canvas, points}) => {
      const arrowPoints = setArrowPoints(points);
      const arrow = new fabric.Polyline(arrowPoints, {
        strokeWidth: 2,
        stroke: 'rgba(0,0,0,1)',
        fill: 'rgba(0,0,0,1)',
        perPixelTargetFind: true
      });
      arrow.setControlsVisibility({
        bl: false,
        br: false,
        mb: false,
        ml: false,
        mr: false,
        mt: false,
        tl: false,
        tr: false,
        mtr: false
      });
        
      const control1 = createControl({canvas, index: 0, arrow})
      const control2 = createControl({canvas, index: 1, arrow})
      
      arrow.on('moving', e => handleMoving(e, canvas, [control1, control2]))
      arrow.on('moved', e => handleMoved(e, canvas, [control1, control2]))
    
      canvas.add(arrow)
      canvas.add(control1)
      canvas.add(control2)
      return arrow;
    }
    
    (function() {
      const canvas = this.__canvas = new fabric.Canvas('c', { width: 1500, height: 1000 });
        const arrowObj = createArrow({canvas, points: {x1: 50, y1: 50, x2: 200, y2: 200}})
    })();

Thanks in advance for your help!




Ionic / Angular testing [closed]

I'm looking for a way to test my Ionic/Angular app.

What automatic testing tool would you recommend?

Thank you in advance for your answer;

Sacha




Cannot access a website service via my Microsoft Azure VM. Website says I am using a proxy or vpn. How do I change this?

I am trying to run a couple of website performance tests on https://tools.keycdn.com/performance. However, the website states that I am using a proxy or vpn which blocks me from using their services. I did not actively set up either of those.

I am accessing the website via my Azure Ubuntu VM, manually navigating to that website via a Chrome browser. How can I either change those Azure settings or alternatively hide those settings, so that this website does not block me anymore?




ASP .NET Core Web API + Android kotlin App

I've made a ASP.NET Core Web API (hosted locally IIS Express) and I'm trying to get data from it from my Android app (kotlin), but I always get a "Bad request" or "FileNotFoundException" (depending on which method of getting the data is used). I know I can successfully retrieve data from other web API's, but not for mine.

I also tried googling my problem but with no luck on finding the answer.

Retrieving data from my Web API works from browser (http://localhost:24517/bar?username=smthg&password=smthg)

My C# controller:

[HttpGet]
        [Route("[controller]")]
        public Bar Authenticate(string username, string password)
        {
            Bar bar = new Bar();
            try
            {
                var user = context.Users.FirstOrDefault(u => u.Username == username && u.Password == password);

                bar = context.Bars.
                    Include(b => b.Inventory).
                    ThenInclude(i => i.Items).
                    Include(b => b.Users.Where(u => u.Id == user.Id)).
                    ToList().
                    Find(b => b.Users.ToList().Find(u => u.Id == user.Id) == user);
            }
            catch (Exception)
            {
                
            }


            return bar;
        }

My kotlin request:

const val URL = "http://192.168.0.13:24517/bar"
const val USERNAME = "username=";
const val PASSWORD = "password=";

class BarRepo : IRepoBar {

    override fun getBarByUserAsync(userName: String, password: String): Bar {
        val url = "$URL$USERNAME$userName&$PASSWORD$password"

        val apiResponse = URL(url).readText()



        val obj = Json.decodeFromString<Bar>(apiResponse)
        return obj
    }
}



add more debug devices in flutter

i am using flutter for web development, and i want to run it on different browsers...

opera, chrome, firefox and etc...

so i am trying to find a way to add this to my devices list

i have opera downloaded and set my default browser but it doesn't recognize it

and by default it use edge web

i am using vscode as my editor

flutter devices

output:

1 connected device:
Edge (web) • edge 

is there a way to add other browsers to my devices like (chrome, firefox or opera) ??




JavaScript - PWA - possible to send and receive data using NFC

I need to implement NFC (near field communication) in a PWA (progressive webapplication).

I use this code but not worked:

Writing a string to an NFC tag:

if ("NDEFWriter" in window) {
const writer = new NDEFWriter();
await writer.write("Hello world!");
 }

Scanning messages from NFC tags:

if ("NDEFReader" in window) {
    const reader = new NDEFReader();
    await reader.scan();
    reader.onreading = ({ message }) => {
   console.log(`Message read from a NFC tag: ${message}`);
   };
}

Is it possible to use NFC in any way in a PWA?




Transaction cannot be rolled back because it has been finished with state: commit

let transaction
try{
    transaction = await ctx.app.model.transaction();
    const newPageResult = await pageService.add(addPageResult, { transaction });
    await transaction.commit();
    throw new Error("do rollback")

}catch(){
   transaction.rollback()
}
2021-04-28 17:02:53,801 ERROR 14904 [-/127.0.0.1/-/75306ms POST /page/copyPage] nodejs.Error: Transaction cannot be rolled back because it has been finished with state: commit
    at Transaction.rollback (/Users/my/work/node_modules/sequelize/lib/transaction.js:85:35)
    at PageController.copyPage (/Users/my/work/app/controller/pageController.ts:418:31)
    at process._tickCallback (internal/process/next_tick.js:68:7)

I have read source code, If await transcation.commit(), this.finished must be "commit"

So If want to rollback must throw error... Here is the source code

enter image description here

enter image description here




How I Dropped My Cumulative Layout Shift (CLS) To Zero [closed]

We use T Soft But we score is 0.7 (https://prnt.sc/126uskl) (elizamoda.com) The other web site use T Soft but CLS score is 0 (https://prnt.sc/126uznt) (https://www.caykursatis.com/)

How I Dropped My Cumulative Layout Shift (CLS) To Zero Thanks..




Display of grid

There is a code

    $(document).ready(function() {
        /*
        all__buttons=document.querySelectorAll('.header__button');
        
            [].forEach.call(all__buttons, function(selected__button){
                selected__button.addEventListener('click', function(event){
                    event.target.style.backgroundColor='#5f3ec0';
                    event.target.style.color='#ffffff';
                
                });
            }); 
        */
    
        $('.header__button').click(function(event){
                $('.header__button').removeClass('lilac');
                $(this).addClass('lilac');
                event.target.style.color='#ffffff';
        }
        );
    
if ((document.documentElement.clientWidth >= 320) and (document.documentElement.clientWidth <= 639))
{
const getItem = `<div class="cardexample">
                            <div class="mobileimage">
                                    <img class="mobiles" src="../img/mobileimage.png">
                            </div>
                            <div class="content__title">
                                Iphone 11, почему такой же как и Pro Max, может быть большим в 3 строки вот так
                            </div>
                            <div class="video__icon">
                                <span>
                                    <button class="crashvideo">Краш видео</button>
                                </span>
                                <span>
                                    <a href="#"><img class="youtube__icon-play" src="../img/Vector.png"></a>
                                </span> 
                                <span>
                                    <button class="crashvideo" id="ex2">Краш видео</button>
                                </span>                         
                            </div>
                            <div class="content__text">
                                Видео разбор с ответами на самые часто задаваемые вопросы может быть большим в 3 строки, видео разбор с ответами на самые часто задаваемые
                            </div>
                            <div class="endlink">
                                <a href="#">Читать далее</a>
                            </div>              
                        </div>
                        `;

            const getAllItems = () => {
                let content = '';
                
                for (let i=0; i<4; i++) {
                    content+=getItem;
                }
                return content;
            }       

            const renderAllItems = () => {
                document.getElementById('content').innerHTML=getAllItems();
            }

            renderAllItems();
        }           
    
        if ((document.documentElement.clientWidth >= 640) and (document.documentElement.clientWidth <= 1023))
        {
            document.getElementsByClassName('content__article').innerHTML = getItem;
            
        
        }
    
    
    }
    
    
    )
body {
    margin: 0;
    padding: 0;
}

:root {
    --containerfullwidth: 768;
}
.globalcontainer {
    margin-top: 0px;
    margin-right: calc((39/var(--containerfullwidth)*100)*1%);
    margin-bottom: 0px;
    margin-left: calc((39/var(--containerfullwidth)*100)*1%);
    /*height: 100%;*/
}

.header > .header__text {
position: relative;
width: 93px;
height: 24px;
left: 0;
margin-top: 129px;
margin-bottom: 20px;

font-family: TT Norms;
font-style: normal;
font-weight: bold;
font-size: 24px;
line-height: 100%;
/* identical to box height, or 24px */


color: #000000;
}

/*
.header__buttons {
    left: 0;
    top: 193px;
}
*/


.header__button {
    width: 75px;
    height: 30px;
    border-radius: 4px;
    border-color: #5f3ec0;
    background-color: #fff;
    margin-right: 1.75%;
    display: flex;
    justify-content: center;
    align-items: center;
    white-space: nowrap;
}

.header__buttons {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 7px 15px 7px 0px;
    overflow: hidden;
    /*margin-right: 10%;*/
}

.content {
    display: grid;
    grid-template-areas: "content__parttext content__parttext"
                         "content__parttext content__parttext"
                         "content__parttext content__parttext"
                         "content__parttext content__parttext";
    grid-template-columns: 1fr 1fr;
}

.content__article {
    grid-area: content__parttext;
}
<html>
<head>
<!-- <link rel="stylesheet" href="testsite.css">-->
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Test Example</title>
<link rel="stylesheet" type="text/css" href="../css/mobile.css" media="screen and (min-width: 320px) and (max-width: 639px)"></link>
<link rel="stylesheet" type="text/css" href="../css/tablet.css" media="screen and (min-width: 640px) and (max-width: 1023px)"></link>
<link rel="stylesheet" type="text/css" href="../css/desktop.css" media="screen and (min-width: 1024px) and (max-width: 1920px)"></link>
<script type="text/javascript" src="http://code.jquery.com/jquery-3.6.0.min.js"></script>

</head>
<body>
    <div class="container">
        <div class="globalcontainer">
                <div class="header">
                        <div class="header__text">
                            Обзоры
                        </div>
                        <div class="header__buttons">
                            <!-- <span> -->
                                <button class="header__button">Все</button>
                                <button class="header__button">Видео</button>               
                                <button class="header__button">Текст</button>               
                                <button class="header__button">Обзоры</button>
                                <button class="header__button">Сравнения</button>
                                <button class="header__button">Краш видео</button>
                                <button class="header__button">Распаковка</button>
                            <!-- </span> -->
                        </div>
                </div>      
                <div class="content" id="content">      
                        <div class="content__article">
                        
                        </div>
                        <div class="content__article">
                        
                        </div>
                        <div class="content__article">
                        
                        </div>
                        <div class="content__article">
                        
                        </div>              
                        <div class="content__article">
                        
                        </div>
                        <div class="content__article">
                        
                        </div>
                        <div class="content__article">
                        
                        </div>
                        <div class="content__article">
                        
                        </div>              
                </div>              
                </div>              
                <button class="show__more">Показать еще</button>
        <!-- </div> -->
        <div class="footer">
                <div class="logo__company">
                </div>
                <div class="contacts">
                    <div class="contacts__title">
                        Контакты
                    </div>
                    <div class="contacts__telephones">
                        <div class="telephone1">
                        +7 (800) 333 32 24
                        </div>
                        <div class="telephone2">
                        +7 (812) 448 68 11
                        </div>
                    </div>
                    <button class="requestcall">
                        Заказать звонок
                    </button>
                </div>
                <div class="internetshop">
                        <div class="internetshop__title">
                            Интернет магазин
                        </div>
                        <div class="disclosure__arrow">
                            >
                        </div>
                </div>
                <div class="company">
                        <div class="company__title">
                            Компания
                        </div>
                        <div class="disclosure__arrow">
                            >
                        </div>
                </div>
                <div class="help__to__the__buyer">
                        <div class="help__to__the__buyer__title">
                            Помощь покупателю
                        </div>
                        <div class="disclosure__arrow">
                            >
                        </div>                  
                </div>
                <div class="socialnetworks__links">
                        <div class="socialnetworks__links__title">
                            Мы в соц. сетях
                        </div>
                        <div class="socialnetworks__links-images">
                            <div class="facebook-image">
                                <embed src="../img/facebook.svg">
                            </div>
                        </div>
                </div>
                <div class="allrights">
                        <div class="allrights__text">
                            © 2020 Все права защищены
                        </div>
                </div>
        </div>          
    </div>
<script type="text/javascript" src="jsactions.js"></script>
</body>
</html>

It should be displayed as at https://www.figma.com/file/noqP1gzhrAlGAErPNBgknp/test?node-id=0%3A1 (tablet view), but my pictures (content block) after header__buttons are not displayed. Tell me how to fix the display.




mardi 27 avril 2021

WebRTC VIdeo Streaming

I'm streaming a video file from a peer to multiple peers. What I'm trying to do is set the duration of the video as well as where the streaming peer is in the video (seek time) for all peers.

I was able to set the correct duration using the Plyr video player, but whenever I'd like to seek into the video for a peer, it just resets to zero at the moment when srcObject is set to the streaming peer's MediaStream, after that seeking is not possible at all, it just throws me back to the current position (time elapsed since start).

Of course, I've tried to debug the problem. I went into Plyr's source, what I found out is that, obviously, Plyr uses the HTML5 media. So, I logged what the video tag looks like when playing and found out that the duration is Infinity. I think that this might be the problem, of course, it's just a guess. It only sets itself if there's an active source as that property is read-only.

How can I set the duration as well as seek in time WITHOUT a source?

I'd love to hear any solution/workaround for this. Thank you.




I have Just created a new SignUp page but this is not working

I have Just created a new Sign Up page but this is not working. I made an error alert to check whether password is same or not but it is not showing that alert my code is given below Please help me to solve this......

export function SignupForm(props) {
  const { switchToSignin } = useContext(AccountContext);
  const emailRef = useRef();
  const passwordRef = useRef();
  const passwordConfirmRef = useRef();
  const { SignUp } = useAuth();
  const [error, setError] = useState("");
  const [loading, setLoading] = useState(false);

  async function handleSubmit(e) {
    e.preventDefault();

    if (passwordRef.current.value !== passwordConfirmRef.current.value) {
      return setError("Password does not match");
    }

    try {
      setError("");
      setLoading(true);
      await SignUp(emailRef.current.value, passwordRef.current.value);
    } catch {
      setError("Failed to create an account ");
    }
    setLoading(false);
  }

  return (
    <BoxContainer>
      {error && (
        <div class="alert" variant="danger">
          {error}{" "}
        </div>
      )}
      <FormContainer onSubmit={handleSubmit}>
        <Input type="email" id="email" placeholder="Email" required ref={emailRef} />
        <Input type="password" id="password" placeholder="Password" required ref={passwordRef} />
        <Input type="password" id="confirm-password" placeholder="Confirm Password" ref={passwordConfirmRef} />
      </FormContainer>
      <Marginer direction="vertical" margin={10} />
      <SubmitButton disabled={loading} type="submit">
        Signup
      </SubmitButton>
      <Marginer direction="vertical" margin="1em" />
      <MutedLink href="#">
        Already have an account?
        <BoldLink href="#" onClick={switchToSignin}>
          Signin
        </BoldLink>
      </MutedLink>
    </BoxContainer>
  );
}




File upload fails when phone screen turns off

In my web app, when submitting a form with a file to be uploaded, if the user pushes the button to turn the screen off before the upload finishes, it doesn't get uploaded. I'm assuming this is because the browser has been put into the background to sleep. I've searched for the answer here for how to approach this problem, but haven't found anything for a web app. Is there a way to keep the browser awake in the background until the file upload finishes, or a way to detect when the browser sleeps and then wakes up, or should I just show the user a message to Please Wait and hope they don't shut the screen off?




Interface directly with AWS

How can I make a graphical interface that loads images from AWS? The images must be displayed in the interface together with buttons for their classification. What platform facilitates this?




Safari 5.1.7 in Windows 10 is not working

I have installed Safari 5.1.7 in windows 10. And it doesn't work all. I can't access any domain. attempts to connect apple.com And when I try to connect to a local dev server like http://localhost:8081, it becomes a blank page. blank page in localhost But the page content is coming. source is coming Please help me.




Is It possible to store database in different cpanel and website in another cpanel

I want to host a website in which I want to store database in another place and website domain in different place please someone suggest if this is possible.




Python Flask - How to display print statements in another Python module to a web page?

I am a beginner in web programming using Flask in Python. I've built a web page the takes a couple of inputs from the user and clicking a command button on the page leads to another Python module's main method being invoked. I want to print the console outputs of that python script to a webpage(continuously if possible). Sample code is:

>  @app.route('/register', methods=["POST"]) 
>  def register():
>     ip_address = request.form.get("IP_ADDRESS")
>     router_location = request.form.get("Routers_Location")
>
>     def g():
>         output = xyz.main(ip_address, router_location)
>         for line in output:
>             yield line
>
>     return Response(g(), mimetype='text/html')

Where xyz is the python script that I am importing in the above code and main() contains few print statements. Currently, I am using a list to have the content of the print statements appended to it and return it back to the caller function(In this case, the caller is g()).

I need to print all the print statements to a web page as it prints on the console. Any help would be appreciated.




What is disadvantage of UUID-based URL?

I'm developing a Q&A site.

I'm using uuid for the id of questions, and will use that for the url as well.

Question data

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "title": "This is a question",
  "content": "How are you?"
}

URL

https://example.com/questions/550e8400-e29b-41d4-a716-446655440000

However, I have never seen a website that includes the UUID in the URL. For example, a url of a question in stackoverflow is something like https://stackoverflow.com/questions/12345678/this-is-a-question.

Is it a bad practice?




Suggestion for tech stack that is good for interactive forms?

tl dlr: Looking for a tech stack for a SaaS project where I can efficiently provide users with interactive forms that updates fields as they interacts with input fields.

I have an idea for a SaaS project but I'm struggling a bit on deciding a technology stack. I'm not the most experienced web developer but I come from an OO world so I feel very much at home when I can model stuff with classes. I like to focus on the "core" functionality which is the most important and I want to make sure that I can develop it efficiently. To give a bit of context, the project is a calculation tool which takes numerous inputs and has numerous output fields. A spreadsheet on steroids if you will. Actually, as a PoC, the calculations were done in a spreadsheet and that is what I want to present in a SaaS solution - just nicer.

I'm not set on any particular language but open to hear what language/framework will benefit me the most. What I'm most concerned about is not having to do too much cumbersome work when it it comes to manipulating the model. Whether it being handled fully on the frontend or sent back and forth between frontend and backend. I would like something were I can easily define components/views that represents fields and have the calculations update as the user interacts with the form/inputs. I don't want to replicate models in both frontend and backend.

Just to get an idea of what I've been trying to model, here are some example classes that I've been experimenting with in Java (again, I'm not set on Java as the final language). Don't worry to much about the types. It just to get an idea of how I would like to structurally model the calculation and tie fields together.

public abstract class Field<T> {

    protected final String name;

    public Field(String name) {
        this.name = name;
    }

    public abstract T getValue();

    public String getName() {
        return this.name;
    }
}

public class InputField<T> extends Field<T> {

    protected T value;

    public InputField(String name) {
        super(name);
    }

    @Override
    public T getValue() {
        return this.value;
    }

    public void setValue(T value) {
        this.value = value;
    }
}

public class IntegerField extends InputField<Integer> {
    public IntegerField(String name) {
        super(name);
    }
}

public class IntegerSumField extends Field<Integer> {

    private final List<InputField> fields;

    public IntegerSumField(String name, InputField... fields) {
        super(name);
        this.fields = Arrays.asList(fields);
    }

    @Override
    public Integer getValue() {
        return fields.stream().mapToInt(f -> f.getValue()).sum();
    }
}

public class CalculationSection {
    private final IntegerField input1 = new IntegerField("User Input 1");
    private final IntegerField input2 = new IntegerField("User Input 2");
    private final IntegerSumField output1 = new IntegerSumField(input1, input2);
}

Now this is just a simple example - obviously the real deal has many more fields and sections/sub-calculations. It would be nice to be able to declare a view for CalculationSection and have views for the various Fields being reused - and have the model updated as the user interacts. The calculations should be persistable so some backend has to handle the model.

I'm also looking for SaaS boilerplates (don't mind paying) to get me going - I just don't know what to look for since I don't know which language/framework is best for my use-case.

I know this is quite a mouthful but I've been thinking about this for a while and now I finally decided to ask SO about it - would love to hear your suggestions and thoughts about this.




Create web setup installer for the UAT project Web Form. ASP.net C#

I have no problem in rebuild the UAT file project. Rebuild UAT file project is a success and has no error. But once the UAT Web Setup has created, so to rebuild it got 1 failed. The error is:

ERROR: File 'NdefLibrary.dll' targeting 'AMD64' is not compatible with the project's target platform 'x86'

Image of the error (image link)

How supposed to solve this? Already searched but no solution found.

Also has try to change the compatibility platform under Build tab > Configuration Manager, but error still remain the same.




Should we add Open Graph meta properties to our websites?

Following the steps of the HTML boilerplate from Manuel Matuzovic to bring my own HTML up to speed, I ran into some Open Graph meta properties. Now, I'm skeptical about adding these, because it seems the only thing they do is integrate my content (web pages published in the open for anyone to read, with no tracker no ads) better into Facebook (a walled garden with trackers and ads).

To look for opinions, I searched for "should you add open graph to your website?" on various search engines, and all the results that come up told me how to add Open Graph to my website for Open Graph. What about the other side of the coin?

I've tried:

  • "fsf on open graph" (no counter opinion)
  • "against open graph" (nothing came up either)
  • "mozilla on open graph" (turned up a Firefox extension for Open Graph...)
  • "don't open graph" (new result! "Don't forget about OpenGraph" xD)

Eventually I thought of "what are the cons of open graph", which turned up two pages:

Have some folks in the open formulated more educated opinions. e.g. about the impact of the adoption of this protocol on the open web? Are there also some pros of Open Graph that contribute to the common good, e.g. enabling some semantic web features?

Can we share relevant links and discuss counter opinions here?




How to switch redirect status code from 308 to 301 when there is no trailing slash in the end of URL

I have node js server and when I try to my domain like www.mysite/en-de (without slash) I get 308 redirect

What I need to change to have 301 status code in case of lack trailing slash?




Invalid element name:- display-name One of the following is expected:- distributable, context-param , filter, servlet, etc

I am trying to solve this error... This error is showing by default when I create new project within dynamic web project option.. The scenario is project creates successfully but when I expand web.xml file inside webapp folder errors are showing....

Pls click the code of web.xml file:-

<?xml version="1.0" 
encodingg="UTF-8"?>
<web-appxmlns:xsi="http://
www.w3.org/2001/XMLSchema-
instance" 
xmlnss="http://java.sun.com
/xml/ns/javaee" 
xsii:schemaLocation="http:
//java.sun.com/xml/ns/javaee 
httpp://java.sun.com/xml/
ns/javaee/web-app_2_5.xsd" 
versionn="2.5">
<display-name>helloweb</display- 
name>
</web-app>

This is the attachment of error:-

[https://i.stack.imgur.com/savdu.png[1]




CSS debugging on Macbook for different Windows laptops

My web pages being developed on Macbook breaks on windows laptop(margin and padding are abnormal).

Any way of checking my css during development on different screens ?

PS : Browser is same (Chrome).




How do I show the files of a FTP directory on a wordpress page and make it available for download?

So I got a task in which I need to make a download page. The files for that download page are on a ftp server and when a new file gets uploaded to the ftp it should be automatically updated.

I looked for plugins but I didn't really find any. I got the word press download manager and the automatic ftp add on. With that I automatically got it onto same ftp on which the website is, but that is still not shown on the page.

Do you have any idea of a plugin or a way on how to do that? (or maybe even on how to do it with wpdm?)

I really feel like I searched through 50% of google and don't know what else to do to get that task done. Thanks in advance.




lundi 26 avril 2021

Как в cookie хранить значение checkbox, чтобы у сайта была возможность вкл темный режим django

мой инпут☝

views.py👇👇

def layout(request):
    form = UserLogin()
    return render(request, 'layout.html', {'user': form})



How can I send data from Server to Client without GET request from the client?

(Sorry for my bad english)

Hi! I asking me a question... If I want to create a chatting web-application with NodeJS, how can I send data from the server to the client without GET request from the client ?


(example)

That I want :

Server - WRITE -> Client

That I know :

Client - GET -> Server - WRITE -> Client

The major problem with the second one is that I need to refresh data all the time. I search for a solution OTHER than Socket.IO, but it seems to be impossible or very complicated :/

Please help me :c !




Web developer job interview questions

I was given two questions required to submit prior to the interview. If you could give me some ideas it'd help me a lot. Thanks.

  1. One is in the situation where Restful API has to be provided but the server is not ready or fully developed yet. Then in this case, how can one provide service to Front-End first?

  2. One is in the situation where database isn't ready or fully developed yet. How then can one find the way to test whether his or her developed service is working well with the database?

Thank you.




RSS from web app - CORS problems - simple solution [duplicate]

I want to add RSS to my webApp.

I encountered this “CORS” problem which cause the request to be failed (in the dev env anyway),

Access to XMLHttpRequest at 'http://rss.cnn.com/rss/edition.rss' from origin 'http://localhost:3007' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

and I’m aware to such solution of using “CORS” proxies, or create one proxy by myself.

There are problems with such online server since, it’s restricted, I need to request temp access each time.

https://cors-anywhere.herokuapp.com/

My question is how do I should do it?

And why this problem has no other simple solution that can be implemented in the code level?

The web is full with “simple data” pages which CORS same origin restrictions aren’t relevant there. To open new proxy only for access data from localhost seems exaggerate task in my eyes.




Lateral distance inside flex

There is a site Test site. How in the mobile version to set the lateral distance inside the flex containing the text Internet shop and an arrow rotated by 90 degrees? For an online store, the distances to the left and top are 15px and 25px from the contact block, for the down arrow, the distances to the right and top are 18px and 30.62px from the contact block.

What is the default distance for justify-content: space-between?




Web Design in need of review

I am working on a website for my career and would like to know how to improve sales.

the website is www.rebelheartsartwork.org and I think I have done a good job and the pricing is fair.

Just looking for feedback on the website and such.




No information is available for this page

or my site google console has stooped to read the site and when search in google it says "No information is available for this page. Kindly Help




Add Serial Search Feature On Wordpress Website

I’m trying to build a website where people can type a MacBook or iMac Serial number and it shows what Unit it is and the year it was manufactured like Powerbookmedic and beetstech, but I don’t know how to go about this. How do I get this database or API?




Checking screen sizes in javascript

How in javascript can you check the screen sizes (in the if) (I mean the size indicated in the media request) and, depending on this check, draw the page content?




Background color in HTML is not applied to the whole page

I made the background of the body gray . I added a picture to the body part but the back of the picture is white. but the back of the h4 sticker is gray . why the back of the picture is not gray .It happens if I manually give the basement px but I want it to do it automatically.

HTML CODES

<body class="body" style="background-color: #212325" > 
    
    <h4 class="h4"> <i style="color: yellow;" class="bi bi-upload"></i> Dikkat Çeken Yeni Diziler</h4>

    <div class="container">
      <div class="box">
      <a href="">  <img style="width: 200px; height: 300px;" src="assets/images/thePianist.jpg" alt="Shadow and Bone" ></a>
      </div>  
    </div>
   
     
</body>

CSS CODES

.h4{
    color: rgb(214, 214, 214);
    padding-bottom: 15px;
}

.body{
    padding-left: 15px;
    padding-top: 10px;
}

.container {
    width: 80%;
    padding: 80px 0;
    display: flex;
    flex-direction: row;
    float: left;
}

.box {
    width: 150px;
    height: 150px;
    background: gray;
    margin: 0px 14px;
    transition: 0.5s;
}

.box img {border-radius: 0px;}

.box:hover {
    transform: scale(1.1);
    background: black;
    z-index: 2;
}

It Look Like This :

unwanted image

I Want it look like this :

wanted




Pixi JS fill behaviour vs SVG fill behaviour

I'm wondering if there's a way to get the behaviour of Pixi.JS's Graphics API to fill the same way SVG paths are filled. I am guessing there may not be a quick-fix way to do this.

Basically, in SVGs when a path with a fill crosses over itself, the positive space will automatically get filled, whereas in the Pixi.JS Graphics API, if the path crosses itself it seems to try and fill the largest outside space.

This is quite difficult to explain in text so here is a codepen to show the differences between the two and how the same data will cause them to render in different ways.

And so you can see the code, here is my SVG:

<svg width="800" height="600" viewBox="0 0 800 600" xmlns="http://www.w3.org/2000/svg" style="background-color:#5BBA6F">

    <path style="fill: #E74C3C; stroke:black; stroke-width:3" d="M 200 200 L 700 200 L 600 400 L 500 100 z" />
</svg>

And here is the Pixi.js implementation:

import * as PIXI from "https://cdn.skypack.dev/pixi.js";

 const app = new PIXI.Application({
      width: 800,
      height: 600,
      backgroundColor: 0x5bba6f
    });
app.start();
document.getElementById("root").appendChild(app.view)

const lineData = {
  color: 0xe74c3c,
  start: [200, 200],
  lines: [
    [700, 200],
    [600, 400],
    [500, 100],
  ]
};

  const { start, lines, color } = lineData;
  const g = new PIXI.Graphics();

    if (g) {
      g.clear();
      g.lineStyle({width:3})
      g.beginFill(color);
      g.moveTo(start[0], start[1]);
      lines.map((l) => g.lineTo(l[0], l[1]));
      g.closePath();
      g.endFill();
      app.stage.addChild(g);
    }

Thanks for taking a look.




Why ı cant change plugin.js path?

I am trying to implement Infinty-v2.0.0 theme. Why url has two dot ?I m sure there wasnt dot character in url(the error was shown in the pictures) . Pages are mostly work.But everytime when ı refresh page ,ı get plugin.js error in every time.I think this error cause switchery.min.css not found or another error . How can fix plugin.js ?

 <?php
    <script src="<?php echo base_url("assets");?>/assets/js/plugins.js"></script> ?php>

datatables.min.css

switchery.min.css




Old error message wont go away Eclipe - Tomcat

I am trying to implement simple rest-ful web-sevice where i get book number from url and embed book name in a json object. I followed a tutorial. It is working fine. So i furthered my work by adding data access stuff to retrieve credentials from data base and add to json object. The moment i ran service it gave me a couple of messages. i removed the code (data access), stopped tomcat, cleaned, re-built project and restarted tomcat. cleared history of chrome. but no matter what, service wont go in the previous state. Here initial class file (snippet 1):-

 package book;
//annotations
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import org.apache.tomcat.util.codec.binary.Base64;
import org.json.simple.JSONObject;
@Path("/number")
public class bnumber {
@GET
@Produces("application/json")
@Path("{booknumber}")
   //  public JSONObject numberinfo(@PathParam("booknumber") int bnumb) {       
JSONObject obj = new JSONObject();
String bname = "test book";
obj.put("name", bname);
obj.put("bookid", bnumb);
return obj;
}
}

the url that i use

   localhost:8080/WS/number/1234

i get output

    {name,test book; bookid,1234}

Now i added persistance to get data from db i recieved a myriad of errors (snippet 2):-

package book;
//annotations
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import org.apache.tomcat.util.codec.binary.Base64;
import org.json.simple.JSONObject;
@Path("/number")
public class bnumber {
@GET
@Produces("application/json")
@Path("{booknumber}")
   //  public JSONObject numberinfo(@PathParam("booknumber") int bnumb) {       
JSONObject obj = new JSONObject();
String bname = "test book";
//............data from db...............
List booklist = new ArrayList();
Session session = HibernateUtils.currentSession();

Criteria cri = session.createCriteria(BookInfo.class);
cr.add(Restrictions.eq("bookid",bnumb);
booklist = cr.list();
bname = boolist.get(0).getName();
//.......................................
obj.put("name", bname);
obj.put("bookid", bnumb);
return obj;
}
}

The errors i get for this are:=

Unresolved compilation errors:-
Illegal modifier for getName() only static final allowed
Duplicate local variable bnumb

So i reverted code back to snippet 1. However, the above mentioned error wont go away. Further, why cant i access db in this class, i have to as i need to get info for the book from DB. If not in this class, then what is the correct method?




best way to lock fields and methods in web app?

I've decided to build in my web and "read-only" mode which means that the user wont be able to changes certain data in certain field. I want to know what is the best way to prevent him from changing field and calling certain method that might change the current state (will break the read-only mode).

  1. I would've freeze everything but the problem is that some fields are not object so I cant freeze them

  2. I can use a lock for every methods I'm calling which will return if the read-only == true but that seems stupid to add it for each method

  3. I can try to do something with the event-listner but sit might be a problematic.

p.s I don't mind doing working hard, just want to make sure what the best practice for that scenario.

thanks again :)




JavaScript Regular Expression : I want to replace last 4 words of my variables

I'm currently making an e-commerce website with Spring, Java and Javascript. I want to hide the last four words of the users when they register a question like

hello123 >> hell**** stackoverflow >> stackover****

This is the code that I've written in my jsp.

<table>
<td id="userId">${ qna.userId }</td>
</table>

<script>
var userId = document.getElementById("userId");
    
    function maskingNumbers(userId) {
           return userId.replace(/\d(?=\d{4})/g, "*");
         }
</script>

Well, my "userId" still prints out on its original form. It would be really thankful if you be specific with the steps.




Media query not working (or something else) [duplicate]

There is a code (file tablet.css)

body {
    margin: 0;
    padding: 0;
}

.globalcontainer {
    margin-top: 0px;
    margin-right: (calc(39/768*100)%);
    margin-bottom: 0px;
    margin-left: (calc(39/768*100)%);
    /*height: 100%;*/
}

.header > .header__text {
position: relative;
width: 93px;
height: 24px;
left: 0;
margin-top: 129px;
margin-bottom: 20px;

font-family: TT Norms;
font-style: normal;
font-weight: bold;
font-size: 24px;
line-height: 100%;
/* identical to box height, or 24px */


color: #000000;
}

/*
.header__buttons {
    left: 0;
    top: 193px;
}
*/


.header__button {
    width: 75px;
    height: 30px;
    border-radius: 4px;
    border-color: #5f3ec0;
    background-color: #fff;
    margin-right: 1.75%;
    display: flex;
    justify-content: center;
    align-items: center;
    white-space: nowrap;
}

.header__buttons {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 7px 15px 7px 0px;
    overflow: hidden;
    /*margin-right: 10%;*/
}
<html>
<head>
<!-- <link rel="stylesheet" href="testsite.css">-->
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Test Example</title>
<link rel="stylesheet" type="text/css" href="../css/mobile.css" media="screen and (min-width: 320px) and (max-width: 639px)"></link>
<link rel="stylesheet" type="text/css" href="../css/tablet.css" media="screen and (min-width: 640px) and (max-width: 1023px)"></link>
<link rel="stylesheet" type="text/css" href="../css/desktop.css" media="screen and (min-width: 1024px) and (max-width: 1920px)"></link>
<script type="text/javascript" src="http://code.jquery.com/jquery-3.6.0.min.js"></script>

</head>
<body>
    <div class="container">
        <div class="globalcontainer">
                <div class="header">
                        <div class="header__text">
                            Обзоры
                        </div>
                        <div class="header__buttons">
                            <!-- <span> -->
                                <button class="header__button">Все</button>
                                <button class="header__button">Видео</button>               
                                <button class="header__button">Текст</button>               
                                <button class="header__button">Обзоры</button>
                                <button class="header__button">Сравнения</button>
                                <button class="header__button">Краш видео</button>
                                <button class="header__button">Распаковка</button>
                            <!-- </span> -->
                        </div>
                </div>
        </div>
    </div>
<script type="text/javascript" src="jsactions.js"></script>
</body>
</html>     

And it is displayed as in the screenshot below

Tablet view

Where is the padding margin-left: (calc (39/768 * 100))%;? (fillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillerfillervfillerfillerfillerfillervvfillerfillerfillerfillerv)