Search the Community
Showing results for tags 'javascript'.
-
So I have a quiz assignment for my computer science class, which asks me to: Generally, I just dont know how to put the function in there by using Array variables. If anyone has any idea it would be mighty appreciated. I don't have much js experience, so anything slightly more advanced like loops are kind of out of the question. My code so far: <script> var avg var Student = [ prompt("Enter Name","Name"), prompt("Enter Test Score 1","0"), prompt("Enter Test Score 2","0"), prompt("Enter Test Score 3","0"), prompt("Enter Test Score 4","0"), ] alert() //? </script>
- 2 replies
-
- javascript
- html
-
(and 1 more)
Tagged with:
-
(reposting this in the Programming section because I realized it probably belongs here and didn't get any responses, sorry mods if this isn't allowed) I have little to no experience with web development so far so I've just been reading up on minimal documentation to accomplish the project I'm working on. However, some of the data on the page/server is sensitive to my organization (Google Apps-based) so I'd like to set up a simple login page that only accepts Google accounts ending with @organization.org which will then grant access to the main HTML page. This thread seemed to be promising: Restrict Login Email with Google OAuth2.0 to Specific Domain Name But I'm not sure how to even setup a login page at all, regardless of domain-restricting. I wasn't able to find any OAuth documentation to help me with this either. Is this something that OAuth can do? Also, is there any way I should be setting permissions/restricting access to the actual files (such as my main .json data file) to prevent unintended access?
-
Website and update parts of it (etc notification on this page)
Joveice posted a topic in Programming
Hi, So I have a page with a notification icon in the top, it also has a badge over it with numbers of notifications found in the database for that user (refresh the page and it will update if there is a new notification) Now how can I have it update etc every 30 sec? or every min? Where can I learn about this or find a snippet that works for most things? I know nothing about how this works and would be really happy if someone could tell me about it or point me in the right direction -
I am accessing an online api to get xml file with many ids. This is my code var https = require('https'); var xml2js = require('xml2js'); var parser = new xml2js.Parser({optionName: 'normalize'}); var concat = require('concat-stream'); parser.on('error', function(err) { console.log('Parser error', err); }); https.get("https://www.leaksapi.com/clinton-emails/from/<APIKEY>/Hillary%20Clinton", function(resp) { resp.on('error', function(err) { console.log('Error while reading', err); }); resp.pipe(concat(function(buffer) { var string = buffer.toString(); var cleanedString = string.replace("\ufeff", ""); parser.parseString(cleanedString, function(err, result) { console.log('Finished parsing:', err, result); }); })); }); And I keep on getting an Error: Non-whitespace before first tag. Even when I have cleared the first non-whitespace character in the line var cleanedString. Parser error Error: Non-whitespace before first tag. Line: 0 Column: 1 Char: [ at error (C:\Users\Snama\node_modules\sax\lib\sax.js:642:8) at strictFail (C:\Users\Snama\node_modules\sax\lib\sax.js:662:22) at Object.write (C:\Users\Snama\node_modules\sax\lib\sax.js:935:11) at Parser.exports.Parser.Parser.parseString (C:\Users\Snama\node_modules\xml2js\lib\xml2js.js:508:31) at Parser.parseString (C:\Users\Snama\node_modules\xml2js\lib\xml2js.js:7:59) at C:\Users\Snama\Documents\DonaldTrumpPropaganda\webreader.js:17:14 at ConcatStream.<anonymous> (C:\Users\Snama\node_modules\concat-stream\index.js:36:43) at emitNone (events.js:91:20) at ConcatStream.emit (events.js:185:7) at finishMaybe (C:\Users\Snama\node_modules\concat-stream\node_modules\readable-stream\lib\_stream_writable.js:475:14) What am I doing wrong. Thanks
- 2 replies
-
- node js
- javascript
-
(and 1 more)
Tagged with:
-
I have been failing on making an array with Images. I changed the code back to it's working state before I starting the edits for the image array. If any one can give me some tips or help on how to start the array. I will post the code and the functions that are giving me issues. Thanks in advanced for the help. var $ = function(id) {return document.getElementById(id); }//end $ window.onload = function () { //Provide answer for Question 1 here ////////////////////// spooks(); }; function spooks() { var reindeerCounter=[];//the array for the counter reindeerCounter[noname]=0;//the count for anything else that is not a reindeer reindeerCounter["blitzen"]=0;//the count for blitzen reindeerCounter["comet"]=0;//the count for comet reindeerCounter["cupid"]=0;//the count for cupid reindeerCounter["dancer"]=0;//the count for dancer reindeerCounter["dasher"]=0;//the count for dasher reindeerCounter["donner"]=0;//the count for donner reindeerCounter["prancer"]=0;//the count for prancer reindeerCounter["rudolph"]=0;//the counter for rudolph reindeerCounter["vixen"]=0;//the counter for vixen reindeerCounter["bumble"]=0;//the counter bumble var noname;//the counter for the noname reindeers var user;//what the user enters var reindeer ={names:["blitzen","comet","cupid","dancer","dasher","donner","prancer","rudolph","vixen","bumble"]};//the array for the reindeer names for (var n=0; n<1; n++) { do { user=prompt("Enter:blitzen, comet, cupid, dancer, dasher, donner, \nprancer, rudolph, vixen,and type exit to see score").toLowerCase(); if(user===reindeer["names"][0]) { reindeerCounter[user]++; } else if(user===reindeer["names"][1]) { reindeerCounter[user]++; } else if(user===reindeer["names"][2]) { reindeerCounter[user]++; } else if (user===reindeer["names"][3]) { reindeerCounter[user]++; } else if (user===reindeer["names"][4]) { reindeerCounter[user]++; } else if (user===reindeer["names"][5]) { reindeerCounter[user]++; } else if (user===reindeer["names"][6]) { reindeerCounter[user]++; } else if (user===reindeer["names"][7]) { reindeerCounter[user]++; } else if (user===reindeer["names"][8]) { reindeerCounter[user]++; } else if(user!==reindeer["names"]) { reindeerCounter[noname]++; } } while (user!=="exit"); displayThemSpooks(reindeerCounter[user]); } function displayThemSpooks(blitzen,bumble,comet,cupid,dancer,dasher,donner,noname,prancer,rudolph,vixen) { if(reindeerCounter["blitzen"] >1) { document.writeln("<p> blitzen was entered"+" "+reindeerCounter["blitzen"]+ " \n </p>"); displayThemSpookspic(reindeerCounter["blitzen"],"blitzen"); } else if(reindeerCounter["blitzen"]===0) { document.writeln("<p>blitzen was not spotted </p>"); } else { document.writeln("<p> You entered"+" "+reindeerCounter["blitzen"]+ " blitzens</p>"); displayThemSpookspic(reindeerCounter["blitzen"],"blitzen"); } if(reindeerCounter["comet"] >1) { document.writeln("<p> comet was entered"+" "+reindeerCounter["comet"]+ " \n </p>"); displayThemSpookspic(reindeerCounter["comet"],"comet"); } else if(reindeerCounter["comet"]===0) { document.writeln("<p> comet was not spotted</p>"); } else { document.writeln("<p> You entered"+" "+reindeerCounter["comet"]+" comets</p>"); displayThemSpookspic(reindeerCounter["comet"],"comet"); } if(reindeerCounter["cupid"] >1) { document.writeln("<p> cupid was entered"+" "+reindeerCounter["cupid"]+ " \n </p>"); displayThemSpookspic(reindeerCounter["cupid"],"cupid"); } else if(reindeerCounter["cupid"]===0) { document.writeln("<p> cupid was not spotted </p>"); } else { document.writeln("<p> You entered"+" "+reindeerCounter["cupid"]+" cupids</p>"); displayThemSpookspic(reindeerCounter["cupid"],"cupid"); } if(reindeerCounter["dancer"] >1) { document.writeln("<p> dancer was entered"+" "+reindeerCounter["dancer"]+ " \n </p>"); displayThemSpookspic(reindeerCounter["dancer"],"dancer"); } else if(reindeerCounter["dancer"]===0) { document.writeln("<p> dancer was not spotted </p>"); } else { document.writeln("<p> You entered"+" "+reindeerCounter["dancer"]+" dancers</p>"); displayThemSpookspic(reindeerCounter["dancer"],"dancer"); } if(reindeerCounter["dasher"] >1) { document.writeln("<p> dasher was entered"+" "+reindeerCounter["dasher"]+ " \n </p>"); displayThemSpookspic(reindeerCounter["dasher"],"dasher"); } else if(reindeerCounter["dasher"]===0) { document.writeln("<p> dasher was not spotted </p>"); } else { document.writeln("<p> You entered"+" "+reindeerCounter["dasher"]+" dashers</p>"); displayThemSpookspic(reindeerCounter["dasher"],"dasher"); } if(reindeerCounter["donner"] >1) { document.writeln("<p> donner was entered"+" "+reindeerCounter["donner"]+ " \n </p>"); displayThemSpookspic(reindeerCounter["donner"],"donner"); } else if(reindeerCounter["donner"]===0) { document.writeln("<p> donner was not spotted </p>"); } else { document.writeln("<p> You entered"+" "+reindeerCounter["donner"]+" donners</p>"); displayThemSpookspic(reindeerCounter["donner"],"donner"); } if(reindeerCounter["prancer"] >1) { document.writeln("<p> prancer was entered"+" "+reindeerCounter["prancer"]+ " \n </p>"); displayThemSpookspic(reindeerCounter["prancer"],"prancer"); } else if(reindeerCounter["prancer"]===0) { document.writeln("<p> prancer was not spotted </p>"); } else { document.writeln("<p> You entered"+" "+reindeerCounter["prancer"]+" prancers</p>"); displayThemSpookspic(reindeerCounter["prancer"],"prancer"); } if(reindeerCounter["rudolph"] >1) { document.writeln("<p> rudolph was entered"+" "+reindeerCounter["rudolph"]+ " \n </p>"); displayThemSpookspic(reindeerCounter["rudolph"],"rudolph"); } else if(reindeerCounter["rudolph"]===0) { document.writeln("<p> rudolph was not spotted</p>"); } else { document.writeln("<p> You entered"+" "+reindeerCounter["rudolph"]+" rudolphs</p>"); displayThemSpookspic(reindeerCounter["rudolph"],"rudolph"); } if(reindeerCounter["vixen"] >1) { document.writeln("<p> vixen was entered"+" "+reindeerCounter["vixen"]+ " \n </p>"); displayThemSpookspic(reindeerCounter["vixen"],"vixen"); } else if(reindeerCounter["vixen"]===0) { document.writeln("<p> vixen was not spotted </p>"); } else { document.writeln("<p> You entered"+" "+reindeerCounter["vixen"]+" vixens</p>"); displayThemSpookspic(reindeerCounter["vixen"],"vixen"); } if(reindeerCounter[noname] >1) { document.writeln("<p> other was entered"+" "+reindeerCounter[noname]+ " \n </p>"); displayThemSpookspic(reindeerCounter[noname],"bumble"); } else if(reindeerCounter[noname]===0) { document.writeln("<p> other was not spotted</p>"); } else { document.writeln("<p> You entered"+" "+" "+reindeerCounter[noname]+" noname</p>"); displayThemSpookspic(reindeerCounter[noname],"bumble"); } } function displayThemSpookspic(counters,spookPic )//have to change this and the way it gets photo to an array. { var imagesreindeer=[]; imagesreindeer[0]="Images/blitzen.png"; imagesreindeer[1]="Images/bumble.png"; imagesreindeer[2]="Images/comet.png"; imagesreindeer[3]="Images/cupid.png"; imagesreindeer[4]="Images/dancer.png"; imagesreindeer[5]="Images/dasher.png"; imagesreindeer[6]="Images/donner.png"; imagesreindeer[7]="Images/prancer.png"; imagesreindeer[8]="Images/rudolph.png"; imagesreindeer[9]="Images/vixen.png"; for(var num=1;num<=counters;num++ ) { var tag="<img src='Images/"+spookPic + ".png' alt='reindeer pictures' height='40' width='40'>"; document.write(tag); } } }
- 3 replies
-
- javascript
- html
-
(and 1 more)
Tagged with:
-
I am making an application, in C++, that needs to get an resulting aspx file from a postback. I don't know of a way of getting the required postdata since the page encodes some of the data; specifically __VIEWSTATE and __EVENTVALIDATION values. I have been trying to use libcurl to accomplish this post, yet, I don't know the postdata to send. When I look at chrome's header tab for the post both __VIEWSTATE and __EVENTVALIDATION ids have lengthy unrecognizable values. Submit button is calling: onlick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("btnPage1", "", true, "", "", false, false))" I found these definitions: function WebForm_PostBackOptions(eventTarget, eventArgument, validation, validationGroup, actionUrl, trackFocus, clientSubmit) { this.eventTarget = eventTarget; this.eventArgument = eventArgument; this.validation = validation; this.validationGroup = validationGroup; this.actionUrl = actionUrl; this.trackFocus = trackFocus; this.clientSubmit = clientSubmit; } function WebForm_DoPostBackWithOptions(options) { var validationResult = true; if (options.validation) { if (typeof(Page_ClientValidate) == 'function') { validationResult = Page_ClientValidate(options.validationGroup); } } if (validationResult) { if ((typeof(options.actionUrl) != "undefined") && (options.actionUrl != null) && (options.actionUrl.length > 0)) { theForm.action = options.actionUrl; } if (options.trackFocus) { var lastFocus = theForm.elements["__LASTFOCUS"]; if ((typeof(lastFocus) != "undefined") && (lastFocus != null)) { if (typeof(document.activeElement) == "undefined") { lastFocus.value = options.eventTarget; } else { var active = document.activeElement; if ((typeof(active) != "undefined") && (active != null)) { if ((typeof(active.id) != "undefined") && (active.id != null) && (active.id.length > 0)) { lastFocus.value = active.id; } else if (typeof(active.name) != "undefined") { lastFocus.value = active.name; } } } } } } if (options.clientSubmit) { __doPostBack(options.eventTarget, options.eventArgument); } } Now the code for _doPostBack called towards the end: function __doPostBack(eventTarget, eventArgument) { if (!theForm.onsubmit || (theForm.onsubmit() != false)) { theForm.__EVENTTARGET.value = eventTarget; theForm.__EVENTARGUMENT.value = eventArgument; theForm.submit(); } So it is looking more like I need some way of calling the javascript functions in order to do the posting for me. I might be wrong since I am not a well experienced programmer but how would I get around posting to this webpage?
-
This is very hard to explain. How do I make a form that adds to a link? For example: When I enter "test" into the form, it takes you to www.example.com/item/test Another example: When I enter "hello" it takes me to www.dictionary.com/words?=hello Is this possible? And if it is how do I do it? I want to integrate this into my site.
- 2 replies
-
- html
- javascript
-
(and 3 more)
Tagged with:
-
The title is pretty explanatory of what i need, couldn't find it anywhere else so I'm asking if it is even possible I dont know PHP, so i made my own Login API in C# and the client side is just JavaScript (idk if it is even possible with anything else) I have a function in the head that checks for the login, if it fails it redirects back to the index and if it succeeds it keeps the page I dont mind people viewing the page without being logged in, the thing is, if they aren't logged in, sometimes the login process takes time and it lets other page contents load (images and that stuff) which causes a bit more bandwidth usage on the server side Is there any way that i could make that function pause the page loading until it completes, and if it is successful resume the page loading... Tried await, but VSC just returns it as an syntax error (actually, nvmd, might be VSC, it does it only on .php files, and it doesnt seem to affect the page loading) Im sorry if i don't understand some stuff about JS and HTML, haven't done something like this before, im a Back-end Developer working mostly in C# .... not JS Thank you !
-
var person = 'Mike'; var age = 28; function myTag(strings, expA, expB) { var str0 = strings[0]; var str1 = strings[1]; var ageStr; if (expB > 99){ ageStr = 'centenarian'; } else { ageStr = 'youngster'; } return `${str0}${expA}${str1}${ageStr}`; } var output = myTag`That ${ person } is a ${ age }`; So I was shown this example, and my first thought was "Oh, you're not actually calling the function, you're just assigning it to output and then theres just a string template there" No myTag is actually run using the string on the right and is called 'Tagged Templates' This is magic and confusing and am not sure if I like it or not. Will probably love it once I become more familiar with it haha
-
<!DOCTYPE html> <html> <head> <title>Password Generator</title> </head> <body> Characters: <input type="number" id="charNum" value="16" min="8" max="100" /><br /> Number: <input type="checkbox" id="num"/><br /> Symbol: <input type="checkbox" id="sym"/><br /><br /> <button id="submit">Submit</button><br /><br /> Your Password: <input type="text" id="yourPw" size="100"/> <style type="text/css"> table td{ /* border: #000 solid 1px; */ border-bottom: 1px solid #000; padding: 5px; } } </style> <script> var char = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; var num = '0123456789'; var sym = '!@#$%^&*=-_'; var charNum = document.getElementById("charNum"); var numBox = document.getElementById("num"); var symBox = document.getElementById("sym"); var submit = document.getElementById("submit"); var yourPw = document.getElementById("yourPw"); submit.addEventListener("click",function(e){ var characters = char; (numBox.checked) ? characters += num : ''; (symBox.checked) ? characters += sym : ''; yourPw.value = password(charNum.value, characters); }); function password(l,characters){ var pwd = ''; for(var i = 0; i<l; i++){ pwd += characters.charAt(Math.floor(Math.random() * characters.length)); } return pwd; } </script> </body> </html> Hey guys, So the HTML webpage opens i can insert no.s use all the buttons but I don't get the output of password in the field upon clicking the "Submit" button. Hoping for a positive response, Basil
-
Hello All I wanted to start programming a bot for Discord and want to host it on a RaspberryPi but am undescided between using the .py or .js library. Thanks for Suggestions about which one I should use. ~Loop Programming languages I already know are C#, PHP
-
Im looking for some new coding challenges to help expand my knowledge of JavaScript
- 3 replies
-
- javascript
- html
-
(and 3 more)
Tagged with:
-
I'm trying to make a basic navigation bar for a website, and I am adding social media icons in the navigation bar as well. I have some basic styling done with it to get the social media icons to actually sit in the navigation bar, but I feel like the way I do it will break on different devices. Below is a screenshot of what the navbar looks like and the css code that is organizing it. Any advice or tips would be appreciated :) body { background-image: url("keto.jpg"); } .navbar { font-family: "Times New Roman", Times, serif; font-style: normal; font-size: 20px; } .navleft { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333; } .navleft li { float: left; } .navleft a { display: block; color: pink; text-align: center; padding: 14px 16px; text-decoration: none; } .navleft a:hover { background-color: #FFC0CB; color: #333; font-style: oblique; } .navright { list-style-type: none; margin-top: -42px; padding: 0; overflow: hidden; background-color: #333; } .navright li { float: right; display: inline; } .navright a { padding: 5px 5px; } .navright img { width: 35px; height: 35px; }
-
Hello. I'm relatively new at coding but I know my way around HTML and css. I'm trying to design a website that has a chatroom for us to talk with and I have absolutely no idea what I am doing. I searched the internet for so long to find a tutorial or something. Anyone have any help? I'm tired of deleting code over and over again.
-
I got tired of all the half-assed attempts people have made to cherry-pick the Bungie.net API to create a "Destiny 2 API library" for node.js. I just built the entire damn thing, from scratch. It's 0 dependency, fully async, and lightening fast. I could use some help testing it before I push V1.0.0 to NPM though. Github Documentation
-
Hi, I'm trying to build a backend system using OCPP 1.6 JSON over websockets in Node. I am having some trouble with the whole websockets thing, I have experience with REST api's but this is throwing me for a loop. Essentially where I am at is that I receive a message from the charger like this: [2, "19223201", "BootNotification", {"chargePointVendor": "VendorX", "chargePointModel": "SingleSocketCharger"} ] I need to put this in a database which I can probably figure out myself, but more importantly I need to de-construct the message and generate an appropriate response. In this case it would look something like this: [3, "19223201", {"status":"Accepted", "currentTime":"2013-02-01T20:53:32.486Z", "heartbeatInterval":300} ] And I have no idea how to do it. Essentially I need a lot of if statements like if the massage has "BootNotification" in it, then send the accept message and if it has something else, then respond appropriately. If someone can help, I'll buy you a beer or coffee or beverage of your choosing? Edit: the documentation for the OCPP protocol is available here: https://www.openchargealliance.org/downloads/
-
Source: https://www.infoq.com/news/2019/10/WebAssembly-wasm-malicious-usage/ There is also a PDF file summary: https://www.dimva2019.org/wp-content/uploads/sites/31/2019/06/DIMVA19-slides-2-R.pdf Or the fully study: https://www.tu-braunschweig.de/Medien-DB/ias/pubs/2019-dimva.pdf My opinion: I knew this was going to happen the very second Chrome turned on WebAssembly. And it did. Back in June of 2018 I had an argument with some people online about how we killed off flash and java, only to bring it back as WebAssembly, and now there's multiple "webasm" implementations that can have holes in it, not just closed-source Java and Flash plugins. This was when some of my clients customers started noticing bad behavior on their websites that previously wasn't present in earlier versions of Chrome and Firefox. The context of that discussion was why we keep giving up sovereignty of webstandards to google. This was not the first thing google pushed that unnecessarily harmed users or site operators. (WebASM) WebAssembly should have been "click to activate", just like flash/java extensions. Sure that might minimize it's usefulness, but at least a legitimate site can go "hey so if you want to play this game/media player, activate wasm for this domain". At this point, WebAssembly hasn't been widely adopted (1 in 600 sites), but it has been used more for malicious uses than not, and that's even worse than flash, which primarily was used for auto-playing obnoxious video ads. When you run into a crypto-miner on a website, your entire computer grinds to nearly a halt, with all the CPU cores getting pinned to 90% or whatever level the miner decided would be "undetectable" unless they were not listening to music and can hear their fans spin up like jet engines.
- 11 replies
-
- wasm
- webassembly
-
(and 3 more)
Tagged with:
-
Hey guys! I have run into at problem where I have two different arrays: // Sample data from function getTimeIntervals() [ RowDataPacket { issue_id: 117648, seconds_elapsed_issue: '318' }, RowDataPacket { issue_id: 118090, seconds_elapsed_issue: '8940' }, RowDataPacket { issue_id: 118092, seconds_elapsed_issue: '5357' }, RowDataPacket { issue_id: 118199, seconds_elapsed_issue: '41604' }, RowDataPacket { issue_id: 118351, seconds_elapsed_issue: '3778' }, RowDataPacket { issue_id: 118395, seconds_elapsed_issue: '2974' }, RowDataPacket { issue_id: 119014, seconds_elapsed_issue: '37680' }, RowDataPacket { issue_id: 119729, seconds_elapsed_issue: '15006' }, RowDataPacket { issue_id: 119735, seconds_elapsed_issue: '26389' }, RowDataPacket { issue_id: 119742, seconds_elapsed_issue: '67' }, ... ] // Sample data from function getIssueData() [ RowDataPacket { project_id: 1445, issue_id: 121007 }, RowDataPacket { project_id: 1445, issue_id: 120921 }, RowDataPacket { project_id: 1445, issue_id: 121011 }, RowDataPacket { project_id: 1420, issue_id: 120454 }, RowDataPacket { project_id: 1420, issue_id: 121004 }, RowDataPacket { project_id: 1445, issue_id: 120868 }, RowDataPacket { project_id: 1467, issue_id: 121010 }, RowDataPacket { project_id: 1445, issue_id: 120870 }, RowDataPacket { project_id: 1420, issue_id: 121009 }, RowDataPacket { project_id: 1445, issue_id: 120018 }, ... ] Now... What I want to do is avoid using a nested for loop for this because using nested for loops is in my opinion the slowest possible way to solve this task (O(n^2) time if I'm not mistaken): I want to add up all elapsed seconds from an issue under the 'project_id' value from the second array. This means producing a result that looks something like this: [ {project_id: 1445, seconds_elapsed: '270129'}, {project_id: 1467, seconds_elapsed: '16012'}, ... ] Does anyone have a solution to this particular problem? Because those I have found out there on the internet, I either do not understand or does not apply to my use case. -- Thanks!
-
Basically I need help if someone can guide or point me in the right direction to rewrite PHP logic in JavaScript What I want to do: In POSTMAN I need to POST payment request to online checkout. I have managed to fill the body form data, with all the needed key/values as I followed the documentation they provide (the place I need to post the request) but I stumbled upon the Signature as they require it to be calculated (not just copy pasted in the request) and the only example they provide is in PHP. Postman Pre-request script is only written in JavaScript so the PHP example they have can't be used. Any help would be appreciated, I've tried writing it on my own, but nothing seems to work, so a reading material or tips would be of a great help! This is the link to their PHP example that needs to be interpreted.
- 7 replies
-
- php
- javascript
-
(and 2 more)
Tagged with:
-
Hey, i am building a site at work using node js, i need it to run a cmd commands (figured out how to do it with shell_process), but the thing is, that i need to run this as a function that parse the data and process it a bit, then retrun it to be compared, displayed and stroed in a db. I also need to run it multiple times, so i figured that putting the function in an external js file, but i cant for the life of me, get the output from the function into the main function, not even to a console.log. Is there any way to use the stdout of the shell_process in the main app? I can really use the help, it is holding me back so badly... Thanks
- 1 reply
-
- node
- javascript
-
(and 3 more)
Tagged with:
-
Hi! I'm in need of some help with my JavaScript work for programming. I need to make a program that adds 2 parameters together as a function and returns them. The problem I'm having is that its a function and I'm still learning how to properly execute functions. Here is the question being asked by my instructor followed by my current progress. Question: *in the image* My answer: //add function - adds two numbers together var add = function( operand1, operand2) { var sum = (operand1 + operand2); return sum; } //Now add two test cases that will call the add function with different parameters. add(10,10);
-
I have been trying to get the Y position of the highest pixel in an image that is not transparent. I want a function where you input an X coordinate and the minimum opacity for a pixel to be considered transparent. It returns the Y coordinate of the highest point of this, the visible image in the canvas, from the imputed X coordinate. I tried this, and am not sure what I got wrong: this.highestPoint = function(x, transparency = 1) { var imageCanvas = document.createElement("CANVAS"); var imageCtx = imageCanvas.getContext("2d"); imageCanvas.width = canvas.width; imageCanvas.height = canvas.height; var image = new Image(); image.src = this.base64Src; imageCtx.drawImage(image, this.x, this.y, this.width, this.height); var highestPoint = -1; var imageData = imageCtx.getImageData(x, this.y, 1, this.height).data; for(var i = 1; i < (imageData.length + 1) / 4; i++){ if(imageData[i * 3] >= transparency){ console.log(i) highestPoint = i; break; } } if(highestPoint != -1){ highestPoint = this.y - highestPoint + 1; } return highestPoint; }
-
I want to store multiple variables and objects in the cloud. I am aware about databases, but I can't find one that is both free and user-friendly. Does anyone have any solution? Thanks in advance.
-
I'm having some trouble accessing a prop from within the History page I'm making using React. In App.js I'm passing user as a prop. <Route exact path="/history" render={(props) => ( <History user={user}/> )} /> user is returned during componentDidMount: componentDidMount() { const user = AuthService.getCurrentUser(); if (user) { this.setState({ user: user }); The interesting fact is that I have another component before History : <HeaderBar user={user}/> And within the HeadBar component, it's able to access the user prop without any problems. However, in History, when I log this.props.user in the constructor, I'm constantly getting undefined. I made sure I have super(props) in the constructor so I'm at a lost right now. What could I be missing that's preventing me from passing the user prop? So right now in History I have: class History extends React.Component { constructor(props) { super(props); console.log(this.props.user) If I add a button within render that logs this exact item, it logs it perfectly. The problem is that I need to use this user information to fetch whatever is going to be rendered on the page.
- 2 replies
-
- js
- javascript
-
(and 1 more)
Tagged with: