I want to use wasm through JavaScript written by myself.
Like that“WebAssembly.instantiateStreaming(fetch(‘xxx.wasm’),importObject)”.
But I have a problem with parameter “importObject”.
How can I build this parameter,importObject?
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
Category Added in a WPeMatico Campaign
I want to use wasm through JavaScript written by myself.
Like that“WebAssembly.instantiateStreaming(fetch(‘xxx.wasm’),importObject)”.
But I have a problem with parameter “importObject”.
How can I build this parameter,importObject?
I’m using embedded code from Microsoft Dynamics in a modal. The first time I open it, it works correctly. However, on subsequent attempts (second, third, etc.), it stops working. Could someone explain why this happens and how I can fix it?
<div class="modal-personalizado">
<div class="modal-content-personalizado">
<div class="modal-personalizado-header">
<span class="modal-title-personalizado fRegular">@RGlobal.SuscripcionNewsletters</span>
</div>
<div class="modal-personalizado-body">
<div id="formContainer" data-form-id='My_Key'
data-form-api-url='https://public-sam.mkt.dynamics.com/api/v1.0/orgs/4dc021bb-8922-ee11-a66b-00224837a3ef/landingpageforms'
data-cached-form-url='https://assets-sam.mkt.dynamics.com/4dc021bb-8922-ee11-a66b-00224837a3ef/digitalassets/forms/My_Key'>
</div>
</div>
<div class="modal-footer-personalizado">
<button type="button" class="boton-cerrar fMedium" onclick="AbrirModalPersonalizado()">@RModalEmail.btnCerrar</button>
</div>
</div>
</div>
<script src="https://cxppusa1formui01cdnsa01-endpoint.azureedge.net/sam/FormLoader/FormLoader.bundle.js"></script>
I opened the modal, closed it, opened it again and expected the Dynamics form to appear, but it didn’t load at all. I tried to load the script dynamically in the document.ready and it also didn’t work.
I have a element.module.css that contains (in reality it’s much more huge, that’s just an example)
.button {
background: red;
}
.button.solve {
border-radius: 3vh;
}
I want to set both classes to my button in Element.jsx `
import classes from "./Element.module.css"
...
return (
<button className = {classes.solve}/>
);
};
I can’t add it all in one class, because I have a few buttons – some of them with class “button”, some with “button solve”.
so I have tried:
<button className = {classes.button} id={classes.solve}/>
<button className = {classes.button + ' ' + classes.solve}/>
it worked, but I still have a question
var number = 0;
for (var i = 0; i < 10; i++) {
number++;
console.log(i + i);
}
this is what ive managed to come up with
i wanted to make numbers 1 through 10 add up and display that number what i have ended up with is it just display the numbers 1,2,3,4,5,6,7,8,9,10 multiplied by two
I am using HTML 5 Video API but it does not work for iOS browser or Safari. Below is my code can you please check and tell me what I did wrong.
const video = document.getElementById('video-ar_ZGU2hsr-video-js');
const play = document.getElementById("playbtn");
playbtn.addEventListener("click",function(){
video.currentTime = 0;
// video.muted = !video.muted;
video.muted = false;
video.play();
});
Example: https://app.gohighlevel.com/v2/preview/ODVPYWzQjdNHZNVdxjqX?notrack=true
I followed HTML5 Video API(https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Client-side_web_APIs/Video_and_audio_APIs) but nothing worked
const media = document.querySelector("video");
const controls = document.querySelector(".controls");
const play = document.querySelector(".play");
const stop = document.querySelector(".stop");
const rwd = document.querySelector(".rwd");
const fwd = document.querySelector(".fwd");
const timerWrapper = document.querySelector(".timer");
const timer = document.querySelector(".timer span");
const timerBar = document.querySelector(".timer div");
const playbtn = document.getElementById("play");
playbtn.addEventListener("click",function(){
media.currentTime = 0;
media.muted = false;
media.play();
});
Image what i want to make How to make an adaptive design for a website with an image, so that there are two columns of text on the image? These columns of text are separated by a vertical line. As shown in my image. Any help would be appreciated. I need that when the screen width is reduced, the right column of text goes down and there is a center line on the left next to that column.
<style>
.bottom-banner {
position: relative;
width: 100%;
margin-top: 100px; /* Добавляем отступ сверху */
}
.image-container {
position: relative;
height: 600px;
}
.image-container img {
width: 100%;
height: 100%;
object-fit: cover;
}
.center-line {
position: absolute;
width: 5px;
height: 100%;
background-color: white;
top: 0;
left: 50%;
height: 500px; /* Высота линии на 100 пикселей короче */
margin: 50px 0;
z-index: 1; /* Устанавливаем высокий уровень слоя (1 или больше), чтобы линия была поверх текстов */
}
.text-container {
position: absolute;
width: 100%;
height: 100%;
top: 0;
background-color: rgba(0, 0, 0, 0.7);
color: white;
display: flex;
align-items: center;
}
.left-text {
flex: 1;
text-align: center;
padding: 0 10px;
display: flex;
flex-direction: column;
font-size: 66px;
font-family: 'Century Gothic';
font-weight: bold; /* Делаем текст жирным */
}
.right-text {
flex: 1;
margin-left: 100px;
display: flex;
flex-direction: column;
font-size: 22px;
font-family: 'Century Gothic';
font-weight: bold; /* Делаем текст жирным */
}
.right-text p i {
margin-right: 10px; /* Добавляем пробел между иконкой и текстом */
}
@media (max-width: 768px) {
.left-text {
font-size: 4vw;
padding: 0 4vw;
}
.right-text {
font-size: 3vw;
margin-left: 1vw;
margin-right: 3vw;
}
.center-line {
width: 1vw;
}
}
</style>
<body>
<div class="bottom-banner" style="margin-top: 100px; font-family: 'Century Gothic'; font-weight: bold;">
<div class="image-container">
<img src="https://balans-buh.ru/image7.jpg" alt="Bottom Banner Image">
<div class="center-line"></div>
</div>
<div class="text-container">
<div class="left-text">
<p>Why choose us?</p>
</div>
<div class="right-text">
<p><i class="far fa-circle"></i>Taking care of business security</p>
<p><i class="far fa-circle"></i>Competently represent the company before regulatory authorities</p>
<p><i class="far fa-circle"></i>We take care of the finance department's problems</p>
<p><i class="far fa-circle"></i>Maintaining records with adaptation to legal requirements</p>
</div>
</div>
</div>
</body>
How to make an adaptive design for a website with an image, so that there are two columns of text on the image? These columns of text are separated by a vertical line. As shown in my image. Any help would be appreciated. I need that when the screen width is reduced, the right column of text goes down and there is a center line on the left next to that column.
In my second ever angular project I have a navbar that I want to make it visible only after the user logs in and make it invisible if he logs in or is not loged in. In this navbar there is also the name of the user…
So what I managed to achieve so far is that upon login the users name is displayed in the navbar but only after I refresh the page. Upon logout the name stays in the navbar even tho I cleaned the local storage…
What I don’t know how to do and am having trouble with is that I can’t make the navbar not be shown on login page and after user logs in only then on al other subpages show the navbar. And whne loging out to hide the navbar again…
I hope I was clear on what my issue is and what I’m having problems with…
Here is my code (I have pasted only the code that is related to login and navbar):
HTML comonent tempalte:
<mat-sidenav-content>
<mat-toolbar *ngIf="currentUser" class="crm-main-toolbar">
<button mat-icon-button (click)="sidenav.toggle()" class="menu-togle">
<mat-icon class="material-symbols-outlined" *ngIf="sidenav.opened">chevron_left</mat-icon>
<mat-icon class="material-symbols-outlined" *ngIf="!sidenav.opened">menu</mat-icon>
</button>
<img src="/assets/icons/logo-white.svg" alt="" class="logo" fxShow.xs="false" routerLink="/dashboard"/>
<img src="/assets/icons/logotype.svg" alt="" class="logo-mobile" fxHide.xs="false" fxHide.gt-xs="true" routerLink="/dashboard"/>
<span class="toolbar-spacer"></span>
<p *ngIf="currentUser" class="user-name" fxShow.xs="false">{{ currentUser.user_name}}</p>
<button mat-icon-button [matMenuTriggerFor]="userMenu" class="circle-button white user-menu">
<i class="zwicon-user"></i>
</button>
<mat-menu #userMenu="matMenu">
<button mat-menu-item routerLink="/login">
<mat-icon class="material-symbols-outlined">account_circle</mat-icon>
My profile
</button>
<button mat-menu-item (click)="logout()">
<mat-icon class="material-symbols-outlined">logout</mat-icon>
Logout
</button>
</mat-menu>
</mat-toolbar>
<div id="content" [ngClass]="{'content-padding' : currentUser}">
<router-outlet></router-outlet>
</div>
</mat-sidenav-content>
here is the component.ts code:
export class MainNavComponent implements OnInit, OnChanges{
currentUser: User;
currentUserSubscription: Subscription;
constructor(
private authService: AuthenticationService,
private router: Router,
) {
this.currentUserSubscription = this.authService.login().subscribe(user => {
this.currentUser = user;
})
}
ngOnInit() {
this.currentUser = this.authService.getUser();
}
ngOnChanges() {
this.currentUser = this.authService.getUser();
}
async logout() {
this.authService.logout();
await this.router.navigate(['/login']);
}
}
here is the auth service code:
export class AuthenticationService {
token = '';
user: User;
login(): Observable<User> {
const params = new HttpParams().append('param', 'value');
return this.http.get<User>(`${environment.apiUrl}azure` + location.search, {params}).pipe(
tap((response: any) => {
console.log('Response from login:', response);
if (response && response.token) {
localStorage.setItem('TOKEN_KEY', response.token);
localStorage.setItem('username',response.user_name);
localStorage.setItem('useremail',response.user_email);
this.setAuthToken(response.token);
this.isLoggedIn = true;
} else {
this.router.navigate(['/login']);
return;
}
}),
catchError(error => {
console.error('Error:', error);
return throwError(error);
})
);
}
isLogedIn() {
const token = localStorage.getItem('TOKEN_KEY');
return !!token;
}
getUser() {
const username = localStorage.getItem('username');
const useremail = localStorage.getItem('useremail');
const token = localStorage.getItem('TOKEN_KEY');
let userModel = new UserModel();
userModel.user_email = useremail;
userModel.user_name = username;
userModel.token = token;
console.log(userModel);
return userModel;
}
setAuthToken(token: string) {
this.authToken = token;
}
getAuthToken(): string | null {
return this.authToken;
}
logout() {
this.isLoggedIn = false;
localStorage.removeItem("TOKEN_KEY");
localStorage.removeItem("username");
localStorage.removeItem("useremail");
}
}
Here is my user model.ts file code:
export interface User {
token: string;
user_email: string;
user_name: string;
validity: number;
}
export class UserModel {
token:string;
user_email: string;
user_name: string;
validity: number;
}
const verifyToken = async (req, res, next) => {
try {
if (req.headers["authorization"] && req.headers.authorization) {
const token = req.headers["authorization"].split(" ")[1];
if (token) {
const jwtkey = "cd9270cce6b16c80dae704dd0c21c27268b3bbfcdd20e3";
if (jwtkey) {
jwt.verify(token, jwtkey, (err, decodedToken) => {
if (err) {
if (err.name === 'TokenExpiredError') {
return res.json({
status: 404,
error: true,
message:'Token expired123', err,
});
} else {
return res.json({
status: 404,
error: true,
message:'Invalid Token'
})
}
}
req.user_id = decodedToken.sub;
next();
});
} else {
return res.json({
status: 404,
message: "Invalid Request*"
});
}
} else {
return res.json({
status: 404,
message: "Invalid Token**"
});
}
} else {
return res.json({
status: 404,
message: "Invalid Request**"
});
}
} catch (error) {
console.log(error);
return res.json({
status: 404,
message: "Invalid token",
error
});
}
}
here The code is verifytoken when user are logout token are not balcklist when user are logout token are balcklist and this not get the data in the api when hit postman not get the data when logout user Token are destryod
I have a function, which adding 1 line of input image to canvas, at the end.
const draw = function(canvas, base64) {
const context = canvas.getContext('2d', { willReadFrequently: true });
const canvas_width = canvas.width
const canvas_height = canvas.height;
context.globalCompositeOperation = "copy"
context.drawImage(context.canvas, 0, -1)
context.globalCompositeOperation = "source-over"
const image = document.createElement("img")
image.onload = () => {
context.drawImage(image, 0, canvas_height - 1);
};
image.src = 'data:image/jpeg;base64,' + base64;
image.onerror = (error) => {
console.log(`Error: ${error}`)
}
}
It’s should look like a waterfall. New piece of data (line, row) arrives every 50 ms(1/20Hz). I think that JS does not have time to render data in such a short period of time. When I decrease to ~14Hz, I got correctly drawn waterfall. I’m stuck, please help
I’ve tried 2 ways to render picture.
I’ve tried to optimize it(preload image)
i was trying to select any one of the element from the lsit displaying when click is made on the particular dropdown selection box but after the elements got listed i could not able to select any element from the list ..
kindly help me out i also tried with many familiar options.
WebElement autocompleteDropdown = driver.findElement(autocompleteSuggestions);
java.util.List suggestionList = autocompleteDropdown.findElements(By.xpath(“//span//ul[@id=’select2-unit_type_id-results’]”));
System.out.println(“suggestion list taken”);
for (WebElement element : suggestionList) {
if (element.getText().equals("1 Bedroom Townhouse"))
{
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(30));
Actions act1 = new Actions(driver);
act1.click().moveToElement(element).click().build().perform();
break;
}
}
This is the condensed user model. I highly assume it is some incompatibility issue with Djangos AbstractUser Class:
class CustomUser(AbstractUser, PermissionsMixin, TimeRegistryBaseModel):
uuid = models.UUIDField(
primary_key=True, default=uuid.uuid4, editable=False)
username = None
email = models.EmailField(unique=True)
gender = models.ForeignKey(Gender, on_delete=models.CASCADE, null=True, blank=True)
verified_status = models.BooleanField(default=False)
bio = models.TextField(null=True, blank=True)
location = models.CharField(max_length=50, null=True, blank=True)
birthdate = models.DateField(null=True, blank=True)
marital_status = models.ForeignKey(MaritalStatus, on_delete=models.CASCADE, null=True, blank=True)
avatar = models.ImageField(
upload_to="avatars/", null=True, blank=True)
objects = CustomUserManager()
USERNAME_FIELD = "email"
REQUIRED_FIELDS: List[str] = [] # TODO: think thoroughly what we actually-required when creating a user
And this is the error message:
Exception inside application: __init__() got an unexpected keyword argument 'password'
Traceback (most recent call last):
File "/home/dci-student/Desktop/DCIstuff/Projects/PlayPal/.venv/lib/python3.8/site-packages/django/contrib/staticfiles/handlers.py", line 101, in __call__
return await self.application(scope, receive, send)
File "/home/dci-student/Desktop/DCIstuff/Projects/PlayPal/.venv/lib/python3.8/site-packages/channels/routing.py", line 62, in __call__
return await application(scope, receive, send)
File "/home/dci-student/Desktop/DCIstuff/Projects/PlayPal/.venv/lib/python3.8/site-packages/channels/sessions.py", line 47, in __call__
return await self.inner(dict(scope, cookies=cookies), receive, send)
File "/home/dci-student/Desktop/DCIstuff/Projects/PlayPal/.venv/lib/python3.8/site-packages/channels/sessions.py", line 263, in __call__
return await self.inner(wrapper.scope, receive, wrapper.send)
File "/home/dci-student/Desktop/DCIstuff/Projects/PlayPal/.venv/lib/python3.8/site-packages/channels/auth.py", line 185, in __call__
return await super().__call__(scope, receive, send)
File "/home/dci-student/Desktop/DCIstuff/Projects/PlayPal/.venv/lib/python3.8/site-packages/channels/middleware.py", line 24, in __call__
return await self.inner(scope, receive, send)
File "/home/dci-student/Desktop/DCIstuff/Projects/PlayPal/.venv/lib/python3.8/site-packages/channels/routing.py", line 116, in __call__
return await application(
File "/home/dci-student/Desktop/DCIstuff/Projects/PlayPal/.venv/lib/python3.8/site-packages/channels/consumer.py", line 94, in app
return await consumer(scope, receive, send)
File "/home/dci-student/Desktop/DCIstuff/Projects/PlayPal/.venv/lib/python3.8/site-packages/channels/consumer.py", line 44, in __call__
self.channel_layer = get_channel_layer(self.channel_layer_alias)
File "/home/dci-student/Desktop/DCIstuff/Projects/PlayPal/.venv/lib/python3.8/site-packages/channels/layers.py", line 357, in get_channel_layer
return channel_layers[alias]
File "/home/dci-student/Desktop/DCIstuff/Projects/PlayPal/.venv/lib/python3.8/site-packages/channels/layers.py", line 78, in __getitem__
self.backends[key] = self.make_backend(key)
File "/home/dci-student/Desktop/DCIstuff/Projects/PlayPal/.venv/lib/python3.8/site-packages/channels/layers.py", line 44, in make_backend
return self._make_backend(name, config)
File "/home/dci-student/Desktop/DCIstuff/Projects/PlayPal/.venv/lib/python3.8/site-packages/channels/layers.py", line 74, in _make_backend
return backend_class(**config)
TypeError: __init__() got an unexpected keyword argument 'password'
WebSocket DISCONNECT /ws/ac326356-19c9-4302-a82d-8d636913e6d0/ [127.0.0.1:56538]
This is the part of the template that tries to create a websocket connection:
const chatSocket = new WebSocket( "ws://" + window.location.host + "/ws/" + roomId + "/" );
I’m extremely new to all of this and haven’t tried much tbh because I wouldn’t even know where to start.
I have got a simple extension that should automatically clear browsing data when I go to a certain page on chrome. I wanted it to fire once the page has finished loading.
When I go to the page it generates the following error…
Uncaught TypeError: Cannot read properties of undefined (reading ‘remove’)
Here is the manifest…
"manifest_version": 3,
"name": "Restart zoopla",
"permissions": ["browsingData"],
"version": "3.0",
"description": "Restart zoopla",
"content_scripts": [
{
"js": ["scripts/content.js"],
"matches": [
"https://www.yourpropertyleads.co.uk/*"
]
}
]
}
and here is the code…
var callback = function () {
alert('browsing data cleared');
};
var millisecondsPerWeek = 1000 * 60 * 60 * 24 * 7;
var oneWeekAgo = (new Date()).getTime() - millisecondsPerWeek;
chrome.browsingData.remove({
"since": oneWeekAgo
}, {
"appcache": true,
"cache": true,
"cacheStorage": true,
"downloads": true,
"fileSystems": true,
"formData": true,
"history": true,
"indexedDB": true,
"localStorage": true,
"passwords": true,
"serviceWorkers": true,
"webSQL": true
}, callback);
in textarea using submit button, and find.JavaScript
Here it shows all the IDs. I want it to show only the ID “sert” and not the ID “ranya” Do not show it directly, but through submit button. Find the number of blockquote IDs through a loop
To modify the provided script to only show blockquotes with the ID “sert” and not “ranya”, and to include a submit button to trigger this action, Thats how i would do it, hope it helps you.:
-Add a submit button to your HTML.
-Modify the JavaScript to include an event listener for the button click.
-Update the loop to only select and display blockquotes with the ID “sert”.
First, add the submit button to your HTML:
<button id="submitBtn">Show Quotes</button>
<blockquote id="sert-1" contenteditable="true">this is a quote for comment😎</blockquote>
<blockquote id="sert-2" contenteditable="true">this is a quote for comment text1</blockquote>
<blockquote id="ranya-1" contenteditable="true">this is a quote for comment text2</blockquote>
<blockquote id="ranya-2" contenteditable="true">this is a quote for comment text3</blockquote>
Then, modify your JavaScript as follows:
document.getElementById('submitBtn').addEventListener('click', function() {
const BLOCKQUOTES = document.querySelectorAll('blockquote');
let text = '';
BLOCKQUOTES.forEach(blockquote => {
if (blockquote.id.startsWith("sert")) {
text += `${blockquote.textContent}.`enter code here` n`;
}
});
let textarea = document.createElement('textarea');
textarea.value = text;
document.body.appendChild(textarea);
});
/* Styling for the textarea */
textarea {
border: 2px solid red;
width: 80vw;
height: 60vh;
}
I’m creating a library where the consumer of the library should be able to go through different steps in the library, and the consumer should be able to decide when the library to go to the next step. To achieve that, I let the consumer pass promises to the library, which the consumer then can resolve when it’s time to go to the next step. A dummy example would be this:
// A library function.
export async function processName(getNamePromise){
const name = await getNamePromise
console.log(`Hello ${name}!`)
}
Now the consumer can decide when the library should go to the next step in the library by resolving the promise. A dummy example:
import {processName} from './the-lib.js'
const getNamePromise = new Promise(resolve => {
document.getElementById(`inputName`).addEventListener('keyup', function(event){
// This JS code does probably not work as it is, but you get the idea.
if(event.keyCode == "enter"){
resolve(event.target.value)
}
})
})
processName(getNamePromise)
This works great! But, sometimes I want to use the library synchronously. I was hoping that passing an already resolved promise to the library would make it run synchronously, but each await in the library seems to put the next step at the end of the event queue, so processName() will in fact run asynchronously anyway:
import {processName} from './the-lib.js'
const getNamePromise = Promise.resolve(`Peter`)
processName(getNamePromise)
console.log(`Done processing!`)
With the code above, Done processing is logged before Hello Peter!. I need it to be the other way around.
I really, really want to avoid using await when calling processName() with a resolved promise, because I need to do this in a frontend framework that automatically re-runs computations as soon as a reactive variable changes, and to speed things up, I also need to use caching of method calls. Being able to use the library in a synchronous way here would be so much easier. And it all would have worked great if awaiting a resolved promise wouldn’t have resulted in a new job in the event queue… -.-
In the library, a workaround that would work is to check if the promise has been resolved or not, and only use await if it hasn’t been resolved, something like this:
// A library function.
export async function processName(getNamePromise){
const name = getNamePromise.isResolved() ? getNamePromise.getResolvedValue() : await getNamePromise
console.log(`Hello ${name}!`)
}
But Promise.isResolved() and Promise.getResolvedValue() don’t exist, and it is a messy solution anyway.
My current workaround is to not wrap the name in a promise when the code should run synchronously, and only use await in the lib when it receives a promise:
// A library function.
export async function processName(getNamePromise){
const name = typeof getNamePromise == "string" ? getNamePromise : await getNamePromise
console.log(`Hello ${name}!`)
}
import {processName} from './the-lib.js'
const name = `Peter`
processName(name)
console.log(`Done processing!`)
Still quite messy, but this is how I do it for now. Does anyone know if a better solution exists to provide a library where the consumer can pass promises to the library (to tell the library when to go to the next “step”), but also special cases where the library should run synchronously?
And does anyone know why awaiting a resolved promise pushes a new job to the event queue? Is it not more logical and faster to simply finish the current job when awaiting a promise that is already resolved?
I’ve got an image on a page, which is linked to a project page – I’ve got it set to zoom in and blur on focus which is working really well, but it shrinks back down. Ideally id want it to stay zoomed and blured, then the click fires so the page changes, without the user seeing the image shrink back down.
This is my current code:
.project-zoom {
transition: transform 1s, filter 1s ease-in-out;
margin: 0 auto;
}
.project-zoom:active {
-ms-transform: scale(10); /* IE 9 */
-webkit-transform: scale(10); /* Safari 3-8 */
transform: scale(10);
filter: blur(2px);
}
So firstly, I need to add a delay so that when I click the image it does the image zoom first.
Then once the image has zoomed, I want it to stay zoomed.
Is it possible?
I’m guessing I’ll need to add a delay to the click with js or jquery, although if its possible in css then that would be much better.