|
Thank you for your reply.
My code is a bit too long and I don't know which code snippet to include in here.
Can I close this message? I found the answer from somewhere else.
|
|
|
|
|
Hi, I need help turning this client side script code into pseudocode
var slideIndex,slides,dots,captionText;
function initGallery(){
slideIndex = 0;
slides=document.getElementsByClassName("imageHolder");
slides[slideIndex].style.opacity=1;
captionText=document.querySelector(".captionTextHolder .captionText");
captionText.innerText=slides[slideIndex].querySelector(".captionText").innerText;
if(slides.length<2){
var nextPrevBtns=document.querySelector(".leftArrow,.rightArrow");
nextPrevBtns.style.display="none";
for (i = 0; i < nextPrevBtn.length; i++) {
nextPrevBtn[i].style.display="none";
}
}
dots=[];
var dotsContainer=document.getElementById("dotsContainer"),i;
for (i = 0; i < slides.length; i++) {
var dot=document.createElement("span");
dot.classList.add("dots");
dotsContainer.append(dot);
dot.setAttribute("onclick","moveSlide("+i+")");
dots.push(dot);
}
dots[slideIndex].classList.add("active");
}
initGallery();
function plusSlides(n) {
moveSlide(slideIndex+n);
}
function moveSlide(n){
var i;
var current,next;
var moveSlideAnimClass={
forCurrent:"",
forNext:""
};
var slideTextAnimClass;
if(n>slideIndex) {
if(n >= slides.length){n=0;}
moveSlideAnimClass.forCurrent="moveLeftCurrentSlide";
moveSlideAnimClass.forNext="moveLeftNextSlide";
slideTextAnimClass="slideTextFromTop";
}else if(n<slideIndex){
if(n<0){n=slides.length-1;}
moveSlideAnimClass.forCurrent="moveRightCurrentSlide";
moveSlideAnimClass.forNext="moveRightPrevSlide";
slideTextAnimClass="slideTextFromBottom";
}
if(n!=slideIndex){
next = slides[n];
current=slides[slideIndex];
for (i = 0; i < slides.length; i++) {
slides[i].className = "imageHolder";
slides[i].style.opacity=0;
dots[i].classList.remove("active");
}
current.classList.add(moveSlideAnimClass.forCurrent);
next.classList.add(moveSlideAnimClass.forNext);
dots[n].classList.add("active");
slideIndex=n;
captionText.style.display="none";
captionText.className="captionText "+slideTextAnimClass;
captionText.innerText=slides[n].querySelector(".captionText").innerText;
captionText.style.display="block";
}
}
var timer=null;
function setTimer(){
timer=setInterval(function () {
plusSlides(1) ;
},3000);
}
setTimer();
function playPauseSlides() {
var playPauseBtn=document.getElementById("playPause");
if(timer==null){
setTimer();
playPauseBtn.style.backgroundPositionY="0px"
}else{
clearInterval(timer);
timer=null;
playPauseBtn.style.backgroundPositionY="-33px"
}
}
|
|
|
|
|
|
pseudocode is nothing more than a human description of an algorithm. You don't have to describe every single line of code, just the general idea of what's going on.
BUT! You DO have to understand what the code is doing and why. That part is up to you.
|
|
|
|
|
Post the code here so we can try it/check it for the problem that you say.
Reading the code on the images/screenshots is difficult, and is more difficult to debug it.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
|
Hi All
Could anybody help me to explain this block of code:
if(flakes[i].y>h){
flakes.splice(i,1)
}
in this project:https://jsfiddle.net/duymax/tpr5f0vL/2/
Thanks alot
|
|
|
|
|
Array.prototype.splice() - JavaScript | MDN[^]
If the item at the specified index in the array has fallen off the bottom of the viewport, that array item is deleted.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
Dear all
could anybody help me to code JS that:
when i mouseup cursor the ball shall not move follow the cursor.
When i mousedown and mousemove the ball shall follow the cursor.
here my code : https:
thanks alot
|
|
|
|
|
|
hello i copied a project in github have been trying to run it my local computer but its not working every time i run npm install i get this error
npm WARN hms@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
how do i solve this
|
|
|
|
|
You probably need to talk to the owner of the git repository.
|
|
|
|
|
Hi, I need help on this question
"We want to know whether to order a particular candy. We should make an order if the total number in stock (inStock) is less than the weekly average sold (weeklyAverage).
Create a function called shouldWeOrderThisCandy that takes in
the inventory array
a specific type of candy (string)
The function should find the candy in the array that matches the name passed in.
When that candy is found, return true if the number inStock is less than the weeklyAverage. Otherwise return false.
If the array doesn't have any candy with that name, return false
This is what I have so far.
function shouldWeOrderThisCandy(inventory, string) {
for (let i = 0; i < inventory.length; i++) {
if (inventory[i] === string && inStock < weeklyAverage) {
return true;
} else {
return false;
}
}
return false
}
|
|
|
|
|
So what help is it that you need?
|
|
|
|
|
Hi My modal popup has stopped working I think it could be because I have loaded similar scripts but new to this so don't know. These are the scripts that my _layout.cshtml tries to load:
<script src="/Scripts/jquery-1.10.2.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tabulator/4.4.3/js/tabulator.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/tabulator/4.4.3/css/bootstrap/tabulator_bootstrap.min.css" rel="stylesheet" />
<link href="https://nightly.datatables.net/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script src="/Scripts/jquery.signalR-2.1.1.js"></script>
The error I get is:
Uncaught TypeError: jQuery(...).modal is not a function
at Object.success (Create:34323)
at fire (jquery-1.10.2.js:3048)
at Object.fireWith [as resolveWith] (jquery-1.10.2.js:3160)
at done (jquery-1.10.2.js:8235)
at XMLHttpRequest.callback (jquery-1.10.2.js:8778)
|
|
|
|
|
Are you sure that the jQuery UI script is being loaded before the script which tries to create or show the jQuery UI Modal?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I can not be sure but I have it working again now. I have changed the order of the scripts to the following:
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tabulator/4.4.3/js/tabulator.min.js"></script>
<link href="https://nightly.datatables.net/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script src="~/Scripts/jquery.signalR-2.1.1.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/tabulator/4.4.3/css/bootstrap/tabulator_bootstrap.min.css" rel="stylesheet" />
Many thanks
|
|
|
|
|
Member 14695956 wrote: <script src="/Scripts/jquery-1.10.2.js"></script>
My guess, yuor jQuery version is quite old. Try latest and see. Current version: Download jQuery | jQuery
Quick check try:
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
Also, make sure reference to bootstrap JavaScript is after jquery file reference.
|
|
|
|
|
Hi Thanks for your reply I needed to keep this version of Jquery due to the fact that I am using signalr and I could only get it to work with this version. I have found a work around by not using jquery-confirm.min.js as this seems to also conflict. and use a Modal form as my alert box. May not be the neatest but it works.
|
|
|
|
|
Hi,
I am almost new with javascript.
I finally succeeded to write the foundation of a small javascript game but I am blocked at one point.
My question is simple: how can I call the function quitGame() from outside the Game() function?
[code]
var settings = "blablah";
new Game(settings);
...
quitGame(settings)
var Game = function(settings) {
...
function quitGame(settings) {
...
}
} [/code]
I would be thankful for any help or comment about my code.
I wish you a pleasant lockdown, stay safe
|
|
|
|
|
|
Working with objects - JavaScript | MDN[^]
The simplest option:
var Game = function(settings) {
...
this.quitGame = function(settings) {
...
}
};
var settings = "blablah";
var game = new Game(settings);
...
game.quitGame(settings);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Is there a way to get the extension of an image if you know it's link? At first I thought of splitting the string with . and get the last part, but the problem with this is that there are some links that don't include the extension at the end so this is not an universal solution.
Because I know the link each time, is there something I can do with an image object (new Image), or how else can I get the extension? All the results I got were to check if it is an image but not it's extension, or the one I explained above, but that won't work in every scenarios.
This will be done in a extension for Firefox.
modified 9-Nov-20 16:23pm.
|
|
|
|
|
mebbe something like...
file = url.split('/').pop();
|
|
|
|