r/JavaScriptHelp • • Nov 20 '21

❔ Unanswered ❔ Error: Infinite loading

2 Upvotes

https://ibb.co/0QPNBV9

I get this error. I am in need of help.

Here are the codes:

var salesChartCanvas = $('#salesChart').get(0).getContext('2d')

var salesChartData = {

labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],

datasets: [

{

label: 'Digital Goods',

backgroundColor: 'rgba(60,141,188,0.9)',

borderColor: 'rgba(60,141,188,0.8)',

pointRadius: false,

pointColor: '#3b8bba',

pointStrokeColor: 'rgba(60,141,188,1)',

pointHighlightFill: '#fff',

pointHighlightStroke: 'rgba(60,141,188,1)',

data: [28, 48, 40, 19, 86, 27, 90]

},

{

label: 'Electronics',

backgroundColor: 'rgba(210, 214, 222, 1)',

borderColor: 'rgba(210, 214, 222, 1)',

pointRadius: false,

pointColor: 'rgba(210, 214, 222, 1)',

pointStrokeColor: '#c1c7d1',

pointHighlightFill: '#fff',

pointHighlightStroke: 'rgba(220,220,220,1)',

data: [65, 59, 80, 81, 56, 55, 40]

}

]

}

var salesChartOptions = {

maintainAspectRatio: false,

responsive: true,

legend: {

display: false

},

scales: {

xAxes: [{

gridLines: {

display: false

}

}],

yAxes: [{

gridLines: {

display: false

}

}]

}

}

// This will get the first returned node in the jQuery collection.

// eslint-disable-next-line no-unused-vars

var salesChart = new Chart(salesChartCanvas, {

type: 'line',

data: salesChartData,

options: salesChartOptions

}

)


r/JavaScriptHelp • • Jan 07 '22

❔ Unanswered ❔ Help with JS Webpage query

2 Upvotes

Hey guys,

I have a website that I am trying to implement a dark mode on. Unfortunately because of how it is set up applying the below script to 'body' does not apply to all of the elements i need it to apply to.

         });
              $( ".change" ).on("click", function() {
            if( $( "body" ).hasClass( "dark" )) {
                $( "body" ).removeClass( "dark" );
                $( ".change" ).text( "OFF" );
            } else {
                $( "body" ).addClass( "dark" );
                $( ".change" ).text( "ON" );
              
            }
        });

As you can see this will apply a class to the body which amends the styling of the element. However I cannot seem to figure out how to apply this to multiple elements and so far the only fix I have is a super inelegant solution:

 $( ".change" ).on("click", function() {
            if( $( ".topbar ul.nav>li>a" ).hasClass( "dark" )) {
                $( ".topbar ul.nav>li>a" ).removeClass( "dark" );
                $( ".change" ).text( "OFF" );
            } else {
                $( ".topbar ul.nav>li>a" ).addClass( "dark" );
                $( ".change" ).text( "ON" );
              
            }
        });
              $( ".change" ).on("click", function() {
            if( $( ".container" ).hasClass( "dark" )) {
                $( ".container" ).removeClass( "dark" );
                $( ".change" ).text( "OFF" );
            } else {
                $( ".container" ).addClass( "dark" );
                $( ".change" ).text( "ON" );
              
            }
        });

As you can see I am just copying the script and pasting it below for all of the additional elements that I need the class added to. Does anyone know how I can reduce this because this is janky as hell and I cannot find anything online to help.


r/JavaScriptHelp • • Jan 03 '22

✔️ answered ✔️ Load a page then perform a click

2 Upvotes

After a backend call, I need to redirect a user to a page then put them on the correct tab. I tried this

$('body').load('http://localhost:8085/abc/def/123', function() { 
	document.getElementById('foo').click(); 
});

But there are some issues. Some of my layout loads incorrectly. Perhaps it's because the page is loaded into the body tag?

Is there perhaps some other way I can do this?

Thanks.


r/JavaScriptHelp • • Dec 22 '21

❔ Unanswered ❔ Adobe Acrobat Custom Calculation

1 Upvotes

I am creating a fillable rent roll in Acrobat for work and am having trouble with a nuanced calculation. The calculation is based on the number of vacant units in a building and their corresponding square footage. I am wondering if it is possible to write an if-then calculation based on if a check box is filled? If someone has any advice on the best way to write this script, it would be much appreciated. Also, if I am in the wrong place, please point me to a more appropriate community.

Note: I am new to both Acrobat and Java but I have created 85% of the forms I need to and can't finish the rest until I figure out how to write this calculation. I also posted this in r/Acrobat but they don't have many members. (To add context on how little I know: I also posted in r/javahelp not realizing the difference between the language.)


r/JavaScriptHelp • • Dec 30 '21

❔ Unanswered ❔ Appending Text fields to email subject line

1 Upvotes

I have a PDF that I'm editing in NitroPDF Pro. There are two text fields in the PDF that I would like to use to compose the subject line. The first text field is labeled Date and the second text field is labeled Time. No matter what I try the file name of the PDF is what is appended to the subject line. I tried using the code below but to no avail. I know nothing about Java Script so any help would be greatly appreciated. Thanks for your time!

var Date = getField("Date").value; var Time = getField("Time").value;

cSubject: "ADVERT: "+Date+" "+Time+"


r/JavaScriptHelp • • Nov 24 '21

❔ Unanswered ❔ Copy to clipboard without HTML?????

2 Upvotes

How do I copy to the clipboard without using html, but with only JavaScript? Is there even a way?