How integrate stylelint with eslint? I searched on Google and Github and I saw a lot of packages. But what is the official way to do it?
I also searched in stylelint docs but could not find any explaintion.
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
Category Added in a WPeMatico Campaign
How integrate stylelint with eslint? I searched on Google and Github and I saw a lot of packages. But what is the official way to do it?
I also searched in stylelint docs but could not find any explaintion.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>Etch-a-Sketch</title>
<link rel = "stylesheet" href="style.css">
</head>
<body>
<div class="banner">
<div class="banner-text">
<h1> Etch-a-Sketch </h1>
</div>
</div>
<div class="divcontainer">
<div id="container"></div>
</div>
<script src="app.js"> </script>
</body>
</html>
.banner {
display: flex;
justify-content: center;
}
.divcontainer{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
#container{
margin-top: 100px;
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr
1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
}
.box {
height: 20px;
width: 20px;
}
let container =
document.getElementById('container');
function getGrid(gridNumber) {
for (let i = 1; i <= gridNumber * gridNumber; i++)
{
const row = document.createElement('div');
row.style.border = '1px solid red'
container.appendChild(row).classList.add('box');
}
}
getGrid(16);
I am making a simple etech a sketch and so far i have created a grid of square divs. i need some direction on where to go from here. i think i need to attach keydown event listeners of each of the divs that i injected using javascript dom manipulation but how do i add event listeners to divs injected?
I am pretty new to angular js, and have to upgrade build-angular library from 0.13.6 to 13.3.8 or latest.
While upgrading, i am getting a lot of dependency issues. Probably code compatibility would also need to be checked in such a major jump.
I want to know, what should be a checklist to check when doing such upgrades. Where can i find a document with details about dependencies or any migration document when doing such update.
More details –
I need to add a new property inside dat.GUI to control the fontsize of an Angular Three custom component called NgtSobaText. I have found this answer but it didn’t work for me.
app.component.html
<ngt-soba-text
text="Angular Three Demo"
[position]="[-8, 25, 20]"
[rotation]="[0, 0.5 | pi, 0]"
fontSize="6"
outlineColor="white"
outlineWidth="0.3"
color="blue"
letterSpacing="0"
#text
>
</ngt-soba-text>
app.component.ts
import { Component, ElementRef, ViewChild } from '@angular/core';
import * as dat from 'dat.gui';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {
@ViewChild('text', { read: ElementRef }) divText?: ElementRef;
gui: dat.GUI = new dat.GUI();
ngAfterViewInit() {
this.gui.add(
this.divText?.nativeElement.attributes[2].value,
'fontsize',
1,
12,
1
);
}
}
This code results in the below image. I have the attribute but I can’t set a new value:
If I console.log(this.divText?.nativeElement.attributes); the result is:
I have access to those properties but, If I try this:
this.gui.add(
this.divText?.nativeElement.attributes.fontsize,
'fontsize',
1,
1,
1
);
I got this error core.mjs:6362 ERROR Error: Object "[object Attr]" has no property "fontsize". I think I need to get the whole NgtSobaText as a component (maybe as an object) because the dat.gui add() function takes: Object, prop name, min, max.
Hello there.
I want to implement a small game for myself, it will not have super functions, etc.
I want to implement this game together with ReactJS + Game Engine, but could not find a suitable game engine with documentation.
Maybe you know something similar to solve my problem
I have a date:
start : 2022-07-13 08:22:22
process : 50 minute
And I want to output sum total
total = 2022-07-13 09:12:22 // total = start + process minute
I’m using javascript for sum
function myFunction() {
var datestart = $("#start").val();
var process = $("#process").val();
total = datestart + process;
alert(total);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
IS that possible to get the sprite position data and pass it to next scene?
Scene 1
preload() {
this.load.image('neutral_emoji', '/image/neutral.png');
this.load.image('sad_emoji', '/image/sad.png');
this.load.image('happy_emoji', '/image/smiley.png');
}
create() {
var emoji = ['sad_emoji', 'happy_emoji'];
this.neutral = this.add.image(0, 0, 'neutral_emoji');
this.emotion = this.add.image(0, 0, emoji[Math.floor(Math.random() * emoji.length)]);
this.aGrid = new AlignGrid({scene: this,rows: 11,cols: 11});
this.aGrid.placeAtIndex(57,this.neutral);
this.aGrid.placeAtIndex(63,this.emotion);
Align.scaleToGameW(this.neutral,.1);
Align.scaleToGameW(this.emotion,.1);
}
As the code above the neutral emoji is placed at position 57 and sad/smiley is placed at 63.I would like to pass the position data and texture key to Scene 2
Hello I have 2 html files and now I am printing everythinng in 1 of the htmls. When I click a button I want to print everything on the 2nd HTML. Here are the codes
questionaire: 1st html
questionaire1: 2nd html
HTML1:
<head>
<title>Your Survey Form</title>
<link rel="stylesheet" href="DemoSurveyStyle.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="alternate stylesheet">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
</head>
<body>
<ol id="menu">
<li> <a href="DemoSurvey.html">Home</a> </li>
<li> <a href="new.html">CreateSurvey</a> </li>
</ol>
<h1 id="myText" contenteditable="true">Survey Name</h1>
<div id="buttons">
<button type="button" id="addSectionButton">Add Section</button>
</div>
<!-- <button type="button" id="copyButton">Duplicate Survey</button> -->
<button type="button" id="clearButton">Clear Survey</button>
<button type="button" id="testButton">Test</button>
<p id="testingBox">testingBox</p> <p id="testingBox1">testingBox1</p>
<p id="testingBox2">testingBox2</p> <p id="testingBox3">testingBox3</p>
<p id="testingBox4">testingBox4</p>
<p id="testingBox5">testingBox5</p> <p id="testingBox6">testingBox6</p>
<p id="testingBox7">testingBox7</p>
<form>
<div id="questionaire"></div>
</form>
<p class="counters" id="numberOfOptionsQuestions"></p>
<p class="counters" id="numberOfShAnQuestions"></p>
<p class="counters" id="numberOfLoAnQuestions"></p>
<p class="counters" id="numberOfNumQuestions"></p>
<p class="counters" id="numberOfStarQuestions"></p>
<p class="counters" id="testingText"></p>
<script src="DemoCode.js"></script>
</body>
</html>
HTML2:
<html>
<head>
<title>Your Survey Form</title>
<link rel="stylesheet" href="DemoSurveyStyle.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="alternate stylesheet">
</head>
<body>
<ol id="menu">
<li> <a href="DemoSurvey.html">Home</a> </li>
<li> <a href="new.html">CreateSurvey</a> </li>
</ol>
<button type="button" id="copyButton">Duplicate Survey</button>
<p id="testingBox10">testingBox10</p>
<form>
<div id="questionaire1"></div>
</form>
<script src="DemoCode.js"></script>
</body>
</html>
And the part of Javascript that prints:
for (let i = 0; i < allSectionsArray.length; i++) {
newSection(true, allSectionsArray[i][0]);
for (let j = 0; j < allSectionsArray[i][3].length; j++) {
switch (allSectionsArray[i][3][j][1]) {
case 0:
newOption(questionnaire.querySelector("div.section:last-child ul"), true, j, i);
break;
case 1:
newShAnSubquestion(questionnaire.querySelector("div.section:last-child ul"), true, j, i);
break;
case 2:
newLoAnSubquestion(questionnaire.querySelector("div.section:last-child ul"), true, j, i);
break;
case 3:
newNumSubquestion(questionnaire.querySelector("div.section:last-child ul"), true, j, i);
break;
case 4:
newStarSubquestion(questionnaire.querySelector("div.section:last-child ul"), true, j, i);
break;
}
}
}
}
I want to print everything on questionaire1 but simply changing to questionaire1 in javascript when I print doesn’t seem to work
Using Functional Component, I am trying to find the scroll position of an element, but the listener function isn’t registering as scrolling occurs. Can anyone explain why this is happening.
Here is the code for reference
export default function App() {
const [scrollPosition, setScrollPOsition] = useState(0);
const innerRef = useRef<HTMLParagraphElement>(null);
const handleScroll = () => {
console.log("handle scroll");
// setScrollPOsition((scrollPosition) => scrollPosition + 1);
};
useEffect(() => {
if (innerRef.current) {
innerRef.current.addEventListener("scroll", handleScroll);
return () => innerRef.current?.addEventListener("scroll", handleScroll);
}
}, []);
return (
<div className="App">
<span className={"scrollValue"}>
scroll position of first header: {scrollPosition}
</span>
<h1 ref={innerRef}>Find My position on window</h1>
<h2>Heading Element</h2>
...
...
<h2>Heading Element</h2>
</div>
);
}
Here is the code sandbox link
here i am sharing a code of update panel which i am using on my website, the code is working well on localhost but after online hosting, the website is not working (after visible page load it showing state list)
Thanks in advance 🙂
<%@ Register Assembly=”AjaxControlToolkit” Namespace=”AjaxControlToolkit” TagPrefix=”asp” %>
<asp:ScriptManager ID=”ScriptManager1″ runat=”server” ></asp:ScriptManager>
<asp:DropDownList ID="ddlcountry" runat="server" class="form-control" AutoPostBack="true" OnSelectedIndexChanged="ddlcountry_SelectedIndexChanged">
</asp:DropDownList>
<asp:UpdatePanel ID="up1" runat="server" >
<ContentTemplate>
<asp:DropDownList ID="txtstate" AutoPostBack="true" runat="server" class="form-control" OnSelectedIndexChanged="txtstate_SelectedIndexChanged"></asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlcountry" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
First of all, sorry the bad english!
Im trying to fill te text field on whatsapp web throgh an extension that im making, but i dont know how to make it, i can set the thext of the span, but it doesnt appears in the message field!
I hope you can help me!
Video of the problem!
https://www.youtube.com/watch?v=WoPLpg3orho
This is the contentscript
var allP = document.getElementsByTagName("p").length;
if (allP > 0) {
var myP = document.getElementsByTagName("p")[0];
var mySpan = myP.children[0];
mySpan.textContent = "You desired Message";
alert(myS.textContent);
}
I am having issues passing in two values in my select component and working in React. I am currently passing in the correct id value in the selected options.. however when I am passing to the body in newCapabilities, it is receiving a the id value (agent.agentId) instead of the intended name value (agent.agent). I need to be able to send both of the id value and name value that I am mapping through in agent.
What am I doing wrong here?
react-component.js
const handleChangeForm = (e) => {
const { id, value } = e.target
setForm({
...form,
[id]: value
})
}
const addCapabilities = async (tableName, body) => {
const newCapabilities = {
agent
}
response(newCapabilities)
}
<form>
<label>Agent</label>
<select className='add-cap-select' id='agent' onChange={handleChangeForm}>
<option value=''>Agent</option>
{agents.map((agent, index) => (
<option key={index} value={agent.agentId}>
{agent.agent}
</option>
))}
</select>
</form>
so I just make my first project and I have a problem I’m facing right now
so when I press the button it’s supposed to go to ‘belum selesai dibaca’ or id=”incompleteBookshelfList”
but its always showing in the ‘Selesai dibaca’ or id=”completeBookshelfList”
anyone know what should I do because I’ve been tinkering with it for a few days and have not found the correct way yet
this is the repository
https://gitfront.io/r/user-2883908/RJRPjrov1UfT/Front-end-submission/
I think the problem I’m facing is in the javascript files in the makeBook function but I still don’t know the correct way to solve it
const books = [];
const RENDER_EVENT = 'render-book';
document.addEventListener(RENDER_EVENT, function () {
const uncompletedBOOKList = document.getElementById('incompleteBookshelfList');
uncompletedBOOKList.innerHTML = '';
const completedBOOKList = document.getElementById('completeBookshelfList');
completedBOOKList.innerHTML = '';
for (const bookItem of books) {
const bookElement = makeBook(bookItem);
if (!bookItem.isCompleted)
uncompletedBOOKList.append(bookElement);
else
completedBOOKList.append(bookElement);
}
});
function generateId() {
return +new Date();
}
function generateBookObject(id, title, author, year, isCompleted) {
return {
id,
title,
author,
year,
isCompleted
}
}
function clearForm() {
const bookTitle = document.getElementById("inputBookTitle");
const bookAuthor = document.getElementById("inputBookAuthor");
const bookYear = document.getElementById("inputBookYear");
const isCompleted = document.getElementById("inputBookIsComplete");
bookTitle.value = "";
bookAuthor.value = "";
bookAuthor.value = "";
bookYear.value = "";
isCompleted.value = false;
}
function addBook() {
const bookTitle = document.getElementById('inputBookTitle').value;
const bookAuthor= document.getElementById('inputBookAuthor').value;
const bookYear = document.getElementById('inputBookYear').value;
const IsCompleted = document.getElementById('inputBookIsComplete').value;
const generatedID = generateId();
const bookObject = generateBookObject(
generatedID,
bookTitle,
bookAuthor,
bookYear,
IsCompleted);
books.push(bookObject);
document.dispatchEvent(new Event(RENDER_EVENT));
saveData();
}
document.addEventListener('DOMContentLoaded', function () {
const submitForm = document.getElementById('inputBook');
submitForm.addEventListener('submit', function (event) {
event.preventDefault();
addBook();
clearForm();
});
if (isStorageExist()) {
loadDataFromStorage();
}
});
function makeBook(bookObject) {
const textTitle = document.createElement('h2');
textTitle.innerText = bookObject.title;
const textAuthor = document.createElement('p');
textAuthor.innerText = bookObject.author;
const textYear = document.createElement('p');
textYear.innerText = bookObject.year;
const textContainer = document.createElement('div');
textContainer.classList.add('book_item');
textContainer.append(textTitle, textAuthor, textYear);
const container = document.createElement('div');
container.classList.add('item', 'shadow');
container.append(textContainer);
container.setAttribute('id', `book-${bookObject.id}`);
if (bookObject.isCompleted) {
const undoButton = document.createElement('button');
undoButton.classList.add('undo-button');
undoButton.addEventListener('click', function () {
undoBookFromCompleted(bookObject.id);
});
const trashButton = document.createElement('button');
trashButton.classList.add('trash-button');
trashButton.addEventListener('click', function () {
removeBookFromCompleted(bookObject.id);
});
container.append(undoButton, trashButton);
} else {
const checkButton = document.createElement('button');
checkButton.classList.add('check-button');
checkButton.addEventListener('click', function () {
addBookToCompleted(bookObject.id);
});
container.append(checkButton);
}
return container;
}
function addBookToCompleted (bookId) {
const bookTarget = findBook(bookId);
if (bookTarget == null) return;
bookTarget.isCompleted = true;
document.dispatchEvent(new Event(RENDER_EVENT));
saveData();
}
function findBook(bookId) {
for (const bookItem of books) {
if (bookItem.id === bookId) {
return bookItem;
}
}
return null;
}
function removeBookFromCompleted(bookId) {
const bookTarget = findBookIndex(bookId);
if (bookTarget === -1) return;
books.splice(bookTarget, 1);
document.dispatchEvent(new Event(RENDER_EVENT));
saveData();
}
function undoBookFromCompleted(bookId) {
const bookTarget = findBook(bookId);
if (bookTarget == null) return;
bookTarget.isCompleted = false;
document.dispatchEvent(new Event(RENDER_EVENT));
saveData();
}
function findBookIndex(bookId) {
for (const index in books) {
if (books[index].id === bookId) {
return index;
}
}
return -1;
}
function saveData() {
if (isStorageExist()) {
const parsed = JSON.stringify(books);
localStorage.setItem(STORAGE_KEY, parsed);
document.dispatchEvent(new Event(SAVED_EVENT));
}
}
const SAVED_EVENT = 'books';
const STORAGE_KEY = 'BOOK_APPS';
function isStorageExist(){
if (typeof (Storage) === undefined) {
alert('Browser kamu tidak mendukung local storage');
return false;
}
return true;
}
document.addEventListener(SAVED_EVENT, function () {
console.log(localStorage.getItem(STORAGE_KEY));
});
function loadDataFromStorage() {
const serializedData = localStorage.getItem(STORAGE_KEY);
let data = JSON.parse(serializedData);
if (data !== null) {
for (const book of data) {
books.push(book);
}
}
document.dispatchEvent(new Event(RENDER_EVENT));
document.addEventListener(SAVED_EVENT, function () {
console.log(localStorage.getItem(STORAGE_KEY));
})
}
Thats the javascript file
I’m writing a shopping cart in Django which uses sessions. I want to send the ID of the selected item to the server via Javascript’s fetch API. When I use HTML’s native form with method=post, my server app works correctly but when I use fetch API I get errors. Here is my button code:
<button class="btn btn-primary addtocart" id=2 onClick="GFG_click(this.id)">Add to Cart</button>
Here is the JavaScript:
<script>
function GFG_click(clicked) {
fetch('cart/add/', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
id : '1'
}),
})
.then((res) => JSON.stringify(res.json()))
.then((data) => {
// Do some stuff ...
})
.catch((err) => console.log(err));
}
</script>
Here is the Django’s URL pattern:
path('cart/add/', views.cart_add, name='cart_add')
Here is the cart_add view:
def cart_add(request):
if request.method == 'POST':
cart = Cart(request)
id = request.POST.get('id')
product = Product.objects.get(id=id)
cart.add(product=product)
return JsonResponse("success")
And this is the error I get:
Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
DoesNotExist at /playground/cart/add/
Product matching query does not exist.
Request Method: POST
Request URL: http://127.0.0.1:8000/playground/cart/add/
Django Version: 4.0.5
Exception Type: DoesNotExist
Exception Value:
Product matching query does not exist.
In this line:
product = Product.objects.get(id=id)
I am working with Reactjs (nextjs), i have two variable i just want that if my variable “first” is
empty then “second” variable should display,How can i do this ? I tried with following code but not working,
Where i am wrong ?
const Post = ({ post }) => {
const router = useRouter();
const first = post?.description_front_french
const second = post?.description_front
return (
<>
if(first)
return(
<>
<div className="product-des" dangerouslySetInnerHTML={{ __html: first }} />
<>
);
return
(
<>
<div className="product-des" dangerouslySetInnerHTML={{ __html: second }} />
<>
);
</>
);
};