« first day (55 days earlier)      last day (152 days later) » 

05:07
monk
 
8 hours later…
13:19
monking
 
5 hours later…
18:05
How many JavaScript people do we have on the site?
so many
full-time ones would be me and Ismael I think
everyone in the cardshifter tcg working on the html client is doing angular js
so that's at least @SirPython and @Simon (i forget his full name)
i'm sure there are many more, but those are the only that come to mind from 2nd
18:24
thank you
hey, will you check my work here --> codereview.stackexchange.com/a/103803/18427
do I need to be using "let"?
@IsmaelMiguel @ARedHerring @SirPython ▲▲▲▲▲
Sorry, didnt see.
@ let, if you're using a browser that supports ES6 or using a transpiler like babel, then you want default to using const (instead of var). Only use let when you want to have a mutable variable (which is actually quite rare, usually).
DON'T USE LET!!!
I REPEAT!!!
DON'T USE LET!!!
if you are not supporting only browsers that use es6 or not using a transpiler like babel, as @IsmaelMiguel, don't use let, or const. browsers that don't support ES6 will moan at you.
That is code for Userscripts
That will run on Chrome
@Malachi you could write your code like this instead:
var final = sortedTeamNames.map(function(teamName) {
  if(rankingsTable.hasOwnProperty(teamName)) {
    return rankingsTable[teamName];
  };
  return undefined;
});
18:31
If you use let, you ruined 90% of your 'market share'
we don't tend to like for in javascript.
@IsmaelMiguel only if you don't use a transpiler.
@ARedHerring Do you want to include a transplier with a userscript?
@IsmaelMiguel you know transpiling is something you do before distributing your code, right?
also, with regards to 'not working on Chrome'..
block-scoped bindings work just fine on the majority of recorded Chrome versions as long as you are using strict mode... which you should be.
30% of your userbase will not be able to use let. however, youl'l be transpiling with babel, so that's not an issue.
Partial = broken
Stay away!
...no
lol
stop being such an es6-phobe.
the partial support as it says shows it only works in strict mode.
18:33
I'm not
it only works in strict mode on the server, as well.
Malachi should be using strict mode.
And a transpiler.
It doesn't even work in Firefox by default (according to your link)
You're right!
Good thing this is a UserScript, which only runs in Chrome.
(quote you)
No, it doesn't run only on Chrome
And a transpiler will convert let to var. That doesn't mean you shouldn't use let, because let will still have its semantics enforced by a code linter.
18:34
But Chrome is one of the "markets"
The biggest one
Do you want a SyntaxError with that?
..what?
A transpiler isn't going to give you a syntax error
there is no reason to not use let/const/ other ES6 features
While ES6 isn't the default, please, stay away from it
Ignore what @IsmaelMiguel is saying because it's stupid
It's not
It really is. All of the ES6 features can be converted into ES5 features because they are syntactic sguar.
every single one.
As long as you run your source code through a transpiler to ensure backwards compatibility, you will be fine to use ES6.
Why? because every single React application is written in ES6.
Facebook is a React application.
Last I checked, Facebook wasn't having any issues with compatibility.
18:38
Fine, fine fine fine fien fien fien ine fienfien
Please stop spouting nonsense. ES6 is fine to use as long as you run it through a transpiler like Babel, no different to how you would run CoffeeScript through a transpiler.
If you don't want to use it - fine - but don't try and tell people not to use it for no good reason
The good reason is because it is too green
ES6 is the future, within a few years it will be the default and you're better off learning it now given the best web framework uses it.
that would be a valid point if the draft was not finalised
But it is - all the features you see in Es6 now will be the ones that are supported by browsers natively in 2-3 years
there are going to be no more changes to the spec until es7 now
Tell me
What browsers use ES6 by default, entirelly, without transpliers or what-not?
Likely all of the mainstream ones
Not the ones now, of course not.
But that's why you use a transpiler to maintain backwards compatibility
Edge already supports a few features from ES6, Chrome is on the way there (ChromeCanary is even closer). Firefox is working towards it albeit at a slower pace
Safari doesn't and probably won't, but Safari doesn't support a great deal number of things, not just JavaScript features (see: CSS3)
18:42
Safari is stopped on time
And again, you have transpilers that will make Safari support the javascript natively
and/or polyfills
I mean, safari doesn't even support webm
Safari is the IE on Mac
which is basically supported by every other browser and is a standard replacement for gifs on imgur and reddit, two of the largest sites in the world.
@IsmaelMiguel and on iOS
And because not every browser supports ES6 and because it isn't perfectly supported everywhere, I don't recommend using ES6 for user-facing needs
Things that require the user to copy-paste code
Uhm.
you don't need to copy paste code through babel
18:46
They'll copy ES6 into a non-ES6 browser and say your code is broken
there is this thing called the command line
I really don't get this. You're assuming the end user has to copy and paste your code.
Userscript
.... lol
write your userscript. run it through a transpiler. distribute the result of that
your end user does not have to do the transpilation, you can
I wouldn't adventure for such road
Now you are just making excuses
There's no valid reason for you to NOT do that.
18:48
I'm not ...
For now, there is
It would be the exact same process if you wrote your UserScript in coffeescript.
Which I don't
yeah, you don't. and that's fine.
But there's no reason to discourage other people from doing it
ES6 has given me a lot of productivity with the new module system, classes, arrow functions and generators
Yes, but ES6 != Coffeescript
uhm, actually ,no
coffeescript supports es6 features and transpiles them to es5
see: yield.
18:50
I know what yield is
as of coffeescript.... 1.9, I believe.
Honestly, we are beating on rocks
I don't really see it that way
They won't move, no matter how much we shout at them
you are convinced es6 and coffeescript are different, despite the fact tehy are not
there's no reason to not use es6. you can choose to not use it if you want, but don't go saying "DON'T USE IT OMG" to other people when you simply can't formulate a valid argument
18:51
Then why you need a coffeescript "compiler"?
...what?
you need a coffeescript transpiler to translate the syntax of that language into another one.
Coffeescript has to be compiled to Javascript, as far as I know
babel will do the exact same thing with es6 code.
Look. example time.
function foo() {
  return () => this.bar;
}
this 'compiles' to this
function foo() {
  var _this = this;

  return function () {
    return _this.bar;
  };
}
18:53
That I know
That's a closure
=> is the "big arrow notation" to create functions
Yes. But the first one is es6 code, second is the result of running it through babel.
Would you agree you could use the second one in an es5 browser?
SyntaxError is the result of going through IE, Chrome and others
yes.
that's why you run the SECOND one through a browser.
But you WRITE the first one, and babel will turn it into the second one for you.
Or you could write the 2nd one
which is 2 more lines of code
'use strict';
class Foo {
  constructor() {
    this.bar = 'baz';
  }

  print() {
    console.log(this.bar);
  }
}
turns into
'use strict';

var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
would you rather I write the second one..?
18:58
You sure you need all that?
if you want to use properties.. yes
you do realize the only difference between that code and 'normal' es5 classes is that the second one just ensures that you are calling with 'new' and ensures that the things are defined as proper es5 properties
if you removed the first 6 lines of generated content, you would have almost exactly the same as what you would normally have in es5 anyway
If you want to tell him to use ES6 when it is still green, go ahead
yeah, it's new. but it's finalised.
It's not going to change now and there's no reason to not use it
19:02
The specification is
The implementation isn't
which is why we use transpilers to replicate everything in es5 so you don't have to worry about the implementation
right now you save LOC and you get compile time support (for example, with const and es6 modules)
in a years time the beta channels of browsers will be doing it all natively anyway
you have nothing to lose and everything to gain.
wow
is this guy right?
This is clearer by only a trivial amount. The code should not be any faster (haven't tested) but it is one hell of a lot less portable.Brock Adams 31 mins ago
sorry guys, I got pulled away right before someone pinged me here....
He's right, for-of is es6-only syntax and is only used for generators
and I tried to read what you guys were saying and I got lost
But it does transpile to ES6.
19:08
this code is not meant for IE though either
@ARedHerring I don't know what you are saying here?
ok, es6 = what for-of is from.
transpile = basically compile from one language into another.
for-of is an es6-only feature, which is new and so has low browser adoption. however, it is a standard feature. you can transpile es6 to es5 and get all of the features of es6 written in es5 form.
this comes out to look something like this.
Of course, you wouldn't do this by hand.. you'd run all of your finished code through babel and distribute the output instead of the original code.
Holy Jesus!
yeah, it's pretty ugly.
But that's because it uses iterators (rather than for loops) and it has to account for object smaps sets and generators
"Is it pretty or ugly?" "Both. Pretty ugly!"
the code is compatible wherever this user is using the userscript, @ARedHerring
say that 5 times fast
19:15
@Malachi the code will be compatible with es5 browsers as long as you run it through babel.
The file size might be larger.
However, in the case of this userscript, you don't need to use any es6 features at all. You shouldn't be using for-of, really
@ARedHerring why is that?
Well, because you don't need to
You have an input array, and you need to run a function over it.
use Array.prototype.map.
Javascript tends to prefer functional higher order functions than imperative constructs.
and your code looks a lot neater using functional constructs rather than imperative ones.
you got me all confused. I am not a professional JavaScript programmer, I consider myself a beginner when it comes to JavaScript, maybe intermediate, but only because I code in other languages and know the a portion of JavaScript Syntax
OK, we'd prefer this:
function getFinalTeams(rankings, teamNames) {
  return teamNames.map(function(teamName) {
    return rankings[teamName];
  });
}

function displayFinalResult() {
  var finalResults = getFinalTeams(rankingsTable, Object.keys(rankingsTable));
  GM_setValue(tableName, JSON.stringify(finalResults));
  displayResults(finalResults);
}
Instead of this:
function displayFinalResult () {
    //Sort team name
    var sortedTeamNames = Object.keys (rankingsTable).sort ( function (zA, zB) {
        return zA.localeCompare (zB);
    } );

    //Store team name and rank array in a single array
    for (var J in sortedTeamNames) {
        var teamName    = sortedTeamNames[J];
        if (rankingsTable.hasOwnProperty (teamName) ) {
            final[teamName] = rankingsTable[teamName]
        }
    }

    //Save array to browser
    GM_setValue (tableName,  JSON.stringify (final) );
And even then displayFinalResult doesn't actually make any sense. It sorts the team names by locale, but then assigns them in a random order in the final array anyway. So you could remove the sorting. once you do that, you work out hat actually all you're doing is returning the values of rankingsTable in the order they were already in.
So displayFinalResult's sort and iteration does absoultely nothing lol
I'll answer any questions you have when i get back.
AFK
Alright
Meanwhile, I'm cloning a disk
19:23
lol
I need a beer
FYI that Brock Adams has a lot of JavaScript Reputation on SO Gold Badge even
19:35
back
Left
Right
Forward
@Malachi yes, but so does a guy I corrected earlier on Angular
This guy has 1400 rep in teh Angular tag an he was completely incorrect
Rep is simply a matter of how many questions you've answered
@ARedHerring teh eh
Math.floor(now/8.64e7);
this magic number hurts me in my soul
Soul?
Where do I get one of those?
19:40
step 1) don't be born ginger
I'm not
Step 2?
step 2: no idea
Great
But seriously
Why such an horrible number?
no idea. that's the problem with magic numbers :\
Did you wrote it?
19:44
No, it's from the question that @Malachi was reviewing but I hav eno idea what it means.
Ask the O.P.
@ARedHerring I agree
@ARedHerring and I agree
I couldn't decide what to do with that number
20:04
LOL
I am not too familiar with jQuery. The majority component of this script was created by @BrockAdams. The majority of my code is in displayResults() — Bijan 25 mins ago
no wonder why he was all up in this! lol
lol....
the majority of it is ugly as fk
...
*facepalm*
function displayResults(result) {
    //Get saved results
    var myList      = {};
    var myListObj   = GM_getValue (tableName,  "");
    if (myListObj) {
        myList      = JSON.parse (myListObj);
    }
    //Check if we have already fetched results for the day
    if (typeof result === 'undefined') { result = myList; console.log("Loading pre-loaded data");}
    var player = document.querySelectorAll('span[class="Fz-xxs"]'); //Get player element
    var opp = document.querySelectorAll('a[class="F-reset"]'); //Get opposing team element
HOLY MOTHER OF GOD!
its really bad.
what's separation of data and dom?
A mystic creature, acording to the O.P.
20:39
I am taking it that I cannot navigate the DOM like this
> reviewItems[i].parentNode.nextSibling.className('dashboard-title').ChildNodes;
@IsmaelMiguel I like bugging you about this stuff..... @ARedHerring I haven't decided about bugging you yet....
That would be a REALLY bad idea, @Malachi
lol I figured
it doesn't work...
it would but you shouldnt do it anyway
that will couple your javascript wayyyyy too heavily to your DOM
what do you suggest?
or I could get it working this way, then post it, you answer it, then we all get a little bit of reputation and I get to learn something new today....?
use a class
.js-dashboard
don't use complex html dom structures like that
use flat structures, 1 level deep at most
20:49
I can't change the HTML structure
not mine
can you add a class to the html file?
if not then yeah yu're setuck with it.
you have to use what you posted
but if you can add classes.. do it
that's what they are there for.
how do I use what I have posted? it wouldn't work
let me mess with it a bit here
.parentNode.nextSibling.querySelector('.dashboard-title')
className isn't a function
21:19
tells me that querySelector is not a function either
22:09
Hey Guys, anyone want to take a look at my code here --> github.com/malachi26/ReviewQueueNotifier/blob/master/… <-- and see if they can find something that I am doing wrong. there are no errors in the console but the notification isn't popping up. did I misspell something or delete something????
Sorry, I had to leave
TTQW off home to dinner and a movie with the kids myself
hopefully I get back to this tonight at home....
Sorry, but I'm feeling like shit.
I will try to check it later

« first day (55 days earlier)      last day (152 days later) »