« first day (2264 days earlier)      last day (2909 days later) » 

11:03
Hello everyone
@ChristopheCosta Welcome to the JavaScript chat! Please review the room rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
@Sheepy is 0 prefix for octal ? I thought 0x is octal
I will go through docs again, after I reach home from office
0x is hex
0o is octal
0 is legacy octal
0 is zero
11:21
you're 0
Hi guys.
I wrote a simple JavaScript Slider plugin
The problem here is, I want it so that I can use multiple instances of it.
How would I be able to do that?
@rlemon Jesus christ hahaha
any ideas why in this gitignore foo.d.ts is still ignored

build
!/build/foo.d.ts
@Abhishrek did you fix your ts - webpack issue?
> /build
@FlyingGambit 0 is octal. 0x is hexdecimal. And this shows that you don't use strict mode, because strict mode disallows octal to prevent accidents and confusions like this :)
11:32
Strict mode disallows leading-0-octal syntax.
But allows 0o
@MueyiwaMosesIkomi Welcome to the JavaScript chat! Please review the room rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
Read
Does anyone use IDM here (Internet Download Manager)
?
@littlepootis no luck
Hi guys.
setInterval(function () {

                self.hideSlide(self.slider.current);

                if (self.slider.current == self.slider.max) {
                    self.slider.current = -1;
                }

                self.slider.current++;

                var main = self;

                setTimeout(function () {
                    if (main.slider.images.length > 0) {
                        main.showSlide(main.slider.images[main.slider.current], main.slider.current);
                    } else {
I have that code
A closure, calling setTimeout which has naother closure
How would I access the global this
For the main setInterval, I have var self = this; before it.
But doing var main = self; doesn't work.
11:37
@SuperUberDuper /build is not relative
change
!/build/foo.d.ts
to
!build/foo.d.ts
@HassanAlthaf var self2 = this before setIn
I actually can use self inside.
But, the value is changing a bit.
I get undefined for a particular value
@littlepootis still no luck
Actually, fixed it.
But I get a weird error.
Uncaught TypeError: Cannot read property 'protocol' of undefined
at Object.<anonymous> (client?93b6:111)
at Object.<anonymous> (client?93b6:138)
at __webpack_require__ (bootstrap fefc7a9…:52)
at Object.672 (main.bundle.js:217)
at __webpack_require__ (bootstrap fefc7a9…:52)
at webpackJsonpCallback (bootstrap fefc7a9…:23)
at main.bundle.js:1
protocol of what?
undef
11:40
No idea.
debug it
Those are auto generate files
Could it be that some variables are colliding?
debug the client
main.bundle.js:217
__webpack_require__(363);
Goes to modules[moduleId].call(module.exports, module, module.exports, webpack_require);
webpack config?
11:43
I don't even use webpack
;o
I use bower and npm
I have
Angular 2 if that makes any difference
its using webpack under the hood
@HassanAlthaf If you say you aren't using Webpack
Something certainly is.
A dependency of yours, perhaps
Yeah, dependency.
What could it be... hmm
What generates main.bundle.js?
go check the issues on github for angular2
11:44
No idea, I don't have it in me
I tried to check the link and apparently, it's in the root folder
probably angular cli or bundled build script
could be
It is angular
But it has something to do with the file I have right now.
As soon as I remove this slider library, that error goes away.
@towc 2D semitransparency is comparatively easy, but I assume that you wouldn't use webGL for 2D
@KendallFrey I would :P
import './polyfills.ts';

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';
import { AppModule } from './app/';

if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule);
11:46
@HassanAlthaf or you could switch to vanilla, less of a black box
@MueyiwaMosesIkomi Can the Internet Download Manager download the Internet for me?
loooooool
I found the problem.
@Sheepy Of course
I am doing something wrong in my library
11:47
Why do you think it's called Internet Download Manager?
@HassanAlthaf Now open an issue with the library and tell them to have a better error message.
I made the library
There's some programmatic error.
It works fine if I want it to
Use it only once.
But when I use it twice, it breaks.
@HassanAlthaf Look for the side effects
@HassanAlthaf Just want it to work so you could sleep.
@littlepootis It's a personal project, so... I could skip this, but I wanna fix this somehow.
Learn something new.
11:54
@HassanAlthaf Does that code work?
If it is, it might be more fitting on Code Review
@MadaraUchiha It works perfectly fine. I just want it to be able to be used more than once.
It works as expected.
But I want to know how to make it work in an Object-Oriented way
@HassanAlthaf @HassanAlthaf Somewhere in that code, you're relying on a global variable.
Yeah, I figured that's the problem.
The first instance replaces the second instance.
And not in "static" code either, somewhere in the code that is supposed to run per instance, you have a global shared state
I mean, the second instance replaces the first.
How would I make it to work with different states?
11:56
@HassanAlthaf Right, I see the problem.
You have a shared slider = {} variable that both instances use
You should be using this instead
Yes
I did that too.
When I do that,
The protocol error comes up.
Let me show you the code I wrote.
class Person {
  constructor(name) {
    this.name = name;
  }

  getName() {
    return this.name;
  }
}

const p1 = new Person('Madara');
const p2 = new Person('Hassan');

console.log(p1.getName(), p2.getName()); // Madara, Hassan
Is it safe to use ES6 syntax?
@HassanAlthaf this.slider is never defined.
@HassanAlthaf What's the browser support you're aiming for?
It is.
Aiming for IE9+
Including mobile browsers
Like Safari, Opera
11:59
In that case, you can use Babel
But even without, class is just syntax sugar
How do I replicate that exact same syntax
Using pre-ES6 JS?
function Person(name) {
  this.name = name;
}

Person.prototype.getName = function() {
  return this.name;
}
Where do you define the variable
@HassanAlthaf What variable?
The rest is exactly the same
SliderModule.init.prototype = {
        slider: {},

        showSlide: function (data, index) {
I did it inside the prototype part.
Is it wrong?
12:01
@HassanAlthaf Things you place on the prototype are shared among all instances
And things you place on this are per-instance.
So your slider is still shared between all objects.
As a general rule, only place methods on the prototype.
Oh, so, you just write this.<variable>
Until you know better.
In the constructor?
@HassanAlthaf Correct.
Just like I defined this.name in my example
Ohh, thanks!
I'll try and let you know the results.
Thank you very much @MadaraUchiha
Works flawlessly now.
JS is hard at times but interesting.
12:05
JS's OO is conceptually different from classical OO that PHP and Java have
But I think it's more flexible and powerful.
12:24
I like C# ;]
I don't really like PHP OO that much. You anyway need procedural code to write OO apps.
Java is good too.
I'm writing JS after ages
I couldn't find a good date answer on SO - most likely my google-fu is not up to par - so I composed one. If you are interested in js date, you're welcomed to take a look and comment.
+1. Would be nice to include how to get the present date.
@HassanAlthaf I think that's the first case of no parameters?
@Sheepy My bad, didn't see it.
Nice post dude! Very helpful.
Guess I can format the code better. After dinner.
12:53
@Mosho so, really weird
On Sahar's computer and on @MadaraUchiha's the hot reload takes 0.5 seconds and on mine and on Nitzan's it takes 20 seconds
user5915322
Hey all,

can some1 help me with this question ?
user5915322
0
Q: drag and drop doesnt upload

Jr programmeurI use a drag and drop upload. The thing I don't get is when I use the click it will upload. But if I use the drag and drop it won't upload but I don't get any error to go with. https://jsfiddle.net/7zswysft/ In this example I use the code for clicking (https://jsfiddle.net/tv391f0p/) $("#butt...

user5915322
the problem is it has to work with google drive api
user5915322
otherwise (in a form) it was easier for me to fix this problme
user5915322
problem*
13:26
HI, can i convert plain text to HTML tag for send mail.
"&nbsp; &nbsp; &nbsp; &nbsp; &lt;tbody&gt;<br />"
@HardikMansaraa You need to unescape the text you have, and find out how to send html email with your email library.
Just finished answering a question, took me more than 45 mins but I feel all thrilled and proud of my answer :D
My first answer to a question with bounty :D
@TrojanByAccident We got answers , check stackoverflow.com/questions/41340836/…
@Sheepy Thanks for answering, I will have to ask TrojanByAccident and see if he has any questions
13:59
I vote we throw away our current date/times and come up with something sensible.
I support you
I propose we split the day into 17 hours. each of those split into 61 minutes, with 10 seconds each (seconds were too short).
day = 13 hours in summer and day = 17 hours in winter
like the romans
Now.. go write me a new Date object that handles it all.
me hides behind the biggest pillow
14:03
you should try jQuery.emulateInParallelUniverse(...)
Also, all leap day/minutes/seconds will accumulate, to be dispersed whenever I am running late and need more time.
lol thats how I really feel now
who cares about time, throw away all the clocks and watches, just go home when it becomes dark
> throw away all the clocks and watches
The world did that years ago. We use our phones, now.
14:07
XD
Good one. :)
7 Hats FTW :D
14 hats FTW
The Date answer, by the way, took me two nursing sessions to compose and the in-between time to edit.
When I play MMO I count time by cooldown. When I play baby the baby is my alarm clock.
14:12
nursing sessions ? You work as a male nanny ?
Hye guys...in firefox default debugger...what is the equivalent of "run to here"...in other words executing a script to a specific line in code...
I think the toughest hat to find is the one called "Maverick"
dumb question, but is it bad practice to implement children as a function in React?
render() {
  const { data, children } = this.props;
  return (<div className={styles.list}>{data.map(children)}</div>);
}
14:29
Is it possible to return an Html helper from jquery? I don't want to return an action, I need to return Html.BeginForm as I am dynamically adding rows to a table.
@corvid it's not a function, it's the result of a function. nothing wrong.
Some will argue it's more readable to put the map before the return, but that's just style.
@Kramb rephrase, that didn't make much sense.
@corvid How would children be a function?
ohh, children is a function, i didn't realize. but yes, that's possible.
<MyComponent>{(x) => x}</MyComponent>
Aha
But why?
since that child never gets passed to react, it's replaced in the render(), it's not an error.
No good reason
14:36
Sorry @Luggage, I think I figured it out. I'm adding rows to a table with ajax, but I needed the razor @using(Html.BeginForm()) added to each row and I could not for the life of me figure it out.
But I think @HttpUtility.JavaScriptStringEncode is going to put me on the right path
if data is an array from another source, and the map function is longer, then you may use children just do you can put it inline, in the 'body' of the component.
No difference than sticking it in another property, though
<MyList data={someArray}>
    {(item) => (
        <div> blah blah blah { item.foo } blah </div>
    )}
</MyList>
It's child abuse, but hey.. we're all guilty of that.
14:55
0
Q: webgl - don't empty canvas on each frame

towcI was trying to recreate the effect achieved by this code in the 2d context: // frame background "repaint" ctx.fillStyle = 'rgba(0,0,0,.08)'; ctx.fillRect( 0, 0, w, h ); // draw rest of frame which essentially adds a "trail". An example can be seen here: http://codepen.io/towc/pen/mJzOWJ I e...

^ @ssube @KendallFrey
@towc I still think of webgl in terms of 3D. If you're truly not doing 3D, why are you using webgl?
because it's so much faster :P
webgl is just a rasterizer. You need to put in the 3d maths yourself anyway. In the same way you can put 3d maths in the 2d context
ehm
not really

« first day (2264 days earlier)      last day (2909 days later) »