In this question it’s clarified.
However I just noticed that create-amplify can be executed like this:
npm create amplify
So does npx and npm work the same way now?
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
Category Added in a WPeMatico Campaign
In this question it’s clarified.
However I just noticed that create-amplify can be executed like this:
npm create amplify
So does npx and npm work the same way now?
I don’t need to support this behavior as a library author or anything, but if I wanted to run something in my own project before yarn install, is there really no way to do that anymore since preinstall was removed?
I would like to select the text that was entered in the input field without using jQuery or any other library. Only using Vanilla JS. The goal is to check whether the word was fully selected. If it is only part of the word, in the console will be outputed the responsive message, that is isn`t still full word. But after achieving full word, will be outputed responsive message
<form id="login">
<div class="form-group">
<label for="username">Username</label>
<input id="username" type="text" name="username">
</div>
</form>
I created a responsive mobile navbar with a toggle button. One can open and close the toggle button by clicking on it. However when the links inside the mobile navbar are clicked, the page scrolls down to the respective section but the mobile navbar remains open.
I tried to create a cons links and select all the links with getElementById abd to remove the status active but after the link being clicked but the code does not work.
Here is my HTML code:
<div class="dropdown-menu">
<ul>
<li><a href="#home" id="links">Home</a></li>
<li><a href="#about" id="links">About</a></li>
<li><a href="#projects" id="links">Projects</a></li>
<li><a href="#contact" id="links">Contact</a></li>
</ul>
</div>
And here is the JS code:
const toggleBtn = document.querySelector('.toggle-btn')
const toggleBtnIcon = document.querySelector('.toggle-btn i')
const dropDownMenu = document.querySelector('.dropdown-menu')
toggleBtn.onclick = function () {
dropDownMenu.classList.toggle('open')
const isOpen = dropDownMenu.classList.contains('open')
toggleBtnIcon.classList = isOpen ? 'fa-solid fa-xmark' : 'fa-solid fa-bars'
}
In an attempt to find unused translations in an application, I’d like to find all passed arguments to a function that can be statically determined. What’s the best way to go about this problem? Introspection? Using code mods or similar that can parse the AST?
Scenarios that I’d like to cover are e.g.:
translate("abc"); // "abc"const arg = "abc"; translate(arg); // "abc"const arg1 = "abc"; const arg2 = "xyz"; translate(arg1 + arg2); // "abcxyz"const arg1 = "abc"; const arg2 = "xyz"; const arg = arg1 + arg2; translate(arg); // "abcxyz"const arg = "abc"; const getArg = () => arg; translate(getArg()); // "abc"If there are also non-static invocations on the form translate(getUserInput()), then I’d be happy if I could get that as well as "getUserInput()" or similar. But this scenario is not crucial.
I would like to get an array of all arguments, not having to “review search results” in the editor or terminal.
Any tips out there?
for(var i=1;i<10;++i){
setTimeout(()=>{
console.log(i);
},1000)
}
// Print 1 to 10 numbers using var only with setTimeout
I am currently using the free version of Metabase for learning and testing purposes. I’ve set up two dashboards for two different users based on hardcoding state names into the filters. The expectation is that users should only be able to view data for their respective states.
For example, if a user from Karnataka login, they should only see data related to Karnataka, and similarly for another user from a different state.
The Problem:
When a user from Karnataka logs in, they are initially presented with the correct data. However, if they manually modify the URL and change the query parameter from select_state=Karnataka to another state like select_state=Kerala, they can then access data for Kerala, which should not be permitted.
For example:
Original URL (working as expected):
/dashboard/4-state-report-karnataka?state_param=Karnataka
Modified URL (security issue):
/dashboard/4-state-report-karnataka?state_param=Kerala
I would appreciate your help in fixing this issue or guiding me towards the correct way to implement state-specific access restrictions that cannot be overridden by URL changes.
Thank you for your attention to this matter!
Created two dashboards for each state user with the same question card, But state user-1 logs in and manipulates URL and sees data of other state
This unauthorised access exposes data from other states, which breaks the intended state-specific restrictions. My expectation was that each user would be restricted to their own state data, regardless of any changes they make to the URL.
I am trying to display a variant metafield that has a “predicted date of arrival” on my product pages. I have already created the variant metafield and added the values.
I am also able to display the current variant metafield in my product pages. However, the value does NOT change when I select a different variant.
I am using the Expanse theme and I have duplicated the code for displaying variant SKUs in the product pages. I have edited this code to render the variant metafield.
Can someone check my code and help me fix the issue?
I’d really appreciate it.
Here is the working code for Variant SKUs:
{%- liquid
assign product = section.settings.product | default: product
-%}
<variant-sku data-product-id="{{ product.id }}" data-section-id="{{ section.id }}">
{%- if variant.sku != blank -%}
SKU: {{ variant.sku }}
{%- endif -%}
</variant-sku>
<script type="module">
import 'components/variant-sku'
</script>
import { EVENTS, subscribe } from '@archetype-themes/utils/pubsub'
class VariantSku extends HTMLElement {
connectedCallback() {
this.variantChangeUnsubscriber = subscribe(
`${EVENTS.variantChange}:${this.dataset.sectionId}:${this.dataset.productId}`,
this.handleVariantChange.bind(this)
)
}
disconnectedCallback() {
this.variantChangeUnsubscriber?.()
}
handleVariantChange({ detail }) {
const { html, sectionId, variant } = detail
if (!variant) {
this.textContent = ''
return
}
const skuSource = html.querySelector(`[data-section-id="${sectionId}"] variant-sku`)
if (skuSource) {
this.textContent = skuSource.textContent
}
}
}
customElements.define('variant-sku', VariantSku)
Here is my NON working code for displaying the Variant Metafield:
{%- liquid
assign product = section.settings.product | default: product
-%}
<variant-meta data-product-id="{{ product.id }}" data-section-id="{{ section.id }}">
( ships approx: {{ variant.metafields.variant.date | replace: 'predicted-arrival-','' }} )
</variant-meta>
<script type="module">
import 'components/variant-metafield'
</script>
import { EVENTS, subscribe } from '@archetype-themes/utils/pubsub'
class VariantMeta extends HTMLElement {
connectedCallback() {
this.variantChangeUnsubscriber = subscribe(
`${EVENTS.variantChange}:${this.dataset.sectionId}:${this.dataset.productId}`,
this.handleVariantChange.bind(this)
)
}
disconnectedCallback() {
this.variantChangeUnsubscriber?.()
}
handleVariantChange({ detail }) {
const { html, sectionId, variant } = detail
if (!variant) {
this.textContent = ''
return
}
const metaSource = html.querySelector(`[data-section-id="${sectionId}"] variant-meta`)
if (metaSource) {
this.textContent = metaSource.textContent
}
}
}
customElements.define('variant-meta', VariantMeta)
Npm starting issue
I intended to resume my react project.when I try to entering npm start comment ,it stucks and happens nothing. Even after installed all required packages there happens nothing! sometimes it starts and stuck within a second!
I have a array of messages messages = await ChatMessage.find() , each message has replyTo field which is defined as mongoose.Schema.Types.ObjectId referencing ref:chattingMessage document.
In db , replyTo stores references of two types of objects chattingMessage and groupMessage.
I want to populate replyTo given it stores references to any type objects.
I implemented a function which populates all the messages which are referenced to chattingMessage correctly but fails for groupMessage. Here is the implementation.
// chattingMessage -> ChatMessage , groupMessage -> Message
async function populateReplyTo(messages) {
const populatedMessages = await Promise.all(messages.map(async (message) => {
if (message.replyTo) {
let replyMessage = await ChatMessage.findById(message.replyTo);
if (!replyMessage) replyMessage = await Message.findById(message.replyTo);
if (replyMessage) {
console.log('Found replyMessage:', replyMessage); // even though it console logs correctly
message.replyTo = replyMessage; // populated message is not assigned ??
} else {
console.log('No replyMessage found, assigning null');
message.replyTo = null;
}
}
if (message.replyTo && message.replyTo.sender) {
const replySender = await User.findById(message.replyTo.sender).select('_id username name');
if (replySender) {
message.replyTo.sender = replySender;
}
}
return message;
}));
console.log(populatedMessages)
return populatedMessages;
}
Here is logging of terminal
Found replyMessage: {
_id: new ObjectId("6714e824c212c22e48b96c89"),
sender: new ObjectId("6714e1acc212c22e48b92089"),
content: 'hii',
chat: new ObjectId("66604d0079ebab20eec4da73"),
replyTo: null,
status: 'Read',
messageType: 'ChatMessage',
deletedBy: [],
reports: [],
isDeleted: false,
attachments: [],
createdAt: 2024-10-20T11:23:16.998Z,
updatedAt: 2024-10-23T13:45:07.054Z,
__v: 0
} but populated one is not assigned , instead i only find reference in replyTo
[
{
_id: new ObjectId("671681fada25dcde60b63526"),
sender: new ObjectId("66dafffec77d3018b2b0ddb3"),
receiver: new ObjectId("6714e1acc212c22e48b92089"),
messageType: 'ChatMessage',
subscriptionRequestMessageAction: 'none',
message: 'where to start',
replyTo: new ObjectId("9023e824c212c22e48b96c89"), // why reference , even though I got the object logged above
status: 'Read',
deletedBy: [],
reports: [],
createdAt: 2024-10-21T16:31:54.514Z,
updatedAt: 2024-10-23T15:47:24.551Z,
__v: 0
}
]
clearly there is a problem in assignment. or Am I missing something. Any help is appreciated..
I have 3 charts on a component in my angular app.
I need to create text label plugins to show on the chart. Each chart needs to have specific plugin assigned to it. I have searched a lot and could not find any solution.
As of now i am registering the plugins globally with Chart.register() which is making the appearance undesirable because all of the label plugins gets applied to all of the charts.
is there any way to apply specific plugins to specific charts?
I am using ng2-charts and defining my charts like with BaseChartDirective.
@ViewChildren(BaseChartDirective) charts?: QueryList<BaseChartDirective>;
I am creating plugins like this
function createLabelPlugin(text: string, xPosition: number, yPosition: number) {
return {
id: 'customLabelPlugin',
afterDraw(chart: any) {
const ctx = chart.ctx;
ctx.save();
ctx.font = 'bold 16px Arial';
ctx.fillStyle = 'black';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
// Draw the text at the specified position
ctx.fillText(text, xPosition, yPosition);
ctx.restore();
}
};
}
there is no way i am able to proceed past the very first page of my site in node. i click login but i am stuck there. i tried so much with gpt and claude, too much changes in my file now, but no progress.
this is my github repository, please help
https://github.com/sagarsth/mel-tool.git
i tried changing index, login, root, vit-config, json-config, remix-config, it all started after changed in team.tsx where i tried to same data and ID logs to track chnaged in created field.
I have this prefix
nuxt.config.js
export default {
router: {
base: ''
},
}
Now I want to check when window width less than 768px, the router base will change to
router: {
base: '/sp'
},
How can I do this?
I created a simple image lightbox using JavaScript. But I couldn’t manage to do smooth transitioning while opening and closing it. I tried transition and/or animation properties but couldn’t succeed. I appreciate if you can tell me what I should do to smoothly open and close the lightbox on “click” and “Escape key” events.
const images = document.querySelectorAll('img');
const container = document.querySelector('.container');
const divEl = document.createElement('div');
const img = document.createElement('img');
divEl.id = 'overlay';
divEl.className = 'overlay';
img.id = 'invisibleImg';
function reset() {
divEl.classList.remove('active');
img.src = '';
}
container.appendChild(divEl);
for (let i = 0; i < images.length; i++) {
images[i].addEventListener('click', () => {
divEl.classList.add('active');
img.src = images[i].src;
divEl.appendChild(img);
divEl.addEventListener('click', function (e) {
if (e.target === e.currentTarget) reset();
});
document.addEventListener('keydown', function (e) {
if (e.key === 'Escape') reset();
});
});
}
#overlay {
display: none;
}
#overlay.active {
display: block;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.9);
}
#invisibleImg {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 300px;
aspect-ratio: 1;
cursor: default;
padding: 12px;
background-color: white;
}
Error Images.
I have been recently working on my website however, ever since I started using JavaScript to try to inherit the navbar and the footer to every page, I would get a 404 error.
When the page loads, it suppose to load in the Navbar.html and the Footer.html that are from the components folder. The JavaScript or scripts.js would fetch the Navbar.html and Footer however it returns with an error.
ErrorLog
components/footer.html:1
Failed to load resource: the server responded with a status of 404 ()
scripts.js:13 Error: Error: Failed to load footer
at scripts.js:5:19
(anonymous) @ scripts.js:13
components/navbar.html:1
Failed to load resource: the server responded with a status of 404 ()
scripts.js:28 Error: Error: Failed to load navbar
at scripts.js:20:19
(anonymous) @ scripts.js:28
// script.js
// Load footer from footer.html
fetch('../../components/footer.html')
.then(response => {
if (!response.ok) {
throw new Error('Failed to load footer');
}
return response.text();
})
.then(data => {
document.getElementById('footer-placeholder').innerHTML = data;
})
.catch(error => {
console.error('Error:', error);
});
// Load navbar from navbar.html
fetch('../../components/navbar.html')
.then(response => {
if (!response.ok) {
throw new Error('Failed to load navbar');
}
return response.text();
})
.then(data => {
document.getElementById('navbar-placeholder').innerHTML = data;
})
.catch(error => {
console.error('Error:', error);
});
// index.html within body tag
<body>
<div class="container mt-5">
<!-- Navbar will be placed here -->
<div class="navbar-placeholder"></div>
<!-- Footer will be loaded here -->
<div id="footer-placeholder"></div>
</div>
// Scripts
<script src="./assets/js/scripts.js"></script>
</body>
Portfolio-Website/
├── .gitattributes
├── .gitignore
├── index.html
├── README.md
├── .git/
├── .vs/
├── assets/
│ ├── css/
│ │ └── style.css
│ ├── images/
│ │ ├── Graduate/
│ │ │ └── graduate.png
│ │ ├── movielist/
│ │ │ └── movielist.png
│ │ └── resume/
│ │ └── IMG_1301.jpg
│ └── js/
│ └── scripts.js
├── components/
│ ├── footer.html
│ └── navbar.html
├── pages/
│ ├── about.html
│ ├── contact.html
│ ├── graduation-invite.html
│ ├── movie-ranking.html
│ └── resume.html
Repository: https://github.com/Francefernance12/Portfolio-Website.git
Website: https://francefernance12.github.io/Portfolio-Website/
I tried to change the relative paths in various ways, use error handling in the JS file by using the website developer tools, and I even use AI chatgpt to check if my Javascript code was correct. It resulted in the same fetching error. I am not sure if its the problem with github pages hosting or if its due to my codes.