Javascript how to append all class list to innerHTML

I want to remove all the elements in the page except for the elements that I want.
So I am thinking of this method:

document.body.innerHTML = texts.innerHTML;

I tried the code below but it only appends the 1st element of texts to body.innerHTML.

var texts = document.getElementsByClassName('HoXoMd D1wxyf G4EHhc');
for(let text of texts){
    document.body.innerHTML = text.innerHTML;
}

I tried the code below but nothing happens:

var texts = document.getElementsByClassName('HoXoMd D1wxyf G4EHhc');
for(let text of texts){
    document.body.innerHTML += text.innerHTML;
}

i am new to javascript thanks

NPM install in Visual Studio Code adds .cmd, .ps1 files to my VSCode explorer

When I run npm install in my javascript project in VSCode, It adds .cmd, .ps1 and files without extensions to the VSCode explorer window. This is annoying and floods my explorer window. Is there a setting that is leading to this and How can I stop these files from displaying and cluttering my project

I tried adding the .ps1 and .cmd file extensions in the Files:Exclude settings. But the files without an extension still appear.

Message at the top of WooCommerce checkout page for NON logged in users with specific product category

The scenario is:
The customer is not registered, he chooses a product from category (aaa) to buy.
Now I want a message to be displayed to him at the top of the checkout page.
For the following code, only the condition of NON LOGGED in is included, how can I add a category to it.
Thankful

/** Message at the top of WooCommerce checkout page for NON LOGGED in users  */
 
add_action( 'woocommerce_before_checkout_form', 'wnd_checkout_code', 2 );

function wnd_checkout_code( ) {
    if ( is_page('checkout') && ! is_user_logged_in() ) {
        echo '<div class="woocommerce-info">';
        echo 'New Customer? Please add your details';
        echo '</div>';
    }
}

Where to store an rsa key pair

I am building a React.JS application that is supposed to encrypt and decrypt data.

I’m using the subtlecrypto api to create RSA key pairs. I want to store them, preferably in the browser, in a way the user can re-use them when he returns to the site.

I absolutely do NOT want to store them in any kind of server or online storage, because that would defeat the purpose of the whole exercise.

Is there a dedicated facility to store secrets like that? If not, what is the most secure option available?

Redirect with Session flash data not showing in blade

i have problem with success -> Result i can’t see Result after Redirect Success

Home.blade.php

<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
</head>
<body>

    <center>
    <form method="POST" action="{{ route ('imei') }}" style="margin-top:5%">
        @csrf
        <p><input type="text" style="padding: 15px 10px 10px; font-family: 'Source Sans Pro',arial,sans-serif; border: 1px solid #cecece; color: black;box-sizing: border-box; width: 50%; max-width: 500px;" name="imei" autocomplete="off" maxlength="50" placeholder="Write here IMEI or SN"></p>
        <select name="service" id="service" style="padding: 15px 10px 10px; font-family: 'Source Sans Pro',arial,sans-serif; border: 1px solid #cecece; color: black;box-sizing: border-box; width: 50%; max-width: 500px;">
            <option value="0" selected="selected">PLEASE CHOOSE CHECKER</option>
            <optgroup label="iPHONE SERVICES">
                <option value="0.01">1.10 - APPLE SOLD BY & COVERAGE &#x26A1;</option>
            </optgroup>
        </select>
        <br /><br />
        <button onClick="this.form.submit(); this.disabled=true; this.value='Please Wait'; " type="submit" style="background-color: #2ABCA7; padding: 12px 45px; -ms-border-radius: 5px; -o-border-radius: 5px; border-radius: 5px; border: 1px solid #2ABCA7;-webkit-transition: .5s; transition: .5s; display: inline-block; cursor: pointer; width: 20%; max-width: 200px; color: #fff;">Submit</button>
    </form>

</center>


  <script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>

    @if(Session::has('success'))
        
        <script type="text/javascript">
            Swal.fire({
              position: 'center',
              icon: 'success',
              title: "{!! Session::get('success') !!}",
              showConfirmButton: false,
              timer: 2500
            })
        </script>

    @elseif(Session::has('error'))
        
        <script type="text/javascript">
            Swal.fire({
              position: 'center',
              icon: 'error',
              title: "{!! Session::get('error') !!}",
              showConfirmButton: false,
              timer: 2500
            })
        </script>

    @endif


</body>
</html>

Controller

public function imeiSubmit() {


 
    $format = "html"; // Display result in JSON or HTML format
     $imei = $_POST['imei']; // IMEI or SERIAL Number
     $apiKey ='veCwe-bzgzE-JP9NE-ZHEaS-PxFuq-rnmLz';
     $service = $_POST['service']; // Service ID

     $balanceUrl = 'https://alpha.imeicheck.com/api/php-api/balance?key='.$apiKey;

     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $balanceUrl);
     curl_setopt($ch, CURLOPT_POST, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
     curl_setopt($ch, CURLOPT_TIMEOUT, 60);

     $balance = curl_exec($ch);
     curl_close($ch);

     if ($balance == '{"balance":"0.00"}') {
        return redirect()->back()->with('error', 'balance 0.00!');
     }
     
     if($service != 'demo') {
      $service = preg_replace("/[^0-9]+/", "", $service);
     }

     if(strlen($service) > 4 || $service > 250)
    {
        return redirect()->back()->with('error', 'Service ID is Wrong!');
    }

    if(!filter_var($imei, FILTER_VALIDATE_EMAIL))
    {
        if(strlen($imei) < "11" || strlen($imei) > "15")
        {
            return redirect()->back()->with('error', 'IMEI or SN is Wrong!');
        }
    }
        
         $curl = curl_init ("https://alpha.imeicheck.com/api/php-api/create?format='.$format.'&key='.$apiKey.'&service='.$service.'&imei='.$imei");
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
         curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60);
         curl_setopt($curl, CURLOPT_TIMEOUT, 60);
         $result = curl_exec($curl);
         curl_close($curl);

         return redirect()->back()->with('success', PHP_EOL.$result);
        // // echo PHP_EOL."<br/><br/>".PHP_EOL.$result; // Here the result is printed

         
    }

i want after submit get result with sweet alert but not working how can put $result with redirect back the Success

so anyone have solve this problem please let me

because the Result not Display

or

another solution

And

Thanks

getting error warning in MUI TextField component with select

getting error in console MUI: children must be passed when using the TextField component with select.

               <TextField
                select
                id="outlined-basic"
                label="User Name"
                name="user"
                size="small"
                {...teamForm.getFieldProps("user")}
                error={teamForm.touched.user && teamForm.errors.user}
                helpertext={teamForm.touched.user && teamForm.errors.user}
              >
                {list?.map((option) => (
                  <MenuItem key={option.username} value={option.name}>
                    {option.name}
                  </MenuItem>
                ))}
              </TextField>

How to export into excel a table with date range

The modal below contains 2 datepickers From and To:

<div class="form-group row">
    <div class="col-12 col-md-6">
        <label for="from_date" class="mb-2 mb-md-0 col-12 col-md-12 text-muted">From</label>
        <div class="col-md-12">
            <input 
                id="from"
                type="date"
                name="from"
                class="form-control"
                value-type="YYYY-MM-DD"
                format="YYYY-MM-DD"
                :input-attr="{name: 'from'}" 
                ref= "from"
            >
        </div>
    </div>
    <div class="col-12 col-md-6">
        <label for="to_date" class="mb-2 mb-md-0 col-12 col-md-12 text-muted">To</label>
        <div class="col-md-12">
            <input 
                id="to"
                type="date"
                name="to"
                class="form-control"
                v-model.trim="$v.export.to.$model"
                value-type="YYYY-MM-DD"
                format="YYYY-MM-DD"
                :input-attr="{name: 'to'}"
                ref= "to"
            >
        </div>
    </div>
    <div>
        <button type="button" v-on:click="submitQuery()">Export</button>
    </div>
</div>

The button will call submitQuery() function:

submitQuery() {
    var url = "{{ route('timesheet.export') }}?";
    var table = $(this.$el)
        .find("#table-list")
        .DataTable();
    var params = $.param(table.ajax.params());
    window.location.href = url + params;
}

web.php

Route::get('/report/export', 'TimesheetController@export')->name('timesheet.export');

The export() function in controller:

public function export(Request $request, TimesheetFilters $filters){
    $from_date=$request->from;
    $to_date = $request->to;
    $query = DB::table('timesheets')
        ->whereBetween('created_at',[$from_date,$to_date])
        ->orderBy('id');
    $data = generateDatatables($query, $filters, $request, 'timesheet');
    return Excel::download(new TimesheetExport($data), 'Report.xlsx');
}

TimesheetExport:

<?php
namespace AppExports;
use AppTimesheet;
use IlluminateContractsViewView;
use MaatwebsiteExcelConcernsFromView;
use MaatwebsiteExcelConcernsFromQuery;
use MaatwebsiteExcelConcernsExportable;
use MaatwebsiteExcelConcernsWithHeadings;
use MaatwebsiteExcelConcernsFromCollection;
use MaatwebsiteExcelConcernsShouldAutoSize;
use IlluminateSupportFacadesDB;

class AllTimesheetExport implements FromView, ShouldAutoSize {
    use Exportable;
    protected $date;
    public function __construct($data) {
        $this->data = $data;
    }
    public function view(): View {
        $data = $this->data;
        return view('excel.timesheet', compact('data'));
    }
}

Lastly, I have this blade template for the export structure:

<table class="table table-bordered table-hover table-striped table-sm">
    <thead>
    </thead>
</table>
    
<table class="table table-bordered table-hover table-striped table-sm">
    <thead>
        <tr>
            <th>ID</th>
            <th>Timesheet No</th>
            <th>Status</th>
            <th>Created At</th>
        </tr>
    </thead>
    <tbody>
    @foreach($data as $key => $timesheet)
        <tr>
            <td>{{ $timesheet->id }}</td>
            <td>{{ $timesheet->number }}</td>
            <td>{{ $timesheet->status_code }}</td>
            <td>{{ CarbonCarbon::parse($timesheet->created_at)->format('d/m/Y') }}</td>
        </tr> 
    @endforeach
    </tbody>
</table>

The export procedure an empty excel file. How to fix this?

I’m getting error while making an alias system in discord.js

I was making an alias system for my discord bot, and I wanted to say: “if the user entered the wrong command name or alias then return: invalid command/alias”, but I’m getting an error:

C:UsersPooyanDesktopPDM Bot Maineventsguildmessage.js:16
                    if(!cmd || client.commands.find(a => !a.aliases && !a.aliases.includes(cmd))) return message.channel.send('Invalid command');
                                                                                  ^

TypeError: Cannot read properties of undefined (reading 'includes')
    at C:UsersPooyanDesktopPDM Bot Maineventsguildmessage.js:16:83

My code:

module.exports = async (message, client, Discord) => {
    const prefix = process.env.PREFIX;

    if(!message.content.startsWith(prefix) || message.author.bot) return;

    const args = message.content.slice(prefix.length).split(/ +/);
    const cmd = args.shift().toLowerCase();

    const command = client.commands.get(cmd) || 
                    client.commands.find(a => a.aliases && a.aliases.includes(cmd));
                    if(!cmd || client.commands.find(a => !a.aliases && !a.aliases.includes(cmd))) return message.channel.send('Invalid command');
}

I’m using discord.js v13 and Node.js v16.14.2

Failed to load resource: net::ERR_FAILE

my code is this
$.ajax({
type: ‘Get’,
url: ‘https://kf.kobotoolbox.org/assets/a7GG9SXYtLTCS4FLm4mjjP/submissions/?
format=json’,
dataType : ‘jsonp’,
success: function(data) {
console.log(data);
},
error: function(data) {
console.log(“error”);
}
});

when i enter the url on web browser i got the data
but i can not access with ajax

How to link your own js file using chrome or other webside [closed]

I need to link one more css file to not my page but i can not open it normally because table tr is to small and i dont see what is inside. Host said it’s too much work for me he will not change css. I wrote a js file changing this css for me and I need to know how to include it. I tried to do Ctrl + Shift + J and post there some js lines but i need to load fully file with a few clicks

C3.JS and Importing JSON data into charts

I am having difficulty getting my JSON data fitting into the C3.JS charts properly.

I am querying my database as such:

def mysqlconnect():
    conn = pymysql.connect(
        host='localhost',
        user='dylan',
        password='cookies',
        db="nano_detections",
        charset='utf8mb4',
        cursorclass=pymysql.cursors.DictCursor)
    cursor = conn.cursor()
    cursor.execute("Select SPECIES, COUNT(*) FROM detections GROUP BY species")
    output = cursor.fetchall()

    conn.close()
    return output

then I am creating the json object as such

output = mysqlconnect()
print(f"json: {json.dumps(output)}")
with open('static/json_data.json', 'w') as outfile:
    outfile.write(json.dumps(output, indent=4))
outfile.close()
json_file = json.dumps(output, indent=4)

this is then sent to the function call in Flask

@app.route("/", methods=['GET'])
def home():
    return render_template("index.html", json_file=json_file)

Here is a sample of the json file:

[
{
    "SPECIES": "WHITE TAILED TROPIC",
    "COUNT(*)": 5920
},
{
    "SPECIES": "TRUMPTER SWAN",
    "COUNT(*)": 10512
},
{
    "SPECIES": "CASPIAN TERN",
    "COUNT(*)": 1556
},

…..

    {
    "SPECIES": "SUPERB STARLING",
    "COUNT(*)": 1
},
{
    "SPECIES": "WALL CREAPER",
    "COUNT(*)": 4
},
{
    "SPECIES": "WILD TURKEY",
    "COUNT(*)": 1
},
{
    "SPECIES": "BLACK TAIL CRAKE",
    "COUNT(*)": 1
}]

Where I am trying to run it as

<html>
    <head>
        Hello
        <script src="https://unpkg.com/[email protected]/dist/d3.min.js"></script>
        <link href="https://unpkg.com/[email protected]/c3.min.css" rel="stylesheet">
        <script src="https://unpkg.com/[email protected]/c3.min.js"></script>
    </head>
    <body>
        <div id="chart"></div>

        <script>
var json_data = '{{json_file}}';

var chart = c3.generate({
    data: {
        type: 'bar',
        json: json_data,
        keys: {
            x: 'SPECIES',
            value: ['COUNT(*)']
        }
    },
    axis: {
            x: {
                type: 'category'
            }
    },
    bar: {
        width: {
            ratio: 0.5
        }
    }
});

console.log(json_data);
        </script>
    </body>
</html>

My confusion is why does my attempt to load json_file not work but the following code does work.

var chart = c3.generate({
    data: {
        type: 'bar',
        json: [
            { 'SPECIES': 'X', 'COUNT(*)': 5920 },
            { 'SPECIES': 'Y', 'COUNT(*)': 10512 },
            { 'SPECIES': 'Z', 'COUNT(*)': 1556 }
        ],
        keys: {
            x: 'SPECIES',
            value: ['COUNT(*)']
        }
    },
    axis: {
            x: {
                type: 'category'
            }
    },
    bar: {
        width: {
            ratio: 0.5
        }
    }
});

How to target an element using input type checkbox

I have a dropdown type list that will get hidden after specific device width and by default dropdown box will be visible nd user cant be able to collapse it.
Default state for input is also hidden.

Suppose the device width is 804px,and the dropdown gets hidden and input gets visible. So, By clicking the input the user can see the contents of the dropdown.
But for some reason I’m unable to target the dropdown box using the input field. Wasted a whole day on this….

html:

<div class="hireDevs">
        <div class="headers">
            <h2>Hire Developer Team</h2>
            <label for="team-lists">
                <input type="checkbox" class="add-lists" id="team-lists" hidden>
                <i class="ri-add-fill"></i>
            </label>
        </div>
        <div class="team-lists">
            <a href="#">Android App Developers</a>
            <a href="#">iOS App Developers</a>
            <a href="#">Flutter App Developers</a>
        </div>

css:

input[type="checkbox"]:checked ~ .team-lists{
    display: flex;
    height: 430px;
}