Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Bill NYSE posted:

Is it okay to ask React questions here? I'm not totally grasping a concept and want to figure this out.

A checkbox group can have a parent, global, checkbox that propagates its state to all children. If one of the children is un-checked then the parent should also be. I have two groups of checkboxes and can un-check them all when I un-check the parent, but can't seem to grasp how to get them all checked initially (on the first click) within the same call to this.setState -- the tutorial and documentation have basically gotten me this far: https://jsfiddle.net/x0b1Lzc4/1/ but I don't feel that I'm doing this the React way.

Since the "checkedness" of one box affects others, don't keep it in component state. Have a wrapper around all the boxes, and every check / uncheck goes to it, and it process the resulting state, then passes it all down as props to individual checkbox components along with the callback to call on change. You are kind of there-ish, but it's late and the code is hard to read on my phone so I can't really offer any better advice right now. Tomorrow though!

Adbot
ADBOT LOVES YOU

Video Nasty
Jun 17, 2003

Okay, I had skimmed through the portion of the documentation on wrappers and have a basic concept but I'll need to spend some time getting it all figured out.
Let me see what I can do with this and reach out if I'm still not getting it. Thanks!

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Bill NYSE posted:

Okay, I had skimmed through the portion of the documentation on wrappers and have a basic concept but I'll need to spend some time getting it all figured out.
Let me see what I can do with this and reach out if I'm still not getting it. Thanks!

Check out Dan Abamov's thing on presentational and container components: https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0#.mahwdiqum

I have found using Redux had really helped my "react thinking" in that it learned me to keep app state in a single place. Even if you don't use Redux, I highly recommend reaind up on it and watching his awesome redux intro course on egghead as the concepts in it are very valuable. https://egghead.io/courses/getting-started-with-redux

Fish Ladder Theory
Jun 7, 2005

Bill NYSE posted:

Is it okay to ask React questions here? I'm not totally grasping a concept and want to figure this out.

A checkbox group can have a parent, global, checkbox that propagates its state to all children. If one of the children is un-checked then the parent should also be. I have two groups of checkboxes and can un-check them all when I un-check the parent, but can't seem to grasp how to get them all checked initially (on the first click) within the same call to this.setState -- the tutorial and documentation have basically gotten me this far: https://jsfiddle.net/x0b1Lzc4/1/ but I don't feel that I'm doing this the React way.

I made a plnkr showing how i'd do it. i also changed to class syntax, brought in babel for es6/7 syntax, and used lodash instead of jquery to give you a better idea of how a modern react app would be written (and to save myself a headache trying to remember how the old style works).

https://plnkr.co/edit/jUHEqoAihxyeucgR0LNS?p=preview

the basic idea is that only one piece of state matters: which individual languages are selected. Everything else can be derived from that-- so for example, the state of a parent checkbox for a language group is a function of whether all children in its group are selected.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Fish Ladder Theory posted:

I made a plnkr showing how i'd do it. i also changed to class syntax, brought in babel for es6/7 syntax, and used lodash instead of jquery to give you a better idea of how a modern react app would be written (and to save myself a headache trying to remember how the old style works).

https://plnkr.co/edit/jUHEqoAihxyeucgR0LNS?p=preview

the basic idea is that only one piece of state matters: which individual languages are selected. Everything else can be derived from that-- so for example, the state of a parent checkbox for a language group is a function of whether all children in its group are selected.

Another quick and dirty take on this (FLT's approach is certainly fine, just figured seeing other ways is helpful!) is using "dumb" components that don't have any knowledge of their own state/ logic. The single "smart" component sets up all the handlers so the components themselves have no idea about languages, checked-ness, etc. I take the initial list of languages, and map it to an app state" that has information about the selected state of each lang. That way all app state is stored in a single place, and *not* in the DOM. I also skipped lodash and all that, since babel was included, so just use that!

Please note that I didn't actually implement the state-switching because I am lazy, and because storing things the way I did isn't the best (because I'm lazy) but you can quickly get it all working by filling in the comments with actual code. In a "Reduxy" app, the handlers would be actions, and modifying the state would happen in a pure reducer function that would ship a new state back to TreeContainer to render. But again, I am lazy.

https://plnkr.co/edit/xHK5RILmc8P2Q8PTvrnU?p=preview

hooah
Feb 6, 2006
WTF?
I'm working through the Eloquent JavaScript book (again; didn't get too far last time), and found an unexpected thing with arrays:
JavaScript code:
var range = function(start, end) {
  result = [];
  for (var i = start; i <= end; i++) {
    result.push(i);
  }
  return result;
}

var sum = function(array) {
  result = 0;
  for (value in array) {
    result += value;
  }
  return result;
}
The for loop in the sum function seems to turn the numbers in the array into strings representing that number (e.g. "1" rather than 1). I verified this by sticking a console.log(typeof value); in the loop. However, if I do a traditional for loop with a start, end, and increment, then use the loop variable to index into the array, it works fine. What's going on here?

Weekend Bridges
Apr 8, 2015

by Smythe

hooah posted:

I'm working through the Eloquent JavaScript book (again; didn't get too far last time), and found an unexpected thing with arrays:
JavaScript code:
var range = function(start, end) {
  result = [];
  for (var i = start; i <= end; i++) {
    result.push(i);
  }
  return result;
}

var sum = function(array) {
  result = 0;
  for (value in array) {
    result += value;
  }
  return result;
}
The for loop in the sum function seems to turn the numbers in the array into strings representing that number (e.g. "1" rather than 1). I verified this by sticking a console.log(typeof value); in the loop. However, if I do a traditional for loop with a start, end, and increment, then use the loop variable to index into the array, it works fine. What's going on here?

for...in is for looping over the properties of an object, which are strings. try these:

code:
var x
for (x in { a: 1, b: 2, c: 3 }) console.log(x)
console.log(Object.keys(['a', 'b', 'c']))
var arr = []
arr[3] = 'c'
console.log(Object.keys(arr))
for (x in arr) console.log(x)
var i
for (i = 0; i < arr.length; ++i) console.log(arr[i])

Weekend Bridges fucked around with this message at 18:12 on Jul 9, 2016

Sedro
Dec 31, 2008

Weekend Bridges posted:

for...in is for looping over the properties of an object, which are strings. try these:

You can also use for...of since ES6

hooah
Feb 6, 2006
WTF?
Thanks for the explanation. Now for a new question. I'm trying to mess around with this "open all unread in new tabs" GreaseMonkey script:
JavaScript code:
// ==UserScript==
// @id             jerkikosnewtabs
// @name           jerkikosnewtabs
// @version        1.0
// @namespace      
// @author         
// @description    
// @include        [url]http://forums.somethingawful.com/*[/url]
// @match					[url]https://forums.somethingawful.com/*[/url]
// @grant          GM_openInTab
// @run-at         document-end
// ==/UserScript==
var forum = document.getElementById('forum');
if (forum)
{
  var button = document.createElement('a');
  button.href = '#';
  button.innerHTML = 'Open New Posts in New Tabs';
  button.style.cssFloat = 'right';
  button.style.marginRight = '8px';
  button.addEventListener('click', NewPostsInNewTabs, false);
  var where = document.evaluate('THEAD/TR/TH[contains(@class,\'title\')]', forum, null, 7, null);
  where = where.snapshotItem(0);
  if (where)
  {
    where.insertBefore(button, where.firstChild);
  }
}
function NewPostsInNewTabs(event)
{
  var eval,
  node,
  name;
  event.preventDefault();
  eval = document.evaluate('TBODY/TR/TD/DIV/DIV/A[contains(@class,\'count\')]', document.getElementById('forum'), null, 7, null);
  OpenTabLoop(eval);
  return;
}
var i = 0;
function OpenTabLoop(eval) {
  if (i < eval.snapshotLength) {
    setTimeout(function () {
      node = eval.snapshotItem(i);
      node = node.href;
      i++;
      OpenTabLoop(eval);
      GM_openInTab(node);
    }, 10);
  }
}

// function OpenTabLoop(eval) {
//   for (var i = 0; i < eval.snapshotLength) {
//     node = eval.snapshotItem(i).href;
//     GM_openInTab(node);
//   }
// }

The existing OpenTabLoop function (the uncommented one) is recursive, and it doesn't seem to need to be. So I re-wrote it using a simple for loop. However, if I enable my version and comment out the original, the "Open New Posts in New Tabs" button disappears. This doesn't make any sense to me. What is going on?

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

Sedro posted:

You can also use for...of since ES6

For...of works differently. It is an iterator of each object in a container, where for...in is iterating over the objects properties.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Skandranon posted:

For...of works differently. It is an iterator of each object in a container, where for...in is iterating over the objects properties.

I like to use forEach for iterating over an array. It's like for...in but actually does the correct thing - only downside is you can't break forEach, but it wouldn't be javascript without having five ways of doing the same thing that are broken in subtly different ways.

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

Bruegels Fuckbooks posted:

I like to use forEach for iterating over an array. It's like for...in but actually does the correct thing - only downside is you can't break forEach, but it wouldn't be javascript without having five ways of doing the same thing that are broken in subtly different ways.

I believe for...of is faster as it does not need to create a closure for every iteration.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

Skandranon posted:

I believe for...of is faster as it does not need to create a closure for every iteration.

The closure is only created once isn't it?

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

HappyHippo posted:

The closure is only created once isn't it?

Not sure about native ES6 support, but TypeScript turns it into a straight up for() loop without any closures at all when targetting ES5.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Bruegels Fuckbooks posted:

I like to use forEach for iterating over an array. It's like for...in but actually does the correct thing - only downside is you can't break forEach, but it wouldn't be javascript without having five ways of doing the same thing that are broken in subtly different ways.

You use forEach when you want to do some operation for each element of the array.

If you're trying to find any value that satisfies a condition (after which you would want to break from the loop), use some()

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



hooah posted:

JavaScript code:
// function OpenTabLoop(eval) {
//   for (var i = 0; i < eval.snapshotLength) {
//     node = eval.snapshotItem(i).href;
//     GM_openInTab(node);
//   }
// }
The existing OpenTabLoop function (the uncommented one) is recursive, and it doesn't seem to need to be. So I re-wrote it using a simple for loop. However, if I enable my version and comment out the original, the "Open New Posts in New Tabs" button disappears. This doesn't make any sense to me. What is going on?

Your for loop syntax is incorrect so the whole script fails to parse and so won't run. There have to be three expressions and you only wrote two.

hooah
Feb 6, 2006
WTF?
Oh for gently caress's sake.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



hooah posted:

Oh for gently caress's sake.

I know, right?

necrotic
Aug 2, 2005
I owe my brother big time for this!

Skandranon posted:

Not sure about native ES6 support, but TypeScript turns it into a straight up for() loop without any closures at all when targetting ES5.

Yeah, forEach is in most browsers now (all?) and writing a shim is super simple for older ones.

If TypeScript is not hoisting the closure when transpiling thats loving dumb, though.

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

necrotic posted:

Yeah, forEach is in most browsers now (all?) and writing a shim is super simple for older ones.

If TypeScript is not hoisting the closure when transpiling thats loving dumb, though.

How is that dumb? A closure is not needed, just like you do not need one for a for() loop.

FAT32 SHAMER
Aug 16, 2012



Hey all, I'm relatively new to node.js/javascript/json, and I've been banging my head against the wall since last night trying to figure this out.

I'm using Discordie to write a Discord bot that has certain commands, and one of those commands i would like to be "!invite". Looking at the documentation, calling the method .createInvite returns a Promise<Object, Error>, with the Object being a JSON object, then gives this example of creating an invite and getting its response.

JavaScript code:
channel.createInvite({
  max_age: 60 * 60 * 24,
  // value in seconds
  max_uses: 0,
  // pretty obvious
  temporary: false,
  // temporary membership, kicks members without roles on disconnect
  xkcdpass: false
  // human readable
});
// Example response:
{
  "max_age": 86400,
  "code": "AAAAAAAAAAAAAAAA",
  "guild": {
    "id": "00000000000000000",
    "name": "test"
  },
  "revoked": false,
  "created_at": "2015-10-16T10:45:38.566978+00:00",
  "temporary": false,
  "uses": 0,
  "max_uses": 0,
  "inviter": {
    "username": "testuser",
    "discriminator": "3273",
    "id": "00000000000000000",
    "avatar": null
  },
  "xkcdpass": null,
  "channel": {
    "type": "text",
    "id": "000000000000000000",
    "name": "testchannel"
  }
}
The part that I need from this returned object is the value of "code", but I can't figure out how to access that information. Here's my code as it stands:

JavaScript code:
	var generateInvite = e.message.channel.createInvite({"temporary": false, "xkcdpass": false});
			
	e.message.channel.sendMessage(generateInvite.code);
	
however all it returns is "undefined". Am I missing something here? Is the reason I can't figure this out because I don't know how Promises work yet? Or am I listening for a response on a variable that will not give a response?

I know that the code itself is generating the invite because it shows up in the list of active invites, but I can't figure out how to make it show the code value. I tried JSON.stringify(generateInvite.code) but that still returned "undefined"

FAT32 SHAMER fucked around with this message at 18:43 on Jul 11, 2016

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

Tusen Takk posted:

Hey all, I'm relatively new to node.js/javascript/json, and I've been banging my head against the wall since last night trying to figure this out.

I'm using Discordie to write a Discord bot that has certain commands, and one of those commands i would like to be "!invite". Looking at the documentation, calling the method .createInvite returns a Promise<Object, Error>, with the Object being a JSON object, then gives this example of creating an invite and getting its response.

The part that I need from this returned object is the value of "code", but I can't figure out how to access that information. Here's my code as it stands:

JavaScript code:
	var generateInvite = e.message.channel.createInvite({"temporary": false, "xkcdpass": false});
			
	e.message.channel.sendMessage(generateInvite.code);
	
however all it returns is an empty bracket. Am I missing something here? Is the reason I can't figure this out because I don't know how Promises work yet? Or am I listening for a response on a variable that will not give a response?

I know that the code itself is generating the invite because it shows up in the list of active invites, but I can't figure out how to make it show the value. I tried JSON.stringify(generateInvite.code) but that still returned an empty bracket

Assuming createInvite() returns a promise, then yes, you are not doing promises right. You need to do generateInvite.then( function(res) { e.message.channel.sendMessage(res.code); });

FAT32 SHAMER
Aug 16, 2012



Skandranon posted:

Assuming createInvite() returns a promise, then yes, you are not doing promises right. You need to do generateInvite.then( function(res) { e.message.channel.sendMessage(res.code); });

Holy poo poo I love you <3

Do you guys have any recommendations on materials for reading up on Bluebird/Promises?

edit: so piggy backing off of this whole promises thing, how would I stick this promise into another promise, ie

JavaScript code:
	var generateInvite = e.message.channel.createInvite({"temporary": false, "xkcdpass": false});
					
	e.message.author.openDM().then(dm => dm.sendMessage(`You have been kicked from the **${e.message.guild.name}** server for using a slur.` + 
	`Please consider this a probation. When you feel that you are ready to not use that sort of language, feel free to rejoin us by following this link: ${inviteCodeFromPromise}`));
edit2: would it be something more like this:

JavaScript code:
generateInvite.then( function(res) { e.message.author.openDM().then(dm => dm.sendMessage(`You have been kicked from the **${e.message.guild.name}** server for using a slur.` + 
				`Please consider this a probation. When you feel that you are ready to not use that sort of language, feel free to rejoin us by following this link: [url]https://discord.gg/[/url]` + res.code)); });

FAT32 SHAMER fucked around with this message at 19:30 on Jul 11, 2016

necrotic
Aug 2, 2005
I owe my brother big time for this!

Skandranon posted:

How is that dumb? A closure is not needed, just like you do not need one for a for() loop.

forEach takes an anonymous function. Is TypeScript transpiling forEach(function(e) { console.log(e) }) to:

code:
for(var i = 0; blah gently caress blah) {
  (function(el) {
    console.log(el)
  }).call(null, el)
}
or

code:
for(var i = 0; blah gently caress blah) {
  console.log(el)
}
or

code:
var handler = function(e) { console.log(e) }
for(var i = 0; blah gently caress blah) {
  handler.call(null, el)
}
The first one is creating a new closure every iteration of the loop. The second changes the semantics and would make return gently caress things up. The latter seems like the "correct" transpiling approach.

However, the best is just to define a forEach shim and not transpile to ES5 at all.

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

necrotic posted:

forEach takes an anonymous function. Is TypeScript transpiling forEach(function(e) { console.log(e) }) to:

code:
for(var i = 0; blah gently caress blah) {
  (function(el) {
    console.log(el)
  }).call(null, el)
}
or

code:
for(var i = 0; blah gently caress blah) {
  console.log(el)
}
or

code:
var handler = function(e) { console.log(e) }
for(var i = 0; blah gently caress blah) {
  handler.call(null, el)
}
The first one is creating a new closure every iteration of the loop. The second changes the semantics and would make return gently caress things up. The latter seems like the "correct" transpiling approach.

However, the best is just to define a forEach shim and not transpile to ES5 at all.

I was not talking about forEach. I was talking about the ES6 for...of(). It translates for...of to a for() loop. There are no closures because there are no passed functions, there is just inline code.

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

Tusen Takk posted:

Holy poo poo I love you <3

Do you guys have any recommendations on materials for reading up on Bluebird/Promises?

edit: so piggy backing off of this whole promises thing, how would I stick this promise into another promise, ie

JavaScript code:
	var generateInvite = e.message.channel.createInvite({"temporary": false, "xkcdpass": false});
					
	e.message.author.openDM().then(dm => dm.sendMessage(`You have been kicked from the **${e.message.guild.name}** server for using a slur.` + 
	`Please consider this a probation. When you feel that you are ready to not use that sort of language, feel free to rejoin us by following this link: ${inviteCodeFromPromise}`));

You can either nest promises like so. You can also use Bluebird functions like all(), which will aggregate the provided promises into a single promise which is resolved when all aggregated promises are resolved.

code:
x = getPromise();

x.then( function(res) { return res.code; })
	.then( function (resCode) { doThingWithCode(resCode); }	

FAT32 SHAMER
Aug 16, 2012



Skandranon posted:

You can either nest promises like so. You can also use Bluebird functions like all(), which will aggregate the provided promises into a single promise which is resolved when all aggregated promises are resolved.

code:
x = getPromise();

x.then( function(res) { return res.code; })
	.then( function (resCode) { doThingWithCode(resCode); }	

Okay, so it'd be more like

JavaScript code:
generateInvite.then( function(res) { return res.code }
	.then(e.message.author.openDM().then(dm => dm.sendMessage(`You have been kicked from the **${e.message.guild.name}** server for using a slur.` + 
`Please consider this a probation. When you feel that you are ready to not use that sort of language, feel free to rejoin us by following this link: discord.gg/` + res.code))); );
?

Or is that not how you stack promises

:shobon:

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

Skandranon posted:

I was not talking about forEach. I was talking about the ES6 for...of(). It translates for...of to a for() loop. There are no closures because there are no passed functions, there is just inline code.

You said for...of was faster than forEach because it doesn't need to "create a closure for every iteration." I pointed out that forEach only needs to create a closure once. You responded that "Not sure about native ES6 support, but TypeScript turns it into a straight up for() loop without any closures at all when targetting ES5." I'm guessing that "it" here refers to for..of, and this is why everything's confusing? I also thought you were referring to forEach in that sentence.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Skandranon posted:

I was not talking about forEach. I was talking about the ES6 for...of(). It translates for...of to a for() loop. There are no closures because there are no passed functions, there is just inline code.

My bad, I mixed it in with the forEach talk.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe
I need help figuring out how to proceed with a 3D project I want to prototype. Basically I want to make a "simple" little 3D environment containing a lone box with some little 3D "tokens" that can use the mouse to move around and pile up. What would be a good library for this? Three.JS seems to be the de-facto library for 3D work in Javascript but it seems so daunting as I'm not much of a 3D programmer, so I'm wondering if there's a more approachable library I could look into :sweatdrop:

Parts Kit
Jun 9, 2006

durr
i have a hole in my head
durr
loving stupid question that's driving me up the wall: I'm trying to make a very generic script for fading text in boxes in/out. In the html they are structured as a sequence of divs, with a container, the individual boxes, and each box then has a "heading" and "text" which are superimposed on each other. Idea is that when a mouse hovers over the individual boxes the heading fades out and the text fades in. Everything is done generally with classes instead of individual IDs, but I've not been able to find something that lets me grab all the objects without stuffing them into something that requires an index, and the methods of retrieving the index I've seen require a specific content match.

While I could give them all IDs it would add a significant amount of specificity that I'm trying to avoid.

First attempt was through CSS but it won't let me hit both the heading and text at the same time.

ed: I would also very much like to avoid jquery at this time.

Parts Kit fucked around with this message at 02:59 on Jul 13, 2016

Depressing Box
Jun 27, 2010

Half-price sideshow.
Could you post an example of what your HTML structure looks like?

Parts Kit
Jun 9, 2006

durr
i have a hole in my head
durr
code:
<div id="boxBox">

	<div class="box">
		<div class="boxDesc">
			<h3>title for box 1</h3>
		</div>
		<div class="boxText">
			<p>description of poo poo</p>
		</div>
	</div>

	<div class="box">
		<div class="boxDesc">
			<h3>title for box 2</h3>
		</div>
		<div class="boxText">
			<p>description of poo poo</p>
		</div>
	</div>

	[etcetera for however many boxes are required]

</div>
What I've been trying to do is when the mouse enters a "box" class div it causes the title to go to opacity zero and the description to go to opacity 100% for its child elements.

Depressing Box
Jun 27, 2010

Half-price sideshow.
Something like this?

Parts Kit
Jun 9, 2006

durr
i have a hole in my head
durr
gently caress, I knew there had to be a way to do that in CSS, but couldn't find the syntax for some reason and doing it on the p and h3s directly didn't work for whatever reason. :shepface:

Thank you so much!

Parts Kit
Jun 9, 2006

durr
i have a hole in my head
durr
That thing pissed me off so bad yesterday and I blew more time on it than I want to admit. Would you like an av, no-ads, or archives cert as extra thanks?

Chenghiz
Feb 14, 2007

WHITE WHALE
HOLY GRAIL

Tusen Takk posted:

Holy poo poo I love you <3

Do you guys have any recommendations on materials for reading up on Bluebird/Promises?

This is pretty much the canonical explanation for promises: http://www.html5rocks.com/en/tutorials/es6/promises/

Depressing Box
Jun 27, 2010

Half-price sideshow.

Parts Kit posted:

That thing pissed me off so bad yesterday and I blew more time on it than I want to admit. Would you like an av, no-ads, or archives cert as extra thanks?

No extra thanks necessary, I enjoy excuses to put the CSS rattling around in my head to good use. :)

stoops
Jun 11, 2001
I have this jqplot graph script I'm using that works on chrome, but doesnt on IE.

I think I nailed the problem to this piece of code, and I thought maybe I can run it thru JSLint and figure it out, but I'm not sure about the Foreach errors, or the parseInt error.

Any help is appreciated

code:
function printTable(file) {

var reader = new FileReader();
reader.readAsText(file);
reader.onload = function(event){
var csv = event.target.result;
var studentData = $.csv.toArrays(csv);

for(var i = 0; i < studentData.length; ++i){
	studentData[i] = studentData[i].map(val => parseInt(val, 10));
}
callPlot(studentData);
};

reader.onerror = function(){ alert("Unable to read " + file.fileName); };
}

Adbot
ADBOT LOVES YOU

necrotic
Aug 2, 2005
I owe my brother big time for this!
Which ie? Does ie even support inline functions like that map call?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply