Search the Community
Showing results for tags 'javascript'.
-
javascript Need help with some javascript code. Just leaning
HoennHero posted a topic in Programming
Hello I'm wondering if I can get some input on This very simple program I'm writing as part of my learning javascript. what I'm trying to accomplish is to ask the user a question, using a prompt command. Take the data they provide and give one of two responses. This also might be the wrong place to ask this is so could you direct to a relevant source? The problem is that after asking the user for Yes or No the desired response is not displayed // I'm trying have the user enter Yes or No, this should be put into the variable answer, if im correct. var answer = prompt("Jacob loves Pizza, do you like pizza to? Yes or No?."); if (answer == Yes) { alert("Jacob is glad"); } if (answer == No) { alert("Jacob doesn't believe you..."); } //thanks in advance for any help! I have included the .js file below script.js- 8 replies
-
- codeing
- trouble shooting
-
(and 1 more)
Tagged with:
-
Some of you may have saw a post from yesterday asking the same thing, but now I've advanced a little in my project. So this project asks me to: I have limited knowledge on JS and would only like to use what I so have already - loops and related are possibly out of the question. I have gotten most of it done ( I think ) but am stumped on getting one functions data into another. My code: https://js.do/code/ohgoodgodwhatamidoing
-
Hello, So, I've been toying with some code in Snap! (An awesome Scratch mod that allows you to code directly in JS) trying to create a tileset generator for a game I'm working on, however the issue I'm having is that tiles are not rotating as intended. The math for my calculations appears correct however rotation is not occurring as intended. rot refers to the rotation around the viewpoint in degrees. this.tWidth refers to the width of a tile rotated by an angle. this.tHeight refers to the height of a tile rotated by an angle. // Ensure we're not drawing. this.up(); // Dimensions of our tilemap. wide = 2; high = 2; //convert our angle in degrees to radians. ang = (rot) * (3.1415 / 180); // Lists containing all valid points along the X and Y axis. cX = []; cY = []; // Generate list of all valid locations along the X axis. clock = 0; while (clock < wide) { cX.push((Math.sin(ang) * (this.tWidth[rot] * clock)) - (Math.cos(ang) * (this.tHeight[rot] * clock))); clock = clock + 1; }; // Generate list of all valid locations along the Y axis. clock = 0; while (clock < high) { cY.push((Math.cos(ang) * (this.tWidth[rot] * clock)) + (Math.sin(ang) * (this.tHeight[rot] * clock))); clock = clock + 1; }; //Draw the grid, rotated by X amount of degrees. rendX = 0; while (rendX < cX.length) { rendY = 0; while (rendY < cY.length) { this.gotoXY(cX[rendX], cY[rendY]); this.doStamp(); rendY = rendY + 1; }; rendX = rendX + 1; } If anyone can spot what's wrong with my math here, it would be very much appreciated.
-
Using THREE.JS to display object with realtine change as well
kebo2015 posted a topic in Programming
I was wondering if anyone here knows anything on Three.JS if so please help me: I am new to using Three.JS and webgl and I was wondering if there was a way to change elements on a 3d file in real time. I have a file that I need to simulate LEDs changing over a period of time. At first from what I had gathered I thought the simplist way to do it was to make multiple UV images with blender for my sequence and change the MTL file in a loop to point at the different images. The problem with this was was that I couldn't get the OBJ to even show up with the MTL loader. I could only get the OBJ in plain white without MTL loader. So my real issue is, 1) why won't my MTL show my png layer with my OBJ 2) how can I best animate it? Thanks and let me know if you have questions. -
I am creating a web interface for a programs web api. Basically, when you go to certain urls, it will cause certain things to happen within the program. One feature is to go to localhost:35747/currentsong and the webpage will show: <html class="gr__localhost"><head><link rel="alternate stylesheet" type="text/css" href="resource://gre-resources/plaintext.css" title="Wrap Long Lines"></head><body data-gr-c-s-loaded="true"><pre>{"Played":true,"Album":"This Town (Single)","Artist":"Niall Horan","AudioUrl":"http://mediaserver-sv5-rt-1-v4v6.pandora.com/access/5432348434435674266.mp4?version=5\u0026lid=1043894297\u0026token=HYP%2BTNubLzUPabITlCUwnDhIBiumWp88GR69hgfKEppuKTdi2DfbGtfRLai60zFqmWuxVnl%2FTKphteoCZ2YfPU6yO0jSFY%2F8SUwaPMWI1VDepyELxjOzceRHhj0WEbG3YDcNkcrQqa3wFuK%2Brrk4yix3gmYYF8MPLN2f62bYA2p%2FscYyA9dVf2jEGC3OC5fxRFRNzRXv9gcTUV%2BCXal8cJoBG3o2pyA4vTaqnn2n6z7Htt4XwPxBfPXNcHEbq3aFUomtMobL2vhhiOCHKL%2FbL6SFTqBZizoGX3fKOj9JQFtk4xlGyrZWJurXRWo8RLFVB3u8XxHWS2n6CLgYk6chZ9YwIRfelNpm0lPLbuSKT3eyXnjhIr4u66rG%2BJO8WrZMssdj%2FSJx%2BbmOjS3aYj68zyWLApyvTOJmD8QR2BS%2FpUsxABL5ohTe0T8UwSPGXaRveFLtXOFzjTMia0qumpV4QXtZzVrAbKBBYsgcmlySpu%2FoHOkH%2BvE6iCUkeuSfl79UgI9nomHkRfMcyMg9JgBJ4Mqc43jJGMN3eTMGECsXlS0oxhgP426Qtw%3D%3D","FileGain":-5.26,"Rating":2,"Loved":false,"Banned":false,"RatingString":"none","StationID":"2942869338374836249","TrackToken":"P5fbtkfFjlW9vrl8YUmd-G5rmpYHZEXMkjoo3nYr6CzWJvfB-wp244FYoYhcWtu5IyMLMxDrfQ8DFPfyAFcDu4Q","SongTitle":"This Town","SongDetailUrl":"http://www.pandora.com/niall-horan/this-town-single/this-town?dc=232\u0026ad=1:28:1:03811::0:0:0:0:506:247:NH:33015:0:0:0:0:0:1","ArtistDetailUrl":"http://www.pandora.com/niall-horan?dc=232\u0026ad=1:28:1:03811::0:0:0:0:506:247:NH:33015:0:0:0:0:0:1","AlbumDetailUrl":"http://www.pandora.com/niall-horan/this-town-single?dc=232\u0026ad=1:28:1:03811::0:0:0:0:506:247:NH:33015:0:0:0:0:0:1","AlbumArtUrl":"http://mediaserver-cont-sv5-3-v4v6.pandora.com/images/public/int/7/2/4/2/00602557202427_500W_500H.jpg","AmazonAlbumID":"B01M0X2A3D","AmazonTrackID":"B01LYB7M23","Tired":false,"StartTime":"\/Date(-62135578800000)\/","Finished":false,"PlaylistTime":1478107302,"Station":{"ID":"2942869338374836249","IdToken":"2942869338374836249","IsCreator":true,"IsQuickMix":false,"Name":"Nuzzle 2?","UseQuickMix":true,"ArtUrl":null,"InfoUrl":"https://www.pandora.com/login?target=%2Fstations%2F88381d024083c8417d0439a5c5229e9576c0cf7739194ea6","ThumbsUp":0,"ThumbsDown":0,"ArtCacheFile":"C:\\Users\\nuzzl\\AppData\\Roaming\\Elpis\\Cache\\Station_2942869338374836249","SkipLimitReached":false,"SkipLimitTime":"\/Date(-62135578800000)\/"},"IsStillValid":true}</pre></body></html> Anway, THis is the part that matters: <pre>{"Played":true,"Album":"This Town (Single)","Artist":"Niall Horan","AudioUrl":"http://mediaserver-sv5-rt-1-v4v6.pandora.com/access/5432348434435674266.mp4?version=5\u0026lid=1043894297\u0026token=HYP%2BTNubLzUPabITlCUwnDhIBiumWp88GR69hgfKEppuKTdi2DfbGtfRLai60zFqmWuxVnl%2FTKphteoCZ2YfPU6yO0jSFY%2F8SUwaPMWI1VDepyELxjOzceRHhj0WEbG3YDcNkcrQqa3wFuK%2Brrk4yix3gmYYF8MPLN2f62bYA2p%2FscYyA9dVf2jEGC3OC5fxRFRNzRXv9gcTUV%2BCXal8cJoBG3o2pyA4vTaqnn2n6z7Htt4XwPxBfPXNcHEbq3aFUomtMobL2vhhiOCHKL%2FbL6SFTqBZizoGX3fKOj9JQFtk4xlGyrZWJurXRWo8RLFVB3u8XxHWS2n6CLgYk6chZ9YwIRfelNpm0lPLbuSKT3eyXnjhIr4u66rG%2BJO8WrZMssdj%2FSJx%2BbmOjS3aYj68zyWLApyvTOJmD8QR2BS%2FpUsxABL5ohTe0T8UwSPGXaRveFLtXOFzjTMia0qumpV4QXtZzVrAbKBBYsgcmlySpu%2FoHOkH%2BvE6iCUkeuSfl79UgI9nomHkRfMcyMg9JgBJ4Mqc43jJGMN3eTMGECsXlS0oxhgP426Qtw%3D%3D","FileGain":-5.26,"Rating":2,"Loved":false,"Banned":false,"RatingString":"none","StationID":"2942869338374836249","TrackToken":"P5fbtkfFjlW9vrl8YUmd-G5rmpYHZEXMkjoo3nYr6CzWJvfB-wp244FYoYhcWtu5IyMLMxDrfQ8DFPfyAFcDu4Q","SongTitle":"This Town","SongDetailUrl":"http://www.pandora.com/niall-horan/this-town-single/this-town?dc=232\u0026ad=1:28:1:03811::0:0:0:0:506:247:NH:33015:0:0:0:0:0:1","ArtistDetailUrl":"http://www.pandora.com/niall-horan?dc=232\u0026ad=1:28:1:03811::0:0:0:0:506:247:NH:33015:0:0:0:0:0:1","AlbumDetailUrl":"http://www.pandora.com/niall-horan/this-town-single?dc=232\u0026ad=1:28:1:03811::0:0:0:0:506:247:NH:33015:0:0:0:0:0:1","AlbumArtUrl":"http://mediaserver-cont-sv5-3-v4v6.pandora.com/images/public/int/7/2/4/2/00602557202427_500W_500H.jpg","AmazonAlbumID":"B01M0X2A3D","AmazonTrackID":"B01LYB7M23","Tired":false,"StartTime":"\/Date(-62135578800000)\/","Finished":false,"PlaylistTime":1478107302,"Station":{"ID":"2942869338374836249","IdToken":"2942869338374836249","IsCreator":true,"IsQuickMix":false,"Name":"Nuzzle 2?","UseQuickMix":true,"ArtUrl":null,"InfoUrl":"https://www.pandora.com/login?target=%2Fstations%2F88381d024083c8417d0439a5c5229e9576c0cf7739194ea6","ThumbsUp":0,"ThumbsDown":0,"ArtCacheFile":"C:\\Users\\nuzzl\\AppData\\Roaming\\Elpis\\Cache\\Station_2942869338374836249","SkipLimitReached":false,"SkipLimitTime":"\/Date(-62135578800000)\/"},"IsStillValid":true}</pre> I want my webpage (Hosten on localhost:80) to be able to take the information above, and but it accordingly into titled sections, for example, in the above, it says "Loved":false. I wan't the html to say "False". And the same for everything else, the song tame, artist, ablum image, ect. If your wondering, this program is called ELPIS, a custom pandora client.
-
I am trying to get a better understanding on how Associative arrays work before I tackle my assignment. I made a function that created the reindeer name array and name array. I have the prompt asking for a name, in this case it's going to be blitzen to test it out. I just need to know what I am doing wrong. Thanks again in advanced for the help. var $ = function(id) {return document.getElementById(id); }//end $ window.onload = function () { //Provide answer for Question 1 here ////////////////////// associatve(); } function associatve () { var reindeer =[]; reindeer["name"]="blitzen","comet","cupid","dancer","dasher","donner","prancer", "rudolph","vixen","bumble"; var blitzen = reindeer["name"]=[0];//should equal blitzen var comet = reindeer["name"]=[1]; //should equal comet var cupid = reindeer["name"]=[2]; //should equal cupid var dancer = reindeer["name"]=[3]; //should equal dancer var dasher = reindeer["name"]=[4]; //should equal dasher var donner = reindeer["name"]=[5]; //should equal donner var prancer = reindeer["name"]=[6]; //should equal prancer var rudolph = reindeer["name"]=[7]; //should equal rudolph var vixen = reindeer["name"]=[8]; //should equal vixen var bumble = reindeer["name"]=[9]; //should equal bumble var user=prompt("enter a name"); var inputFromUser = user; if(inputFromUser==reindeer["name"][0]) //or should it be this //if(inputFromUser==blitzen) { alert("you got it"); } else { alert("Try again"); } }
-
The issue that I am running into is, When the user enters "bat","witch","ghost", and an "unknown"(not a bat, ghost, or a witch). It keeps a counts and shows the image of a bat,ghost,witch,and an unknown x number of times that it was entered. The unknown image keeps showing up when the user types in either a ghost or bat or witch and even when the user types in "done" to stop the count. It shows an unknown was entered. Any help would be appreciated. There are 3 functions in the java Script , The problematic functions are (displaythemspooks, spooks,displaythemspookspic). Thanks in Advanced!!! var $ = function(id) {return document.getElementById(id); }//end $ window.onload = function () { //Provide answer for Question 1 here document.getElementById("title").innerHTML = (" <h1> JavaScript Control Structures Test Document.</h1>"); ////////////////////// testQuestion2(); testQuestion3(); } //////////////////////////////////////////////////////// function oddOrEven(inputFromUser)//the input from the user { document.writeln("<ul>");//start of the unorder list if(isNaN(inputFromUser)||inputFromUser==="")//if the input is not a number //or is blank { for(var counter=1; counter<=10; counter++) { if(counter % 2 == 0)//even { document.writeln("<li>"+ counter+ "Is Even.</li>"); } else { document.writeln("<li>" + counter+ "Is Odd.</li>"); } } } else { for(var counter=1;counter<=inputFromUser;counter++) { if(counter % 2 == 0) { document.writeln("<li>"+counter+"Is Even.</li>"); } else { document.writeln("<li>"+counter+"Is Odd.</li>"); } } } document.writeln("</ul>");//the end of the unorder list tag. //append child.element("</Ul>")??? } function testQuestion2() //the function that works with the oddr even { var user=prompt("Enter a number,please.");//prompts the user to enter a number var inputFromUser=parseInt(user);//parses the input and adds it to input for the user oddOrEven(inputFromUser);//calls on the method and runs through the code. }//end testQuestion2 //////////////////////////////////////////////// function testQuestion3() { spooks(); } /////////////////////////////////////////////// function spooks() { var unknown=0; var ghost=0; var witch=0; var bat = 0; var user; for (var n=0; n<1; n++) { if(user!=="done") { n-=1; user=prompt("bat,witch, or ghost").toLowerCase(); if(user==="bat") { bat+=1; } else if(user==="ghost") { ghost+=1; } else if (user==="witch") { witch+=1; } else if(user!=="bat"||user!=="ghost"||user!=="witch") { unknown+=1; } } } displayThemSpooks(witch,bat,ghost,unknown); } function displayThemSpooks(witch,bat,ghost,unknown) { if(witch >1) { document.writeln("<p> Witch was entered"+witch+ " \n </p>") displayThemSpookspic(witch,"witch"); } else if(witch===0) { document.writeln("<p> No witches were spotted </p>"); } else { document.writeln("<p> You entered"+witch+" witches</p>") displayThemSpookspic(witch,"witch"); } if(bat >1) { document.writeln("<p> bat was entered"+bat+ " \n </p>") displayThemSpookspic(bat,"bat"); } else if(bat===0) { document.writeln("<p> No bat were spotted</p>"); } else { document.writeln("<p> You bat"+bat+" bat</p>") displayThemSpookspic(bat,"bat"); } if(ghost >1) { document.writeln("<p> ghost was entered"+ghost+ " \n </p>") displayThemSpookspic(ghost,"ghost"); } else if(ghost===0) { document.writeln("<p> No ghost were spotted </p>"); } else { document.writeln("<p> You entered"+ghost+" ghost</p>") displayThemSpookspic(ghost,"ghost"); } if(unknown >1) { document.writeln("<p> unknown was entered"+unknown+ " \n </p>") displayThemSpookspic(unknown,"unknown"); } else if(unknown===0) { document.writeln("<p> No unknowns were spotted </p>"); } else { document.writeln("<p> You entered"+unknown+" unknowns</p>") displayThemSpookspic(unknown,"unknown"); } } function displayThemSpookspic(count,spookPic ) { for(var num=1;num<=count;num++ ) { var tag="<img src='Images/" + spookPic + ".png' alt='spooky picture' heigt='40' width='40'>"; document.write(tag); } } <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="author" content="Enter your name here"> <title>Web Programming - Unit 8</title> <script type="text/javascript" src="javascript/basics.js"> </script> </head> <body> <h1 id="title"> </h1> <p></p> </body> </html> Unit 9- Functions (1).zip
-
I am in the process of making a validation function for a date. I need help figuring out how to make it not accept the date entered if the date is not for 2 days in advanced. So if today's date is 10/30/2016 an error should show up saying that the date has to be 2 days from today's date. (11/01/2016). I will post just the section with the function and go from there. Thanks in advanced. var $ = function(id) { return document.getElementById(id); }//end $ window.onload = function() { $("theForm").reset(); //Clear previous entries in FF $("btnSubmit").onclick = validateForm; $("btnReset").onclick = resetForm; $("currentTime").innerHTML = (new Date).toLocaleString(); $("txtCustName").required = true; $("txtCustName").onblur = validateUserName; $("txtTitle").required = true; $("txtTitle").onblur = validateBookTitle; $("cmbFormat").onblur = validateBookFormat; $("cmbFormat").required = true; $("txtPrice").min = 10; $("txtPrice").max = 100; $("txtPrice").required = true; $("txtPrice").onblur=validateQuotedPrice; $("txtQuantity").required = true; $("txtQuantity").onblur=validateQuanityOrdered; $("rdoDiscover").onclick = hidePaymentOptionError; $("rdoPayPal").onclick = hidePaymentOptionError; $("rdoVisa").onclick = hidePaymentOptionError; $("rdoDiscover").required = true; $("rdoPayPal").required = true; $("rdoVisa").required = true; $("rdoDiscover").onblur=validatePaymentOption; $("rdoPayPal").onblur=validatePaymentOption; $("rdoVisa").onblur=validatePaymentOption; $("dtpDelivery").required = true; $("dtpDelivery").onblur=validateDate; $("dtpDelivery").max="2017-12-31"; $("dtpDelivery").min="2016-01-01"; } function validateDate() { var ptr = $("dtpDelivery"); //Pointer to input field var err = $("errDelivery"); //Pointer to field's error marker err.style.visibility = "visible"; //Regular Expression for yyyy-mm-dd //2016-11-26 2016-10-31 var patternForYyyyMmDd = /^\d{4}-\d{2}-\d{2}$/; if(ptr.value=="") { var enteredDate = ptr.value.replace(/[-\.]/g, "/");; if(isDate(enteredDate)) { //Before checking range, make sure date is the right format if(!enteredDate.match(patternForYyyyMmDd)) { //Reformat it enteredDate = new Date(enteredDate).format("yyyy-mm-dd"); }//end if if(enteredDate < ptr.min || enteredDate > ptr.max) { err.title = "Date must be between " + ptr.min + " and " + ptr.max + "."; } else { err.style.visibility = "hidden"; ptr.value = enteredDate; }//end if out of range } else { err.title = "This is not a recognizable date."; }//end if isDate } // else // { //Display error if required // } //end if missing return err.style.visibility=="hidden"; }//end validateDate
- 5 replies
-
- html
- javascript
-
(and 1 more)
Tagged with:
-
Just want to thank you ahead of time for helping me out. The issue that I am running into is creating a un-ordered list with 3 numbers that the user inputs. **THIS IS MY ASSIGNMENT** Please don't give me the answer right away I just need some guidance. I have a HTML file and Java Script File. I am trying to create the table from the javascript file. I have assigned the numbers and prompted the user to enter their numbers. I have been using FireFox With FireBug to run the files. I am using Notepad++ and cloud9 for my IDE. Thanks again! <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="author" content="Enter your name here"> <title>Web Programming - Unit 8</title> <script type="text/javascript" src="javascript/basics.js"> </script> </head> <body> <h1 id="title"></h1> </body> </html> var $ = function(id) {return document.getElementById(id); }//end $ window.onload = function () { //Provide answer for Question 1 here document.getElementById("#title") { document.write("JavaScript Control Structures Test Document."); } ////////////////////// testQuestion2(); testQuestion3(); } function testQuestion2() { var firstNumber; var secondNumber; var thirdNumber; var number1; var number2; var number3; firstNumber = prompt("Enter First Number"); secondNumber= prompt("Enter Second Number"); thirdNumber= prompt("Enter Third Number"); number1= parseInt(firstNumber); number2= parseInt(secondNumber); number3= parseInt(thirdNumber); //console.log("first"+" "+firstNumber+" "+"Second"+" "+secondNumber+" "+"Third"+" "+thirdNumber); }//end testQuestion2 function testQuestion3() { }//end testQuestion3 index.zip
-
I have this here and all I'm wondering is under `document.createTextNode(addLocation.name);` How do I add more than one item? For example, would it work if i did `document.createTextNode(addLocation.name, addLocation.description)`? below is the full code for my function, it's meant to grab a bunch of different fields from localstorage and put them into different HTML elements in the same div but right now it only does 1 of the fields (the name, called "name" as a variable) function locationcardload(){ var allLocations = document.getElementById("locationList"); ; rawTxt = localStorage.getItem("locations") LocationArray = JSON.parse(rawTxt); ; for (var x=0; x<LocationArray.length; x++) { var addLocation = LocationArray[x]; var additem = document.createElement("div") additem.classname = "icon"; additem.className = "item"; ; var LocListText = document.createTextNode(addLocation.name); additem.appendChild(LocListText); allLocations.appendChild(additem); } }
- 1 reply
-
- javascript
- ionic
-
(and 1 more)
Tagged with:
-
I am trying to loop through a number that a user enters. For example if a user enters the number 45. It should start a 1 and go through 45. (1,2,3,......45) . ANY guidance would be appreciated. The code that I have sets the results on a table(Thanks to VorticalBox and Mr_KoKa help). It loops through but does not display the increments. So if I enter 8. it shows the number 8 times(88888888) not 12345678. Thanks again. function testQuestion2() { //empty array to store our numbers var number =[] var num = parseInt(prompt("enter number")) //loop x times for(i=0; i<num; i++) { //store each input in the array number[i] = num; } //start of list var ul = document.createElement('ul'); //loop every item in array for (i=0;i<number.length; i++) { var li = document.createElement('li'); //adds current array item to the page li.innerHTML = number[i]; ul.appendChild(li) } //end of list document.body.appendChild(ul); }
-
Hello, So when I upload a file it creates a new row in the table. if I click Delete nothing happens. if I click delete on a file that was there on page load it works. If I refresh and click the newly created one it works. Html code (first row is the javascript added one) <tbody id="filetable"> <tr> <td>Untitled.jpg</td> <td>jpg</td> <td></td> <td>1 second ago</td> <td>joveice</td> <td> <a href="/cdn/file/95" class="btn btn-success btn-xs">VIEW</a> <button class="btn btn-danger btn-xs deleteFile" data-id="95">DELETE</button> </td> </tr> <tr> <td>Untitled.jpg</td> <td>jpg</td> <td></td> <td>1 minute ago</td> <td>joveice</td> <td> <a href="/cdn/file/94" class="btn btn-success btn-xs">VIEW</a> <button class="btn btn-danger btn-xs deleteFile" data-id="94">DELETE</button> </td> </tr> </tbody> As you can see there is nothing different on them other than the ID (which is correct) JS $('.deleteFile').on('click', function() { toastr.options = { "closeButton": true, "debug": false, "progressBar": true, "preventDuplicates": false, "positionClass": "toast-top-right", "onclick": null, "showDuration": "400", "hideDuration": "1000", "timeOut": "7000", "extendedTimeOut": "1000", "showEasing": "swing", "hideEasing": "linear", "showMethod": "fadeIn", "hideMethod": "fadeOut" }; var dataId = $(this).attr('data-id'); var $tr = $(this).closest('tr'); $.ajax({ url: '/cdn/file' + '/' + dataId, type: 'DELETE', data: { '_token': 'token' }, success: function( msg ) { if ( msg.status === 'success' ) { $tr.find('td').fadeOut(100, function () { $tr.remove(); }); Snackbar.show({ text: msg.msg, pos: 'top-right' }); } else { Snackbar.show({ text: 'Oops.. ' + msg.msg, textColor: '#ff0000', pos: 'top-right' }); } }, error: function( data ) { if ( data.status === 422 ) { Snackbar.show({ text: 'Oops.. Something went wrong!', textColor: '#ff0000', pos: 'top-right' }); } } }); return false; }); I just started doing JS and I don't know why this is happening.
-
i need help with this program. im really trying not to learn js just trying to get through this class Create a file called index.html and a file called min-max.js. In min-max.js create a class called MinMax. This class should have the following: constructor(numbers) // constructor should store an array of numbers in a member variable called numbers findMinMax() // this function returns an array that holds the minimum and maximum values of numbers. (You can use the code from the previous assignment to help with this) removeMax() // this function removes the first instance of the maximum value in numbers and returns the numbers member variable. Example: numbers = [3,9,0,1,7,9]. After this function is called numbers = [3,0,1,7,9] In your index.html file link min-max.js. Add javascript that instantiates a MinMax object and call findMinMax() and removeMax() on the object and log the results to the console. Do NOT use the array sort method or any pre-written min and max javascript functions to solve these problems.
-
Hello ! I need help. Im making a simple page for people to post messages that are updated 3-4 times per week. for people with absolutly 0 knowledge of computers. im currently doing a form that stores the info in a variable (as a string with html code in it) I want to, when I click "update" that the server takes that string, copy it and replace the text inside the index.html file somewhere else on the website (the display page) how do I do that ?
-
Hey guys, So I've been developing a game using the Sphere RPG Engine and after installing it's successor, MiniSphere, I've run into some problems with my code. The Engine uses Core Javasript with it's own API instead of the browser APIs you would be used to using with Chrome of Firefox. So lets say I want to create a hat constructor and wish to create an instance of a green hat using said constructor I had written: var hat = function(color) { this.color = color; }; hat.prototype = {}; hat.prototype.getInfo = function() { return this.color; }; aHat = new hat("Green"); what I get as an error is the following: TypeError: [Object object] is not constructable. Now, this code worked perfectly fine before and did it's job well, however with Minisphere I just can't seem to figure out for the life of me how to get it working. I've done a bit of googling around however whatever I try just doesn't seem to work, or I end up with more constructor related errors.
-
Hey, So yesterday I installed KDE Neon on my laptop which surprisingly worked after like the 6th try however it's been awhile since I've actively used linux for anything other than running the occasional server. So I was wondering, what IDE would you guys recommend using? I'm looking for something that I can easily compile C/C++ code in, that has a dark look so it's easy on my eyes, it would also need to be able to allow me to build code from inside the IDE rather than having to manually build my code in a terminal. Optionally it would be nice if the IDE also supported Python and Core JavaScript or allowed me to define new syntax highlighting definitions.
- 7 replies
-
- editors
- programming
-
(and 3 more)
Tagged with:
-
looking for a program that takes an input of numbers and returns the min and max value of the set.
-
So, for the purpose of learning, I've been writing a 3D renderer, and I've been running into some issues involving what I can only guess is my math. The issue I'm having is with a function I've written called rotate3d, I can rotate on two axis at the same time, however for some reason whenever I rotate along both X and Y simultaneously, I run into a weird issue where the polygon or object being rotated will stretch or distort. I'm not sure what it is I'm doing wrong here, and I've been trying for days to figure out what is wrong with my math. Here is a screenshot of a wireframe cube rotated by 45 degrees on both the X and Y axis (Yes, I know the FOV of 600 is ridiculous but it actually produces a result comparable to an FOV of 70 on a standard game): And here is the function: function rotate3d(x, y, z, rx, ry, rz) { // Calculate the ratio for degrees to radians var ratio = (3.1415 / 180); var rxa = rx * ratio; var rya = ry * ratio; var rza = rz * ratio; // Rotate around the Y axis. var x1 = (Math.cos(rya) * x) - (Math.sin(rya) * z); var y1 = y; var z1 = (Math.sin(rya) * x) + (Math.cos(rya) * z); // Rotate around the X axis. var x2 = x1; var y2 = (Math.cos(rxa) * y) - (Math.sin(rxa) * z); var z2 = (Math.sin(rxa) * y) + (Math.cos(rxa) * z); // Rotate around the Z axis. var x3 = (Math.cos(rza) * x1) - (Math.sin(rza) * y2); var y3 = (Math.sin(rza) * x1) + (Math.cos(rza) * y2); var z3 = z2; //system.pushEvent("grapler3d", "Rotated X: " + x + " Y: " + y + " Z: " + z + " to X: " + x3 + " Y: " + y3 + " Z: " + z3); return([x3, y3, z3]); }; If anyone knows what it is I'm doing wrong here, any help would be greatly apreciated.
-
Hey guys, so I'm writing the game engine for a game inspired by the original SimCity games (1 through 4) and I'm running into some issues trying to align the map. For whatever reason the map will re-align to 0 whenever I go to click the mouse. The code is relying on a mouse library I've written that provides various information whenever the mouse is clicked such as the distance from the point of origin, the angle of the hypothetical line connecting the current position and the origin as well as some other stuff. If needed I can paste that in as well. EDIT: I should probably also mention that this code does not rely on any browser APIs to do what it does. Instead it relies on the Sphere v1.5 API that provides access to DirectX and OpenGL. (You can find sphere here if you're interested. I recommend using your own IDE btw: spheredev.org) I'm not entirely sure why it's resetting with each click, I was hoping that someone here can help me figure out why it might be doing this or if there is a better way to go about aligning the map. EDIT: the primary suspect is isoMap.prototype.setCameraPos, which manages map alignment depending on whether mode is true or false. I haven't implemented the second mode yet. the function is located at the bottom of the script. isomap.js: /* IsoMap Version 0.1.4 Part of the isotope library written by Michael Warner This is used For creating and rendering Isometric tilemaps. */ var isoMap = function (id) { this.map = {}; this.map.id = id; this.map.tiles = {}; // Zero the camera offset this.map.offX = 0; this.map.offY = 0; // Set the tileSize this.map.tileWidth = 32; this.map.tileHeight = 32; // Calculate the psuedo-coordinates of the corners of the tile this.tileYa = ((Math.sin(0.785375) * this.map.tileWidth) + (Math.cos(0.785375) * this.map.tileHeight)) * Math.sin(0.3926875); this.tileXa = (Math.cos(0.785375) * this.map.tileWidth) + (Math.sin(0.785375) * this.map.tileHeight); this.tileXb = -1 * this.tileXa; this.tileYb = -1 * this.tileYa; this.map.defX = (system.screen.width / 2) - this.tileXa; this.map.defY = (system.screen.height / 2) - this.tileYa; this.offX = 0; this.offY = 0; // Calculate the actual size based on the pseudo-coordinates. this.map.tileWidth = this.tileXa - this.tileXb; this.map.tileHeight = this.tileYa - this.tileYb; x = (this.map.tileWidth / 2); y = (this.map.tileHeight / 2); // Create our map this.map.rows = 6 this.map.lines = 6; this.map.matrix = []; // Create a default tile this.map.tiles.blank = CreateSurface(this.map.tileWidth + 1, this.map.tileHeight + 1, CreateColor(0, 0, 0, 0)); this.map.tiles.blank.line(x, this.tileYb + y, this.tileXa + x , y, CreateColor(0, 0, 255)); this.map.tiles.blank.line(this.tileXa + x , y,x , this.tileYa + y, CreateColor(0, 0, 255)); this.map.tiles.blank.line(x, this.tileYa + y, this.tileXb + x, y, CreateColor(0, 0, 255)); this.map.tiles.blank.line(this.tileXb + x, y, x, this.tileYb + y, CreateColor(0, 0, 255)); this.map.tiles.set = []; this.map.tiles.off = []; system.console.pushEvent(system.verbose.world, '[System] Created map with ID "' + this.id + '"'); }; isoMap.prototype = {}; // It's been awhile so I forgot why I did this with this function. /*isoMap.prototype.getDimensions = function () { return [this.map.x.length, this.map.y.length, this.map.z.length]; };*/ // Renders the frame of a single Tile. isoMap.prototype.drawTileFrame = function (xP, yP, tileID) { if (tileID == null) { this.map.tiles.blank.blit(xP, yP); } else { this.map.tiles.set[tileID].blit(xP, this.map.tiles.off[tileID] + yP); }; }; // Sets map size. isoMap.prototype.setSize = function (width, height) { size = 0; while (size < width * height) { this.map.matrix.push(null); size = size + 1; }; }; // Renders an isometric map. isoMap.prototype.render = function (mode) { xPos = this.map.defX; yPos = this.map.defY; a = 0 b = 0 c = 0 if (mode == "WIREFRAME") { while (a < this.map.rows) { b = 0; while (b < this.map.lines) { this.drawTileFrame(xPos, yPos, this.map.matrix[(a * this.map.lines) + b]); b = b + 1 xPos = xPos + this.tileXa; yPos = yPos + this.tileYa; }; a = a + 1 //this.drawTileFrame(xPos, yPos, null); xPos = this.map.defX - (this.tileXa * a); yPos = this.map.defY + (this.tileYa * a); }; system.console.pushEvent(system.verbose.world, 'Pushed new frame of "' + this.map.id + '" with offset of ' + this.offX + " by " + this.offY + " pixels"); } else { }; }; // Sets a specified tile on the map. isoMap.prototype.setTile = function (x, y, tileID) { if (x >= 1) { if (y >= 1) { system.console.pushEvent(system.verbose.tiles, 'Set tile at X:' + x + ' Y:' + y + ' to "' + tileID + '"'); this.map.matrix[((x - 1) * this.map.lines) + y - 1] = tileID; }; }; }; // Fills a specified area on the map. isoMap.prototype.fill = function (x1, y1, x2, y2, tileID) { if (x >= 1) { if (y >= 1) { sX = x1; sY = y1; width = Math.abs(x1 - x2) + 1; height = Math.abs(y1 - y2) + 1; system.console.pushEvent(true, "Replacing area of " + width + "x" + height + ' tiles with "' + tileID + '" (' + width * height + " tiles)"); x = x1 - 1; while (x < width) { y = y1 - 1 ; while (y < height) { this.map.matrix[(x * this.map.lines) + y] = tileID; y = y + 1; }; x = x + 1; }; }; }; }; //Projects a specified image so that it is useable for isometric rendering without performance loss. isoMap.prototype.projectTile = function(surface, name) { tile = surface.clone(); tile.rotate(0.785375, true); tile.rescale(this.map.tileWidth + 1, this.map.tileHeight); this.map.tiles.set[name] = tile.clone(); this.map.tiles.off[name] = 0; }; //Generates a new tile of the specified color, useful for prototyping. isoMap.prototype.generateTile = function(color, name) { system.console.pushEvent(system.verbose.tiles, 'Generated tile with name "' + name + '"'); tile = CreateSurface(this.map.tileWidth + 1, this.map.tileWidth + 1, color); return this.projectTile(tile, name); }; //Imports a tile from an image, relis on the projectTile function. isoMap.prototype.importTile = function(path, name) { system.console.pushEvent(system.verbose.tiles, 'Imported tile named "' + name + '" from path: images/' + path); tile = LoadSurface(path); return this.projectTile(tile, name); }; //Allows for aligning the map. Needs work. isoMap.prototype.setCameraPos = function (mode) { if (mode = true) { if (system.cursorStats[0] == false) { this.offX = this.map.defX; this.offY = this.map.defY; } else { this.map.defX = this.offX + system.cursorStats[1]; this.map.defY = this.offY + system.cursorStats[2]; }; }; };
-
Hello all, I was curious if there was a way to have the code to read the first page of the pdf and from that create a thumbnail and display it? This way me or someone else would just have to upload the pdf and the code does everything else for us and we do not have to go into the code every month and have to create a thumbnail manually and then display it. Thanks for your time.
-
Hi Everyone, I've had a lot of help doing something in the Google Sheets editor and have also posted this in the Google Apps Script forum but so far, no one's been able to help and I'm too clueless to help myself. If someone could point me the right direction or help me in any way, it would be much appreciated. Here's my issue. This is all on a spreadsheet online so the .getRange refers to the columns. The functions work perfectly fine and this whole code works fine as is but the problem is that if I have values returning from function concatCustomer() and concat() but NOT concatOther(), the code stops before concat() can be ran. To reiterate, if A2:A has values and E2:E has values returning while C2:C has no values returning due to input, the function for A2:A will run and the code will stop as C2:C won't return values and thus, E2:E's values will no longer be run. Is there an easy way to solve this? Someone in the Google Apps Script forum said to use {};{};{}; but I'm not sure how to input that. Thanks! Oh and just to add what updateConcatCustomer() is, this function is part of a dropdown menu so that other users can click on the dropdown menu, select the function and be able to update the spreadsheet and have the spreadsheet return the values. Hope that explains it! function updateConcatCustomer () { var ss = SpreadsheetApp.getActiveSpreadsheet(); var values = concatCustomer().map(function (e) {return [e];}); var sheet = ss.getSheetByName("Calc"); sheet.getRange('A2:A').clearContent(); sheet.getRange(2, 1, values.length, 1).setValues(values); var values2 = concatOther().map(function (i) {return [i];}); sheet.getRange('C2:C').clearContent(); sheet.getRange(2, 3, values2.length, 1).setValues(values2); var values3 = concat().map(function (k) {return [k];}); sheet.getRange('E2:E').clearContent(); sheet.getRange(2, 5, values3.length, 1).setValues(values3); }
- 1 reply
-
- javascript
- google apps script
-
(and 2 more)
Tagged with:
-
I'm trying to figure out a way to pause an application in Windows 10 with out have to manually do it from the resource monitor. I need to suspend the application for 7-8 seconds. I'm open to any suggestions. I would like to be able to use JavaScript. I will be in full screen mode when suspending the application and batch will minimize the full screen. Any thought or suggestions are welcome. I will be executing the script via a macro button on a keyboard.
- 1 reply
-
- javascript
- vb
-
(and 2 more)
Tagged with:
-
im working on a javascript game and i don't want the player to be able to leave the canvas. i have made it where you can't leave the bottom or right side like this this.hitBottom = function(){ var rockbottom = myGameArea.canvas.height - this.height; var rockside = myGameArea.canvas.width - this.width; if (this.y > rockbottom) { this.y = rockbottom; } if(this.x > rockside){ this.x = rockside; } but i can't figure out how to do the other 2 sides
-
Hi, I forgot how this works. I don't plan in using a submit button and rather use auto-update in radio buttons. I currently have this set of codes: UPDATE 1: I managed to switch from radioButton to Buttons, and changed PHP codes to JavaScript. Problem is, it still cant update once I pressed a button. Do I need to use AJAX? Here's the snippets: <script type="text/javascript" src="script.js"></script> <h4>Store Preference</h4> <form action="" method="POST"> <button type="button" class="btn btn-default btn-md" value="1" id="button" name="store1">Store1</button> <button type="button" class="btn btn-success btn-md" value="2" id="button" name="store2">Store2</button> </form> <script type="text/javascript"> if (value == 1) { coolerName = "Corsair H100i v2"; coolerPrice = 5440; } if (value == 2) { coolerName = "Corsair H100i v2"; coolerPrice = 5450; } document.write("<td>" + coolerName + "</td>"); document.write('<td id="alignRight">'); if (coolerPrice > 0) { document.write(coolerPrice.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,')); } else { document.write(coolerPrice.toFixed(0).replace(/(\d)(?=(\d{3})+\.)/g, '$1,')); } document.write('</td>'); </script> var value = 1; var button = document.getElementById("button"); button.onClick = function() { if (content.name == "store1") value = 1; if (content.name == "store2") value = 2; }
-
Hello everyone ! I’m currently studying computer science and I’d like to create my own website for a professional use. This is what I’m planning to have on it: - General presentation. (Home page) - Detailed CV. - Project page (and pages for each project). - Eventually a “Tutorial” section. I’d like to host it on Gitlab (git), which means it needs to be static: HTML, CSS and JS (etc). However, there are plenty of ways of going about it: Plain, Jekyll, Hexo, Middleman… All use different environments, such as Ruby on Rails, Python or NodeJS. This is where I kind of get lost with the amount of options I have. These environments seem more specialized in blog style websites, am I wrong? I don’t have any knowledge in Python or Ruby for instance. Just for reference, I’m a strong OOP kind of guy, so if it’s possible to translate that into my web dev experience, that would be great. It really comes down to what would be the most appropriate for me to use? Are there other options I should check out? Is there any real advantage in using these SSGs instead of just writing and managing everything yourself? Thanks! ~3751_Creator
- 6 replies
-
- static website
- website
-
(and 4 more)
Tagged with: