I’m creating the calculator in android studio in which i was trying to import the two file such as “import org.mozilla.JavaScript.Context;” and “import org.mozilla.javascript.Scriptable;”. this two libraries file i want to use it but i can not …in error they show “try to resolve class reference” …. so anyone can help me out to reslove the problem.
Category: javascript
Category Added in a WPeMatico Campaign
Write snowflake stored procedure in SQL and JS using for loop
Table contains the order data and has columns city, date, orders, total_sales.
Write a Snowflake procedure in SQL and JS containing ‘For Loop ‘ to get the most grossing day( in terms of total_sales) of the month for each city within the given dataset.
For the following dates, also Orders for each country.
Write procedure in both SQL and Javascript.
Can someone please help.
I used for loop but i allows me to iterate through rows and not throigh coulmn to get maxium revenue.
module resolution not done properly in a vitest test case while using a dependency with type module
Lets say I have a
dependency A
with type module in my project in my node_modules(project’s) .
Now, while running a test case using vitest and react testing library which involves using this dependency (render(). I notice my dependency A needs dependency C which it looks for .
Now when the type=module(package.json) the dependency A looks for C in the node_module within itself (which doesn’t exist and throws an error TypeError : K not a function)
And when the type=commonJs , the dependency A looks for C in the node_module of the project. (which works)
Why is this happening, can i modify the behaviour such that type = module for the dependency of A and make it look in my projects node_modules
Project details:
Bundler: Vite
Node: 18.19
React:18
Dependency A :
Uses Bundler Vite
bundle prepared using lib mode :https://vitejs.dev/guide/build#library-mode
Note: Everything works fine in the browser. No error nothing.
I expect the test case to run by resolving the dependency from the correct path
JS Appending to popup window instead of browser window
First picture: Current state, Second picture: Goal state
Here is my js code:
// ... created frameUp, frameDown, frameRight, frameLeft using createElement("DIV")
function addBorder(){
document.body.appendChild(frameUp);
document.body.appendChild(frameDown);
document.body.appendChild(frameRight);
document.body.appendChild(frameLeft);
}
document.addEventListener("DOMContentLoaded", function () {
var button = document.createElement("button");
button.innerHTML = 'click me';
document.body.appendChild(button);
button.onclick = addBorder;
});
Also, I find that when I place code within the addEventListener, every html edit inside it applies to the popup window instead of the entire browser. Which is why I created the button element inside the addEventListener but not the border element. However, I want to draw a border in the BROWSER rather than the popup every time I press the button.
How do I change where I appendChild, specifically from the popup window to the browser window? When I use document.body, what is it referring to exactly?
TLDR: Want button in popup but border in browser. Can’t figure out how.
How can I set a photo in the chartjs-plugin-data labels v2.1.0 plugin?
I use the ‘chartjs-plugin-data labels v2.1.0’ plugin, to create a wheel of luck, you need to replace the text with img in the labels column, how can this be done?
In regular JS, the labels line has the value ‘2’, ‘3’, and so on, then I want to shove img
How can I solve this problem? Need your help soon
const spinWheel = document.getElementById("spinWheel");
const spinBtn = document.getElementById("spin_btn");
const text = document.getElementById("text");
const spinValues = [
{ minDegree: 31, maxDegree: 60, value: "Ноутбук игровой MSI Katana GF76 12UD-263RU" },
{ minDegree: 0, maxDegree: 30, value: "Lush3 + Ridge x 1 + Микрофон HyperX Quadcast S" },
{ minDegree: 61, maxDegree: 90, value: "Беззеркальная камера Canon EOS R50 Body" },
{ minDegree: 331, maxDegree: 360, value: "Lovense Webcam + Domi 2" },
{ minDegree: 301, maxDegree: 330, value: '"Капуста"' },
{ minDegree: 271, maxDegree: 300, value: '"Картошка"' },
{ minDegree: 211, maxDegree: 240, value: "Apple iPhone 15" },
{ minDegree: 241, maxDegree: 270, value: '"Морковь"' },
{ minDegree: 181, maxDegree: 210, value: "Cougar Throne – кресло для геймеров" },
{
minDegree: 151,
maxDegree: 180,
value: "Сертификат ВБ",
},
];
const size = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10];
var spinColors = ["#303032", "#303032", "#303032", "#303032", "#303032", "#303032", "#303032", "#303032", "#303032", "#303032", "#303032", "#303032"];
let spinChart = new Chart(spinWheel, {
plugins: [ChartDataLabels],
type: "pie",
data: {
labels: ['<img src="/img/11.png">', "2", "3", "4", "5", "6", "7", "8", "9", "10"],
datasets: [
{
backgroundColor: spinColors,
data: size,
},
],
},
options: {
responsive: true,
animation: { duration: 0 },
plugins: {
tooltip: false,
legend: {
display: false,
},
datalabels: {
rotation: 90,
color: "#ffffff",
formatter: (_, context) => context.chart.data.labels[context.dataIndex],
font: { size: 24 },
},
},
},
});
const generateValue = (angleValue) => {
for (let i of spinValues) {
if (angleValue >= i.minDegree && angleValue <= i.maxDegree) {
text.innerHTML = `<p>Поздравляем, вы выиграли: <br> ${i.value} ! </p>`;
spinBtn.disabled = false;
break;
}
}
};
let count = 0;
let resultValue = 101;
spinBtn.addEventListener("click", () => {
// spinBtn.disabled = false;
// text.innerHTML = `<p>Желаю Удачи!</p>`;
let randomDegree = Math.floor(Math.random() * (355 - 0 + 1) + 0);
let rotationInterval = window.setInterval(() => {
spinChart.options.rotation = spinChart.options.rotation + resultValue;
spinChart.update();
if (spinChart.options.rotation >= 360) {
count += 1;
resultValue -= 5;
spinChart.options.rotation = 0;
} else if (count > 15 && spinChart.options.rotation == randomDegree) {
generateValue(randomDegree);
clearInterval(rotationInterval);
count = 0;
resultValue = 101;
}
}, 10);
});
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-datalabels/2.1.0/chartjs-plugin-datalabels.min.js"></script>
<div>
<canvas id="spinWheel"></canvas>
</div>
<div id="spin_btn">spin_btn</div>
<div id="text">text</div>
Load CSS based on network speed
In Gmail, when my internet is slow, it shows a basic page with fewer colors, icons and animations. I want my React project to do something similar. I have two global SCSS files for my project, index.scss and index-lite.scss. How can I make it load the simpler CSS file when the network is slow to make my First Contentful Paint (FCP) faster?
Here is my main index.ts component code.
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { configure } from 'axios-hooks';
import App from './components/App';
import API from './utils/api';
import store from './store';
import './index.scss'; **// or import './index-lite.scss';**
configure({ axios: API });
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root'),
);
Multiple replaces with regular expression pattern using js
I work with php an now I need to do something with js.(I did it with php)
I have string : const sentence = “{{GALLERY_slider_8}} Lorem ipsum dolor sit amet.”;
I want to replace {{GALLERY_slider_8}} with function.
const newString = sentence.replace(/({{2})([A-Z]+)(_{1})(.*)(_{1})(.*)(}{2})/g, function(match, p1, p2, p3, p4, p5, p6, p7, offset, string) {
if (p2 === "GALLERY"){
return`This is gallery images from the ${p4} folder!`;
}else if(p2 === "NUMBERS"){
return`This is my numbers!`;
}
});
console.log(newString);
Everything works as expected and in console I see this
//This is my gallery images from the slider folder! Lorem ipsum dolor sit amet
But if my string is this:
const sentence = “{{GALLERY_slider_8}} Lorem ipsum dolor sit amet {{NUMBERS__}}”;
I want to replace {{GALLERY_slider_8}} and {{NUMBERS__}} with two separate functions.
In console I see this:
//This is my gallery images from the slider_8}} Lorem ipsum dolor sit amet {{NUMBERS_ folder!
So pattern not works as expected!
Please help to find solution for multiple replaces.
How to solve Type error: is not a valid Page expor
am trying to deploy to vercel my next js app but it keeps giving me Type error: Page “app/(adminPanel)/admin/about/page.tsx” does not match the required types of a Next.js Page.
“AdminAbout” is not a valid Page export field.It works on my local machine on local host but when i try to deploy it not working.
this is the page export default where the error occurs:
interface FormProps {
info: Info;
exp: Experience;
}
const AdminAbout = async ({ info, exp }: FormProps) => {
const infos = await prisma.info.findMany();
const experiences = await prisma.experience.findMany();
return (
<div>
<div className="max-w-7xl px-10 mx-auto space-y-5 md:ml-[17rem] pt-20 min-h-screen">
<div className=" flex items-center space-x-2 mb-2 shadow-md rounded-lg bg-primary p-4">
<h1 className="font-bold pl-5 text-primary-foreground">
Description Form
</h1>
</div>
<InfoForm info={info} />
<Table>
<TableCaption>Description Form</TableCaption>
<TableHeader>
<TableRow>
<TableHead className="w-[100px]">Resume</TableHead>
<TableHead>Description</TableHead>
<TableHead className="text-right">Action</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{infos.map((info) => (
<TableRow key={info.id}>
{info.public_id && (
<TableCell className="font-medium">
<CldImage
className="aspect-video"
width={100}
height={100}
src={info.public_id}
alt={"pdf"}
/>
</TableCell>
)}
{/* <TableCell className="font-medium">{info.resume}</TableCell> */}
<TableCell className="font-medium">
{info.description.length > 50
? `${info.description.substring(0, 50)}...`
: info.description}
</TableCell>
<TableCell className="font-medium">
<EditInfoForm info={info} />
</TableCell>
<TableCell className="font-medium">
<DeleteInfoButton id={info.id} />
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
{/* EXPERIENCE TABLE */}
<div className=" flex items-center shadow-md rounded-lg bg-primary p-4 ">
<h1 className="font-bold pl-5 text-primary-foreground">
Experience Form
</h1>
</div>
<ExperienceForm exp={exp} />
<Table>
<TableCaption>Experience Form</TableCaption>
<TableHeader>
<TableRow>
<TableHead className="w-[100px]">Job Title</TableHead>
<TableHead>Company</TableHead>
<TableHead>Year</TableHead>
<TableHead className="text-right">Action</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{experiences.map((experience) => (
<TableRow key={experience.id}>
<TableCell className="font-medium">
{experience.jobtitle}
</TableCell>
<TableCell>{experience.company}</TableCell>
<TableCell>
{experience.year.toLocaleString("default", { month: "long" })}{" "}
{experience.year.getFullYear()}
</TableCell>
<TableCell className="text-right">
<EditExperienceForm exp={experience} />
</TableCell>
<TableCell className="text-right">
<DeleteExperienceButton id={experience.id} />
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
</div>
);
}
export default AdminAbout
i tried the solution from vercel text but still same error
How can i scroll to next div after clicking on radio button or check box using java script
I want to scroll div to down after clicking on check box or radio button bellow is a html of my popup where is a list of radio button and check box which is added in ul in html
<div id="toppings-properties-modal" class="modal fade show" tabindex="-1" style="z-index: 10000; transform: none !important; display: block;" aria-modal="true" role="dialog">
<div class="modal-dialog">
<div class="modal-content mb-3">
<div class="modal-body pb-3" style="background-color: #f5f5f5;max-height:70vh;overflow-y:auto">
<div class="row m-0">
<div class="col-12 py-3" style="background: white;border-radius: 25px;">
<div id="menu-item-img" class="product-img-modal mx-auto" style="background-image: url("/img/Offer_Dish-1.png");"></div>
<h5 id="menu-item-name" class="txt_dark f_merriweather mb-2 mt-3 fs_18 fw-bold">Special Pizza (Medium)</h5>
<p id="menu-item-desc" class="txt_dark f_merriweather lh-base fs_12">Cheese: A combination of mozzarella, cheddar, or other cheeses is typically used to create a gooey and melty layer that covers the pizza.</p>
<h5 class="txt_dark mb-0 mt-2 fs_18 fw-semibold">₹ <span id="menu-item-price">500</span></h5>
</div>
<div class="col-12" id="menu-item-properties" style="display:none">
<div class="mb-2 mt-3 d-flex justify-content-between align-items-center">
<h5 class="txt_dark f_merriweather fs_18 fw-bold">Select any one option</h5>
<p class="fs_12 m-0 required-prop">Required</p>
</div>
<ul id="menu-item-properties-list" class="topping-list"></ul>
</div>
<div class="col-12" id="menu-item-toppings" style="display: block;"><h5 class="txt_dark f_merriweather mb-2 mt-2 fs_18 fw-bold">Special Pizza Crust</h5><p class="txt_dark f_merriweather fs_12"> You can select upto 1 option</p><ul class="topping-list"><li>Thin Crust<div class="d-flex"><label class="container"><input name="menu-topping-681" data-toppingid="2354" data-maxqty="1" data-ispropertytopping="false" data-price="0" type="checkbox" onchange="selectToppings(this)"><span class="checkmark"></span></label></div></li><li>Cheesy Crust<div class="d-flex"><label class="container"><input name="menu-topping-681" data-toppingid="2355" data-maxqty="1" data-ispropertytopping="false" data-price="0" type="checkbox" onchange="selectToppings(this)"><span class="checkmark"></span></label></div></li><li>Achari Crust<div class="d-flex"><label class="container"><input name="menu-topping-681" data-toppingid="2356" data-maxqty="1" data-ispropertytopping="false" data-price="0" type="checkbox" onchange="selectToppings(this)"><span class="checkmark"></span></label></div></li></ul><h5 class="txt_dark f_merriweather mb-2 mt-2 fs_18 fw-bold">Special Pizza Topping</h5><p class="txt_dark f_merriweather fs_12"> You can select upto 5 option</p><ul class="topping-list"><li>Pineapple<div class="d-flex"><label class="container"><input name="menu-topping-682" data-toppingid="2357" data-maxqty="5" data-ispropertytopping="false" data-price="0" type="checkbox" onchange="selectToppings(this)"><span class="checkmark"></span></label></div></li><li>Red Paprika<div class="d-flex"><label class="container"><input name="menu-topping-682" data-toppingid="2358" data-maxqty="5" data-ispropertytopping="false" data-price="0" type="checkbox" onchange="selectToppings(this)"><span class="checkmark"></span></label></div></li><li>Jalapeno<div class="d-flex"><label class="container"><input name="menu-topping-682" data-toppingid="2359" data-maxqty="5" data-ispropertytopping="false" data-price="0" type="checkbox" onchange="selectToppings(this)"><span class="checkmark"></span></label></div></li><li>Fresh Tomato<div class="d-flex"><label class="container"><input name="menu-topping-682" data-toppingid="2360" data-maxqty="5" data-ispropertytopping="false" data-price="0" type="checkbox" onchange="selectToppings(this)"><span class="checkmark"></span></label></div></li><li>Golden Corn<div class="d-flex"><label class="container"><input name="menu-topping-682" data-toppingid="2361" data-maxqty="5" data-ispropertytopping="false" data-price="0" type="checkbox" onchange="selectToppings(this)"><span class="checkmark"></span></label></div></li><li>Mushroom<div class="d-flex"><label class="container"><input name="menu-topping-682" data-toppingid="2362" data-maxqty="5" data-ispropertytopping="false" data-price="0" type="checkbox" onchange="selectToppings(this)"><span class="checkmark"></span></label></div></li><li>Paneer<div class="d-flex"><label class="container"><input name="menu-topping-682" data-toppingid="2363" data-maxqty="5" data-ispropertytopping="false" data-price="0" type="checkbox" onchange="selectToppings(this)"><span class="checkmark"></span></label></div></li><li>Capsicum<div class="d-flex"><label class="container"><input name="menu-topping-682" data-toppingid="2364" data-maxqty="5" data-ispropertytopping="false" data-price="0" type="checkbox" onchange="selectToppings(this)"><span class="checkmark"></span></label></div></li><li>Onion<div class="d-flex"><label class="container"><input name="menu-topping-682" data-toppingid="2365" data-maxqty="5" data-ispropertytopping="false" data-price="0" type="checkbox" onchange="selectToppings(this)"><span class="checkmark"></span></label></div></li><li>Black Olives<div class="d-flex"><label class="container"><input name="menu-topping-682" data-toppingid="2366" data-maxqty="5" data-ispropertytopping="false" data-price="0" type="checkbox" onchange="selectToppings(this)"><span class="checkmark"></span></label></div></li></ul></div>
</div>
</div>
<div class="modal-footer d-flex justify-content-between">
<h5 class="txt_dark m-0 fs_18 fw-semibold">Total Price : ₹ <span id="menu-item-total-price">500</span></h5>
<a class="add-to-cart-modal" onclick="addToCart()" style="">Add to Cart</a>
</div>
</div>
</div>
</div>
and here is a script which i have added
$(document).ready(function () {
function scrollModalBodyToBottom() {
debugger
var modalBody = $('.modal-body');
if (modalBody.length) {
// Find the next ul element
var nextUl = $('.modal-body .row .col-12').next().find('ul'); //$(this).closest('.col-12').next().find('ul');
if (nextUl.length) {
var maxHeight = modalBody.prop('scrollHeight') - modalBody.height();
modalBody.animate({ scrollTop: maxHeight }, 'slow');
}
}
}
$('#toppings-properties-modal').on('shown.bs.modal', function () {
$('input[type="radio"]').on('change', scrollModalBodyToBottom);
$('input[type="checkbox"]').on('change', scrollModalBodyToBottom);
});
});
I want when user click on ready button then it will scroll down to next list of added in ul there is 2 case
1. when user click on radio button then it will scroll to next ul list which
2. when user click on check box it will not move one next script till check box limit will not reach to selection option i.e if i have a 5 item in ul in a list with check box then i have allow to select 2 item or 1 item from that list for when check box limit is done then it will scroll to next ul
mean i have radio button that means there is only open of select will be single item and if there is a check box then user can able to select multiple selection with limit of selection
in give JavaScript it was working bot I’m shucking in to scroll it down to next div and also need a condition as per radio button and check box
How do I remove an image after adding it though JavaScript?
I’m working on a whack-a-mole game, and to create a mole in a hole, i needed an image. I found that image and inserted the image using JavaScript. The following code, I did it in an another file where i was trying to see which thing will work:
<div class="hole" id="h1"></div>
<script>
let mole = `<img src="mole.jpg" height="70px" width="70px" class="mole">`;
let moleNode = document.querySelector('.mole');
document.querySelector('#h1').innerHTML = mole;
document.querySelector('#h1').removeChild(moleNode); // Error: moleNode is not of type node.
// I also tried:
mole.parentNode.removeChild(moleNode); // Same thing as above. Also I thought it wouldn't work because there were 36 holes and I don't actually know how to do it then.
</script>
How to make Bltools Projects, using devtools
Cookies checker creator (BLTOOLS)
Cookies is Bad..
Your response parameter don’t found on your request response..
Try to specify another parameter to validate the good cookies
Please who can help me out
Cookies checker creator (BLTOOLS)
Using devtools.
How to delete element from JSON array of objects by ID
I have Given this JSON structure:
[{"variant_name":"Size","variant_options":["S","M","L","a"]}]
How would you delete an object from the array by key/value?
Let’s say I wish to delete the element with variant_options = S, how to get this result:
[{"variant_name":"Size","variant_options":["M","L","a"]}]
I tried but did’t get any result
How to control header and footer display on print using CSS
I want to customize my header and footer on each page, and in some cases I want to display the header only on first page on print.window() function. I used size: auto; margin: 0.5mm;
but it only disables the header and footer option form the print display window.
For this code how can I achieve that:
<!doctype html>
<html lang="en" dir="ltr">
<head>
@include('layouts.styles')
<script>
const Print = () => {
let printButton = document.getElementById("printPage");
printButton.style.visibility = 'hidden';
window.print();
printButton.style.visibility = 'visible';
}
</script>
</head>
<body class="d-flex justify-content-center align-content-center p-6 flex-column gap-3 mt-3 bg-white">
<header class="d-flex justify-content-evenly align-items-center header">
<img class="bg-transparent" src="{{ asset('assets/images/media/DAIA.png') }}" style="height: 120px; width: 180px"
alt="">
<p class="text-center fs-5 fw-bold align-self-center m-0">د افغانستان اسلامی امارت<br/>د عامی روغتیا وزارت <br/> د
مالی او حسابی چارو معینیت <br/> د اداری ریاست <br/> د بیومدیکل انجنیری دیپارتمنت آمریت</p>
<img class="bg-transparent" src="{{ asset('assets/images/media/MoPH.jpeg') }}" style="height: 110px; width: 160px"
alt="">
</header>
<main>
<div class=" d-flex justify-content-evenly mt-6 fs-6 fw-bold">
<p>تاریخ بررسی: {{ $data['master']['assessment_date'] }}</p>
<p>تمبر مکتوب: {{ $data['master']['maktoob_no'] }}</p>
<p>تاریخ مکتوب: {{ $data['master']['maktoob_date'] }}</p>
<p>{{ $data['master']['hospitals']['en_name'] }} :اسم شفاخانه </p>
</div>
<div class="table-responsive">
<table class="table border fc-direction-rtl text-nowrap text-md-nowrap mb-0" style="background-color: white">
<thead>
<tr class="fw-bold">
<th>#</th>
<th class="fw-bold">اسم ماشین</th>
<th class="fw-bold">سریال نمبر</th>
<th class="fw-bold">تگ نمبر</th>
<th class="fw-bold">تاریخ تولید</th>
<th class="fw-bold">تاریخ انقضا</th>
<th class="fw-bold">حالت</th>
<th class="fw-bold">مفدار</th>
<th class="fw-bold">قیمت</th>
<th class="fw-bold">مجموع</th>
<th class="fw-bold">توضیحات</th>
</tr>
</thead>
<tbody>
<tr>
@foreach($data['details'] as $index=>$dataItem)
<td class="align-middle">{{ $index+1 }}</td>
<td class="align-middle">{{ $dataItem['machinery']['en_name'] }}</td>
<td class="align-middle">{{ $dataItem['serial_no'] }}</td>
<td class="align-middle">{{ $dataItem['tag_no'] }}</td>
<td class="align-middle">{{ $dataItem['mfg_date'] }}</td>
<td class="align-middle">{{ $dataItem['exp_date'] }}</td>
<td class="align-middle">{{ $dataItem['machine_status_id']}}</td>
<td class="align-middle">{{ $dataItem['qnt'] }}</td>
<td class="align-middle">{{ $dataItem['price'] }}</td>
<td class="align-middle">{{ $dataItem['total'] }}</td>
<td class="align-middle">{{ $dataItem['description'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</main>
<footer class="d-flex justify-content-end footer">
<p>ملاحظات</p>
</footer>
<button type="button" id="printPage" onclick="Print()" class="d-block mx-auto btn btn-
primary btn-lg col-2">Print
</button>
</body>
</html>
I also tried to set header and footer display to none, but it didn’t work too.
wxWidgets with GUI with javascript interacting with C++
I am experimenting with wxWidget where the view is an html file with a simple button for now and I want when the button is pressed that a C++ function will be called. I have tried a bunch of things and nothing has been working. I added in my html code and C++ code here. If I click the button I do not see the function OnWebViewNavigating in C++ code getting called.
Any help would be greatly appreciated.
index.html
<!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Local WebView</title>
</head>
<body>
<button id="cppFunctionButton">Click me</button>
<script>
function callCppFunction() {
// Use the postMessage API to communicate with the host (wxWidgets)
alert( "WTF" );
window.parent.postMessage('cppFunction', '*');
}
// Attach the event listener to the button
var cppFunctionButton = document.getElementById('cppFunctionButton');
cppFunctionButton.addEventListener('click', callCppFunction);
</script>
</body>
</html>
c++ wxWidget code
#include <wx/wx.h>
#include <wx/webview.h>
class MyFrame : public wxFrame
{
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame(NULL, wxID_ANY, title, pos, size)
{
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
webview = wxWebView::New(this, wxID_ANY);
sizer->Add(webview, 1, wxEXPAND | wxALL, 5);
SetSizerAndFit(sizer);
// Load the local index.html file
webview->LoadURL("file:///C:/index.html");
// Bind the custom event from JavaScript to a C++ function
webview->Bind(wxEVT_WEBVIEW_NAVIGATING, &MyFrame::OnWebViewNavigating, this);
}
private:
wxWebView* webview;
void OnWebViewNavigating(wxWebViewEvent& event)
{
// Check for the custom event from JavaScript
wxString uri = event.GetURL();
if (uri.StartsWith("cppFunction:"))
{
// Call your C++ function here
wxMessageBox("C++ function called successfully", "Message", wxOK | wxICON_INFORMATION);
// Cancel the navigation
event.Veto();
}
}
};
class MyApp : public wxApp
{
public:
virtual bool OnInit()
{
wxInitAllImageHandlers();
MyFrame* frame = new MyFrame(wxT("wxWebView Example"), wxPoint(50, 50), wxSize(800, 600));
frame->Show(true);
return true;
}
};
wxIMPLEMENT_APP(MyApp);
how to avoid a new line
when I write something in td and press enter key I get a new line. In the console I get whatever I have written + br tag. How can I fix it?
document.querySelector(".add_btn").addEventListener("click", () => {
const table = `<tr>
<td contenteditable="true" class="fill items"></td>
<td contenteditable="true" class="fill quan"></td>
<td contenteditable="true" class="fill rate"></td>
</tr>`;
document
.querySelector(".table_heading")
.insertAdjacentHTML("afterend", table);
const fill = document.querySelectorAll(".fill");
fill.forEach((f) => {
f.addEventListener("keyup", (e) => {
if (e.key == "Enter") {
console.log(f.innerHTML);
}
});
});
});```

