|
DSB Audio (David Sweeney-Bear) wrote: const positionXY = [100, 25, 50, 75];
Aside from what was already said, in the interest of readability, you'd be better off using a object (or array of objects) to act as a hash map here.
const position = { left: 100, top: 25, right: 50, bottom: 75 };
console.log(position.left);
const positions = [{ x: 100, y: 25}, { x: 50, y: 75 }];
console.log(positions[0].x);
Jeremy Falcon
modified 15-Dec-22 17:26pm.
|
|
|
|
|
I have created a web API. If someone tried to loop through thousands of requests to the server (Programmatically), would it lower the performance of the web API?
|
|
|
|
|
Almost certainly. But only you can answer that - we don't have access to your server or your code.
Most APIs implement some form of rate limiting - if a single API key issues too many requests within a given window, the API responds with a 429 status code, and sets a header telling the caller how long they need to wait before trying again.
This won't prevent malicious or misconfigured clients from trying to overwhelm your service, but it should reduce the amount of strain they're able to put on your server. If you're really worried, then you'll need to sign up for a DDoS protection service.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have a problem with my modals. I'm creating my first portfolio website using js and the popup window is not working as I expect.
Everything works fine, only when I open the portfolio item and click "project details" each popup window has the same information about the item. Project name, category etc. do not change. What could be the problem? I will be grateful for your help.
link to project: <a href="https://codepen.io/bartekDD/pen/LYmLBKE">https://codepen.io/bartekDD/pen/LYmLBKE</a>[<a href="https://codepen.io/bartekDD/pen/LYmLBKE" target="_blank" title="New Window">^</a>]
|
|
|
|
|
Hello,
I want to dev an app with users, teachers, students, calendar, scheduler, etc... One user only can access to his own data, never can see other students or calendar of another user (except admin who can access to every data).
I dont know the best model for tthis app with mongodb. What is better:
1. Do every table as a little collection and put a userid key on every table
2. Do one big collection for every user and nested documents or collections for.every table.
What is the best options for a good scalable and performance?
Thanks, i hope u can gelp.me
|
|
|
|
|
Let me check to see if I have this correct. You want each type of user (teacher or student) to have a calendar and scheduler. If you never need to share calendars or schedules then having the calendar/schedule as a capability of the user is a clean way to manage this in Mongo.
|
|
|
|
|
Uff, I'm so sorry for my english. It's so hard for me explain my problem in not native language.
I have users, users can access to his data, and his data are students, teachers, shceduler, calendar, ...
This means, every user have his own data, and this data it's for app tables.
I have a mongodb, no sql.
Thanks, I hope I explained better now.
|
|
|
|
|
I am trying to implement pinch zoom in zoom out in js.
I am almost there, as I have calculated how to detect pinch zoom in zoom out in js using touch events.
....
var dist1=0;
function start(ev) {
if (ev.targetTouches.length == 2) {//check if two fingers touched screen
dist1 = Math.hypot( //get rough estimate of distance between two fingers
ev.touches[0].pageX - ev.touches[1].pageX,
ev.touches[0].pageY - ev.touches[1].pageY);
}
}
function move(ev) {
if (ev.targetTouches.length == 2 && ev.changedTouches.length == 2) {
// Check if the two target touches are the same ones that started
var dist2 = Math.hypot(//get rough estimate of new distance between fingers
ev.touches[0].pageX - ev.touches[1].pageX,
ev.touches[0].pageY - ev.touches[1].pageY);
//alert(dist);
if(dist1>dist2) {//if fingers are closer now than when they first touched screen, they are pinching
alert('zoom out');
}
if(dist1<dist2) {//if fingers are further apart than when they first touched the screen, they are making the zoomin gesture
alert('zoom in');
}
}
}
document.getElementById ('zoom_here').addEventListener ('touchstart', start, false);
document.getElementById('zoom_here').addEventListener('touchmove', move, false);
now i want to translate the img to keep zooming
n i want algo for translate
|
|
|
|
|
I want to create a campaign open window like the one below(cloud link : like excel file)
I want to insert an image and put the date in that location, how do I do that?
https://onedrive.live.com/edit.aspx?resid=329C341DE8ADE63E!14563&ithint=file%2cxlsx&authkey=!APuapFo6nWfcWGI
|
|
|
|
|
Member 15755181 wrote: how do I do that? Probably by writing some code.
|
|
|
|
|
You're going to have to describe, in detail, what a "campaign open window" is.
|
|
|
|
|
I am trying to number each result so that it says:
City #1 is Los Angeles.
City #2 is...
City #3 is...
... and so on.
I was thinking that I had to write something inside the for loop?
<html>
<body style="text-align: center;">
<h2 id="hi">Enter Your Five Favorite Cities</h2>
<form class="" action="index.html">
<input type="text" name="favoriteCities[]" value="" /><br>
<br>
<input type="text" name="favoriteCities[]" value="" /><br>
<br>
<input type="text" name="favoriteCities[]" value="" /><br>
<br>
<input type="text" name="favoriteCities[]" value="" /><br>
<br>
<input type="text" name="favoriteCities[]" value="" /><br>
<br>
<button type="button" name="button" onclick="favoriteCities()">Submit</button>
</form>
<h3 id="hi">Results</h3>
<p id="output"></p>
<script type="text/javascript">
var r = "";
function favoriteCities() {
var input = document.getElementsByName('favoriteCities[]');
for (var i = 0; i < input.length; i++) {
var a = input[i];
r = r + "City #" + "???" + "is " + a.value + ("<br>");
}
document.getElementById("output").innerHTML = r;
}
</script>
</body>
</html>
I am using Notepad++.
|
|
|
|
|
You already have a number, which you're using as the index in the for loop. You just need to add 1 to get the numbers to start at 1 instead of 0 .
You'll also want to HTML-encode the user-supplied data so that it displays properly. The simplest way to do that is to create an element and set its innerText property.
const favoriteCities = function() {
const output = document.getElementById("output");
output.innerHTML = "";
const input = document.getElementsByName("favoriteCities[]");
for (let i = 0; i < input.length; i++) {
const div = document.createElement("div");
div.innerText = `City #${i + 1} is ${input[i].value}`;
output.appendChild(div);
}
};
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Print the following pattern using for loop
*****
****
***
**
*
*
**
***
****
*****
|
|
|
|
|
You just need a loop that counts down from 5 to 1 and then up back to 5. Give it a try. If you need specific assistance with Javascript then go to JavaScript Tutorial[^].
|
|
|
|
|
I got it! Thnx
modified 29-Aug-22 21:01pm.
|
|
|
|
|
|
You have edited every question you have ever posted to read "I got it txh", after you have been given the answer.
This is not only extremely rude, it will NOT prevent your teachers from discovering your attempt to cheat on your homework.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
export class myClass implements OnInit {
counter=0;
static counter:any;
onListItemClick(PackDef: PackDefinition): void {
this.itemClicked.emit(PackDef);
this.counter++;
console.log(this.counter);
and
<pre>import { myClass } from '../../../';
dialogRef.afterClosed().subscribe((result: any) => {
this.saveMyMethod();
console.log("Final1"),
console.log(myClass.counter);
});
saveMyMethod(): void {
console.log("Final2"),
console.log(myClass.counter);
Do you know why I cant have correct counter after "Final1" or "Final2"? but I have a correct counter in myClass.
modified 26-Jul-22 12:58pm.
|
|
|
|
|
Afi_sh wrote: counter=0;
static counter:any;
Took a look at that part real closely.
Jeremy Falcon
|
|
|
|
|
Hello Everyone,
I am in a Core Technologies class and Javascript coding is a topic that I don't fully understand. For our coding assignment, we were directed to www.w3schools.com where we could try different codes, run them and see how they work. When given the original code, I understand how to change it and I see how the modification changes what is displayed but, I don't fully understand the basic elements of the code and how to start from scratch to write one. Can anyone help me out with understanding the basic elements of a code starting from scratch or could you suggest a website that can explain it from scratch? Thank you in advance for any help you can offer.
Regards,
John
|
|
|
|
|
W3Schools Online Web Tutorials[^] is probably the best site for learning web based technologies. So go to the Javascript section and follow it through, it will explain everything.
|
|
|
|
|
|
First, welcome to web development. It's an industry that only continues to grow. We'd be happy to help with specific questions.
As far as just getting started with all the concepts, nothing beats a good book. The website linked is great, but usually book authors take much more time to explain things.
I wish I could recommend a good current book, but I started web development back in the 90s. That crap is out of print by now I'm sure. But, once you do get the concepts, I can recommend a reference website. The Mozilla foundation (same peeps that make FireFox) have an online resource called the Mozilla Developer Network (MDN).
Learn web development | MDN[^]
It will literally be one of the best reference sites to use, once you get the concepts down.
Jeremy Falcon
|
|
|
|
|
Got it! Thnx
modified 29-Aug-22 21:01pm.
|
|
|
|