Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sep 17 09:17:58 <nettoweb_> Hello guys, Im learning JS and create this file and would like some suggestion to start using more OO. till now I just used Namespace in top of my file, Im wondering which good practices I would be using in this script. Just some tips so I can try. Here's my gist: https://gist.github.com/osnysantos/7f61c8887cb740c78e27
- Sep 17 09:28:40 <pr0tocol> hello, everyone.
- Sep 17 09:32:46 <GreenJello> nettoweb_, re namespaces: the best is to use real modules, but that requires a build process (see e.g. browserify)
- Sep 17 09:35:08 <GreenJello> you're using html strings when you should be using e.g. ${'<span>', {class: 'label ...'}).text(value.repla...
- Sep 17 09:35:16 <GreenJello> and using .html when you should use .text
- Sep 17 09:36:26 <GreenJello> your function names don't make sense, you're using jQuery's $.each(xs, fn) when you could just use xs.forEach(fn), and other small issues
- Sep 17 09:44:43 <nettoweb_> GreenJello thank you
- Sep 17 09:45:05 <nettoweb_> GreenJello any other suggestion about a more OO way to build these things
- Sep 17 09:46:10 <GreenJello> strive for simple, I'm not even sure what makes code more or less OO
- Sep 17 09:59:41 <loa> hello, maybe somebody know is there any way to prittytize scripts before debug them in google chrome?
- Sep 17 10:00:02 <loa> maybe there is some kind of addon or something?
- Sep 17 10:01:01 <ThePendulum> hmmm, I have a look-up table from a PDF that has y-coordinates as keys and an array of strings on that y-coordinate as a value. However, unfortunately, there is a certain margin for error when looking up the y-coordinates; it might be up to 0.01 more or less than the y-coordinate in the lookup table. I could account for this by using Array.prototype.findIndex() on the look-up table, but I imagine this makes the lot more expen
- Sep 17 10:06:58 <autrilla> Does es6 have named parameters support?
- Sep 17 10:07:49 <Impaloo> autrilla: ecmascript will never have named parameter support (don't quote me on that)
- Sep 17 10:07:58 <autrilla> Why is that?
- Sep 17 10:10:01 <diamonds> "ecmascript will never have named parameter support" - Impaloo, 2015
- Sep 17 10:11:11 <Impaloo> diamonds: https://www.youtube.com/watch?v=Tl3euCXhpaQ
- Sep 17 10:11:36 <Impaloo> autrilla: I recall reading something about it a couple years ago
- Sep 17 10:12:56 <autrilla> Maybe I'm just thinking in other languages. What do you do when you have to pass "many" parameters to a function or a class constructor?
- Sep 17 10:13:44 <diamonds> lol
- Sep 17 10:14:03 <diamonds> autrilla: the usual pattern in JS is to pass an options OBJECT
- Sep 17 10:14:16 <Impaloo> autrilla: and have small functions that do one thing and one thing only
- Sep 17 10:14:18 <Impaloo> and do it well
- Sep 17 10:14:22 <Impaloo> and is well tested
- Sep 17 10:14:32 <autrilla> Impaloo: eh, yeah. That can't happen with model constructors.
- Sep 17 10:14:41 <Impaloo> not with that attitude!
- Sep 17 10:14:42 <Impaloo> jk
- Sep 17 10:14:45 <autrilla> They do one thing: initialize the model
- Sep 17 10:15:02 <diamonds> alternately, if you want to be fancy pantsy & make a prettier but possibly more confusing API, you can allow variable # or types of arguments by testing argument types
- Sep 17 10:15:23 <autrilla> Object sounds better
- Sep 17 10:15:50 <autrilla> Though it makes it reaaaaally crappy on the other hand, because clients have no idea what your function expects
- Sep 17 10:16:34 <diamonds> so if your fn takes a Function argument and OPTIONALLY an options object, you can function foo(options, fn){ if( typeof options === 'function') {function = options;} /*...*/}
- Sep 17 10:16:53 <diamonds> so they can call foo({a:1},myFn) or just foo(myFn)
- Sep 17 10:17:03 <diamonds> for better or worse this pattern is someone common in the node world
- Sep 17 10:17:10 <autrilla> crappy api
- Sep 17 10:17:31 <autrilla> You guys must love reading documentation for everything
- Sep 17 10:18:32 <Impaloo> autrilla: you can use ES6 object destructuring like; http://pastebin.com/dH53Hr9Y
- Sep 17 10:18:55 <Impaloo> it's... something
- Sep 17 10:19:11 <Impaloo> ES6 object destruct AND default param values*
- Sep 17 10:19:15 <autrilla> js seems like a toddler compared to other languages tbh\
- Sep 17 10:19:22 <Impaloo> autrilla: do.. DO.. DONT YOU
- Sep 17 10:19:28 <diamonds> http://expressjs.com/api.html#app.use
- Sep 17 10:19:35 <Impaloo> ./votekick autrilla
- Sep 17 10:19:42 <diamonds> https://github.com/strongloop/express/blob/master/lib/application.js#L200-L203
- Sep 17 10:20:03 <autrilla> diamonds: yeah, awesome. You'd totally be able to figure out what it does without resourcing to docs or source code
- Sep 17 10:20:05 <diamonds> autrilla: it was designed initially for a pretty small scope & has grown somewhat organically over the years
- Sep 17 10:20:22 <Impaloo> autrilla: http://pastebin.com/dH53Hr9Y will give you what you want, sorta
- Sep 17 10:20:44 <diamonds> autrilla: that one can take: (fn), (str, fn), or ([str], fn, [, fn...]) ;)
- Sep 17 10:20:50 <Impaloo> but you'll need babel
- Sep 17 10:20:53 <autrilla> Impaloo: nah. That function asks for an object... which is totally unclear, because almost everything is an object
- Sep 17 10:20:55 <autrilla> I have babel
- Sep 17 10:20:56 <diamonds> but wait, there's more!!
- Sep 17 10:21:43 <Impaloo> i can't find any discussion about named parameter proposals though
- Sep 17 10:21:43 <autrilla> Impaloo: like, if I have to pass an object, what's the point of having a class in es6?
- Sep 17 10:21:59 <Impaloo> autrilla: wat
- Sep 17 10:22:14 <baxx> what's the way you put numbers in a string in JS? Python it's "something something {}".format(thing)
- Sep 17 10:22:29 <cjohnson> you can just concat them with plus
- Sep 17 10:22:35 <diamonds> http://expressjs.com/api.html#router.METHOD < app.get([str], fn) defines an app route...
- Sep 17 10:22:52 <baxx> cjohnson: ah right, cool I'll try that
- Sep 17 10:22:56 <ThePendulum> express is fantastic stuff after coming from PHP frameworks
- Sep 17 10:23:04 <diamonds> but app.get(str) gets a configuration setting!! http://expressjs.com/api.html#app.get
- Sep 17 10:23:24 <diamonds> app.get: lookup config setting or maybe set a route handler :)
- Sep 17 10:23:26 <autrilla> so, class Student { constructor(name, age, sex, classes, professors, isMinority, isVegetarian, eatsFoobar) {}.... /wrists
- Sep 17 10:23:36 <diamonds> ThePendulum: yeah I like it p well
- Sep 17 10:23:42 <autrilla> And now you have to remember the param order FOREVER!
- Sep 17 10:24:21 <ThePendulum> diamonds: I was fearing the worst trying to get a variable from the URL... nope! app.get('/yourpage/:yourvar')
- Sep 17 10:24:26 <diamonds> autrilla: ABA: Always Be Abstracting. just add more abstraction layers so you don't have to remember arg order :)
- Sep 17 10:24:30 <diamonds> more and more layers
- Sep 17 10:24:40 <autrilla> diamonds: eh.
- Sep 17 10:24:45 <autrilla> You still have to know it.
- Sep 17 10:24:47 <ThePendulum> and the query string is neatly there as well
- Sep 17 10:24:58 <autrilla> diamonds: how would you abstract that?
- Sep 17 10:25:22 <autrilla> You can't abstract models. You can break them into pieces, not abstract them, you'll have to know every detail when you create a new model.
- Sep 17 10:25:42 <ThePendulum> I'm wondering what the best way would be to make a look-up table if I have fuzzy keys :/
- Sep 17 10:26:53 <diamonds> autrilla: I'm sort of joking... some frameworks add a million abstraction layers "so you can change the underlying [class] w/o having to update all your code"
- Sep 17 10:27:16 <manners13> hey guys i wonder if someone could tell me how to do this
- Sep 17 10:27:22 <manners13> ive got his
- Sep 17 10:27:24 <manners13> https://jsfiddle.net/3tnk4ong/
- Sep 17 10:27:29 <diamonds> ThePendulum: that .get would look up a config var named /yourpage/:yourvar yes?
- Sep 17 10:27:40 <autrilla> I profoundly dislike how badly js works with tooling because it's type system sucks.
- Sep 17 10:27:57 <diamonds> manners13: what's your goal?
- Sep 17 10:28:06 <manners13> but i need the data from the text area to be posted to the contactlog.php script
- Sep 17 10:28:25 <manners13> im new to javascript and ajax so please be gentle
- Sep 17 10:28:27 <yansanmo> manners13, you need to send the value in the send()
- Sep 17 10:28:50 <manners13> yes but how lol with get it was this.value then +str
- Sep 17 10:29:10 <yansanmo> xmlhttp.send("contactlog=" + encodeURIComponent(arguments[0]));
- Sep 17 10:29:19 <manners13> but how do i do it with post when i have to declare what to send before the textarea input
- Sep 17 10:29:27 <diamonds> manners13: tbh don't even bother learn to write XHR requests by hand unless you have some good reason to. there are a zillion good AJAX libs to make this easier & fetch api will replace XHR in the future anyway
- Sep 17 10:29:30 <yansanmo> also, you have xmlhttp and contactlogpost variable in your code
- Sep 17 10:29:39 <diamonds> !g superagent @ manners13
- Sep 17 10:29:40 <ecmabot> manners13: visionmedia/superagent · GitHub <https://github.com/visionmedia/superagent>
- Sep 17 10:29:47 <ThePendulum> diamonds: hmm, I was aiming at sending parameters with the URL
- Sep 17 10:29:57 <autrilla> So you have to write stuff like this? https://www.irccloud.com/pastebin/WGfYMZmK/
- Sep 17 10:30:01 <yansanmo> manners13, you can't use both variable name
- Sep 17 10:30:03 <diamonds> ThePendulum: you'd need a handler fn as final arg there
- Sep 17 10:30:12 <diamonds> ThePendulum: with just .get(str) it looks up config
- Sep 17 10:30:39 <ThePendulum> diamonds: app.get('/hello/:what', function(req, res) { console.log(req.params.what); } would tell you what you were greeting in your URL for whatever obscure greeting because this is not how you should be doing hello worlds
- Sep 17 10:30:54 <ThePendulum> diamonds: what do you mean, look up config?
- Sep 17 10:31:04 <manners13> kk sorry that was a mistake
- Sep 17 10:31:20 <diamonds> ThePendulum: http://expressjs.com/api.html#app.get < "Returns the value of name app setting, where name is one of strings in the app settings table. "
- Sep 17 10:31:29 <diamonds> anyway #express :)
- Sep 17 10:31:43 <yansanmo> manners13, like that: https://jsfiddle.net/3tnk4ong/1/
- Sep 17 10:31:46 <ThePendulum> well yes, you'd want to use it at some point, lol
- Sep 17 10:39:36 <autrilla> Ok, why should I use actual classes instead of just doing stuff like this? https://www.irccloud.com/pastebin/v5LFa46E/
- Sep 17 10:43:00 <morenoh149> autrilla: that's a json object
- Sep 17 10:43:00 <DannyFritz> autrilla: essentially the same thing. class just has some sugar.
- Sep 17 10:43:20 <morenoh149> there's also no methods in that example
- Sep 17 10:43:31 <DannyFritz> for data though, i would keep it to just a plain old object
- Sep 17 10:43:32 <autrilla> morenoh149: I could put some method in them, sure
- Sep 17 10:44:04 <autrilla> js objects are just the same thing as python dictionaries, you just give it a key and whatever value you want
- Sep 17 10:44:10 <morenoh149> Class is just js sugar for a js closure
- Sep 17 10:45:13 <autrilla> Heh, so there's my API mock done, I guess.
- Sep 17 10:47:37 <morenoh149> yeah, unless you need state or variable encapsulation I see no reason to use a Class-class
- Sep 17 10:49:52 <renlo> Class-class?
- Sep 17 10:50:03 <morenoh149> es6 Class syntax
- Sep 17 10:50:57 <renlo> public class JavaScript implements ES6
- Sep 17 10:56:26 <pikajude> what the heck. flow is written in ocaml?
- Sep 17 10:56:29 <pikajude> of all the languages to use
- Sep 17 10:56:45 <deniska> should've used erlang
- Sep 17 10:57:44 <morenoh149> should've use haskell
- Sep 17 10:57:59 <morenoh149> or ML
- Sep 17 10:58:03 <pikajude> should've used haskell
- Sep 17 10:58:19 <pikajude> all type systems are an imperfect attempt to be haskell
- Sep 17 11:00:10 <fred1807> how can I make this script points to a external local file? https://github.com/ariya/phantomjs/raw/master/examples/technews.js (This example is pointing to http://google.../news....) I want to make it point to a local file, and read the url form that file
- Sep 17 11:03:28 <Alex112358> Have a handlebars question, anyone here able to possibly provide some assistance?
- Sep 17 11:05:16 <morenoh149> Alex112358: don't ask to ask. also node.js is probably more appropriate channel
- Sep 17 11:07:45 <kegdev> yay i'm registered
- Sep 17 11:17:06 <MikeD_> if I want the first character from a string, is there any reason i should not use mystring[0] ?
- Sep 17 11:18:32 <baxx> is there a way to see a variables type in the firefox debugger?
- Sep 17 11:18:37 <natrixnatrix89> Hi there.
- Sep 17 11:19:16 <natrixnatrix89> I'm wondering - Am I the only JS developer, who thinks Mean.js is crap?
- Sep 17 11:19:20 <laserco> baxx: typeof() ?
- Sep 17 11:20:24 <MikeD_> why do you think that?
- Sep 17 11:20:27 <natrixnatrix89> It just feels so tangled..
- Sep 17 11:21:44 <natrixnatrix89> and the acl.. var roles = (req.user) ? req.user.roles : ['guest']; It just checks data passed in the request, to determine whether user can access
- Sep 17 11:22:20 <natrixnatrix89> or was it already handled in the middleware?
- Sep 17 11:24:50 <laserco> natrixnatrix89: yes its pretty well understood now that angular and mongo are stinky doo doo, but unfortunately many companies are too invested in it already
- Sep 17 11:25:28 <tejasmanohar> hey all! anyone here worked w/ CI services? i'm trying to evaluate codeship vs CircleCI?
- Sep 17 11:25:42 <natrixnatrix89> Well it's obvious about mongo and angular. I do like express.js but the architecture of mean.js seems just so bizzare
- Sep 17 11:25:59 <natrixnatrix89> has anyone seen a successful project built on meanjs?
- Sep 17 11:26:01 <morenoh149> tejasmanohar: I like codeship
- Sep 17 11:26:09 <morenoh149> but circleci has a free tier
- Sep 17 11:26:23 <morenoh149> natrixnatrix89: freecodecamp.com
- Sep 17 11:26:41 <baxx> laserco: yeah that's like a console.log() output (has to be done from the code?) I was wondering if one could just view a variables type by clicking on it some how in the debugger
- Sep 17 11:26:48 <tejasmanohar> yea i guess codeship can be a bit pricy morenoh149
- Sep 17 11:27:22 <tejasmanohar> morenoh149: if you don't mind me asking, what do you prefer about codeship to circleci?
- Sep 17 11:27:24 <laserco> natrixnatrix89: yeah, I have. It's fast and easy, but isn't scaleable/maintainable.
- Sep 17 11:27:26 <morenoh149> tejasmanohar: I like the ui but I was on the free tier they since removed
- Sep 17 11:27:34 <tejasmanohar> ah
- Sep 17 11:27:38 <tejasmanohar> yeah i don't like circle's UI
- Sep 17 11:28:38 <laserco> baxx: I sensed that's what you meant. I belive the output is color coded. green = number, orange = string, etc
- Sep 17 11:28:40 <natrixnatrix89> > It's fast and easy, but isn't scaleable/maintainable.
- Sep 17 11:28:42 <natrixnatrix89> I agree
- Sep 17 11:29:11 <natrixnatrix89> But the "fast and easy" part isn't that fast and easy either.. There's still a learning curve to follow the tangled architecture
- Sep 17 11:29:21 <natrixnatrix89> and still there's that code repetition etc..
- Sep 17 11:29:42 <natrixnatrix89> "fast and easy" just stands for the part where you don't have to do oauth yourself.
- Sep 17 11:30:49 <laserco> natrixnatrix89: I suppose, I only new javascript at the time, so in that sense it was easier than learning ruby, clojure, or whatever
- Sep 17 11:31:33 <natrixnatrix89> heh, right
- Sep 17 11:31:51 <morenoh149> natrixnatrix89: I'd do MERN, mongo express react and node
- Sep 17 11:32:54 <natrixnatrix89> Yes, that would be interesting.. But still I'd like to see more sanity in how the expressjs is handled
- Sep 17 11:33:37 <natrixnatrix89> Ok. I'm relieved I'm not alone.. Let's get back to work
- Sep 17 11:34:36 <morenoh149> natrixnatrix89: try hapi or strongloop if you want more architectural guidance above express
- Sep 17 11:34:49 <morenoh149> express is more like sinatra or flask
- Sep 17 11:34:58 <morenoh149> hapi/strongloop are more like rails or django
- Sep 17 11:35:14 <morenoh149> gah he left
- Sep 17 11:35:56 <laserco> morenoh149: don't worry I enjoyed your analogy
- Sep 17 11:37:17 <Drewery> I definitely enjoyed it too ! :)
- Sep 17 11:37:29 <Drewery> I mean if there is more you would want to add I am definitely ears!
- Sep 17 11:38:08 <morenoh149> that's all folks 😸
- Sep 17 11:40:13 <wdbl> How important is bundling for performance? I'm getting obsessed with the perfect build system (using gulp) - the next part I have to do is bundling and I want to just start working on the actual freaking app at this point... Is downloading one huge js file *always* better than say 9 or 10 individual ones?
- Sep 17 11:42:04 <holodoc> wbdl: There is no such thing as "always better".
- Sep 17 11:42:16 <wdbl> I see gulp-bundle-assets - is that pretty standard for gulp users?
- Sep 17 11:42:21 <morenoh149> wdbl: just make the app. I too sometimes get stuck on over optimizing
- Sep 17 11:42:22 <wdbl> holodoc: true
- Sep 17 11:42:52 <laserco> wdbl: bundling isn't about performance, it's for organization in development.
- Sep 17 11:42:55 <holodoc> wdbl: Do your app first, then think about optimization. Otherwise you will never finish.
- Sep 17 11:43:10 <wdbl> Is bundling usually easy for everyone? (JS devs...) I'm kind of an old but new JS dev (all this new stuff keeps making me feel like a newb)
- Sep 17 11:43:37 <holodoc> wbdl: At the end do performance tests. It's easier to otpimize when you have the final product. If you start doing it upfront you are making assumptions about the final product.
- Sep 17 11:43:41 <wdbl> I just wonder if I'm making a mountain out of a mole-hill
- Sep 17 11:43:50 <wdbl> ok
- Sep 17 11:44:04 <manners13> ok i must still be doing something wrong
- Sep 17 11:44:08 <manners13> https://jsfiddle.net/3tnk4ong/3/
- Sep 17 11:44:12 <wdbl> holodoc, laserco - thanks for your advice
- Sep 17 11:44:31 <wdbl> I will get it out of my head that I *neeeeeed* bundling to be in place before getting to work
- Sep 17 11:44:36 <Rabbles> wdbl, I'd prefer 20 javascript files. It's easier to debug, and they get cached
- Sep 17 11:44:46 <manners13> returns this as print_r ($_POST)
- Sep 17 11:44:48 <manners13> Array ( [contactlog] => undefined )
- Sep 17 11:45:04 <morenoh149> wdbl: you just uglify then pipe to concat. done.
- Sep 17 11:45:05 <wdbl> ok great, I actually prefer NOT bundling too because I like things to be simple
- Sep 17 11:45:21 <Rabbles> wdbl, Don't worry about bundling unless you have huge images and assets to send over. 20 javascript files is nothing. Let the browser handle the details there.
- Sep 17 11:45:50 <wdbl> sweet guys. Thanks so much for your support
- Sep 17 11:45:52 <morenoh149> to get debugging you generate a sourcemap as well wdbl https://github.com/mikach/gulp-concat-sourcemap
- Sep 17 11:46:28 <wdbl> I work alone all the time and I'm sick of not having anyone to lean on for stuff like this
- Sep 17 11:47:16 <netameta> what does {,*/} means in grunt file ?
- Sep 17 11:47:56 <laserco> the ideal performance scenario is that the user supplies the libraries. This is what Stallman proposes.
- Sep 17 11:48:29 <laserco> same idea as cachine, but more like homebrew
- Sep 17 11:48:33 <laserco> caching*
- Sep 17 11:58:33 <fcanela> hello, I have a doubt about scopes and binding
- Sep 17 11:59:55 <fcanela> I have have created a "scope object" like this: var scope = { 'context' : context }, then used that object to bind a function: var func = otherfunc.bind(scope);
- Sep 17 12:00:25 <fcanela> in otherfunc, if I call 'context' it's not found, but if I call 'this.context', it works nice
- Sep 17 12:00:59 <fcanela> why? I though that when a undeclared variable is found, JS search in first available scope (this) and then goes up the chain
- Sep 17 12:01:20 <fcanela> but somehow, it doesn't link 'context' to 'this.context'
- Sep 17 12:01:28 <ThePendulum> >> !!(test)
- Sep 17 12:01:29 <ecmabot> ThePendulum: ReferenceError: test is not defined
- Sep 17 12:01:36 <ThePendulum> I wish that returned false :(
- Sep 17 12:01:42 <ThePendulum> >> test ? true : false
- Sep 17 12:01:42 <ecmabot> ThePendulum: ReferenceError: test is not defined
- Sep 17 12:01:49 <ThePendulum> huh, hmmm
- Sep 17 12:02:13 <ThePendulum> >> var test = {'hello': 'world'}; test.world ? true : false;
- Sep 17 12:02:13 <ecmabot> ThePendulum: (boolean) false
- Sep 17 12:02:29 <ThePendulum> >> var test = {'hello': 'world'}; !!test.world;
- Sep 17 12:02:29 <ecmabot> ThePendulum: (boolean) false
- Sep 17 12:02:30 <ThePendulum> interesting
- Sep 17 12:03:16 <ThePendulum> >> if(test) { console.log(':)', ':('); }
- Sep 17 12:03:16 <ecmabot> ThePendulum: ReferenceError: test is not defined
- Sep 17 12:03:40 <ThePendulum> oki
- Sep 17 12:07:34 <L8D> ThePendulum: what were you trying to do?
- Sep 17 12:07:53 <L8D> |> var test; !!(test)
- Sep 17 12:07:58 <L8D> >> ;
- Sep 17 12:07:58 <ecmabot> L8D: (boolean) false
- Sep 17 12:08:16 <stickperson> is the “=>” operator an es6 think? i’ve seen it in functions but don’t know what it does here: “return next => action =>”
- Sep 17 12:08:29 <L8D> >> var test; if (test) { console.log(':)', ':('); }
- Sep 17 12:08:29 <ecmabot> L8D: undefined
- Sep 17 12:08:44 <L8D> stickperson: yes, the 'x => y' syntax is a feature of ES6
- Sep 17 12:09:17 <stickperson> L8D: what is it doing in this bit of code? https://github.com/gaearon/redux-thunk/blob/master/src/index.js
- Sep 17 12:09:22 <L8D> stickperson: (next => action => ...) is the same as writing: (function(next) { return function(action) { return ...; }; })
- Sep 17 12:09:34 <stickperson> ah, ok
- Sep 17 12:10:12 <stiang> can someone help me figure out what I need to change to be able to call a method in baseClass from *another* method in baseClass? https://jsfiddle.net/rpaxjqak/
- Sep 17 12:10:17 <L8D> stickperson: although I think using that syntax in that case was a bad idea. The code gets a little hard to follow
- Sep 17 12:10:43 <ThePendulum> L8D: I was imagining it would allow to try if a variable exist
- Sep 17 12:10:48 <ThePendulum> but apparently that only works for object properties
- Sep 17 12:10:53 <ThePendulum> hmm
- Sep 17 12:10:59 <ThePendulum> >> test; !!(test);
- Sep 17 12:10:59 <ecmabot> ThePendulum: ReferenceError: test is not defined
- Sep 17 12:11:06 <L8D> stickperson: you don't want to use prototypal inheritance?
- Sep 17 12:11:06 <stickperson> L8D: agreed. so when you see “=>”, it’s an anonymous function with whatever the words are (“next” and “action”) as parameters
- Sep 17 12:11:30 <stickperson> L8D: not my code. just tryng to understand someone else’s
- Sep 17 12:11:48 <L8D> stickperson: well if it's just a single variable name, that'll be the first parameter, otherwise you need parenthases for multiple parameters
- Sep 17 12:12:01 <L8D> b> ((x, y) => x + y))(1, 2)
- Sep 17 12:12:04 <babelbot> L8D: (error) /usr/lib/node_modules/babel/node_modules/babel-core/lib/babel/transformation/fil ... https://git.io/vnUsN
- Sep 17 12:12:12 <stickperson> L8D: gotcha. do you know where “next” and “action” come from in that code?
- Sep 17 12:12:16 <L8D> stickperson: with the next => action => ... it's returning a functio from a function
- Sep 17 12:12:37 <L8D> stickperson: so 'next' and 'action' are arguments, but they're for two different functions
- Sep 17 12:12:47 <stickperson> L8D: yup, that part makes sense
- Sep 17 12:12:53 <L8D> stickperson: just like writing: (function(next) { return function(action) { return ...; }; })
- Sep 17 12:12:58 <stickperson> yup
- Sep 17 12:13:31 <r0x0rZ> what are some bigger open source projects that I could contribute to that use JS as their main language?
- Sep 17 12:14:11 <L8D> r0x0rZ: https://github.com/rackt/react-router
- Sep 17 12:14:27 <r0x0rZ> L8D: will check it out thanks
- Sep 17 12:14:38 <stickperson> L8D: thanks for the help
- Sep 17 12:18:10 <stiang> did anybody get a chance to look at my fiddle? https://jsfiddle.net/rpaxjqak/ - been stuck at it for hours. I would like for methods in baseClass to be able to call each other, just can’t figure out how.
- Sep 17 12:19:05 <jimminimy> Hey there. I need to apply a -ms-behavior in ie8 from a cross origin domain. I've figured out how to get the contents of the .htc file using XDomainRequest() - is there a way to apply this as a data uri?
- Sep 17 12:22:31 <deltab> jimminimy: get a Blob and pass it to Object.createURL
- Sep 17 12:22:49 <deltab> URL.createForObject? something like that
- Sep 17 12:23:01 <wsieroci__> what do you think about using node.js and postgres? Is there some production ready ORM?
- Sep 17 12:23:42 <jimminimy> deltab: i need to do this in ie 8
- Sep 17 12:27:08 <deltab> !this @ stiang
- Sep 17 12:27:08 <ecmabot> stiang: If a function call is of the form `a.b()`, `this` will be the object you accessed the "b" property from. Otherwise, if it's of the form `a()`, `this` will be `undefined`, which is turned into the global object if the function wasn't defined in strict mode. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this http://javascriptweblog.wordpress.com/2010/08/30/understanding-javascripts-this/
- Sep 17 12:27:48 <deltab> stiang: https://jsfiddle.net/rpaxjqak/1/
- Sep 17 12:28:08 <deltab> jimminimy: sorry, no idea
- Sep 17 12:28:27 <jak2000> http://postimg.org/image/juabep2i7/ <--- why selectted item is false? can anyone explain me? thanks
- Sep 17 12:29:29 <L8D> jak2000: if you switch to the console at that break point, you can type in expressions there
- Sep 17 12:29:50 <L8D> jak2000: I would simply try "this.text == $myProd" first
- Sep 17 12:30:02 <deltab> sharkhat: hi
- Sep 17 12:30:05 <deltab> ThePendulum: hi
- Sep 17 12:30:23 <jak2000> L8D OK testing
- Sep 17 12:31:24 <jak2000> this.text == $myProd is false not know why
- Sep 17 12:31:41 <L8D> jak2000: from there, you can try to just copy the two strings and compare then as literals, to make sure there isn't any getter magic going on
- Sep 17 12:31:52 <jak2000> this.text = "[AGROFRUTAS] AGROFRUTAS" and $myProd = "[AGROFRUTAS] AGROFRUTAS"
- Sep 17 12:32:01 <L8D> jak2000: my guess is that there are weird UTF-8 characters messing things up
- Sep 17 12:32:21 <L8D> jak2000: those aren't normal brackets from what I see
- Sep 17 12:32:26 <jak2000> [AGROFRUTAS] AGROFRUTAS" == "[AGROFRUTAS] AGROFRUTAS" false :(
- Sep 17 12:32:44 <deltab> jak2000: I see two spaces in the latter
- Sep 17 12:32:50 <jak2000> how to fix?
- Sep 17 12:32:54 <jak2000> oo i seee
- Sep 17 12:32:56 <jak2000> deltab
- Sep 17 12:32:57 <jak2000> :)
- Sep 17 12:32:59 <jak2000> checking
- Sep 17 12:32:59 <L8D> jak2000: https://en.wikipedia.org/wiki/Chinese_punctuation
- Sep 17 12:33:19 <L8D> well that's not chinese, but whatev
- Sep 17 12:33:28 <L8D> my guess is it's some utf-8 whitespace black-magic
- Sep 17 12:33:32 <ThePendulum> 'lo deltab
- Sep 17 12:33:47 <deltab> ThePendulum: do you work out your fuzzy matching problem?
- Sep 17 12:34:19 <deltab> jak2000: console.log(encodeURIComponent(this.text))
- Sep 17 12:34:35 <ThePendulum> deltab: not efficiently. I'm overthinking the entire logic again anyway
- Sep 17 12:34:47 <hashtag__> ThePendulum, deltab: What should be fuzzily matched? :)
- Sep 17 12:34:51 <deltab> jak2000: (or as a watch, however you want to do it)
- Sep 17 12:35:41 <deltab> ThePendulum: maybe round the number used as the key, and check the two closest
- Sep 17 12:37:08 <hashtag__> ThePendulum: what are you trying to achieve?
- Sep 17 12:37:22 <persina> I keep forgetting...how do I write this if graph is a variable> "results.append("<img src='graph'>");"
- Sep 17 12:39:20 <ThePendulum> hashtag__: I have a lookup object with exact coordinates as keys and I need to find the exact keys with a rough y-coordinate
- Sep 17 12:39:24 <ThePendulum> there is a 0.01 margin
- Sep 17 12:39:36 <hashtag__> ThePendulum: google maps api and such?
- Sep 17 12:39:43 <ThePendulum> I guess I could round them
- Sep 17 12:39:44 <ThePendulum> oh no
- Sep 17 12:39:46 <hashtag__> don't the open street maps and similar geo databases got this kind of look up supported?
- Sep 17 12:39:48 <ThePendulum> PDFs
- Sep 17 12:39:50 <hashtag__> oh
- Sep 17 12:40:03 <hashtag__> so you got x,y coords and you want to find out the element the coords point to?
- Sep 17 12:40:09 <hashtag__> or an element roughly next to it?
- Sep 17 12:40:16 <hashtag__> ah, this is for the pdf email software you told me, right?
- Sep 17 12:40:22 <ThePendulum> yeah
- Sep 17 12:40:29 <hashtag__> there is existing commercial software that does exactly this with pdfs
- Sep 17 12:40:35 <ThePendulum> oh?
- Sep 17 12:40:45 <ThePendulum> which is?
- Sep 17 12:41:32 <hashtag__> http://www.pdf-tools.com/pdf/pdf-extract-content-metadata-text.aspx
- Sep 17 12:42:11 <ThePendulum> that tool won't know what it's reading either
- Sep 17 12:42:22 <ThePendulum> all it can tell me is that the text exists at x,y which I already know
- Sep 17 12:42:27 <deltab> ggVGc: hmm? you can listen for an event at any time
- Sep 17 12:42:32 <hashtag__> http://www.interhacktives.com/2014/03/12/extract-data-pdf/
- Sep 17 12:42:35 <ThePendulum> the challenge here is to tell my tool that the text at x,y is an address or an order quantity
- Sep 17 12:43:02 <hashtag__> ThePendulum: you got database table fields, so you clean up the element text and then you insert it?
- Sep 17 12:43:05 <R13ose> How do I reverse the slideshow images so they slide to the right instead of the left on this page: http://smtc.com/ ?
- Sep 17 12:43:24 <ThePendulum> hashtag__: first I need to find the right text in the huge stack of texts :P
- Sep 17 12:43:37 <hashtag__> ThePendulum: regexp :)
- Sep 17 12:43:42 <ThePendulum> hashtag__: and Tabula is not useful here because it's a manual tool
- Sep 17 12:43:50 <ThePendulum> I'm not sure how regex can help me here
- Sep 17 12:43:51 <deltab> ggVGc: I'm probably missing what you mean
- Sep 17 12:44:07 <hashtag__> ThePendulum: there must be a pattern in the data - otherwise it isn't automatable anyway (which I don't think)
- Sep 17 12:44:15 <ThePendulum> not in the text
- Sep 17 12:44:19 <hashtag__> why not?
- Sep 17 12:44:20 <ThePendulum> there is a pattern in the coordinates
- Sep 17 12:44:23 <ThePendulum> but regex can't help me with that
- Sep 17 12:44:36 <deltab> sharkhat: see that 'data:' at the start? the whole PDF is in the URL, encoded in base64
- Sep 17 12:44:38 <ThePendulum> because when you order a car, it won't have the same order description as when I order a pot of peanutbutter
- Sep 17 12:44:47 <hashtag__> so there is only one element which contains lots of text - so now you need to extract the text
- Sep 17 12:44:52 <ThePendulum> and the quantity '20' could also be part of a phone number
- Sep 17 12:44:55 <hashtag__> from this one element
- Sep 17 12:44:56 <hashtag__> aha
- Sep 17 12:45:09 <deltab> sharkhat: is that a page you're generating?
- Sep 17 12:45:13 <hashtag__> so the only pattern is the position of the text of this single element
- Sep 17 12:45:18 <ThePendulum> the only way for me to know what text has what meaning is by looking at the original PDF, and establishing a profile with exact coordinates
- Sep 17 12:45:38 <ThePendulum> "between 20 and 40 y you will find orders with each row starting at 7.49 x"
- Sep 17 12:45:41 <hashtag__> the easiest thing which comes to mind would be probably macroing the mouse to drag-select at that position
- Sep 17 12:45:56 <ThePendulum> that requires a manual action
- Sep 17 12:46:01 <hashtag__> ThePendulum: the pdf lib API you are using doesn't offer a method for this?
- Sep 17 12:46:10 <ThePendulum> well, no
- Sep 17 12:46:20 <hashtag__> could there be a better suited pdf api?
- Sep 17 12:46:23 <ThePendulum> no
- Sep 17 12:46:27 <hashtag__> oh damn
- Sep 17 12:46:32 <ThePendulum> this is already very useful
- Sep 17 12:46:43 <ThePendulum> I just need to find the most efficient way to search the stack
- Sep 17 12:46:49 <hashtag__> so you get the text of that element and now you have to find out where the part of text is that wold be on that position
- Sep 17 12:46:59 <ThePendulum> I have absolutely no issue finding these elements, it already works in v1 of this tool
- Sep 17 12:47:16 <ThePendulum> but now there are a few more variables to take into account
- Sep 17 12:47:20 <hashtag__> hm
- Sep 17 12:47:24 <ThePendulum> hashtag__: I have the text and the position
- Sep 17 12:47:30 <ThePendulum> and I have a profile that tells me the position and its meaning
- Sep 17 12:47:35 <hashtag__> so you have to find out what kind of combination it is ?
- Sep 17 12:47:43 <ThePendulum> so I need to compare this huge stack of random texts to the profile
- Sep 17 12:47:44 <hashtag__> like two text fields with this kind of text means bill of this kind
- Sep 17 12:47:57 <hashtag__> aha
- Sep 17 12:48:10 <hashtag__> you iterate over the elements and check whether they are the elements for the given position?
- Sep 17 12:48:10 <ThePendulum> I have a profile that tells me the phone number is at [12.04, 13.564] for example
- Sep 17 12:48:15 <ThePendulum> yeah
- Sep 17 12:48:17 <hashtag__> o
- Sep 17 12:48:19 <hashtag__> ok
- Sep 17 12:48:25 <ThePendulum> which isn't too hard for things like single phone numbers
- Sep 17 12:48:30 <hashtag__> and the pdf api got no such function "give me element at position xy"
- Sep 17 12:48:35 <hashtag__> you have to make it yourself
- Sep 17 12:48:35 <ThePendulum> because that's 1 item at a fixed position for every single invoice
- Sep 17 12:48:49 <ThePendulum> well that's not hard
- Sep 17 12:48:51 <hashtag__> hm, a for loop over the items and checking the position?
- Sep 17 12:48:52 <hashtag__> ok
- Sep 17 12:48:56 <ThePendulum> the fun part is orders
- Sep 17 12:48:59 <morenoh149> does anyone think phantomjs is good enough. Or do you really want to test your site against real browsers?
- Sep 17 12:49:06 <ThePendulum> because there might be 1 order, there might be 20 orders
- Sep 17 12:49:14 <hashtag__> morenoh149: a real end to end test would involve real browsers the end users are using
- Sep 17 12:49:14 <ThePendulum> and they might be on 1 row or 2
- Sep 17 12:49:19 <ThePendulum> and they might be in columns or not
- Sep 17 12:49:23 <hashtag__> ThePendulum: oh god
- Sep 17 12:49:49 <ThePendulum> so what I do at the moment is find the x-coordinate of any order, which is the same for every order but otherwise unique in the invoice
- Sep 17 12:50:03 <hashtag__> I see
- Sep 17 12:50:06 <ThePendulum> then I'll also know its y-coordinate, and I know the rest of the row will have the same y-coordinate
- Sep 17 12:50:12 <ThePendulum> so I need to search the stack for that y-coordinate
- Sep 17 12:50:17 <deltab> morenoh149: it's not one or the other: use one for speed, and the other for accuracy
- Sep 17 12:50:18 <hashtag__> for loop?
- Sep 17 12:50:29 <hashtag__> nested foor lop? :P
- Sep 17 12:50:31 <hashtag__> loop
- Sep 17 12:50:32 <ThePendulum> hashtag__: yes, I could just go through the original stack a million times until I have all the data
- Sep 17 12:50:36 <ThePendulum> but that's very expensive
- Sep 17 12:50:40 <hashtag__> aha
- Sep 17 12:50:45 <hashtag__> you can use a hash or something like that
- Sep 17 12:50:51 <ThePendulum> so I'm trying to figure out how to reduce the amount of lookups and the expense of each lookup
- Sep 17 12:50:52 <hashtag__> for a cheap look up of a particular field
- Sep 17 12:50:59 <hashtag__> a small internal database may help
- Sep 17 12:51:04 <morenoh149> I guess accuracy trumps in my case. it's just such a hassle to set up selenium
- Sep 17 12:51:15 <hashtag__> morenoh149: true, though there are paid services for this
- Sep 17 12:52:17 <ThePendulum> hashtag__: the lovely thing I just discovered is also that an order may have optional fields. so I can't just say "grab all items from this row" and map them to the meaning of those items. I have to check whether there are optional fields
- Sep 17 12:52:31 <ThePendulum> because if there is data missing in a row it'll offset the entire map
- Sep 17 12:53:31 <ThePendulum> it's all not very difficult to pull off
- Sep 17 12:53:37 <ThePendulum> but it's tricky to do it efficiently
- Sep 17 12:53:41 <hassoon> anyone who can tell me why isn't that said bootstrap modal with the id #myModal hiding when i ask it hide ? http://pastebin.ca/3163906
- Sep 17 12:54:05 <ThePendulum> come again?
- Sep 17 12:54:07 <R13ose> Any thoughts on my question?
- Sep 17 12:54:41 <ThePendulum> R13ose: why do you want them sliding to the right? that'd feel a bit unnatural
- Sep 17 12:54:51 <ThePendulum> R13ose: none the least, what library are you using for it?
- Sep 17 12:56:01 <morenoh149> ah it's not so bad. selenium delivers a jar with all the browsers bundled
- Sep 17 12:56:36 <ThePendulum> a physical jar?
- Sep 17 12:56:39 <ThePendulum> oh, java?
- Sep 17 12:56:59 <hashtag__> R13ose: ah hi
- Sep 17 12:57:08 <hashtag__> morenoh149: docker may be your friend
- Sep 17 12:58:09 <L8D> ThePendulum: they package all the browsers up into a mason jar and ship it to your home
- Sep 17 12:58:32 <R13ose> ThePendulum: Bootstrap. This is what is asked of me, " slides now auto slide to left. need to reverse to slides to right."
- Sep 17 12:58:37 <R13ose> hashtag__: hi
- Sep 17 12:58:42 <graphettion> Can someone help me out? I'm not sure exactly how to put this string back together. - https://jsfiddle.net/ekt2ee0z/1/
- Sep 17 12:58:51 <ThePendulum> R13ose: but that's not how it works
- Sep 17 12:58:54 <hashtag__> mason jar :O
- Sep 17 12:58:59 <ThePendulum> that's not how any of this works
- Sep 17 12:59:52 <R13ose> ThePendulum: Thanks for letting me know and I will let people know that but can this be reversed anyways?
- Sep 17 12:59:54 <ThePendulum> R13ose: There should be a cycle function somewhere in Bootstrap
- Sep 17 13:00:01 <hassoon> anyone who can tell me why isn't that said bootstrap modal with the id #myModal hiding when i ask it to hide ? http://pastebin.ca/3163906 :p
- Sep 17 13:00:08 <L8D> graphettion: you can do: strArray[i] = firstLetters + strArray[i].slice(1);
- Sep 17 13:00:18 <ThePendulum> R13ose: You can copy it and change 'next' to 'prev' and vice versa I think
- Sep 17 13:00:23 <deltab> graphettion: concatenate the capital with the rest of the word
- Sep 17 13:00:38 <ThePendulum> R13ose: not how to let it start at the right slide though
- Sep 17 13:00:40 <sharkhat> deltab: yes it is autogenerating, sorry i was away
- Sep 17 13:01:08 <L8D> graphettion: or: strArray[i] = firstLetters + strArray[i].slice(1).toLowerCase();
- Sep 17 13:01:18 <ThePendulum> R13ose: you want it to actually cycle the other way, right? not just reverse the order of the images?
- Sep 17 13:01:46 <R13ose> ThePendulum: Give me a sec
- Sep 17 13:01:58 <ThePendulum> R13ose: http://responsivebp.com/javascript/carousel/
- Sep 17 13:02:04 <ThePendulum> R13ose: this plugin allows you to reverse direction by the looks of it
- Sep 17 13:02:08 <ThePendulum> natively
- Sep 17 13:02:28 <L8D> "natively"
- Sep 17 13:02:34 <ThePendulum> although
- Sep 17 13:02:42 <ThePendulum> I think it actually just reverses the way the buttons work
- Sep 17 13:02:50 <deltab> sharkhat: what sort of URL do you want it to have?
- Sep 17 13:02:54 <ThePendulum> so > moves the slide to the right
- Sep 17 13:03:04 <sharkhat> name of the product would be nice
- Sep 17 13:03:15 <R13ose> ThePendulum: This is what I found: http://getbootstrap.com/javascript/#carousel Client asked to reverse the auto direction of slideshow.
- Sep 17 13:03:20 <ThePendulum> I wonder if it wouldn't be easier to just swap your left and right brain halfs
- Sep 17 13:03:28 <ThePendulum> I don't think it works like that either but it might be easier to try
- Sep 17 13:03:52 <deltab> sharkhat: I mean is it to be served over http or what?
- Sep 17 13:03:58 <R13ose> ThePendulum: are you saying I shouldn't do this and tell the client not to do this?
- Sep 17 13:03:59 <sharkhat> yes
- Sep 17 13:04:13 <ThePendulum> R13ose: that, yes, even if you do end up finding a way
- Sep 17 13:04:19 <ThePendulum> I'd really urge them not to
- Sep 17 13:04:33 <ThePendulum> because it's rather unnatural, the lack of support in these modules gives a clue as well
- Sep 17 13:04:34 <deltab> sharkhat: so the server will have to generate it?
- Sep 17 13:04:44 <sharkhat> client side generated
- Sep 17 13:04:58 <jerv_> What is a reasonable way to test if a string contains at least one tab?
- Sep 17 13:05:03 <ThePendulum> R13ose: but if they're like "m8 I'll throw another $100 at you" then consider to ignore your instinct
- Sep 17 13:05:17 <ThePendulum> but they'll probably want you to pay for not doing it the wrong way right away
- Sep 17 13:05:25 <R13ose> ThePendulum: did you look at events direction in the page I showed you?
- Sep 17 13:05:47 <deltab> sharkhat: the client can only make data: and blob: urls
- Sep 17 13:05:48 <ThePendulum> R13ose: well, does it work?
- Sep 17 13:05:57 <ThePendulum> R13ose: eh
- Sep 17 13:06:00 <ThePendulum> R13ose: no, that won't do what you want
- Sep 17 13:06:14 <ThePendulum> R13ose: that just tells you whether the carousel is sliding to the left or the right
- Sep 17 13:06:25 <ThePendulum> it doesn't affect anything, it's an event
- Sep 17 13:06:25 <R13ose> ThePendulum: I thought so, just was checking.
- Sep 17 13:06:58 <ThePendulum> you can slide it from right to left manually hence the indication in the event
- Sep 17 13:07:00 <graphettion> deltab, L8D: Thank you! I just needed to know to concatenate them.
- Sep 17 13:07:06 <ThePendulum> but the automatic cycle doesn't seem configurable
- Sep 17 13:08:12 <jimminimy> Does anyone know how I can apply text as a behavior in IE8 at runtime? Rather than -ms-behavior: url(behavior.htc); I have the contents of the file as a string. Is there anyway to get it in there?
- Sep 17 13:09:23 <deltab> jimminimy: does it support data:?
- Sep 17 13:09:24 <Impaloo> graphettion: http://goo.gl/Z20clV
- Sep 17 13:09:45 <Impaloo> es6 gives me the tingles
- Sep 17 13:10:02 <jimminimy> deltab: I've been trying to figure it out for a while. Looks like IE8 does support data - I haven't been able to get the format right
- Sep 17 13:11:00 <R13ose> ThePendulum: from what the client said, what do you assume they mean?
- Sep 17 13:12:44 <ThePendulum> R13ose: what did they tell you exactly?
- Sep 17 13:14:21 <jimminimy> deltab: -ms-behavior: url(data:text/x-component;base64,...) that's what it looks like in the style
- Sep 17 13:16:15 <persina> Is there a javascript method that converts a string to a valid url?
- Sep 17 13:16:51 <R13ose> ThePendulum: the above what I said to you
- Sep 17 13:17:32 <samssh> persina, A valid URL is stored as a string. What is the format of the data you want to convert into a URL?
- Sep 17 13:18:10 <persina> samssh: Like it converts spaces into "%20" and things like that
- Sep 17 13:18:48 <sunya7a> I would like to drag an object (let's say rectangle) over some text and then have that text highlighted over which I drop the rectangle. Any suggestions on how I might be able to accomplish this?
- Sep 17 13:18:54 <samssh> persina, So you need it encoded. I think there is a method to suit.
- Sep 17 13:18:58 <samssh> !mdn url encode
- Sep 17 13:18:59 <ecmabot> samssh: encodeURIComponent() - JavaScript | MDN <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent>
- Sep 17 13:19:14 <Impaloo> sunya7a: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Drag_and_drop is a good start
- Sep 17 13:19:59 <Impaloo> sunya7a: basically, you define an element to be "draggable" through HTMl5 attribute, then there are native browser events when an element is being dragged over
- Sep 17 13:20:21 <Impaloo> so you can document.querySelector('.my-text').on('dragover', function () { // omg! })
- Sep 17 13:20:32 <samssh> persina, It's that or https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI
- Sep 17 13:20:38 <sunya7a> Impaloo, thank you. I will give that a read
- Sep 17 13:20:46 <samssh> persina, I honestly don't remember the difference right now.
- Sep 17 13:24:32 <ThePendulum> R13ose: I'm not sure what you're referring to
- Sep 17 13:24:36 <ThePendulum> would you mind repeating it?
- Sep 17 13:25:21 <R13ose> ThePendulum: this is what they asked "to reverse the auto direction of slideshow."
- Sep 17 13:25:53 <ThePendulum> yes, that's going to require you to rewrite bootstrap's cycle function by the looks of it
- Sep 17 13:26:01 <R13ose> ThePendulum: thanks.
- Sep 17 13:26:09 <ThePendulum> and I'd recommend discouraging your client
- Sep 17 13:26:20 <R13ose> ThePendulum: I am doing that now.
- Sep 17 13:28:51 <loa> hello, how i can debug js code running from as3 flash? i have chromium, all my tries to set some breakpoints no working.
- Sep 17 13:29:27 <R13ose> ThePendulum: what about http://stackoverflow.com/questions/16877562/twitter-bootstrap-carousel-cycle-items-right-to-left-rtl-reversed Would that help me in anyway?
- Sep 17 13:30:53 <ThePendulum> R13ose: that's what I'm saying, rewrite the cycle function to do what you want :P
- Sep 17 13:31:01 <ThePendulum> that's the accepted answer there as well
- Sep 17 13:31:37 <ThePendulum> it's a 2½ year old answer though, so I wouldn't just copy that
- Sep 17 13:32:18 <ThePendulum> R13ose: copy that function, add it back as cycleReversed or something, and make the necessary changes
- Sep 17 13:32:28 <R13ose> ThePendulum: the updated answer is from Feb 22.
- Sep 17 13:32:33 <ThePendulum> thus reverse the image order and call .next and .prev the other way round
- Sep 17 13:32:43 <ThePendulum> still, carefully assess the method as it is in your source
- Sep 17 13:33:26 <R13ose> ThePendulum: You are saying this will work in the end?
- Sep 17 13:33:50 <ThePendulum> it probably will, it'll just feel unnatural to use
- Sep 17 13:33:58 <ThePendulum> hence disregarding, I'd discourage your client to use it
- Sep 17 13:34:13 <ThePendulum> don't get me started on carousels in general :P
- Sep 17 13:34:15 <R13ose> ThePendulum: great
- Sep 17 13:34:22 <R13ose> ThePendulum: I want to hear
- Sep 17 13:34:44 <ThePendulum> afaik there have been multiple studies literally no one actually sees the information they provide
- Sep 17 13:34:58 <ThePendulum> http://shouldiuseacarousel.com/
- Sep 17 13:35:41 <ThePendulum> so yeah, use them if you get paid for it
- Sep 17 13:36:16 <R13ose> ThePendulum: I have seen that site before. What should I use instead?
- Sep 17 13:37:11 <ThePendulum> I imagine a gallery that makes all items visible at once
- Sep 17 13:37:20 <ThePendulum> might want to consult #design or #web for that
- Sep 17 13:37:34 <cjohnson> just show the content all on the page
- Sep 17 13:37:43 <ThePendulum> webshops and the like aren't really my expertise
- Sep 17 13:37:59 <cjohnson> there's really no reason to "slide through" content. people have scrollbars for a reason
- Sep 17 13:38:18 <cjohnson> if it must be broken up, use actual pagination
- Sep 17 13:39:40 <jimminimy> After doing some googling, I came across this: http://stackoverflow.com/questions/1145861/has-anyone-gotten-ie8-to-read-dhtml-behaviors-encoded-as-base64d-data-uris
- Sep 17 13:39:59 <jimminimy> Is that to say there's no way to do what I want to do?
- Sep 17 13:40:25 <cjohnson> did you read the answer? sounds like it's pretty clear
- Sep 17 13:40:43 <jimminimy> Since apparently it won't work even if I figure out how to inject it dynamically.
- Sep 17 13:43:38 <Fleuv> Hixon10, Could some one tell me why my element doesn't give away certain css properties (height in this case).
- Sep 17 13:43:44 <Fleuv> HI***
- Sep 17 13:44:18 <cjohnson> Fleuv: and your code is...?
- Sep 17 13:44:29 <Fleuv> cjohnson, let me make an example :D
- Sep 17 13:49:00 <Fleuv> Sorry guys (cjohnson), I hope this clears things up: http://jsfiddle.net/vzwfcpt6/
- Sep 17 13:49:18 <Fleuv> height is 0.
- Sep 17 13:49:33 <Fleuv> or null..
- Sep 17 13:50:27 <ThePendulum> >> 0 === null
- Sep 17 13:50:27 <ecmabot> ThePendulum: (boolean) false
- Sep 17 13:50:52 <tcsc> Fleuv: needs to be '.element'
- Sep 17 13:50:59 <R13ose> ThePendulum: thanks for all the help. The person who is talking to the client said they will consult the client.
- Sep 17 13:51:36 <ThePendulum> xD
- Sep 17 13:52:07 <ThePendulum> reminds me of that game you'd play in elementary school where you'd tell a fib to someone next to you and let it go round a circle of kids
- Sep 17 13:52:13 <ThePendulum> and by the end of it you'd get a completely different message
- Sep 17 13:52:41 <Fleuv> tcsc, thanks I guess I screamed to early ;)
- Sep 17 13:54:35 <R13ose> afk
- Sep 17 14:00:26 <samssh> ThePendulum, Telephone!
- Sep 17 14:02:17 <samssh> But there's always that kid who says the wrong thing on purpose.
- Sep 17 14:08:05 <Rabbles> << ([1,2,3] === [1,2,3])
- Sep 17 14:08:54 <Rabbles> >> ([1,2,3] === [1,2,3])
- Sep 17 14:08:54 <ecmabot> Rabbles: (boolean) false
- Sep 17 14:09:06 <Rabbles> Why isn't that true?
- Sep 17 14:09:39 <deltab> Impaloo: what's the content of http://goo.gl/Z20clV ?
- Sep 17 14:09:43 <Rabbles> >> ([] === [])
- Sep 17 14:09:43 <ecmabot> Rabbles: (boolean) false
- Sep 17 14:09:45 <Rabbles> :(
- Sep 17 14:10:32 <ThePendulum> samssh: yeah we'd consistently get "Mrs. Robin is a cunt" at the end, it was suspicious
- Sep 17 14:11:01 <ThePendulum> >> [] === []
- Sep 17 14:11:01 <ecmabot> ThePendulum: (boolean) false
- Sep 17 14:11:02 <samssh> !
- Sep 17 14:11:06 <ThePendulum> I mean why would it be true
- Sep 17 14:11:16 <ThePendulum> >> 'hello' === 'hello'
- Sep 17 14:11:16 <ecmabot> ThePendulum: (boolean) true
- Sep 17 14:11:54 <Rabbles> ThePendulum, Because they're both empty arrays? Why is it false is my question
- Sep 17 14:11:59 <samssh> Rabbles, === doesn't compare the objects, it compares the reference to the objects.
- Sep 17 14:12:00 <Rabbles> >> ([] == [])
- Sep 17 14:12:00 <ecmabot> Rabbles: (boolean) false
- Sep 17 14:12:05 <ThePendulum> Rabbles: but you're creating a new array
- Sep 17 14:12:14 <ThePendulum> even if it's empty, they're not the same array
- Sep 17 14:12:19 <samssh> (arrays are objects BTW)
- Sep 17 14:12:20 <ThePendulum> you can compare the values and conclude it is
- Sep 17 14:12:33 <ThePendulum> >> {} === {}
- Sep 17 14:12:33 <ecmabot> ThePendulum: SyntaxError: syntax error
- Sep 17 14:12:34 <samssh> >>{} === {}
- Sep 17 14:12:34 <ecmabot> samssh: SyntaxError: syntax error
- Sep 17 14:12:36 <ThePendulum> xD
- Sep 17 14:12:39 <ThePendulum> >> [] == []
- Sep 17 14:12:39 <ecmabot> ThePendulum: (boolean) false
- Sep 17 14:12:44 <Havvy> >> ({} === {})j
- Sep 17 14:12:44 <ecmabot> Havvy: SyntaxError: missing ; before statement
- Sep 17 14:12:45 <samssh> ThePendulum, High five!
- Sep 17 14:12:46 <Havvy> >> ({} === {})
- Sep 17 14:12:46 <ecmabot> Havvy: (boolean) false
- Sep 17 14:12:57 <ThePendulum> >> [O]__[O]
- Sep 17 14:12:57 <ecmabot> ThePendulum: SyntaxError: missing ; before statement
- Sep 17 14:13:15 <Havvy> `{} === {}` parses as `[empty block, triple equality operator, empty object]`
- Sep 17 14:13:17 <Rabbles> Ok sure but with 'hello' === 'hello' you're creating two separate string objects aren't you?
- Sep 17 14:13:36 <Rabbles> why wouldn't == work?
- Sep 17 14:13:36 <deltab> Rabbles: not objects, no
- Sep 17 14:13:42 <samssh> Rabbles, Strings are treated as primitives unless you specify otherwise.
- Sep 17 14:13:44 <ThePendulum> >> samssh === 'sassy'
- Sep 17 14:13:44 <ecmabot> ThePendulum: (boolean) true
- Sep 17 14:13:50 <samssh> You know it
- Sep 17 14:13:58 <Rabbles> lmao
- Sep 17 14:14:51 <Rabbles> Is there a way to quickly compare two arrays?
- Sep 17 14:15:33 <ThePendulum> Array.prototype.every() might be able to help out
- Sep 17 14:15:36 <ThePendulum> if you want to know if they're equal
- Sep 17 14:15:42 <ThePendulum> if you're looking for the difference, that won't help
- Sep 17 14:16:14 <ThePendulum> however, Array.prototype.filter() would :P
- Sep 17 14:16:39 <samssh> Rabbles, It also depends on what he array contains. And array of objects would need to be compared recursively.
- Sep 17 14:16:45 <samssh> *An
- Sep 17 14:16:51 <Rabbles> Ew :(
- Sep 17 14:17:05 <samssh> Yeah
- Sep 17 14:18:12 <samssh> Rabbles, So it depends on the context for the compare. Sometimes using .every() might be fine with numbers, string, or objects that define an .equal method (or similar).
- Sep 17 14:18:30 <Rabbles> I'm surprised there isn't a way to shallowly compare two arrays that doesn't involve a callback.
- Sep 17 14:18:37 <Rabbles> Not that it's a big inconvenience, just surprising
- Sep 17 14:18:41 <samssh> I usually just try to avoid comparing arrays in JS.
- Sep 17 14:19:01 <ThePendulum> yeah I'm writing a shallow compare function
- Sep 17 14:19:10 <Drewery> anybody opinionated on grunt vs gulp
- Sep 17 14:19:11 <steven10172> Is this the most efficient way to go about resetting an object to some default values while keep reference? http://pastebin.com/ddm1J6UM
- Sep 17 14:19:12 <ThePendulum> why would it involve a callback?
- Sep 17 14:19:18 <ThePendulum> Drewery: pick whatever makes the most sense to you
- Sep 17 14:19:24 <ThePendulum> it's an endless debate
- Sep 17 14:19:39 <Drewery> ThePendulum: agreed I was just bored, I am sorry :\
- Sep 17 14:19:42 <samssh> Drewery, I like gulp
- Sep 17 14:19:54 <Drewery> yeah so far I like gulp as well
- Sep 17 14:20:19 <edgarjoya> Hey
- Sep 17 14:20:26 <edgarjoya> everyone
- Sep 17 14:20:38 <edgarjoya> has anyone done in-context paypal integration popup with meteor
- Sep 17 14:20:49 <edgarjoya> https://developer.paypal.com/docs/classic/express-checkout/in-context/integration/
- Sep 17 14:22:36 <deltab> Rabbles: http://es5.github.io/x11.html#x11.9.3
- Sep 17 14:22:37 <graphettion> I suck so bad at basic javascript algorithms :/
- Sep 17 14:23:06 <ThePendulum> Rabbles: http://jsfiddle.net/ThePendulum/y1vdLjp6/
- Sep 17 14:23:07 <ThePendulum> shallow compare
- Sep 17 14:23:20 <ThePendulum> might be a better way really
- Sep 17 14:25:19 <ThePendulum> Rabbles: http://jsfiddle.net/ThePendulum/y1vdLjp6/
- Sep 17 14:25:22 <ThePendulum> that one finds the 'odd one out'
- Sep 17 14:25:33 <ThePendulum> which I think might be more accurate
- Sep 17 14:25:36 <ThePendulum> eh, accurate
- Sep 17 14:25:41 <ThePendulum> closer to what you'd expect it to do
- Sep 17 14:25:51 <ThePendulum> anyway, I can't think of a use for them, and they'd need improvement
- Sep 17 14:26:05 <Rabbles> ThePendulum, http://jsfiddle.net/ThePendulum/y1vdLjp6/
- Sep 17 14:26:31 <Rabbles> I mean http://jsfiddle.net/y1vdLjp6/2/
- Sep 17 14:26:59 <Rabbles> Sure I can do that. I though modifying DOM objects like that is bad idea
- Sep 17 14:27:09 <falafel> what DOM objects?
- Sep 17 14:27:17 <hackal> Hello, I am appending my own '<style>...</style>' to head with jQuery. However the CSS is being applied with delay. I understand this is due to CSS being added by JavaScript but I would like to ask if there is any way to eliminate or reduce the delay as much as I can. Any advice appreciated
- Sep 17 14:27:23 <ThePendulum> Rabbles: yes, that'll also work
- Sep 17 14:27:26 <falafel> Extending native prototypes is not a good idea if that's what you meant
- Sep 17 14:28:04 <Rabbles> That is what I meant thanks
- Sep 17 14:28:11 <django_> hey
- Sep 17 14:28:16 <django_> whats the syntax error here: http://pastebin.com/rCMK4CxV
- Sep 17 14:28:18 <django_> (small piece of code)
- Sep 17 14:28:33 <django_> error: SyntaxError: missing ) after argument list
- Sep 17 14:28:41 <falafel> django_, missing ) in line 5
- Sep 17 14:28:45 <falafel> follow open closing parens
- Sep 17 14:28:46 <django_> why
- Sep 17 14:28:54 <falafel> (function(data){}
- Sep 17 14:28:56 <falafel> missing )
- Sep 17 14:29:05 <django_> since when
- Sep 17 14:29:27 <falafel> since forever, pernes must match on both sides
- Sep 17 14:29:29 <falafel> *parens
- Sep 17 14:29:36 <larrydavid> Hi. Not a webdev so bear with me. I'd like to make a webapp which fetches status data from a server, and displays it on the screen. Data is associated with an entity shown as an icon on a map, user clicks on an icon to view the full status data for that. There's authentication of multiple users, permission to view certain types of data, etc. Now it's clear I'll need Javascript to show this
- Sep 17 14:29:36 <larrydavid> in the browser, but any suggestions on what to use in the back-end to make my life easy?
- Sep 17 14:29:38 <Rabbles> DOM Objects are the javascript objects created from parsing the HTML document?
- Sep 17 14:30:03 <larrydavid> Wikipedia is not giving enough information to answer that question
- Sep 17 14:30:05 <falafel> django_, your editor must have a way to go to the next open/closing match, in Vim for example you do %
- Sep 17 14:30:21 <falafel> if it is not there when you do that, or jumps to a location you didn't expect, then it is missing
- Sep 17 14:30:45 <deltab> Rabbles: yes (though they're not specifically *javascript* objects)
- Sep 17 14:31:01 <django_> falafel: ok..now i get an error for return data; SyntaxError: expected expression, got keyword 'return'
- Sep 17 14:31:27 <falafel> django_, what your code look like now?
- Sep 17 14:31:39 <graphettion> I don't even know how to attempt this, lol - https://jsfiddle.net/L20rthze/
- Sep 17 14:31:50 <larrydavid> did my question go through? I'm not sure if I logged in in time
- Sep 17 14:31:59 <django_> falafel: http://pastebin.com/W39qqgZj
- Sep 17 14:32:25 <Hannibal_Smith> Rabbles, https://developer.mozilla.org/en-US/docs/Web/JavaScript/JavaScript_technologies_overview contains a good definition
- Sep 17 14:32:26 <django_> larrydavid: use nodejs
- Sep 17 14:32:30 <falafel> django_, now it is just invalid syntax
- Sep 17 14:32:36 <falafel> django_, what happened to the braces?
- Sep 17 14:32:41 <deltab> "function(data) (" is wrong
- Sep 17 14:32:49 <django_> ...
- Sep 17 14:32:54 <django_> i thought it was {} --> ()
- Sep 17 14:32:59 <django_> missing "(
- Sep 17 14:33:00 <falafel> django_, best practice to never forget punctuation, write it all first
- Sep 17 14:33:13 <falafel> django_, .success(function(){})
- Sep 17 14:33:21 <django_> http://pastebin.com/rCMK4CxV
- Sep 17 14:33:23 <django_> where is the mstake here
- Sep 17 14:33:31 <django_> ahh
- Sep 17 14:33:34 <django_> lets see
- Sep 17 14:34:07 <larrydavid> django_: my worry with Node.js is that all the ecosystem consists of a few github projects mentioned in random stackoverflow posts and blog posts. There's no real documentation tying everything together.
- Sep 17 14:34:27 <deltab> django_: match each ( and { with its pair
- Sep 17 14:34:28 <larrydavid> I'm a bit scared to jump in because of that.
- Sep 17 14:34:39 <falafel> larrydavid, what do you mean?
- Sep 17 14:34:51 <falafel> larrydavid, there is plenty of documentation here https://nodejs.org/api/
- Sep 17 14:35:11 <larrydavid> not for Node itself, but for all the stuff on top of Node that one would use to save time
- Sep 17 14:35:13 <django_> larrydavid: nodejs is documented and works great
- Sep 17 14:35:16 <django_> wal mart funded it i htikn lol
- Sep 17 14:35:17 <larrydavid> like Express.js's wikipedia page has 2 sentences.
- Sep 17 14:35:25 <django_> yeah i feel you
- Sep 17 14:35:26 <larrydavid> so when I was researching earlier, I discarded it
- Sep 17 14:35:27 <django_> i also had doubts
- Sep 17 14:35:33 <falafel> larrydavid, mmm, Express... plenty of docs as well http://expressjs.com/4x/api.html
- Sep 17 14:35:35 <django_> so i asked and ppl say its good
- Sep 17 14:35:52 <django_> falafel and deltab ty!
- Sep 17 14:35:55 * hugdru
- Sep 17 14:36:13 <larrydavid> falafel: yeah I know I was just worried. So you're seconding django's recommandation of Node.js?
- Sep 17 14:36:27 <falafel> larrydavid, recommendation for what? I missed that part...
- Sep 17 14:36:45 <larrydavid> <larrydavid> Hi. Not a webdev so bear with me. I'd like to make a webapp which fetches status data from a server, and displays it on the screen. Data is associated with an entity shown as an icon on a map, user clicks on an icon to view the full status data for that. There's authentication of multiple users, permission to view certain types of data, etc. Now it's clear I'll need Javascript
- Sep 17 14:36:45 <larrydavid> to show this in the browser, but any suggestions on what to use in the back-end to make my life easy?
- Sep 17 14:37:11 <django_> larrydavid: if you have doubts on extra stuff ask around if its good or build it yourself
- Sep 17 14:37:17 <larrydavid> "fetches status data" can be replaced by "server pushes data when it changes" if you want
- Sep 17 14:38:03 <falafel> larrydavid, yeah, Node is fine for that, I think all you need is Express and some middleware for authentication in the backend
- Sep 17 14:38:23 <larrydavid> django_: I'm really new to web tech, there's so much choice, and it's hard to tell what's unsuitable at first glance. Would take a long time to test everything here: https://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks#Comparison_of_features
- Sep 17 14:38:39 <django_> larrydavid: stackoverflow
- Sep 17 14:38:40 <django_> googe..
- Sep 17 14:38:42 <django_> irc
- Sep 17 14:38:49 <django_> #node.js
- Sep 17 14:39:12 <larrydavid> well #node.js wouldn't give me a neutral answer. I mean what they gonna do, say "go use Django"? :)
- Sep 17 14:39:25 <larrydavid> so I tried #webdev, then here
- Sep 17 14:40:48 <larrydavid> is there a name for a back-end feature that help save you time creating GUIs? Or is that generally done entirely on the front-end using raw data obtained via API requests?
- Sep 17 14:43:32 <NoiseEee> yeah, the latter
- Sep 17 14:44:19 <larrydavid> thanks
- Sep 17 14:45:16 <deltab> larrydavid: you can also generate DOM objects on the server, serialize them to HTML, and send them to the browser
- Sep 17 14:47:19 <larrydavid> deltab: thanks. I knew that actually, but I don't think HTML applies to a webapp with a fancy GUI like I have in mind.
- Sep 17 14:47:57 <sillyslux> graphettion, https://jsfiddle.net/L20rthze/1/
- Sep 17 14:47:58 <larrydavid> it's more like a simple game GUI than anything
- Sep 17 14:50:21 <tcsc> if you're updating every frame you might not want to use html for your gui
- Sep 17 14:50:36 <tcsc> not all web-based games do that though
- Sep 17 15:00:51 <sillyslux> graphettion, https://jsfiddle.net/L20rthze/3/
- Sep 17 15:01:26 <graphettion> sweet, ty sillyslux
- Sep 17 15:02:46 <graphettion> sillyslux: I was having trouble with returning arrays and figured out map does that so I came up with this - https://jsfiddle.net/L20rthze/2/
- Sep 17 15:02:51 <graphettion> I appreciate the help man.
- Sep 17 15:07:37 <sillyslux> yw
- Sep 17 15:08:44 <ThePendulum> >> 21.582 + 0.6
- Sep 17 15:08:44 <ecmabot> ThePendulum: (number) 22.182000000000002
- Sep 17 15:08:49 <ThePendulum> why does it do this
- Sep 17 15:09:00 <ThePendulum> >> 21.582 + 0.600
- Sep 17 15:09:01 <ecmabot> ThePendulum: (number) 22.182000000000002
- Sep 17 15:09:07 <ThePendulum> :/
- Sep 17 15:09:14 <falafel> ThePendulum, floating point math
- Sep 17 15:09:18 <L8D> ThePendulum: IEEE 755
- Sep 17 15:09:37 <ThePendulum> how do I prevent that
- Sep 17 15:09:41 <Impaloo> IEEE 754 actually
- Sep 17 15:09:46 <L8D> ^
- Sep 17 15:10:15 <Impaloo> does anyone know what IEEE stands for, without Googling?
- Sep 17 15:10:22 <Impaloo> i always forget it
- Sep 17 15:10:30 <ThePendulum> institute of electrical and....
- Sep 17 15:10:30 <Impaloo> IETF though
- Sep 17 15:10:33 <ThePendulum> engineers something
- Sep 17 15:10:42 <ThePendulum> institute of electrical and electronics engineers?
- Sep 17 15:11:02 <Impaloo> ThePendulum: googler!
- Sep 17 15:11:03 <ThePendulum> so this is predictable behavior then
- Sep 17 15:11:17 <ThePendulum> Impaloo: I was already on the IEEE 754 page :P
- Sep 17 15:11:29 <falafel> it is normal behavior
- Sep 17 15:11:40 <Impaloo> not very predictable though
- Sep 17 15:11:44 <ThePendulum> how do I account for it?
- Sep 17 15:11:46 <Impaloo> except 0.1 + 0.2
- Sep 17 15:11:53 <falafel> ThePendulum, what exactly are you trying to do?
- Sep 17 15:11:58 <falafel> like, what are you calculating?
- Sep 17 15:12:03 <falafel> floating points are ok for most things
- Sep 17 15:12:24 <ThePendulum> I have the y-coordinate of the first of 2 lines, and I know the difference between the two lines
- Sep 17 15:12:31 <ThePendulum> so I add the difference and then try to find the 2nd line in a lookup table
- Sep 17 15:12:43 <ThePendulum> which obviously isn't going to work if there's a .00000000000002 difference
- Sep 17 15:12:57 <ThePendulum> I guess I need to put back the fuzzy searcher
- Sep 17 15:14:31 <falafel> ThePendulum, if anything you could look for a bigint library
- Sep 17 15:14:45 <falafel> or rather bigdecimal
- Sep 17 15:14:53 <falafel> this one https://github.com/dtrebbien/BigDecimal.js
- Sep 17 15:15:19 <ThePendulum> I was looking at big.js
- Sep 17 15:15:42 <ThePendulum> could someone summarize why this is happening at all?
- Sep 17 15:15:57 <tcsc> ThePendulum: floats are in base 2, and not base 10
- Sep 17 15:16:07 <ThePendulum> right
- Sep 17 15:16:13 <tcsc> it's like how 1/3 can't be represented well in base ten (0.333333333)
- Sep 17 15:16:51 <falafel> ThePendulum, http://floating-point-gui.de/
- Sep 17 15:16:54 <tcsc> ThePendulum: if you can, avoid big decimals.
- Sep 17 15:17:01 <tcsc> they probably won't do what you want.
- Sep 17 15:17:08 <tcsc> even if they do they're very very slow.
- Sep 17 15:17:11 <ThePendulum> right
- Sep 17 15:17:25 <tcsc> are you summing a lot of things, or just a few things
- Sep 17 15:17:35 <falafel> ThePendulum, how were the other numbers calculated? The ones in the table
- Sep 17 15:17:52 <baxx> I'm trying to create some html from within the JS, I'm a bit confused as to what's up here https://jsfiddle.net/3oqg6jgd/2/ . It seems to be messing up around the ('head')[0] part, but I'm not sure why as the html (in the local version at least) has a 'head'. Any pointers would be cool, cheers
- Sep 17 15:17:55 <ThePendulum> they are coordinates, they're given
- Sep 17 15:18:26 <falafel> ThePendulum, but you say you are trying to match th results, right?
- Sep 17 15:18:30 <falafel> how were the results calculated
- Sep 17 15:18:57 <ThePendulum> the coordinate I need is already somewhere in the lookup, the right numbe
- Sep 17 15:19:10 <ThePendulum> I know another coordinate and I know the difference between that one and the one I need
- Sep 17 15:19:21 <ThePendulum> so I add the difference to the known coordinate and try to find it in the lookup table
- Sep 17 15:19:55 <tcsc> ThePendulum: you probably want to bucket them so that close together floats are identical
- Sep 17 15:19:59 <ThePendulum> but it'll be looking for 4.839 exactly, for example, not 4.839000000000000000000002
- Sep 17 15:20:02 <tcsc> are considered identical*
- Sep 17 15:20:04 <ThePendulum> yeah
- Sep 17 15:20:07 <jak2000> deltab: http://postimg.org/image/49u7a0iif/d0d55d58/ strange strange
- Sep 17 15:20:16 <ThePendulum> I need to figure out how to do that efficiently for multiple reasons
- Sep 17 15:20:31 <tcsc> ThePendulum: that's known as quantization
- Sep 17 15:20:40 <tcsc> well, that will at least point you in the right direction
- Sep 17 15:20:42 <ThePendulum> because there might be tolerable variations in the given coordinates as well
- Sep 17 15:21:06 <jak2000> L8D are you there?
- Sep 17 15:21:27 <L8D> jak2000: yeah
- Sep 17 15:21:38 <jak2000> see: http://postimg.org/image/49u7a0iif/d0d55d58/ please
- Sep 17 15:22:43 <L8D> jak2000: ok
- Sep 17 15:23:05 <L8D> the first has one space between [AGROFRUTAS] and AGROFRUTAS, the second has two spaces
- Sep 17 15:23:36 <tcsc> ThePendulum: actually, since your numbers aren't going to be in the 0,1 range quantization isn't what you want
- Sep 17 15:24:06 <tcsc> you could just do Math.floor(num * precision)/precision
- Sep 17 15:24:11 <tcsc> before putting it in a table
- Sep 17 15:24:27 <tcsc> where precision is something like 1 / minimum allowed difference
- Sep 17 15:24:37 <tcsc> so like 1000 or something
- Sep 17 15:24:41 <tcsc> or even less
- Sep 17 15:26:06 <ThePendulum> tcsc: so I'd have to multiply the coordinates by 10 a few times to allow for that?
- Sep 17 15:26:26 <ThePendulum> otherwise I'll just end up with 0 everywhere
- Sep 17 15:26:53 <ThePendulum> in fact
- Sep 17 15:27:50 <ThePendulum> Math.floor(coordinate * (1 / precision)) I guess
- Sep 17 15:27:51 <tcsc> >> var precision = 1000;[30.001, 30.0006, 30.0014].map(function(n) { return Math.round(n*precision)/precision; })
- Sep 17 15:27:51 <ecmabot> tcsc: (object) [30.001, 30.001, 30.001]
- Sep 17 15:28:56 <ThePendulum> hmm
- Sep 17 15:29:00 <tcsc> precision should be a fairly large number.
- Sep 17 15:29:18 <Zak> Can somebody possible check if https://equinox.io/ is up for them? It's hosting some ngrok binaries and I can't seem to get to them :9
- Sep 17 15:29:18 <tcsc> it should be the inverse of whatever your maximum tolerance is
- Sep 17 15:29:30 <tcsc> and round is probably more correct here than floor
- Sep 17 15:29:55 <ThePendulum> tcsc: hence Math.round(coordinate * (1 / precision)) ? that allows me to determine the precision based on the coordinates without having to inverse it manually
- Sep 17 15:29:59 <duckgoose> downforeveryoneorjustme.com/equinox.io
- Sep 17 15:30:32 <Zak> never sure about the accuracy of those sites :(
- Sep 17 15:30:32 <ThePendulum> hold on
- Sep 17 15:30:33 <Zak> but thanks
- Sep 17 15:31:16 <tcsc> hm. determine it based on coordinates how?
- Sep 17 15:32:32 <ThePendulum> so I guess Math.round(coordinate * (1 / precision)) * precision
- Sep 17 15:33:05 <tcsc> sure. but how would you determine it based on coordinates. it needs to be fixed for a given lookup table.
- Sep 17 15:33:05 <ThePendulum> or coordinate / precision
- Sep 17 15:33:11 <ThePendulum> probably more direct
- Sep 17 15:33:19 <ThePendulum> tcsc: yes, it's determined manually
- Sep 17 15:33:26 <tcsc> okay.
- Sep 17 15:33:38 <ThePendulum> but it seems inconvenient having to invert it manually as well, and set it in the profile like that
- Sep 17 15:33:52 <tcsc> well, it doesn't make a big difference.
- Sep 17 15:34:01 <tcsc> it depends what you think of the input as.
- Sep 17 15:34:25 <ThePendulum> it does, it requires you to know the code when profiling and determining the precision
- Sep 17 15:34:57 <ThePendulum> it requires more insight about how that number is established
- Sep 17 15:36:29 <tcsc> eh. it's somewhat subjective. i think both require knowledge into how you're going to use them.
- Sep 17 15:36:33 <tcsc> but w/e
- Sep 17 15:37:00 <timetocode> When I switch browser tabs (in chrome, so far), my javascript in the background tab gets paused. When I switch back to it, it appears to attempt to catch up... but it only certain logic seems to be able to catch up. For example, anything sent via a websocket while it was in the background gets received after it gains focus again. Meanwhile, I have some time-based math which it seems to just skip. What is the nature of this pause/resume? What k
- Sep 17 15:37:00 <timetocode> ind of things can it really resume
- Sep 17 15:38:03 <ThePendulum> tcsc: you'd otherwise only have to look at the set of coordinates and just literally observe the leeway and note it down
- Sep 17 15:38:15 <ThePendulum> without having to worry about converting it in any way
- Sep 17 15:38:20 <netameta> how can i create a page where "/" has some content and its the home state, however when someone at the top menu is selected that content is changed
- Sep 17 15:39:14 <tcsc> i guess i was assuming it was more of a tweakable parameter that you adjust based on the output, as opposed to something where you look at the values and come up with something
- Sep 17 15:39:16 <netameta> like say you have the home state that the url is /, and the about page, when about is clicked the content of the view (where home content was) get replaced with the about
- Sep 17 15:39:16 <ThePendulum> you make the menu item a hyperlink to a new page with new content
- Sep 17 15:39:43 <netameta> ThePendulum, the above meant to me ?
- Sep 17 15:39:53 <ThePendulum> tcsc: it's part of a profile that gives instructions on what a to-be parsed PDF looks like, it's more of a config file than direct input
- Sep 17 15:40:06 <ThePendulum> netameta: yes, why get fancy? :P
- Sep 17 15:40:12 <persina> is there an equivalent of .serialize() for POST?
- Sep 17 15:40:15 <ThePendulum> good ole' HTML anchors
- Sep 17 15:40:37 <netameta> persina, there are some jquery plugins that does it
- Sep 17 15:41:06 <persina> netameta: what do you mean plugins?
- Sep 17 15:41:12 <ThePendulum> tcsc: I'm not sure why I didn't think of just rounding the values everywhere before
- Sep 17 15:41:18 <ThePendulum> d'oh
- Sep 17 15:41:24 <netameta> ThePendulum, yea yea hyperlinks to new states but how where will i put the content of the first page
- Sep 17 15:41:36 <netameta> ThePendulum, or you mean not to use states at all
- Sep 17 15:41:41 <netameta> persina, jquery plugins
- Sep 17 15:41:44 <ThePendulum> if you want to load it dynamically pe se you'll want to use AJAX
- Sep 17 15:42:20 <persina> netameta: what does that mean? explain...
- Sep 17 15:42:24 <netameta> persina, I assume you want to grap the values of a form into an object ? or something like that ?
- Sep 17 15:42:40 <persina> netameta: yes
- Sep 17 15:42:44 <ThePendulum> netameta: but you have to ask yourself if it's worth the hassle
- Sep 17 15:43:09 <netameta> persina, Jquery dont have a native way to do that, you'll need to search for a jqeuery plugin
- Sep 17 15:43:09 <ThePendulum> especially when the user is already navigating a menu, I'm not sure why you'd load the content dynamically
- Sep 17 15:43:28 <persina> netameta: what about serializeArray()?
- Sep 17 15:43:28 <ThePendulum> it's usually something you'd do to update the content in front of the user
- Sep 17 15:43:29 <netameta> ThePendulum, what are you talking about ?
- Sep 17 15:43:39 <netameta> persina, Yea that might work,
- Sep 17 15:43:50 <ThePendulum> netameta: If you don't know than I have no idea what you're asking
- Sep 17 15:44:06 <ThePendulum> you want to change the content on a page whenever someone navigates a menu?
- Sep 17 15:44:28 <netameta> ThePendulum, Are we talking about not using angular at all and simply making a html page with menu that points to other pages ?
- Sep 17 15:44:46 <ThePendulum> I didn't know you're using angular
- Sep 17 15:44:58 <netameta> ThePendulum, Ahhh crap wrong channel...
- Sep 17 15:45:00 <netameta> shiet
- Sep 17 15:45:02 <ThePendulum> LOL
- Sep 17 15:45:03 <tcsc> ThePendulum: worth noting that if you're going to go with a value close to 1, you will want to consider using floor and ceil instead of round, since round will bring stuff from 0.5 above and below, whereas floor will actually be in that range.
- Sep 17 15:45:05 <netameta> sorry for the confusion
- Sep 17 15:45:36 <ThePendulum> yeah, disregard that for angular
- Sep 17 15:45:39 <ThePendulum> I'm not sure how that all works
- Sep 17 15:46:11 <ThePendulum> tcsc: the tolerance / precision value is usually around 0.01
- Sep 17 15:46:27 <tcsc> it probably doesnt matter then.
- Sep 17 15:46:34 <ThePendulum> yeah, probably not too much of a problem
- Sep 17 15:46:55 <ThePendulum> although I am considering to use floor still
- Sep 17 15:47:06 <netameta> Well floor or ceil will have a more "predictable" results
- Sep 17 15:47:08 <ThePendulum> because honestly I'm not sure why the precision matters
- Sep 17 15:47:33 <netameta> because you know you'll always either get +1 or -1 and you can build on that.
- Sep 17 15:47:43 <ThePendulum> if I have 4.346 and another 4.344, with a precision of 0.01, they should really both end up being 4.34
- Sep 17 15:48:09 <ThePendulum> while I'd be getting 4.35 and 4.34 here
- Sep 17 15:49:19 <tcsc> then you probably want floor
- Sep 17 15:49:21 <RonRichie> hey whats up y'll!
- Sep 17 15:49:23 <ThePendulum> I just realized I'l still get that float problem now
- Sep 17 15:49:34 <ThePendulum> oh hmm
- Sep 17 15:49:53 <ThePendulum> I get it with round but not with floor
- Sep 17 15:50:19 <ThePendulum> I'm not sure if that's fundamental or a coincidence
- Sep 17 15:50:25 <tcsc> no that's fundamental
- Sep 17 15:50:51 <RonRichie> tcsc dude lol your diagram helped me a lot, I started making better sense of other recursions as well, I was working on this for an hour and I draw this beautiful masterpiece, it looks correct right? https://repl.it/BIxE/1
- Sep 17 15:51:41 <tcsc> it looks correct at rough glance. does it work?
- Sep 17 15:52:35 <tcsc> gotta run, bbl
- Sep 17 16:01:39 <ThePendulum> I assume I shouldn't be requiring a JSON file in a function?
- Sep 17 16:02:53 <ThePendulum> or can I just do that
- Sep 17 16:03:34 <ThePendulum> like, anywhere
- Sep 17 16:06:08 <Sal> hi, is there a way to check touchstart coords to see if the user tap a specific element?
- Sep 17 16:06:31 <jak2000> L8D yes i see
- Sep 17 16:06:36 <Sal> i need to let the user move a line (div with bottom-border 1px)
- Sep 17 16:06:46 <jak2000> but the value of this.text and $myPRod have exact value or not?
- Sep 17 16:06:54 <Sal> inside a full screen container
- Sep 17 16:15:57 <ThePendulum> interesting
- Sep 17 16:16:47 <ThePendulum> why is require() not asynchronous despite needing to load a file?
- Sep 17 16:17:22 <ThePendulum> discard that
- Sep 17 16:17:44 <deltab> convenience?
- Sep 17 16:19:32 <L8D> ThePendulum: because it would make everything pointless
- Sep 17 16:19:57 <jak2000> L8D ?
- Sep 17 16:20:26 <L8D> jak2000: what I said earlier, they are not the same value
- Sep 17 16:20:33 <L8D> jak2000: one has two spaces, the other has one
- Sep 17 16:20:56 <L8D> jak2000: I'm guessing this is because the DOM added artificial spacing when generating the text content
- Sep 17 16:21:24 <L8D> ThePendulum: if require() was asynchronous, then node.js would be a futile platform for developing applications
- Sep 17 16:21:56 <robertmaxrees> jak2000 those two strings are not the same.
- Sep 17 16:22:12 <robertmaxrees> one has two spaces.
- Sep 17 16:22:15 <robertmaxrees> the other does not.
- Sep 17 16:24:27 <ThePendulum> L8D: yeah, I realized a split second after sending that that that would make things a lot more complicated
- Sep 17 16:25:09 <ThePendulum> is it in any way wrong to require() a JSON file deeper down in an application?
- Sep 17 16:25:09 <hapyt0wn> has anyone messed with cubism
- Sep 17 16:25:12 <hapyt0wn> ?
- Sep 17 16:26:01 <L8D> hapyt0wn: I'm an avid cubist
- Sep 17 16:26:01 <ThePendulum> it's not my style
- Sep 17 16:26:21 <hapyt0wn> L8D can you change the width of the graph
- Sep 17 16:26:24 <L8D> My 3x3 average is 40 seconds
- Sep 17 16:26:40 <jak2000> L8D and robertmaxrees i understand, but why not see the second space in the value of $myprod variable
- Sep 17 16:26:45 <jak2000> making a Fiddle
- Sep 17 16:26:58 <L8D> jak2000: because Chrome hides it for some reason
- Sep 17 16:27:35 <L8D> hapyt0wn: the width is dependent on the width of the parent element
- Sep 17 16:28:01 <L8D> hapyt0wn: well, the width you set for the canvas
- Sep 17 16:28:04 <hapyt0wn> L8D: I scaled the parent element....
- Sep 17 16:28:19 <hapyt0wn> it seemed it was dependent of the amount of data points...
- Sep 17 16:28:40 <hapyt0wn> Can you send pictures through IRC?
- Sep 17 16:29:08 <L8D> hapyt0wn: you can upload to an image hoster
- Sep 17 16:29:10 <L8D> like imgur
- Sep 17 16:29:11 <sillyslux> hapyt0wn, make asciiart pics of it
- Sep 17 16:29:31 <hapyt0wn> L8D: I'm behind a firewall...
- Sep 17 16:29:34 <hapyt0wn> I'm on a work PC
- Sep 17 16:29:36 <hapyt0wn> ....
- Sep 17 16:29:50 <hapyt0wn> I could ssh tunnel but I might get in trouble...
- Sep 17 16:39:32 <Kayra> How do I pass a this.variable into an anyonymous function and still be able to use it outside of the function?
- Sep 17 16:41:03 <robertmaxrees> pass it, or access it?
- Sep 17 16:41:20 <robertmaxrees> like, you want to access the parent function's scope?
- Sep 17 16:43:02 <laphlaw> I'm seeing strange behavior with ajax.. when calling an ajax request, about 10% of the time it fails to even make the ajax request
- Sep 17 16:43:06 <laphlaw> http://pastebin.com/AYrw1Y8X#
- Sep 17 16:44:30 <laphlaw> i'm somewhat suspicious if window.location.replace is interfering somehow, but that isn't called until after the ajax request. I'm honestly baffled
- Sep 17 16:44:42 <larrydavid> Any advice on what to use to create a UI like this? https://i.imgur.com/BsqzzK0.png The data would come from a server via AJAX or websocket. Also, despite the flavor text it's not a game, so I'd like to avoid game engines unless they're the best tool for the job.
- Sep 17 16:45:54 <laphlaw> when it *does* fail, it doesn't execute the error callback function either :(
- Sep 17 16:58:20 <zumba_ad_> so classA has a property say profile. The profile property value is inherited from another class. so var classA = { property = '', showProfile = function() { render property } }; Now classB is a child of classA that also wants to render the property in parent classA. According to my officemate, it's not seeing the inherited value when method is called in classB
- Sep 17 17:06:28 <zumba_ad_> should be call, super, etc?
- Sep 17 17:07:07 <zumba_ad_> I hope someone can make a sample fiddle. it's advance for my level
- Sep 17 17:13:38 <chars6> hi
- Sep 17 17:13:48 <chars6> i'm not sure what i'm doing wrong here
- Sep 17 17:13:56 <chars6> but i want to use a regex inside a switch statement
- Sep 17 17:14:19 <chars6> so, where window.location ends with 'page=account', i want to alert('asdf')
- Sep 17 17:14:29 <chars6> code: http://pastebin.com/ZYyss7CN
- Sep 17 17:14:56 <chars6> it always runs default tho
- Sep 17 17:18:44 <sillyslux> you can't do "case (page.test('page=account$'))"
- Sep 17 17:20:12 <chars6> sillyslux: what is the correct syntax? i chose test because my understanding is it returns a bool
- Sep 17 17:20:50 <sillyslux> test returns bool yes, i'm trying that myself
- Sep 17 17:20:54 <chars6> ultimately, i want 3 of these, for account, shipping, and cart
- Sep 17 17:24:48 <chars6> i might have the regex wrong....
- Sep 17 17:25:03 <chars6> if i run alert(page.test('page=account$')); i still get false when i'm expecting true
- Sep 17 17:32:11 <sillyslux> chars6, try this http://jsfiddle.net/983mchkd/
- Sep 17 17:34:24 <sillyslux> http://jsfiddle.net/983mchkd/1/
- Sep 17 17:35:39 <baxx> under what condition would this be true if(style.styleSheet) ?
- Sep 17 17:36:02 <sillyslux> the latter will work with /?page=shipping&something=else too
- Sep 17 17:39:20 <chars6> sillyslux: i don't understand. is that first line var site = ... supposed to be a string?
- Sep 17 17:39:53 <sillyslux> regex.exec returns an array
- Sep 17 17:40:16 <chars6> no, i mean the /page-(.+)/ part
- Sep 17 17:40:26 <sillyslux> ist value is the full string, 2nd the match, therefore site[1]
- Sep 17 17:40:42 <sillyslux> *1st
- Sep 17 17:40:54 <sillyslux> /page-(.+)/ is the regex
- Sep 17 17:41:16 <chars6> no, line 1. should /page=(.+) be wrapped in apostrophes?
- Sep 17 17:41:26 <sillyslux> no
- Sep 17 17:42:09 <sillyslux> it can be in apo, but doesn't have to
- Sep 17 17:44:38 <timetocode> do browsers fire anything when they put javascript into some sort of throttle/pause such as when a tab is not active?
- Sep 17 17:45:33 <timetocode> i have an app which is only partly recovering when it regains focus
- Sep 17 17:45:59 <undrinkablesoup> So I have <td id="anid"></td>, and then var a = document.getElementById("anid"); How can I figure out the x and y positions of the top-left corner of that element now?
- Sep 17 17:46:13 <undrinkablesoup> Is it as simple as a.style.x and a.style.y?
- Sep 17 17:46:38 <undrinkablesoup> I'm trying to use this to position an element next to it.
- Sep 17 17:47:26 <chars6> sillyslux: cool. now i'm not getting the default to fire when the url doens't have extra paramaters, but i can get around that by wrapping the whole thing in an if statement
- Sep 17 17:47:34 <undrinkablesoup> I can't set position: relative; on the table or the td because it causes various CSS glitches/bugs.
- Sep 17 17:48:10 <chars6> sillyslux: so this is what i'm looking at right now http://pastebin.com/sT4n51XA
- Sep 17 17:48:58 <timetocode> undrinkablesoup, unfotunately that is not a standard thing. You might be able to get something like that with getBoundingClientRect(), and depending exactly how the apge goes you might need to mess with offsets
- Sep 17 17:49:18 <sillyslux> http://jsfiddle.net/983mchkd/2/
- Sep 17 17:52:44 <annoymouse> What's the purpose of the tilde operator?
- Sep 17 17:53:32 <chars6> sillyslux: yeah, whenever the contents of switch() is null i get an error
- Sep 17 17:53:36 <Havvy> Bitwise invert or something? It's not really that useful.
- Sep 17 17:53:53 <Havvy> Mainly because we don't have integral types.
- Sep 17 17:53:58 <chars6> sillyslux: i think screening for null ahead of time is what i'm going to need to do
- Sep 17 17:54:25 <sillyslux> i've seen that error too now
- Sep 17 17:55:04 <sillyslux> well i'd do if() too
- Sep 17 17:55:34 <chars6> sillyslux: thanks for your help!
- Sep 17 17:55:56 <chars6> sillyslux: i can figure out the rest from here
- Sep 17 17:57:01 <annoymouse> Havvy: But when would one use it?
- Sep 17 17:57:41 <Havvy> annoymouse: When programming in C on integral types.
- Sep 17 17:57:44 <sillyslux> i think i've used it once. i really can't remember when and why :(
- Sep 17 17:57:54 <Havvy> Possibly it's used in asm.js.
- Sep 17 17:58:01 <timetocode> annoymouse, the simple answer would be never ;). The complicated answer is that you use it for logical operations involving binary... sometimes in javascript that'll manifest as some cryptic performance hack
- Sep 17 17:58:24 <sillyslux> i do remember it was fun
- Sep 17 17:58:47 <Havvy> >> ~1
- Sep 17 17:58:47 <ecmabot> Havvy: (number) -2
- Sep 17 17:58:51 <Havvy> >> ~~1
- Sep 17 17:58:51 <ecmabot> Havvy: (number) 1
- Sep 17 17:58:56 <Havvy> >> ~-1
- Sep 17 17:58:57 <ecmabot> Havvy: (number) 0
- Sep 17 17:59:00 <annoymouse> I read a blog post about it and the guy said it's useful for str.indexOf()
- Sep 17 17:59:20 <timetocode> I had to use bit logic to make a buffer that could use bits instead of bytes
- Sep 17 17:59:27 <Havvy> >> if (~"abc".indexOf("d")) { true } else { false}
- Sep 17 17:59:27 <ecmabot> Havvy: (boolean) false
- Sep 17 17:59:28 <annoymouse> That way if it finds nothing and returns -1, the ~ will make it into 0, which evaluates as false
- Sep 17 17:59:31 <Havvy> >> if (~"abc".indexOf("b")) { true } else { false}
- Sep 17 17:59:31 <ecmabot> Havvy: (boolean) true
- Sep 17 17:59:51 <Havvy> But that's *really* *really* unreadable. ;)
- Sep 17 17:59:55 <timetocode> I would file that away under "cryptic performance hack"
- Sep 17 17:59:58 <timetocode> minus performance ;)
- Sep 17 18:00:14 <Havvy> if ("abc".indexOf("d") !== -1) { true } else { false} is much more readable.
- Sep 17 18:00:31 <annoymouse> Havvy: Exactly
- Sep 17 18:00:38 <Havvy> And when you can use ES6's library support... "abc".includes("d") would work better.
- Sep 17 18:01:26 <annoymouse> Havvy: Or even > -1
- Sep 17 18:01:52 <annoymouse> So in short, don't use it
- Sep 17 18:05:59 <ljharb> !es6-shim
- Sep 17 18:05:59 <ecmabot> ljharb: To get every backwards-compatible feature of ES6 in every browser and node, use https://www.npmjs.com/package/es6-shim ! It's heavily tested, comes with Promises, and using the !es5-shim as well is strongly encouraged.
- Sep 17 18:06:08 <ljharb> you can use String#includes now :-)
- Sep 17 18:06:21 <Havvy> annoymouse: Why use `>` when you can `!==`?
- Sep 17 18:06:35 <Havvy> ljharb: Bah, I refuse to use es6-shim.
- Sep 17 18:06:42 <ljharb> wat, why
- Sep 17 18:07:03 <annoymouse> Havvy: Less chars. that was the bloggers justification for using tilde in the first place
- Sep 17 18:07:07 <Havvy> It's not worth it in download size.
- Sep 17 18:07:13 <Havvy> At least for what it gives.
- Sep 17 18:09:53 <ljharb> Havvy: i'm not really sure what you mean - it's relatively small, and it gives you a ton of new API
- Sep 17 18:10:11 <ljharb> Map, Set, Promise, new Array methods, including Array.from…
- Sep 17 18:10:29 <ljharb> and more importantly, it fixes bugs in browsers' current implementations of them
- Sep 17 18:11:46 <Havvy> I can use `Object.create(null)` as a Map for when I need maps most of the type. I haven't really needed sets that often in JS. The new array methods are nice, but not entirely necessary.
- Sep 17 18:12:12 <Havvy> If I'm going to have a non-environmental promise, it's going to be bluebird.
- Sep 17 18:12:37 <ljharb> you can't use Object.create(null) for object keys
- Sep 17 18:12:54 <ljharb> ¯\_(ツ)_/¯ at any rate if you don't want to use it, don't, but "download size" is a silly reason
- Sep 17 18:13:04 <timetocode> es6 has object keys? so sexy
- Sep 17 18:13:14 <ljharb> timetocode: ES6 Map does.
- Sep 17 18:13:42 <timetocode> that's exciting
- Sep 17 18:13:42 <ljharb> Array.from, Array#find, Array#findIndex, and Array#fill are the most useful array methods in ES6 imo
- Sep 17 18:16:45 <timetocode> I want to add an api to one of my libs such that people can write myLib.on('update', someUserCode). I haven't made something like that before.. what woudl it be basically... an event emitter and adding a listener that use someUserCode as the callback...?
- Sep 17 18:17:43 <timetocode> also is there a particular merit to blah.onError(cb) vs blah.on('error', cb) ?
- Sep 17 18:18:01 <timetocode> it seems like jquery had the former, and now has the latter
- Sep 17 18:18:06 <ljharb> the latter is consistent with the node EventEmitter API
- Sep 17 18:18:22 <ljharb> and with DOM's addEventListener
- Sep 17 18:19:42 <timetocode> oh the .on function is straight up part of the event emitter.. i seeeeeeeee
- Sep 17 18:32:40 <baxx> what does "if (style.styleSheet)" mean, I can't seem to get to evaluate to true. I'm presuming that it's something to do with style having the property styleSheet
- Sep 17 18:32:40 <baxx>
- Sep 17 18:33:06 <baxx> I'm not sure if that's something that kinda needs the context or not either tbh
- Sep 17 18:33:57 <sillyslux> baxx make a fiddle
- Sep 17 18:34:16 <baxx> sillyslux: cool cool
- Sep 17 18:35:25 <baxx> sillyslux: contrived and colvoluted thing that I was just doing for learning https://jsfiddle.net/v8p0xdLu/
- Sep 17 18:35:50 <baxx> you can see the ifs at the end where I was trying to see whether they would evaluate, but they didn't
- Sep 17 18:39:12 <sillyslux> there is style.sheet
- Sep 17 18:39:38 <sillyslux> fwiw
- Sep 17 18:40:43 <baxx> sillyslux: how come the flag var doesn't get incremented then?
- Sep 17 18:42:01 <baxx> i was following along with it in the firefox debugger and it never went in those if conditions or incremented the flag var
- Sep 17 18:43:43 <sillyslux> there is style.sheet.cssRules[0].cssText
- Sep 17 18:43:46 <sillyslux> in chrome
- Sep 17 18:44:28 <baxx> sillyslux: Ok - so that's something thats 'given' with the browser? And thats just a chrome thing
- Sep 17 18:44:44 <sillyslux> i don't think so
- Sep 17 18:45:07 <baxx> I'm confused :/
- Sep 17 18:46:33 <sillyslux> or yes, i don't see it in ff
- Sep 17 18:47:35 <sillyslux> arrg sorry, yes it's available in ff too
- Sep 17 18:48:09 <baxx> so this 'if' isn't an obvious 'thing'? I'm trying to work out what the point in it is, as I can never get it to actually enter the if statement ... like the append section puts the CSS var into the DOM / HTML / whatever bit, but that other bit's confusing me
- Sep 17 18:48:13 <baxx> ha no worries ;)
- Sep 17 18:48:14 <sillyslux> style.sheet.cssRules[0].cssText has the css definition
- Sep 17 18:48:32 <baxx> sillyslux: ah fuck - is this the no-css / reset css thing that some people use?
- Sep 17 18:48:41 <sillyslux> it's style.sheet not style.styleSheet
- Sep 17 18:49:10 <baxx> sillyslux: ooo I'll test that
- Sep 17 18:50:26 <baxx> sillyslux: ha ok, now it goes into the if ;)
- Sep 17 18:50:54 <sillyslux> :) yes, but there is no style.sheet.cssText
- Sep 17 18:51:19 <baxx> so this if condition is basically asking whether there already exists some kind of style sheet - and if there is to append whatever is in the if onto it?
- Sep 17 18:51:49 <baxx> (just thinking about what the intention was for now rather than how it's not working, if that's doable)
- Sep 17 18:52:20 <sillyslux> you mean the 1st if/else?
- Sep 17 18:52:33 <sillyslux> with cssText=css
- Sep 17 18:52:35 <sillyslux> ?
- Sep 17 18:52:44 <sillyslux> style.sheet.cssRules[0].cssText
- Sep 17 18:53:17 <baxx> yeah the if(style.styleSheet){
- Sep 17 18:53:17 <baxx> style.styleSheet.cssText = css;
- Sep 17 18:53:17 <baxx>
- Sep 17 18:53:31 <sillyslux> that will never match
- Sep 17 18:53:47 <sillyslux> ah maybe in ie?!
- Sep 17 18:53:50 <sillyslux> :D
- Sep 17 18:53:53 <baxx> yeah but am I understanding the intention of it? (Or is trying to do that a pointless exercise)
- Sep 17 18:53:59 <baxx> oh yeah ha, forgot about ie
- Sep 17 18:54:10 <annoymouse> I have two promises that I want to run simultaneously, and when they are both fulfilled, I want to continue
- Sep 17 18:54:10 <baxx> or 'edge' as it like to be known now
- Sep 17 18:54:23 <annoymouse> But I don't want to wait for the first one to complete to start the second one
- Sep 17 18:54:31 <sillyslux> you mean what it's good for?
- Sep 17 18:54:39 <annoymouse> I feel like this should be really simple with Promises. Perhaps I'm missing the point
- Sep 17 18:55:24 <sillyslux> style.appendChild(document.createTextNode(css)) could also have been style.innerHTML=css
- Sep 17 18:55:28 <baxx> sillyslux: i was just trying to understand what that code was doing / trying to do i guess
- Sep 17 18:55:34 <tcsc> oh, is that my code?
- Sep 17 18:55:41 <baxx> tcsc: ;)
- Sep 17 18:55:50 <tcsc> i think i just copied it from other code i had written. it's supposed to add some css to the document.
- Sep 17 18:55:52 <Drewery> hello everybody
- Sep 17 18:55:57 <tcsc> in the head.
- Sep 17 18:56:11 <sillyslux> tcsc you wrote that?
- Sep 17 18:56:19 <tcsc> yeah, it was part of a oneoff
- Sep 17 18:56:28 <sillyslux> where do you get style.styleSheet from?
- Sep 17 18:56:43 <baxx> yeah part of the "stupid, oversimplified, and not terribly accurate, physics engine"
- Sep 17 18:56:54 <tcsc> older code i had written, i think i had heard it was required for certain IE
- Sep 17 18:57:14 <sillyslux> see, ie, told y0ou ;)
- Sep 17 18:57:18 <tcsc> not sure how far back that goes, so I keep using it, even though its probably no longer necessary
- Sep 17 18:57:47 <baxx> sillyslux: yep :)
- Sep 17 18:58:12 <baxx> tcsc: fair, yeah I was trying to get the if to execute and failed a bit
- Sep 17 18:58:17 <tcsc> ah
- Sep 17 18:58:24 <tcsc> yeah, that's a compatibility thing
- Sep 17 18:58:45 <tcsc> i think it might execute if you run it in IE9 but i'm not 100% certain
- Sep 17 18:59:00 <baxx> I thought that it was testing to see whether there was a prexisting style sheet, or if that 'reset css' or something had been run, idk lol
- Sep 17 18:59:14 <baxx> not sure if IE9 is in the debian repos
- Sep 17 18:59:29 <tcsc> lol
- Sep 17 19:00:04 <baxx> oh that's cool then, I can just ignore that as I'm not bothered about compatability at the mo :)
- Sep 17 19:00:55 <sillyslux> haha debian-ie that would be nice
- Sep 17 19:01:43 <baxx> I'd love to be on ##linux when it got announced
- Sep 17 19:01:54 <baxx> I got told off for using pastebin there ha ha
- Sep 17 19:03:00 <sillyslux> which browser are you using baxx?
- Sep 17 19:03:14 <sillyslux> firefox developer edition?
- Sep 17 19:03:14 <baxx> firefox and chrome
- Sep 17 19:03:15 <tcsc> i use pastie usually. but it's not the best, it doesn't support a lot of languages so i have to fudge it sometimes.
- Sep 17 19:03:32 <baxx> No never used dev edition - not sure what the difference is
- Sep 17 19:03:56 <tcsc> i think it has more developer tools but i've never really noticed.
- Sep 17 19:04:19 <tcsc> well, i don't use the non-developer edition much so, i guess i wouldnt notice.
- Sep 17 19:04:28 <baxx> tcsc: you got a little bash function for that or something? I keep meaning to set something up, pasteit isn't so great
- Sep 17 19:04:46 <tcsc> no, i just go to pastie and paste it in
- Sep 17 19:05:05 <sillyslux> when you go to the html panel and right click on that style element and choose the last option "inspect in dom panel" you can browser through all it's properties and find style.sheet
- Sep 17 19:05:24 <baxx> tcsc: manual labor
- Sep 17 19:05:36 <tcsc> sure, but i don't paste a lot
- Sep 17 19:05:50 <tcsc> also, amdahl's law def. applies
- Sep 17 19:05:57 <tcsc> it takes longer to write the thing being pasted
- Sep 17 19:06:00 <tcsc> than it does to paste it
- Sep 17 19:06:02 <baxx> sillyslux: I've been looking in the debug section thing
- Sep 17 19:06:58 <sillyslux> oh i see, that firefox builtin thing
- Sep 17 19:07:03 <sillyslux> i meant firebug..
- Sep 17 19:07:37 <baxx> firebug, everyone told me no one uses that ha
- Sep 17 19:07:51 <tcsc> nobody should use it
- Sep 17 19:07:53 <tcsc> people still due
- Sep 17 19:07:55 <tcsc> err, do*
- Sep 17 19:10:05 <baxx> i can see a fair bit of stuff in variables on the right
- Sep 17 19:10:44 <sillyslux> ff won't show the dom properties on that style element in the jsfiddle frame
- Sep 17 19:11:04 <sillyslux> maybe mine is a bit old
- Sep 17 19:11:36 <baxx> sillyslux: oh sos I'm actually looking at mine from the local file >.<
- Sep 17 19:11:37 <sillyslux> and.. why not firebug? deprecated?
- Sep 17 19:11:57 <tcsc> the builtin tools are waaaay better
- Sep 17 19:11:59 <sillyslux> firebug and chrome work well here
- Sep 17 19:12:04 <tcsc> firebug is its own project
- Sep 17 19:12:09 <tcsc> so it's not deprecated
- Sep 17 19:12:13 <tcsc> it's just, not as good.
- Sep 17 19:12:17 <tcsc> by a wide margin
- Sep 17 19:12:31 <sillyslux> think i read somewhere that they'll merge
- Sep 17 19:12:37 <sillyslux> or did merge
- Sep 17 19:13:10 <sillyslux> didn't use ff in the last 15 months or so
- Sep 17 19:13:13 <ycon_> Hi all, not sure why but my JS won't let me set the amount of results I want form an random number query. Line 17. Any tips? http://jsfiddle.net/jjz977um/13/
- Sep 17 19:13:51 <tcsc> tbh 15 months is longer than i've been writing javascript.
- Sep 17 19:13:53 <undrinkablesoup> timetocode: Dammit. :/
- Sep 17 19:14:38 <baxx> tcsc: what were you doing before, c++ ?
- Sep 17 19:14:41 <tcsc> yes
- Sep 17 19:14:44 <tcsc> and actionscript
- Sep 17 19:15:06 <tcsc> sort of c# too but i started that around the same time as js.
- Sep 17 19:15:13 <baxx> oh right, got better or worse for JS?
- Sep 17 19:15:25 <tcsc> what do you mean?
- Sep 17 19:15:38 <ycon_> Ah I figured it out! js aint so bad after day 2
- Sep 17 19:16:48 <baxx> tcsc: just whether js had been as much / more fun or whatnot
- Sep 17 19:17:06 <tcsc> i like being able to write code and easily distribute it
- Sep 17 19:17:22 <tcsc> but i think it's not a good language for game development since its very hard to guarantee performance.
- Sep 17 19:17:32 <baxx> tcsc: that's a big appeal to me - the react native stuff is interesting as well.
- Sep 17 19:18:02 <sillyslux> ycon_, http://jsfiddle.net/jjz977um/15/
- Sep 17 19:18:11 <baxx> sillyslux: 20 seconds in on this : http://sendvid.com/1ccxrxoz
- Sep 17 19:18:12 <tcsc> we use react for our game editors and it's okay. its fairly tedious tbh.
- Sep 17 19:18:29 <tcsc> it works well in the context of an editor though.
- Sep 17 19:18:29 <baxx> sillyslux: is that the info you were getting in the firebug?
- Sep 17 19:18:45 <baxx> tcsc: what do you mean editors?
- Sep 17 19:18:51 <tcsc> like, content editors
- Sep 17 19:18:59 <ycon_> sillyslux: Thanks. I just needed to change my *10 to *30 (to get 30 results instead of just 10). Thanks
- Sep 17 19:19:05 <tcsc> so that game designers dont have to edit json files and crap
- Sep 17 19:19:30 <baxx> oh right fair, to automate stuff
- Sep 17 19:19:45 <tcsc> basically.
- Sep 17 19:20:07 <ycon_> json files are a headache. Is there any good js library around to conver JS to csv? I've got tonnes to data to sort
- Sep 17 19:20:18 <baxx> I'd love to do visuals or something one day, computer visuals are mathy at hell though so it'll be a while
- Sep 17 19:20:29 <tcsc> yeah, there's a lot of math to it
- Sep 17 19:20:51 <tcsc> although game engines can take care of a decent amount of that for you.
- Sep 17 19:20:58 <baxx> tcsc: which I don't mind, it's just one has to actually have the time to learn it ;)
- Sep 17 19:20:59 <tcsc> depending on what you want to do.
- Sep 17 19:21:10 <tcsc> yeah. i think the math is worth knowing.
- Sep 17 19:21:16 <baxx> yeah its great!
- Sep 17 19:21:29 <baxx> not sure if that sounded sarcastic, it wasn't
- Sep 17 19:21:52 <baxx> I mainly mean like geometric kind of stuff tbh
- Sep 17 19:22:40 <baxx> https://i.imgur.com/StIh4V5.jpg that would be more in line with my meaning than a computer game for example
- Sep 17 19:23:01 <sillyslux> long ago i learned lot's of geometry, that was when i went to school
- Sep 17 19:23:14 <baxx> oh damn erc is loading that gif and it doesn't like it at all
- Sep 17 19:23:17 <tcsc> i imagine that was made in something like blender or after effects or something
- Sep 17 19:23:31 <tcsc> not that you couldn't do it in code
- Sep 17 19:23:36 <sillyslux> 23yrs later i don't remember that much
- Sep 17 19:24:01 <tavl> how can I do something like a fork/join using Q (promise)? I mean: A -> B|C -> D, where B and C need the result from A as input. I tried using Q.All, but I think I'm doing something wrong here. ps: All functions return promises
- Sep 17 19:24:30 <tcsc> i remember when i was in college, i took a computer graphics course and the professor asked me what the equation for a circle is in front of the class
- Sep 17 19:24:32 <tcsc> and i had no idea
- Sep 17 19:24:42 <sillyslux> baxx that one is for ana tudor :p
- Sep 17 19:25:45 <baxx> test
- Sep 17 19:25:47 <tcsc> and that was after i had taken nearly enough math to have a math minor. i think i was just one course short.
- Sep 17 19:25:58 <tcsc> math is one of those things you forget if you dont use it
- Sep 17 19:26:48 <fprophet> so true
- Sep 17 19:27:03 <fprophet> I still use a calculator for simple addition, like 10+5
- Sep 17 19:27:07 <sillyslux> https://twitter.com/anatudor/status/644621903626391553
- Sep 17 19:30:47 <tcsc> i feel like doing those things in pure html/svg and css is practically masochism
- Sep 17 19:31:12 <baxx> tcsc: emacs just shat itself over that gif - not sure if you posted before this message - what do you mean?
- Sep 17 19:31:18 <fprophet> all of my projects are usually done without any addons or libraries
- Sep 17 19:31:30 <baxx> ah shit, you're not talking about that gif ha ha, nw
- Sep 17 19:31:32 <fprophet> except for stuff I cant do myself, like sha encryption in c
- Sep 17 19:31:44 <tcsc> i don't use many libraries when i can avoid it.
- Sep 17 19:31:52 <fprophet> I've never used jquery
- Sep 17 19:32:08 <fprophet> so whenever I have javascript questions I have to spend extra time finding a solution that doesnt use jquery
- Sep 17 19:32:27 <tcsc> i use much more for work, but our deadlines are such that its very hard to avoid.
- Sep 17 19:33:33 <tcsc> but quality suffers, both because i'll use a library even if it only does sort of what i need, and because we have like 2 week deadlines.
- Sep 17 20:03:30 <Kamuela> Nothing wrong with jQuery that anyone has validly argued
- Sep 17 20:03:55 <Kamuela> ^I know that's a pretty bold statement m
- Sep 17 20:04:07 <zomg> Kamuela: it's a valid argument :P
- Sep 17 20:06:41 <Kamuela> Why won't ghost just finish its damned external API
- Sep 17 20:07:06 <Kamuela> It's making me login to view posts. Humbug
- Sep 17 20:24:22 <tcsc> jquery's performance is probably the biggest thing wrong with it
- Sep 17 20:24:36 <tcsc> it's also kind of bloated imo
- Sep 17 20:25:09 <tcsc> but the performance isn't debatable. on mobile it's really bad.
- Sep 17 20:25:24 <tcsc> or at least was like 8 months ago.
- Sep 17 20:54:40 <Kamuela> 2.x or 1.x?
- Sep 17 21:06:36 <Boar> Afternoon everyone, is there anything Special I have to do to get npm modules working with Requirejs?
- Sep 17 21:57:34 <NitroLiq> Anyone awake?
- Sep 17 21:59:57 <Boar> no
- Sep 17 22:03:22 <NitroLiq> That stinks. I could use an extra pair of eyes to help me sort out a wee bit of jquery.
- Sep 17 22:36:44 <vmonteco> Hello!
- Sep 17 22:39:12 <vmonteco> I have a little question about mutations : If <div id="no1"><div id="no2"></div></div> is added to my page : will my MutationObserver get a mutation for each div (one for #no1, one for #no2), or only a mutation for #no1?
- Sep 17 23:02:59 <Robarelli> how do I reference this element inside its options? http://kopy.io/I93nX
- Sep 17 23:03:48 <Robarelli> i want the source to be dynamic, which is taken from an array, keyed by the element's name
- Sep 18 00:28:58 <javascript278> hey guys
- Sep 18 00:29:09 <javascript278> can anyone assist me in my javascript project?
- Sep 18 00:29:16 <nodist> sure
- Sep 18 00:29:32 <javascript278> nodist: great! one sec!
- Sep 18 00:31:03 <javascript278> nodist: I'm trying to build this http://callmenick.com/_development/memory/
- Sep 18 00:31:30 <javascript278> nodist: Basically I have one last feature I want to implement which is to show a preview of the tiles for 10 seconds before the game starts.
- Sep 18 00:31:44 <nodist> ok
- Sep 18 00:31:48 <javascript278> https://github.com/callmenick/Memory
- Sep 18 00:32:09 <javascript278> the codes are in there, to be more specific https://github.com/callmenick/Memory/blob/master/js/memory.js
- Sep 18 00:32:54 <javascript278> I'm not very good at prototype, how do I use the javascript file to create a button, and to show the preview for 10 second and then lead to the game?
- Sep 18 00:33:32 <javascript278> I've toyed around for quite abit, and realise once I add the class "flipped" the tiles will be turned over. So how can I mass "flipped" the tiles for 10 second before removing the class
- Sep 18 00:33:45 <javascript278> And also to not shuffle the preview tiles until the game is over.
- Sep 18 00:33:53 <supay> would it make more sense to use something like semantic-ui for the frontend ui, or reactjs? if you can also explain the advantages of whichever, that would be amazing.
- Sep 18 00:34:01 <nodist> you want to use document.createElement add an on click and append to the html
- Sep 18 00:34:20 <javascript278> okay.
- Sep 18 00:34:32 <javascript278> the problem is the "preview" of the tiles.
- Sep 18 00:38:15 <javascript278> nodist: are you there?
- Sep 18 00:38:33 <nodist> yeah its a lot, im looking
- Sep 18 00:38:40 <javascript278> nodist: yeah thanks!
- Sep 18 00:39:07 <supay> hm? is this the wrong channel to discuss frontend dev? :/
- Sep 18 00:39:42 <javascript278> :/ but isn't javascript also for front end .
- Sep 18 00:40:14 <supay> i guess its possible.. isnt that what react.js is?
- Sep 18 00:41:01 <javascript278> supay: o.o I haven't heard of it :/ taking a look at it right now.
- Sep 18 00:41:22 <GreenJello> supay, semantic ui is for quickly building web sties, react is for building complex web applications that are maintainable long term
- Sep 18 00:41:44 <GreenJello> you could use them together, but you have to wrap the semantic ui stuff in react components
- Sep 18 00:41:54 <javascript278> GreenJello: What about for web applications, I'm currently building web-based games like jigsaw puzzles.
- Sep 18 00:41:59 <supay> GreenJello: ah, i see. and i can use react as the 'View' part in an MVC framework?
- Sep 18 00:42:11 <supay> such as in conjugation with angular?
- Sep 18 00:42:33 <GreenJello> you can, but react and angular don't get along
- Sep 18 00:42:42 <supay> oh
- Sep 18 00:42:44 <GreenJello> a lot of people just use react and other libraries to build applications
- Sep 18 00:42:49 <supay> can react do the MV parts as well?
- Sep 18 00:42:50 <supay> i see
- Sep 18 00:43:03 <supay> it would be helpful if there was a list with such information :(
- Sep 18 00:43:29 <GreenJello> no frameworks; the best use of react is when you need full control; it takes longer to get started with but pays off in the medium to long term
- Sep 18 00:43:32 <supay> so difficult for newbies to get the right technologies installed and begin the learning process (i prefer to learn actively, as in, as i code)
- Sep 18 00:44:01 <supay> interesting. very interesting. i guess ill just have to get react and try it out to see what is possible with it.
- Sep 18 00:44:05 <GreenJello> supay, a good setup is react, webpack, reflux, superagent
- Sep 18 00:45:17 <supay> awesome, googling! ^.^
- Sep 18 00:45:56 <supay> btw, i might be comparing apples with oranges here. but if i want to make a decent sized, scalable web-application would you suggest i go with angular or react and the set you just mentioned?
- Sep 18 00:47:47 <GreenJello> supay, do you want control and maintainability or a faster MVP that you might have to rewrite later on?
- Sep 18 00:48:05 <nodist> <javascript278> you there I added a timeout at the begining but Im not going to take the time to add a button
- Sep 18 00:49:00 <nodist> javascript278 here is the updated function http://jsfiddle.net/nodist/0qdd4xyg/
- Sep 18 00:49:17 <javascript278> nodist: i'm taking a look
- Sep 18 00:51:54 <javascript278> nodist: you select all the inner, and gave them flipped class
- Sep 18 00:52:05 <nodist> yeah
- Sep 18 00:52:22 <javascript278> interesting, i was trying this earlier and i just couldn't get it.
- Sep 18 00:52:28 <nodist> but I only did it for 5s though
- Sep 18 00:52:36 <javascript278> yup i know
- Sep 18 00:52:47 <javascript278> nodist: i tried to createlement
- Sep 18 00:53:01 <javascript278> this.gameButton = document.createElement("button");
- Sep 18 00:53:37 <javascript278> how do I get the button
- Sep 18 00:53:38 <javascript278> to show?? o.o
- Sep 18 00:53:47 <nodist> append to it element
- Sep 18 00:54:33 <javascript278> i did this
- Sep 18 00:54:36 <nodist> eg document.getElementById(id).appnedChild(this.gameButton)
- Sep 18 00:54:45 <nodist> append*
- Sep 18 00:54:51 <javascript278> var x = document.createElement("BUTTON"); var t = document.createTextNode("Click me"); x.appendChild(t); document.body.appendChild(x);
- Sep 18 00:54:54 <javascript278> something like that
- Sep 18 00:54:58 <javascript278> but nothing show
- Sep 18 00:55:30 <nodist> you don't need the document part
- Sep 18 00:55:38 <nodist> lol wait I read it wrong
- Sep 18 00:55:48 <nodist> you don't need the text node
- Sep 18 00:56:57 <javascript278> so i just remove tht and it will work?
- Sep 18 00:57:05 <javascript278> btw the code you sent me, why did you need the var self = this;
- Sep 18 00:57:18 <javascript278> why even initialise self when you didnt use it?
- Sep 18 00:57:19 <javascript278> o.o
- Sep 18 00:57:31 <nodist> var but = document.createElement('button');
- Sep 18 00:57:31 <nodist> but.textContent = 'Hello';
- Sep 18 00:57:31 <nodist> document.body.appendChild(but);
- Sep 18 00:58:00 <nodist> I did use the self
- Sep 18 00:58:04 <nodist> look near the bottom
- Sep 18 01:04:55 <nodist> !mdn promise
- Sep 18 01:04:55 <ecmabot> nodist: Promise - JavaScript | MDN <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise>
- Sep 18 01:08:06 <javascript278> nodist: thanks i got it to work!
- Sep 18 01:08:12 <nodist> np
- Sep 18 01:08:48 <javascript278> nodist: i feel that I will be using this prototype things again. Do you know where I could learn in detail about this?
- Sep 18 01:09:10 <nodist> I guess mdn
- Sep 18 01:09:11 <asd_> Hi. I want to make a bigger image side-by-side with a smaller image on a webpage. https://stackoverflow.com/questions/32645867/how-to-make-this-big-image-side-by-side-with-smaller-image Can someone help?
- Sep 18 01:09:23 <javascript278> mdn?
- Sep 18 01:09:28 <nodist> !mdn mdn
- Sep 18 01:09:28 <ecmabot> nodist: Mozilla Developer Network <https://developer.mozilla.org/>
- Sep 18 01:09:35 <javascript278> !mdn mdn
- Sep 18 01:09:35 <ecmabot> javascript278: Mozilla Developer Network <https://developer.mozilla.org/>
- Sep 18 01:09:42 <javascript278> oH
- Sep 18 01:09:45 <javascript278> wow thanks!
- Sep 18 01:09:48 <javascript278> I'm gonna read up on it
- Sep 18 01:09:52 <nodist> !mdn prototype
- Sep 18 01:09:52 <ecmabot> nodist: Object.prototype - JavaScript | MDN <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype>
- Sep 18 01:09:59 <javascript278> !mdn prototype
- Sep 18 01:09:59 <ecmabot> javascript278: Object.prototype - JavaScript | MDN <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype>
- Sep 18 01:38:57 <Mackan90096> Hi! Does anyone know if and where I can accuire free Javascript stickers?
- Sep 18 01:40:44 <vmonteco> Does anyone know for my MutationObserver question?
- Sep 18 01:45:05 <ankr> Mackan90096 not free.. but http://devswag.com/
- Sep 18 01:45:11 <ankr> otherwise go to conferences
- Sep 18 02:02:40 <zomg> You can just try emailing or tweeting at companies too
- Sep 18 02:02:44 <zomg> I've heard that sometimes works :P
- Sep 18 02:03:43 <Mackan90096> Okay, I want a javascript sticker for my laptop, from where should I get it?
- Sep 18 02:05:04 <ankr> Mackan90096 You could try find a meetup for your favorite technology and go there. Many times they bring stickers etc.
- Sep 18 02:05:29 <Mackan90096> ankr: Hm, I'll google around a bit, thanks
- Sep 18 02:07:05 <ankr> Mackan90096 You sit in sweden?
- Sep 18 02:07:15 <Mackan90096> I do.
- Sep 18 02:07:31 <Mackan90096> Not even close to stockholm or gothenburg though.
- Sep 18 02:07:43 <ankr> Mackan90096 what about malmø?
- Sep 18 02:08:27 <Gilgameshkun> "Gothenburg" has always sounded strange to me. Growing up speaking English in an opposite corner of the world, I'd always heard that city called "Goteborg". :P
- Sep 18 02:08:38 <Mackan90096> That's about an hour from where I live.
- Sep 18 02:08:58 <Mackan90096> Anyways, I'll be right back.
- Sep 18 02:10:51 <ankr> Mackan90096 Maybe you can find something here http://javascript.meetup.com/cities/se/malm%C3%B8/ --- I would check for Copenhagen as well, there's usually a lot going on.
- Sep 18 02:13:20 <moep> hi
- Sep 18 02:13:21 <Mackan90096> Alright
- Sep 18 02:13:24 <Mackan90096> I'm back.
- Sep 18 02:14:26 <Mackan90096> Right. From where should I get stickers?
- Sep 18 02:24:49 <teomar> !help
- Sep 18 02:24:49 <ecmabot> teomar: For help, ask your question. Be patient. Code samples should be pasted in a paste service (see !paste). Tell us 1) what you want to happen, 2) what is actually happening, and 3) any error messages you find (see !describe and !debug).
- Sep 18 02:26:27 <zomg> Yeah I'd imagine might be difficult to get stickers if you don't live in the US :P or have a major city near you
- Sep 18 02:26:38 <zomg> here in Finland pretty much the only place with conferences or anything even resembling that is Helsinki
- Sep 18 02:27:18 <acetoxy> zomg: unixstickers.com :)
- Sep 18 02:27:21 <zomg> I think the commonly used JS logo (yellow box with letters JS) is open source though so if you like it you can grab the SVG and get it printed
- Sep 18 02:27:30 <acetoxy> I just put a vim sticker on my laptop
- Sep 18 02:27:32 <teomar> Here in Sardinia Italy we have plenty of conferences... of shepherds.
- Sep 18 02:27:47 <zomg> I have a Daily WTF sticker on my macbook
- Sep 18 02:27:55 <zomg> got it with the purchase of one of their mugs many years ago :D
- Sep 18 02:28:28 <zomg> and one of these on my car :p http://store.dieselsweeties.com/products/warning-vehicle-transforms-into-robot-stickers
- Sep 18 02:30:48 <teomar> I got a huge GitHub sticker on my macbook, but my fav is my old IBM Thinkpad X31, I have all kinds of stickers on it
- Sep 18 02:31:08 <teomar> most irrelevant to tech though
- Sep 18 02:31:19 <teomar> that robot sticker is awesome
- Sep 18 02:32:10 <teomar> Hey, can someone help me with some JS issues?
- Sep 18 02:33:12 <zomg> Sure, just ask
- Sep 18 02:33:26 <teomar> I'll msg you
- Sep 18 02:35:25 <teomar> so, if you go here http://f6f.e05.myftpupload.com/client (to unlock the coming soon screen) and then here http://f6f.e05.myftpupload.com/prodotto/peperoni/ take a look at the contents of child.js
- Sep 18 02:36:07 <teomar> my problem is that window.* events do not load
- Sep 18 02:36:29 <teomar> I've tried the resize and the onload events, nothing
- Sep 18 02:37:09 <teomar> on the other hand, documen.ready works fine
- Sep 18 02:45:10 <zomg> heh I tried to look at it but just get a fatal error :P
- Sep 18 02:47:49 <teomar> huh?
- Sep 18 02:47:52 <teomar> got a screensht?
- Sep 18 02:48:22 <zomg> Warning: require_once(core/metaboxes.php): failed to open stream: No such file or directory in /home/content/p3pnexwpnas02_data03/79/2736279/html/wp-content/themes/shoelace/functions.php on line 212
- Sep 18 02:48:34 <zomg> Fatal error: require_once(): Failed opening required 'core/metaboxes.php' (include_path='.:/usr/local/php5_4/lib/php') in /home/content/p3pnexwpnas02_data03/79/2736279/html/wp-content/themes/shoelace/functions.php on line 212
- Sep 18 02:48:34 <teomar> ah
- Sep 18 02:48:38 <teomar> I just added some stuff
- Sep 18 02:48:51 <teomar> thanks, nevermind it for now
- Sep 18 02:48:56 <zomg> ok :)
- Sep 18 03:14:15 <teomar> zomg, still around?
- Sep 18 03:14:28 <zomg> yeah
- Sep 18 03:14:35 <teomar> could you please take another look?
- Sep 18 03:14:39 <teomar> fixed the errors
- Sep 18 03:15:29 <zomg> sure
- Sep 18 03:16:23 <teomar> I changed a couple of things
- Sep 18 03:16:26 <zomg> well looks like there's an error because jQuery(..).onload is not a function
- Sep 18 03:16:44 <teomar> jQuery is in compatibility mode for WP
- Sep 18 03:19:38 <teomar> okay, I'm an idiot
- Sep 18 03:28:22 <teomar> fixed, apparently it was a compatibility issue
- Sep 18 03:28:31 <teomar> I replaced $ with jQuery and everything worked.
- Sep 18 03:28:53 <teomar> It's weird though, I've used this method in the past and everything worked fine, don't know what the deal was now.
- Sep 18 03:43:23 <ahoo> do integers have to be quoted in json?
- Sep 18 03:43:49 <Hannibal_Smith> ahoo, no
- Sep 18 03:43:53 <ahoo> thx
- Sep 18 03:45:07 <Gilgameshkun> Non-finite numbers do, or they'll serialize as null.
- Sep 18 03:48:24 <zomg> teomar: iirc wordpress uses jQuery's noConflict mode so that would stop $ from working
- Sep 18 03:49:34 <teomar> I know, but that's why you're supposed to do the whole jQuery.blabla(function($){ thing
- Sep 18 03:49:49 <teomar> I've used it before w/ WP and it worked fine
- Sep 18 03:49:57 <zomg> Ah
- Sep 18 03:50:13 <teomar> now I'm creating my own bootstrap theme and I must have messed up something
- Sep 18 03:50:19 <zomg> I think that works with jQuery(whatever).ready(function($) { }) (or with jQuery(function($) { }) )
- Sep 18 03:51:00 <teomar> yeah, that's what I did
- Sep 18 03:51:14 <teomar> in any case, screw it for now, it was for a very particular project :)
- Sep 18 03:55:50 <Mackan90096> Okay, I have a contenteditable div. How do I insert a tab character at the caret position?
- Sep 18 03:56:10 <Mackan90096> I already have a function to get the caret position and a hook on the tab key.
- Sep 18 03:56:26 <Mackan90096> I'd like to not use jQuery for this.
- Sep 18 03:58:38 <Mackan90096> Nevermind my question, I found a function for it.
- Sep 18 04:12:55 <Mackan90096> Okay, in a contenteditable div, how do I set the caret position?
- Sep 18 04:15:42 <deltab> set a zero-length selection, I think
- Sep 18 04:16:02 <Mackan90096> deltab: How do I do that?
- Sep 18 04:16:30 <deltab> by calling a method, probably
- Sep 18 04:16:47 <Mackan90096> Obviously.
- Sep 18 04:16:54 <Mackan90096> I meant in terms of what method(s)
- Sep 18 04:17:01 <deltab> possibly by getting an object and setting its properties
- Sep 18 04:17:20 <Mackan90096> !mdn contenteditable
- Sep 18 04:17:21 <ecmabot> Mackan90096: Content Editable - Web developer guide | MDN <https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_Editable>
- Sep 18 04:27:17 <dbrock> is it impossible with the es6 module syntax to just import everything from a module?
- Sep 18 04:27:24 <dbrock> import * from "foo" gives a syntax error
- Sep 18 04:28:06 <ankr> try import * as foo from 'foo'
- Sep 18 04:29:57 <dbrock> ah, yeah, that's what I opted for
- Sep 18 04:31:35 <dbrock> I can do export * from "foo" though...?
- Sep 18 04:33:12 <ankr> dbrock all syntaxes are explained here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
- Sep 18 04:34:23 <deltab> dbrock: you always have to specify some name or names to assign to
- Sep 18 05:08:22 <hellyeah> hey
- Sep 18 05:08:36 <hellyeah> can i check button click or not like that? What am i missing here?
- Sep 18 05:12:18 <supay> hellyeah: of course you can. thats what onClick() is for :)
- Sep 18 05:15:36 <hellyeah> supay: when i click button i want to get alert what am i missing here? https://jsfiddle.net/3ssa5stm/17/
- Sep 18 05:17:33 <Jordy> Is there a way to add a "<br/>" between 2 items everytime in a array? ['a', 'b', 'c', 'd'] -> ['a', 'b', '<br/>', 'c', 'd']?
- Sep 18 05:19:31 --- ChanServ gives channel operator status to buu
- Sep 18 05:20:38 <CamC> Hi, hope someone can help. I have a click event (returns position) on a parent div, and a child div inside, when I click it triggers the child, shouldnt it trigger the parent?
- Sep 18 05:22:51 * buu removes quiet on $~a
- Sep 18 05:23:46 <buu> CamC: It depends on how the event is captured and bubbled
- Sep 18 05:24:46 <buu> hellyeah: what on earth is that code
- Sep 18 05:27:04 <Guest33> guys, i need some help with Math. I have a calculation (37554 * 256) + 33 which outputs 9613857 - However with the # 9613857, how do i get back the number 37554?
- Sep 18 05:28:28 <guessx> -33 / 256?
- Sep 18 05:28:33 <buu> Guest33: reverse the operations?
- Sep 18 05:29:48 <Guest33> yeah right ( 9613857 - 33) / 256
- Sep 18 05:29:49 <Guest33> thanks!
- Sep 18 05:32:51 <buu> welp
- Sep 18 05:48:11 <Jordy> Is there a way to add a "<br/>" in between 2 items everytime in a array? ['a', 'b', 'c', 'd'] -> ['a', 'b', '<br/>', 'c', 'd']?
- Sep 18 05:52:33 <ankr> >> ['a', 'b', 'c', 'd'].reduce(function (r, e, i) { if (i && !(i % 2)) { r.push('<br>'); } r.push(e); return r; }, []);
- Sep 18 05:52:33 <ecmabot> ankr: (object) ['a', 'b', '<br>', 'c', 'd']
- Sep 18 05:52:41 <ankr> Jordy try something like that
- Sep 18 05:55:02 <nirakara> hi. I have this JS (https://dpaste.de/QsZs). When i click the allowPost button, i get "clicked" in console and nothing else. when I try clicking the button again i get Uncaught TypeError: Cannot read property 'send' of null (https://github.com/jonashagstedt/swampdragon/blob/master/swampdragon/static/swampdragon/js/dist/swampdragon.js#L330) why would this be?
- Sep 18 05:55:15 <nirakara> it seems that the sockjs connection suddenly refers to nothing after the second click
- Sep 18 06:01:35 <Jax2> Morning all... can someone help a total JS noob for a moment? I have a working script on my site on one page (http://riddlesforall.com/sudoku.php) and I am trying to move it to the new layout at (http://riddlesforall.com/new/sudoku.php) ... I have included links to the same css styles and the .js script yet on the first page, it works, on the 2nd, it doesn't, and I have no clue why
- Sep 18 06:04:15 <buu> Jax2: Have you tried opening up the javascript console
- Sep 18 06:04:54 <Jax2> in chrome?
- Sep 18 06:06:38 <Jax2> It shows me an error - Uncaught TypeError: Cannot set property 'innerHTML' of null
- Sep 18 06:07:22 <Jax2> the error points to this line in the JS code: document.getElementById("display_area").innerHTML = data + "<br />\n";
- Sep 18 06:10:15 <Jax2> ha... figured it out, I missed a tiny little <div id="display_area"></div> at the bottom - thanks for the very brrief, but very helpful suggestion :)
- Sep 18 06:12:26 <Jordy> ty ankr <3
- Sep 18 06:14:24 <nirakara> hi. I have this JS (https://dpaste.de/QsZs). When i click the allowPost button, i get "clicked" in console and nothing else. when I try clicking the button again i get Uncaught TypeError: Cannot read property 'send' of null (https://github.com/jonashagstedt/swampdragon/blob/master/swampdragon/static/swampdragon/js/dist/swampdragon.js#L330) why is the sockjs object getting redefined to null?
- Sep 18 06:21:41 <nirakara> does anyone know anything about data code 3001 when using sockjs
- Sep 18 06:21:53 <nirakara> the connection is just closing
- Sep 18 06:24:24 <bberry> So, we want to have a sort of "new features" page where users can go to and see new changes.... and we're thinking about having it in a blogish style format. Any library recommendations on blog formatting?
- Sep 18 06:24:47 <buu> library.. blog.. formatting?
- Sep 18 06:24:57 <buu> Need more context
- Sep 18 06:30:37 <Sharaal1> bberry: perhaps you want to google "markdown parser javascript"
- Sep 18 06:31:37 <bberry> Sharaal1, probably a good idea. i think the idea is for us to be able to add "posts" through the website interface instead of writing html/css or markdown.
- Sep 18 06:31:53 <bberry> basically my coworker wants a wordpress
- Sep 18 06:32:38 <Sharaal1> wordpress has a WYSIWYG editor, no need of markdown or writing html/css
- Sep 18 06:34:29 <bberry> yeah, i know, i'm guessing that is what he wants. so i think WYSIWYG is probably the best google search term :D
- Sep 18 06:34:31 <bberry> ty!
- Sep 18 06:37:07 <Kamuela> bberry: are you trying to stick to a JavaScript stack or something?
- Sep 18 06:38:08 <Kamuela> a lot of Wordpress comes down to its plugin ecosystem. But if the client wants primarily content management functionality there are admin pages for lots of JS stacks
- Sep 18 06:38:35 <bberry> Kamuela, mostly we want to have full control of the content of our pages (look/feel) instead of having a link to a wordpress.
- Sep 18 06:38:41 <aleray> Hi, I've written a scrip that allows one to select a document in a dropdown and load the selected document in an iframe on the page. This part seems to work, but I don't manage to restore the iframe src value on reload
- Sep 18 06:38:50 <aleray> here is my code: http://dpaste.com/3F77XE7
- Sep 18 06:39:19 <aleray> lines 15 and 16 are meant to restore the state but don't work
- Sep 18 06:40:17 <aleray> actually it works on chromium, but not on epiphany
- Sep 18 06:47:54 <GreenJello> aleray, parse location.hash
- Sep 18 06:48:09 <GreenJello> get the value from there instead of the history object
- Sep 18 06:51:45 <aleray> GreenJello, indeed I can do that. Still curious why the other solution don't work
- Sep 18 06:51:57 <GreenJello> maybe a browser bug
- Sep 18 06:52:18 <aleray> GreenJello, thanks
- Sep 18 06:52:26 <GreenJello> history state is for session stuff, I've only seen it used to track things like scroll position
- Sep 18 06:52:58 <GreenJello> if you want people to be able to link to the state, you put the data in the url and read from the url
- Sep 18 06:57:24 <baxx> requestAnimationFrame can be a bit intense - what's an easy way to limit how many calls this makes? Make a counter variable with if(counter % val) or something or is there a different approach?
- Sep 18 06:58:10 <GreenJello> baxx, what's up?
- Sep 18 06:58:38 <undrinkablesoup> getBoundingClientRect() returns an object with left/top values that appear to work as long as the page has not scrolled. As soon as the page has been scrolled down, the values start to not match up, increasingly more and more the more you scroll. How can I account for that?
- Sep 18 06:59:12 <aleray> GreenJello, thanks it works perfectly
- Sep 18 07:00:45 <baxx> GreenJello: just that sometimes I don't think I need request to be requesting quite so much for what i'm doing, so it'd be cool to limit that a bit
- Sep 18 07:02:50 <GreenJello> undrinkablesoup, maybe you want el.offsetTop/offsetLeft ?
- Sep 18 07:03:25 <GreenJello> baxx, so you want to throttle http requests?
- Sep 18 07:03:31 <undrinkablesoup> Sounds about right.
- Sep 18 07:04:47 <smgs> http://jsfiddle.net/jyoticharan/r4AGd/6/ could someone guide. thanks
- Sep 18 07:04:58 <smgs> i want it in pure javascript only. thanks.
- Sep 18 07:06:11 <GreenJello> smgs, start by looking up the syntax for a "for loop"
- Sep 18 07:06:23 <baxx> GreenJello: I dunno I guess so, just so that if it's currently refreshing 40 times a second I could change that to 10 or whatever just to make it a bit easier on the processer or whatnot
- Sep 18 07:06:50 <smgs> GreenJello: https://jsfiddle.net/d03px1ut/ could you help with this.
- Sep 18 07:07:00 <GreenJello> baxx, underscore/lodash has a function called throttle that lets you say "don't run this more than every 100ms"
- Sep 18 07:07:00 <smgs> i just want to test if it can be done in pure javascript or not. thanks
- Sep 18 07:07:18 <hellyeah> buu: what?
- Sep 18 07:07:36 <baxx> GreenJello: I'm not using and libraries at the mo - I'm only doing something really basic for learning so it's nothing that has to be releasable or whatever
- Sep 18 07:08:40 <GreenJello> throttle is the simplest way to solve that
- Sep 18 07:08:53 <baxx> GreenJello: oh ok cool, didn't mean to be obtuse :)
- Sep 18 07:08:53 <GreenJello> you could write it yourself if you like
- Sep 18 07:09:12 <GreenJello> :-)
- Sep 18 07:09:30 <baxx> GreenJello: if it's simple then yeah, but this was just something that I thought might make sense and maybe commonly done, I guess you've answer 'yes, with throttle though' ha
- Sep 18 07:10:13 <smgs> brb. gtg.
- Sep 18 07:10:26 <baxx> I'm a bit confused about why I'm getting only a small box on this that refreshes : https://jsfiddle.net/9scf62kh/
- Sep 18 07:11:11 <baxx> You can move the ball with the arrow keys - but it can only move a bit
- Sep 18 07:12:00 <zumba_addict> good morning folks. I posted a question on so about inheritance issue. This is the code that was given to. It works. However, I don't know if it's a good solution or if there is a nicer way - http://jsfiddle.net/dqggvjrj/
- Sep 18 07:13:27 <_mouse_> zumba_addict what was the question this is solving?
- Sep 18 07:13:40 <zumba_addict> inheritance issue
- Sep 18 07:13:49 <zumba_addict> let me grab my post
- Sep 18 07:14:08 <zumba_addict> this is what I posted last night - http://stackoverflow.com/questions/32643167/advanced-javascript-inheritance-is-failing-parent-parent-child
- Sep 18 07:15:12 <GreenJello> yeah, that's pretty much how you do it
- Sep 18 07:15:20 <GreenJello> or use es6 classes if you can
- Sep 18 07:15:24 <yansanmo> my question would be, when do you need inheriting in javascript?
- Sep 18 07:15:32 <zumba_addict> got it
- Sep 18 07:15:50 <GreenJello> yansanmo, clearly for implementing people
- Sep 18 07:16:08 <acmello> can you use composition instead?
- Sep 18 07:16:11 <yansanmo> I would like to see a website with that modal
- Sep 18 07:16:19 <yansanmo> *with that model
- Sep 18 07:16:41 <zumba_addict> i was wondering why he had to prototype the method. Why did he not add the method at first?
- Sep 18 07:16:46 <GreenJello> acmello, there's no real code there, so you can't really say if it's good or bad or how you'd do "it" in other ways
- Sep 18 07:17:03 <GreenJello> because there's no "it"
- Sep 18 07:17:58 <zumba_addict> btw, what does this do? ClassA.call(this);
- Sep 18 07:17:58 <undrinkablesoup> GreenJello: offsetTop seems to increase even if the page has not been scrolled.
- Sep 18 07:18:13 <GreenJello> seems to increase?
- Sep 18 07:18:29 <acmello> GreenJello, I'm saying it's a better solution, just saying there're other different ways to deal situations where inheritance my be suitable :)
- Sep 18 07:18:48 <undrinkablesoup> I use the following formula to calculate the Y position of the object: rectObject.top + theElement.offsetTop
- Sep 18 07:18:49 <acmello> I'm not*
- Sep 18 07:19:06 <undrinkablesoup> offsetTop seems to increase for each object (trs).
- Sep 18 07:19:23 <GreenJello> oh right
- Sep 18 07:19:24 <undrinkablesoup> I also tried - instead of +.
- Sep 18 07:19:33 <GreenJello> you want relative to the top of the page?
- Sep 18 07:19:37 <undrinkablesoup> Yeah.
- Sep 18 07:19:43 <undrinkablesoup> (Of course?)
- Sep 18 07:19:47 <ljharb> zumba_addict: that's just calling a function with its receiver set to the current "this"
- Sep 18 07:20:10 <GreenJello> undrinkablesoup, do the clientRect and use document.body.scrollTop
- Sep 18 07:20:18 * undrinkablesoup tries that
- Sep 18 07:20:21 <zumba_addict> thanks ljharb. I put a debugger and ran over the code, the this grew
- Sep 18 07:20:36 <GreenJello> add them together and that should give you the absolute position of the element
- Sep 18 07:20:59 <zumba_addict> looks like that code is what implements the inheritance
- Sep 18 07:21:20 <undrinkablesoup> GreenJello: Same thing seems to happen with that. Sigh.
- Sep 18 07:21:26 <undrinkablesoup> As soon as I scroll, it becomes offset.
- Sep 18 07:21:36 <undrinkablesoup> Only works when it has not scrolled.
- Sep 18 07:22:14 <undrinkablesoup> This is really making my skin crawl...
- Sep 18 07:22:54 <undrinkablesoup> I tried with - as well. Wrong.
- Sep 18 07:23:11 <undrinkablesoup> rectObject.top + document.body.scrollTop
- Sep 18 07:23:14 <undrinkablesoup> rectObject.top - document.body.scrollTop
- Sep 18 07:23:20 <undrinkablesoup> Both work when it has not scrolled.
- Sep 18 07:23:29 <undrinkablesoup> But as soon as it scrolls, the wrong values start being calculated.
- Sep 18 07:24:45 <undrinkablesoup> GreenJello: Turns out that document.body.scrollTop never changes when I scroll.
- Sep 18 07:24:50 <undrinkablesoup> That's why it calculates wrongly...
- Sep 18 07:25:05 <undrinkablesoup> But why doesn't it? Isn't it scrollTop?
- Sep 18 07:25:08 <zumba_addict> so "this" inside a function will have the scope of that function unless we substitute this to another variable like self and use self instead
- Sep 18 07:25:19 <cjohnson> this and scope are totally separate concepts
- Sep 18 07:25:27 <cjohnson> usually we call "this" the context, just to avoid confusion
- Sep 18 07:25:43 <cjohnson> zumba_addict: read this article: http://perfectionkills.com/know-thy-reference/
- Sep 18 07:25:52 <cjohnson> explains exactly how "this" works
- Sep 18 07:25:58 <zumba_addict> k
- Sep 18 07:26:06 <zumba_addict> thanks
- Sep 18 07:26:25 <zumba_addict> i thought scope and context were the same
- Sep 18 07:26:51 <cjohnson> scope = the variables that you have access to
- Sep 18 07:26:56 <ljharb> actually usually we call "this" the "receiver" to avoid confusion
- Sep 18 07:27:02 <ljharb> the word "context" is what causes confusion.
- Sep 18 07:27:06 <cjohnson> aka the current function and all parent wrapping functions
- Sep 18 07:27:34 <cjohnson> I am only going based on what I actually see in the real world, and I've never once seen the word receiver used. many docs use context and scope
- Sep 18 07:27:44 <MinusFour> maybe lexical context but not execution context
- Sep 18 07:29:20 <zumba_addict> i updated the code and the value got overwritten. This is now a real world scenario. What is the ideal way to address this? http://jsfiddle.net/dqggvjrj/1/
- Sep 18 07:29:46 <zumba_addict> i'm referring to the age property I added in ClassC
- Sep 18 07:30:53 <zumba_addict> so am I right that ClassC shouldn't have the same property name? or should I put another property that doesn't exist from the parent?
- Sep 18 07:31:18 <cjohnson> code runs top to bottom zumba_addict
- Sep 18 07:31:30 <cjohnson> setting this.age =10; and then setting this.age = 12; means this.age will be 12
- Sep 18 07:31:38 <zumba_addict> no, it's 10
- Sep 18 07:31:38 <cjohnson> which is what you're doing in ClassC
- Sep 18 07:31:42 <undrinkablesoup> GreenJello: Isn't it window.scrollY?
- Sep 18 07:31:43 <cjohnson> well, no
- Sep 18 07:31:52 <undrinkablesoup> The question goes for everyone else too.
- Sep 18 07:31:56 <cjohnson> you are setting this.age = 10; and then you are immediately after that setting this.age = 12;
- Sep 18 07:31:59 <zumba_addict> that's what I am seeing on the output. It gets overwritten by classB
- Sep 18 07:32:04 <undrinkablesoup> Maybe document.body.scrollTop is legacy and discontinued or something?
- Sep 18 07:32:11 <GreenJello> undrinkablesoup, is the window scrolling or is it the table?
- Sep 18 07:32:21 <undrinkablesoup> GreenJello: The browser window is scrolling, obviously...
- Sep 18 07:32:25 <zumba_addict> i am instantiating classC first which calls classB
- Sep 18 07:32:31 <GreenJello> tables can scroll, it's not uncommon :-)
- Sep 18 07:32:32 <zumba_addict> classC is a child of classB
- Sep 18 07:32:36 <undrinkablesoup> They can?
- Sep 18 07:32:47 <GreenJello> height: 100px; overflow-y: scroll;
- Sep 18 07:32:51 <undrinkablesoup> Well, either way, you said document.body...
- Sep 18 07:32:55 <undrinkablesoup> Not theTableElement.
- Sep 18 07:33:09 <GreenJello> I assumed the viewport was scrolling, yeah
- Sep 18 07:33:14 <GreenJello> try it on another site
- Sep 18 07:33:21 <GreenJello> put document.body.scrollTop in the console
- Sep 18 07:34:16 <undrinkablesoup> Finally it works!
- Sep 18 07:34:28 <undrinkablesoup> "I assumed the viewport was scrolling"
- Sep 18 07:34:30 <voiter> is there a best practice for responsive tooltips? or would you suggest to use a plugin?
- Sep 18 07:34:35 <undrinkablesoup> The viewport = browser/page window?
- Sep 18 07:34:44 <undrinkablesoup> voiter: ?
- Sep 18 07:34:58 <GreenJello> yeah
- Sep 18 07:35:14 <GreenJello> scrollY is also fine, there's a lot of things you can do in many ways in dom
- Sep 18 07:35:40 <shoky> zumba_addict: inheriting by prototype doesn't automatically call the "parent" constructor function for you. that part you do yourself, manually, as you're doing in your fiddle. so line 20 runs before line 11
- Sep 18 07:38:20 <shoky> zumba_addict: er disregard, i'm too tired, wrong, should not have attempted now ;)
- Sep 18 07:38:31 <zumba_addict> :D
- Sep 18 07:38:40 <zumba_addict> let me remove the debugger and see if it changes
- Sep 18 07:38:59 <ELCALOR> does anyone have an answer to this question? http://stackoverflow.com/questions/27712505/get-dom-of-adsense-ad-with-phantomjs
- Sep 18 07:38:59 <MinusFour> you should move the parent constructor call to the top of the constructor of the child
- Sep 18 07:39:17 <shoky> but yea ^ that'd fix your problem
- Sep 18 07:39:45 <zumba_addict> nope, it's still 10. Yup, so this.age on line 20 should be swapped with ClassB.call(this); Right?
- Sep 18 07:40:00 <MinusFour> yes
- Sep 18 07:40:16 <baxx> I'm not sure why the movement is being odd on this https://jsfiddle.net/9scf62kh/11/
- Sep 18 07:40:25 <zumba_addict> that means, I really have to be careful what I'm inheriting and what property names I use
- Sep 18 07:41:00 <zumba_addict> so am I right that when calling the constructor when creating a child, it should always be the first call?
- Sep 18 07:41:05 <GreenJello> which is part of why inheritance can be dangerous and confusing
- Sep 18 07:41:15 <zumba_addict> i'm not sure if my terminologies are right :D
- Sep 18 07:41:31 <GreenJello> yeah
- Sep 18 07:41:44 <zumba_addict> k
- Sep 18 07:41:45 <zumba_addict> :D
- Sep 18 07:41:53 <zumba_addict> here is what I've noticed
- Sep 18 07:43:03 <zumba_addict> here is what I've noticed after I've been running it manually. It constructor is similar to what I was doing in Pascal days where the params sent are updated by the function and are also seen by the caller that sent it. However, I remember add a special symbol before the parameter name
- Sep 18 07:43:30 <zumba_addict> It constructor/The constructor^
- Sep 18 07:43:47 <ljharb> i don't think Pascal is going to be too relevant
- Sep 18 07:44:11 <zumba_addict> i'm referring to the inheritance like of ClassC.call(this)
- Sep 18 07:44:31 <zumba_addict> the this parameter is similar to the pascal parameter when &somevar is used
- Sep 18 07:45:28 <MinusFour> it really is just a function appending values to an object
- Sep 18 07:45:37 <zumba_addict> in passcal function sum(somevar) - the somevar will be the old value even if it gets updated on the function. However, if declared as &somevar, it will be sent back to the caller
- Sep 18 07:45:53 <zumba_addict> yeah MinusFour, that's what I meant. it's like extend?
- Sep 18 07:46:12 <zumba_addict> i think extend does similar thing too. Right?
- Sep 18 07:46:27 <zumba_addict> i don't know if extend is a javascript thing or an underscore thing
- Sep 18 07:46:29 <MinusFour> i don't think so
- Sep 18 07:47:01 <MinusFour> for example A extends B... B shouldn't override properties of A
- Sep 18 07:47:12 <zumba_addict> they will be combined
- Sep 18 07:47:19 <MinusFour> no, A will override B
- Sep 18 07:47:19 <zumba_addict> right?
- Sep 18 07:47:35 <zumba_addict> really?
- Sep 18 07:48:06 <zumba_addict> maybe i'm getting confused with BackboneJS's extend with underscore's extend
- Sep 18 07:48:54 <MinusFour> well, i would think it's a matter of when you are extending A over B
- Sep 18 07:49:21 <MinusFour> although, i can't remember if underscore extends or jquery extends do those checks
- Sep 18 07:50:06 <ljharb> !classes @ zumba_addict
- Sep 18 07:50:07 <ecmabot> zumba_addict: Class hierarchies? Don't do that! http://raganwald.com/2014/03/31/class-hierarchies-dont-do-that.html (See also, !inheritance)
- Sep 18 07:50:10 <ljharb> !inheritance @ zumba_addict
- Sep 18 07:50:11 <ecmabot> zumba_addict: JavaScript does not really have “inheritance” like classical languages. What it has is more properly called “property delegation” or “behavior delegation” http://davidwalsh.name/javascript-objects - ie `foo.bar(baz)` when `!foo.hasOwnProperty('bar')` is essentially doing `Object.getPrototypeOf(foo).bar.call(foo, baz)`
- Sep 18 07:50:12 <ljharb> read those.
- Sep 18 07:50:34 <zumba_addict> thanks for the links, I'll read them once i get to my desk. I'm entering the tunnel soon
- Sep 18 07:57:28 <baxx> still a bit comfused about what's going on with the movement on this https://jsfiddle.net/z09anyn2/1/ . I had the moveX moveY set to just +20 or -20, and then I've tried adding an if to make sure that they're at 0 when a different direction is pressed, but Its not really working and I'm sure it's something pretty basic.
- Sep 18 07:57:29 <baxx>
- Sep 18 08:00:00 <Sal> is there a way to check what element has been clicked?
- Sep 18 08:00:19 <Sal> or do i have to compare pageX with every element on page?
- Sep 18 08:02:11 <ljharb> Sal: it's the "target" property of the event object.
- Sep 18 08:02:21 <ljharb> !mdn event object @ Sal
- Sep 18 08:02:22 <ecmabot> Sal: Event - Web API Interfaces | MDN <https://developer.mozilla.org/en-US/docs/Web/API/Event>
- Sep 18 08:02:50 <Sal> yes, but i can't use target, bevause the element i'm trying to click is a 1px line
- Sep 18 08:03:28 <Sal> and to make it simple to catch, i added a 5px per side clickable area
- Sep 18 08:03:51 <Sal> so, if i use target, it will only work if i click on the line
- Sep 18 08:04:07 <Sal> don't know if i was clear
- Sep 18 08:04:48 <Sal> its a 1px line, but i want to add a 5px tollerance on both sides
- Sep 18 08:04:59 * zumba_addict is back :) I'll check out those links now ljharb
- Sep 18 08:05:45 <ljharb> Sal: if you give the line 5px of margin on both sides, then clicking on the margin will be a click on the line.
- Sep 18 08:05:57 <baxx> i have created a video of the behaviour http://sendvid.com/9iivpzny as demoed in this fiddle https://jsfiddle.net/z09anyn2/2/
- Sep 18 08:08:01 <django_> someone help me with this: http://pastebin.com/Me11fFBr
- Sep 18 08:09:02 <django_> that is the output when the page is loaded
- Sep 18 08:09:32 <fschuindt> Folks, I am trying to get all strings between two brackets in a text using regex. https://jsfiddle.net/11ueputd/ But I am geting no success. Anybody can help me?
- Sep 18 08:10:39 <CamC> Im trying to show a problem but my code doesnt seem to behave on jsfiddle https://jsfiddle.net/xn8w6nxk/1/ its a simple point click
- Sep 18 08:10:59 <MinusFour> django_, so the problem is that $scope.testme is undefined right?
- Sep 18 08:11:09 <smgs> GreenJello: thanks anwyas got it.
- Sep 18 08:11:17 <django_> MinusFour: yes
- Sep 18 08:11:28 <MinusFour> well, that's because $http.jsonp is most likely async
- Sep 18 08:12:00 <shoky> baxx: the jsfiddle behaviour is because scrollbars appear, cause your body is larger than the window, cause your css injection isn't working properly
- Sep 18 08:12:21 <MinusFour> in other words, by the time console.log prints $scope.testme, the $http.jsonp call hasn't call your function that populates that property
- Sep 18 08:12:30 <shoky> baxx: or rather the css you're injecting is not proper css
- Sep 18 08:12:53 <undrinkablesoup> Bleh. It seems as if I forget everything unless I constantly use it.
- Sep 18 08:13:09 <baxx> shoky: ha shit, yeah I just zoomed out on the (local) page and it works as expected >.< I was really confused there. I'm not following about the CSS ?
- Sep 18 08:13:13 <baxx> thanks though
- Sep 18 08:13:19 <undrinkablesoup> Right now, I'm trying to remember the syntax to check if a given integer value is inside an array that looks like var someArray = [ 1, 2, 3, 4, 5 ];
- Sep 18 08:13:28 <shoky> baxx: you have commas , instead of semicolons ;
- Sep 18 08:13:46 <undrinkablesoup> And also, I'm trying to add to that array. I guess for the second problem, I do someArray.push(123);?
- Sep 18 08:13:48 <shoky> baxx: width: 100%,
- Sep 18 08:14:00 <shoky> baxx: height: 100%, padding: 0,
- Sep 18 08:14:00 <MinusFour> undrinkablesoup, so basically indexOf?
- Sep 18 08:14:00 <ljharb> undrinkablesoup: yes, but it's best not to mutate things.
- Sep 18 08:14:06 <ankr> CamC try something like https://jsfiddle.net/11ueputd/1/
- Sep 18 08:14:07 <undrinkablesoup> Mutate them?
- Sep 18 08:14:11 <baxx> shoky: ah of course, school boy all round then, thanks :)
- Sep 18 08:14:17 <undrinkablesoup> MinusFour: Not sure.
- Sep 18 08:14:18 <ljharb> undrinkablesoup: change
- Sep 18 08:14:28 <undrinkablesoup> ljharb: I don't understand what you mean.
- Sep 18 08:14:31 <ljharb> undrinkablesoup: ie, don't add something to someArray. make a brand new array using concat.
- Sep 18 08:14:39 <ljharb> undrinkablesoup: `var newArray = someArray.concat(123)`
- Sep 18 08:14:52 <undrinkablesoup> I fail to see the difference...?
- Sep 18 08:14:53 <baxx> shoky: yeh it works now, thought it would be something trivial, cheers
- Sep 18 08:15:00 <undrinkablesoup> Or rather...
- Sep 18 08:15:01 <shoky> np
- Sep 18 08:15:08 <django_> MinusFour: that means one is running in thebackground right?
- Sep 18 08:15:09 <undrinkablesoup> Why make a new array?
- Sep 18 08:15:20 <ljharb> undrinkablesoup: the difference is that then "someArray" never changes, so it's easier to reason about what it contains, and it's easier for the engine to optimize it.
- Sep 18 08:15:32 <ljharb> undrinkablesoup: mutation in general makes code harder to reason about.
- Sep 18 08:15:44 <CamC> ankr:how does that help?
- Sep 18 08:16:11 <MinusFour> var someArray = [1, 2, 3, 4, 5]; someArray.indexOf(1) > -1; /* true */ someArray.indexOf(0) > - 1; /* false */
- Sep 18 08:16:44 <ljharb> oh right, i skipped the first question
- Sep 18 08:16:50 <ljharb> indexOf, yes
- Sep 18 08:16:58 <MinusFour> or use maps
- Sep 18 08:17:16 <MinusFour> rather, i think maps would be faster for this
- Sep 18 08:17:22 <MinusFour> instead of array
- Sep 18 08:18:28 <MinusFour> django_, yes, the $http.jsonp "runs in the background", so it hasn't finished just yet by the time you call console.log($scope.testme)
- Sep 18 08:18:56 <django_> MinusFour: how do i fix this?
- Sep 18 08:19:08 <django_> my whole program is based off the http call
- Sep 18 08:19:20 <MinusFour> you either continue down the callback path
- Sep 18 08:19:24 <MinusFour> or you start using promises
- Sep 18 08:20:13 <MinusFour> what framework are you using?
- Sep 18 08:21:20 <undrinkablesoup> ljharb: But the whole point is that I'm adding elements to that array.
- Sep 18 08:21:27 <ljharb> undrinkablesoup: right, why?
- Sep 18 08:21:40 <ljharb> undrinkablesoup: i'm suggesting that your program would be designed better, and would work better, if you didn't do that :-)
- Sep 18 08:21:40 <undrinkablesoup> ljharb: Because it's the data structure that contains the items...
- Sep 18 08:21:57 <django_> MinusFour: angular
- Sep 18 08:22:06 <undrinkablesoup> If I make a local copy and add to that, it... won't change the real data structure.
- Sep 18 08:22:19 <ljharb> undrinkablesoup: so instead of having something point to the same array, and keep making changes to it - like it's a big global variable - use functions, that accept an array, and return a new array
- Sep 18 08:22:24 <RangerMauve> Anyone have ideas about looking up variable lookups in snippits of javascript? For example. Given something like "foo.bar = baz(fizz)", how should I go about detecting that `foo`, `baz`, and `fizz` were referenced? The goal is to make my expressions in a templating language fancier.
- Sep 18 08:22:31 <ljharb> undrinkablesoup: i'm saying you shouldn't have one "real data structure"
- Sep 18 08:22:40 <undrinkablesoup> Well, it *is* a global variable.
- Sep 18 08:22:54 <undrinkablesoup> I know a lot of programmers hate global variables, but they are beautiful IMO.
- Sep 18 08:22:55 <RangerMauve> Currently I'm just adding special syntax to have users add a `@` before variable lookups in the scope, but I've been advised to make it fancier
- Sep 18 08:23:22 <ljharb> undrinkablesoup: lol if you have a global variable you've already thrown readability, maintainability, and the last 10 years of best practices out the window, so ¯\_(ツ)_/¯
- Sep 18 08:23:43 <smgs> are there any pure javascript codes ? i want to learn so that i could code for my android device. thanks. i am using DroidScript ( google play Store ) thanks
- Sep 18 08:24:02 <MinusFour> django_, $http.jsonp returns a promise which you could use
- Sep 18 08:24:05 <undrinkablesoup> ljharb: What can I say? I don't get why you hate global variables.
- Sep 18 08:24:15 <undrinkablesoup> I hate shuffling data around and making everything so damn abstract.
- Sep 18 08:24:18 <ljharb> undrinkablesoup: because i'm a programmer with more than zero experience?
- Sep 18 08:24:18 <GreenJello> !eloquent @ smgs
- Sep 18 08:24:19 <ecmabot> smgs: Eloquent JavaScript is a comprehensive introductory Web-based book with examples and a built-in interpreter. http://eloquentjavascript.net/
- Sep 18 08:24:21 <GreenJello> read that
- Sep 18 08:24:26 <django_> MinusFour: where can i read about promises
- Sep 18 08:24:35 <smgs> GreenJello: yup i did read that :).
- Sep 18 08:24:38 <ljharb> !globals @ undrinkablesoup
- Sep 18 08:24:39 <ecmabot> undrinkablesoup: Globals: not even once! It's best to avoid global variables. As variables lose scope, they will be eligible for garbage collection. If they are scoped globally, then they will not be eligible for collection until the global namespace loses scope (e.g. when the page unloads). See also !IIFE
- Sep 18 08:24:50 <GreenJello> smgs, and you understand it?
- Sep 18 08:24:51 <ljharb> that's just a performance reason they're awful. but there's many more.
- Sep 18 08:24:53 <smgs> GreenJello: thanks. testing the first sample code there. thanks
- Sep 18 08:24:55 <MinusFour> django_, to use them?
- Sep 18 08:25:05 <undrinkablesoup> Also, it's annoying that I can do "php.net/whatever" to get to official documentation on PHP stuff, but I have to open my "MozDev" link and manually input a search term to get to not-really-official-at-all documentation on JS.
- Sep 18 08:25:20 <django_> MinusFour: idk what a promose is
- Sep 18 08:25:21 <django_> promise*
- Sep 18 08:25:27 <MinusFour> here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
- Sep 18 08:25:45 <undrinkablesoup> Well, of course I'm not making random variables global for no reason. I only use them for variables that... are... global.
- Sep 18 08:25:50 <RangerMauve> undrinkablesoup: You could read the Ecmasrcript standards. But they're kinda shit for beginners
- Sep 18 08:26:03 <ljharb> undrinkablesoup: http://mdn.io/whatever
- Sep 18 08:26:05 <undrinkablesoup> Like, "var masterContainerOfItems = [];" in the beginning of the script, and then all functions can refer to that one and add items or remove them.
- Sep 18 08:26:17 <ljharb> undrinkablesoup: and no variables should be global. that's a horrible horrible design and you should feel bad for doing it.
- Sep 18 08:26:31 <undrinkablesoup> Global variable shaming?
- Sep 18 08:26:35 <ljharb> absolutely
- Sep 18 08:26:44 <GreenJello> undrinkablesoup, I do l{tab}mdn promise where `l` is the custom search trigger for feeling lucky search
- Sep 18 08:26:51 <ljharb> there should be a tumblr with programmers holding signs like "i made a global variable"
- Sep 18 08:27:13 <ljharb> "i used the with statement"
- Sep 18 08:27:14 <smgs> GreenJello: awesome! the first code ran. Epic!! so very thankful to you. :)
- Sep 18 08:27:23 <ljharb> "i didn't write tests"
- Sep 18 08:27:35 <MinusFour> undrinkablesoup, does your variable literally needs to be reached from everywhere?
- Sep 18 08:27:44 <cjohnson> the answer is no :P
- Sep 18 08:28:13 <RangerMauve> "I modified a built in prototype"
- Sep 18 08:28:19 <ljharb> ^
- Sep 18 08:29:57 <RangerMauve> Anyone know of an uber simple module for parsing JS expressions into something that can be toyed with?
- Sep 18 08:31:10 <cjohnson> RangerMauve: meaning what
- Sep 18 08:31:50 <RangerMauve> cjohnson: Basically, I want something that'd parse a JS expression and tell me what different parts it contains. Like variable lookups and function calls
- Sep 18 08:33:27 <RangerMauve> My specific use case is for parsing expressions in a template library I'm working on
- Sep 18 08:33:39 <RangerMauve> I really just care about variable lookups in the template scope
- Sep 18 08:33:40 <MinusFour> so a JS parser?
- Sep 18 08:34:01 <RangerMauve> A basic one. Like, the fewer features it has the better
- Sep 18 08:34:17 <MinusFour> maybe uglifyjs
- Sep 18 08:34:20 <zetlen> i made a request test library!
- Sep 18 08:34:20 <MinusFour> or esprima
- Sep 18 08:34:24 <zetlen> https://github.com/zetlen/jort
- Sep 18 08:34:29 <zetlen> feedback welcome
- Sep 18 08:34:37 <zetlen> it's just a little tool for single-use mocks of http servers
- Sep 18 08:34:39 <zomg> Esprima's good but it's pretty complex
- Sep 18 08:35:36 <RangerMauve> Yeah, that's the thing. It's like 5.5k SLOC or something crazy like that
- Sep 18 08:36:26 <RangerMauve> I was thinking of maybe not dealing with actual parsing and figuring out a clever regex or something like that
- Sep 18 08:36:44 <ljharb> RangerMauve: JS is a big language. you can't get a correct and small JS parser.
- Sep 18 08:36:48 <ljharb> RangerMauve: and do NOT use regex.
- Sep 18 08:36:50 <ljharb> !regex html @ RangerMauve
- Sep 18 08:36:50 <zomg> JS is pretty flexible so you can structure things in a ton of different ways
- Sep 18 08:36:50 <ecmabot> RangerMauve: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454
- Sep 18 08:36:55 <Lethalman> NO regex
- Sep 18 08:36:57 <ljharb> regular expressions are for regular languages. JS isn't one.
- Sep 18 08:37:04 <zomg> so yeah like ljharb says it's not gonna be parseable like that
- Sep 18 08:37:08 <ljharb> RangerMauve: just use a correct parser, no matter how big it is.
- Sep 18 08:37:18 <zomg> RangerMauve: why are you so concerned about the size anyway?
- Sep 18 08:37:26 <RangerMauve> Because I want this to be used client-side
- Sep 18 08:37:56 <zomg> You should probably just define your own DSL
- Sep 18 08:38:05 <zomg> Something that's simpler to parse
- Sep 18 08:38:07 <ljharb> i really don't think you do want that.
- Sep 18 08:38:15 <ljharb> but if you do, then ship an entire JS parser to the client.
- Sep 18 08:38:59 <RangerMauve> The current DLS I have is a layer over top of JS where using `@` in front of an identifier constitutes a lookup of a variable in the template scope
- Sep 18 08:39:07 <RangerMauve> *DSL
- Sep 18 08:40:10 <RangerMauve> And that works fine since I let the browser deal with syntax errors after I process the expressions to use my `@` thing. But a person I had reviewing my project suggested I try to detect variable lookups automagically
- Sep 18 08:41:14 <RangerMauve> I know for sure that other projects have done that without having to resort to esprima or other full featured parsers,
- Sep 18 08:42:04 <zomg> I don't think any project is attempting to shove JS into a template language
- Sep 18 08:42:12 <zomg> I mean I suppose they could just run it through eval if they do
- Sep 18 08:42:20 <RangerMauve> VueJS and Ractive for one
- Sep 18 08:42:59 <zomg> if they allow full js syntax then they probably eval it
- Sep 18 08:43:07 <ljharb> RangerMauve: "automagically" is another word for "implicit", which is strictly worse imo
- Sep 18 08:43:17 <ljharb> things should be explicit.
- Sep 18 08:43:27 <RangerMauve> Currently I'm using the Function constructor which is essentially eval without the fancy scope features
- Sep 18 08:43:49 <RangerMauve> ljharb: Yeah, that's why I started with my syntax.
- Sep 18 08:44:07 <ljharb> eesh, Function is basically the same as eval
- Sep 18 08:44:33 <zomg> Where does vue.js allow full JS syntax btw?
- Sep 18 08:47:43 <zomg> Ractive uses Function as well it seems
- Sep 18 08:48:03 <zomg> Angular has some sort of expressions which are similar to JS expressions, not sure what they use, but they definitely don't allow full syntax either
- Sep 18 08:50:45 <RangerMauve> zomg: You can use JS expressions in directives in Vue
- Sep 18 08:52:07 <zomg> ok, seems that's also a simplified syntax
- Sep 18 08:55:15 <zap0> if i have var a; in global scope what is it assigned ?
- Sep 18 08:55:29 <MinusFour> undefined
- Sep 18 08:57:30 <zap0> ok. thank you.
- Sep 18 08:59:55 <ljharb> zap0: same thing as in any scope.
- Sep 18 09:01:09 <zap0> ok. i'm a C programmers, trying to comprehend the differences between undefined and null. and also trying to find out if var a; gets assigned a null by default.
- Sep 18 09:01:12 <zap0> clearly not.
- Sep 18 09:01:25 <MinusFour> they are just different
- Sep 18 09:01:30 <zap0> programmer/
- Sep 18 09:01:33 <ljharb> "undefined" is the default value of a variable, and the value returned from a nonexistent object property as well.
- Sep 18 09:01:45 <ljharb> "null" means "no object" and is usually only there if a programmer explicitly put it there.
- Sep 18 09:01:54 <AciD`> exactly
- Sep 18 09:02:00 <persina> Can someone help me here? I'm trying to make serializeArray() return an array with the boxes that are checked. https://bpaste.net/show/7b565173bd21
- Sep 18 09:02:05 <zap0> ok.
- Sep 18 09:02:29 <AciD`> var a; 'gets assigned' to undefined
- Sep 18 09:02:58 <AciD`> then you as a dev must do something like a = null; for it to be null
- Sep 18 09:03:14 <zap0> ok, i got it now! thanks
- Sep 18 09:03:27 <ljharb> persina: what's "generate_map"
- Sep 18 09:03:32 <AciD`> it's pretty handy!
- Sep 18 09:03:40 <ljharb> persina: if it's the <form> tag containing the checkboxes, that should just work.
- Sep 18 09:03:41 <persina> ljharb: the var containing the form
- Sep 18 09:03:50 <ljharb> (assuming it's a jquery object)
- Sep 18 09:04:13 <zap0> DOMContentLoaded event can have multiple listeners.. but how do you determine which order they get run in ?
- Sep 18 09:04:30 <persina> ljharb: It is a jquery object. I'm getting three seperate objects back from serializeArray()
- Sep 18 09:04:55 <persina> ljharb: I want one object containing all three values
- Sep 18 09:05:09 <bluezone> Are you allowed to have one array that contains multiple types in javascript? i.e. [2,3,'foo','lol']
- Sep 18 09:05:21 <ljharb> persina: that makes no sense
- Sep 18 09:05:37 <ljharb> persina: you get an array of objects, each one has a "value" and "name" (or label, i forget) attribute
- Sep 18 09:05:38 <zap0> bluezone, sounds like you want an object.
- Sep 18 09:05:49 <ljharb> persina: you could map that array to an array of values, but an object doesn't make sense.
- Sep 18 09:05:58 <ljharb> since there can be multiple checkboxes with the same name
- Sep 18 09:06:10 <ljharb> bluezone: yes, of course. JS is untyped in that way.
- Sep 18 09:06:10 <bluezone> zap0: just want to know if it's possible so I can avoid iterating over the entire array in my test
- Sep 18 09:06:24 <bluezone> ok
- Sep 18 09:06:26 <zap0> bluezone tias!
- Sep 18 09:06:28 <ljharb> bluezone: that doesn't mean it's a good thing to have tho, you should try to keep arrays unityped
- Sep 18 09:06:42 <MinusFour> persina, jquery documentation says it's for forms and form controls
- Sep 18 09:06:47 <Impaloo> there are typed arrays in ES6
- Sep 18 09:06:58 <persina> MinusFour: this is inside a form
- Sep 18 09:07:01 <MinusFour> ah
- Sep 18 09:07:07 <ljharb> Impaloo: true
- Sep 18 09:07:25 <MinusFour> is generate_map a jquery with a form collection?
- Sep 18 09:07:27 <ljharb> persina: an object (a key-value map) would be incorrect for checkboxes.
- Sep 18 09:08:01 <persina> MinusFour: generate_map is the form variable
- Sep 18 09:08:31 <persina> ljharb: What do you mean? that is how it is being interpreted by serializeArray()
- Sep 18 09:08:40 <ljharb> persina: serializeArray returns an array.
- Sep 18 09:08:48 <ljharb> persina: that array contains N objects, one per checkbox.
- Sep 18 09:08:59 <ljharb> persina: each of those objects has the name of the checkbox, and its value, as properties.
- Sep 18 09:09:21 <ljharb> that's the only sensible data structure to use to represent HTML checkboxes that's not a query string.
- Sep 18 09:09:41 <persina> ljharb: yes, I understand. But if there is a group of checkboxes all with the same name I only want one variable to send with the post.
- Sep 18 09:09:55 <ljharb> persina: then you don't want checkboxes, you want radio buttons.
- Sep 18 09:10:09 <ljharb> checkboxes are for sending multiple values with the same name. radio buttons are for selecting only one out of a group of values with the same name.
- Sep 18 09:10:20 <persina> ljharb: radio buttons only allow one option to be checked, I want to allow any number.
- Sep 18 09:10:33 <ljharb> um, then why would you only send one option with the post?
- Sep 18 09:10:40 <ljharb> if i check 10 options you should send 10 things
- Sep 18 09:10:50 <ljharb> (which is what the browser will do by default)
- Sep 18 09:11:28 <persina> ljharb: I want to send one object containing all the values that are checked. An array of checked values.
- Sep 18 09:11:47 <ljharb> persina: that's how the browser sends it by default.
- Sep 18 09:12:02 <ljharb> persina: whatever you're using on the serverside, if it's not totally broken, will automatically interpret it as an array of the values.
- Sep 18 09:12:16 <ljharb> so you literally don't have to do a thing to make this work. zero JS.
- Sep 18 09:12:46 <ljharb> (also, even though arrays are objects in JS, it's super confusing to call arrays objects, because they're not objects, conceptually)
- Sep 18 09:13:17 <zap0> if there a string.indexOf that is case insensitive?
- Sep 18 09:13:27 <persina> ljharb: For some reason it's veiwing them as separate values and overwritting, and i'm only recieving the last checked checkbox.
- Sep 18 09:13:34 <Impaloo> >> Object.create(Array.prototype)
- Sep 18 09:13:34 <ecmabot> Impaloo: (object) {}
- Sep 18 09:13:37 <ljharb> zap0: no, use regex for that.
- Sep 18 09:13:43 <ljharb> persina: ah! add "[]" on the end of the name.
- Sep 18 09:13:45 <tcsc> or lowercase the string first.
- Sep 18 09:13:53 <ljharb> persina: ie, instead of `name="foo"`, do `name="foo[]"`
- Sep 18 09:14:04 <persina> ljharb: I have that already
- Sep 18 09:14:04 <ljharb> persina: and it will Just Work. (i assume you're using php, or ruby on rails)
- Sep 18 09:14:11 <ljharb> ah. what server tech are you using?
- Sep 18 09:14:17 <persina> ljharb: I'm using django
- Sep 18 09:14:30 <ljharb> ok then you should figure out how to fix django, because doing that is utterly broken.
- Sep 18 09:14:37 <MinusFour> lool
- Sep 18 09:14:46 <ljharb> with multiple values that end in "[]", everything should make an array
- Sep 18 09:14:54 <leptone> how do i round to the nearest tenth?
- Sep 18 09:14:57 <persina> ljharb: that's what I thought too...
- Sep 18 09:15:13 <ljharb> with multiple values that don't end in "[]", php and rails will keep the last thing, and everything else usually makes an array.
- Sep 18 09:15:24 <ljharb> persina: so in all honesty i'd ask the django people how to fix it
- Sep 18 09:15:36 <MinusFour> i didn't know django do that
- Sep 18 09:15:37 <persina> ljharb: k, off to #django
- Sep 18 09:15:39 <ljharb> *especially* if you already have "[]" on the end of your name
- Sep 18 09:15:42 <ljharb> good luck
- Sep 18 09:15:42 <ljharb> !
- Sep 18 09:15:57 <ljharb> persina: you can work around it in JS but you definitely shouldn't have to :-)
- Sep 18 09:16:18 <persina> ljharb: Yea, i know I can but thats messy.
- Sep 18 09:16:23 <ljharb> very
- Sep 18 09:17:31 <zap0> if i have var a = "a string"; and i'm finished with a.. so it can get garbage collected/recycled.. what do i do with a ?
- Sep 18 09:17:54 <MinusFour> delete window.a;
- Sep 18 09:17:56 <cjohnson> leptone: multiply by 10, round, divide by 10
- Sep 18 09:18:36 <leptone> so cjohnson this: Math.round((10.111*10)/10) should output 10.1?
- Sep 18 09:18:42 <ljharb> zap0: nothing
- Sep 18 09:18:42 <leptone> cuz I'm getting 10
- Sep 18 09:18:51 <ljharb> zap0: never use any globals tho, because globals never get garbage collected
- Sep 18 09:18:55 <_mouse_> MinusFour zap0 delete is an expensive function. just let the js internal garbage cpollection handle it
- Sep 18 09:19:06 <ljharb> zap0: but JS is a memory-managed language. do not ever ever ever worry about memory.
- Sep 18 09:19:45 <ljharb> zap0: just make variables when you need to and stop using them when you're done.
- Sep 18 09:20:36 <guessx> leptone:((10.111*10)/10).toFixed(1)
- Sep 18 09:20:57 <zap0> MinusFour, thanks.
- Sep 18 09:21:41 <cjohnson> leptone: nope you have your operations mixed up
- Sep 18 09:21:55 <cjohnson> you're rounding at the end, but I said to round second, THEN divide by 10
- Sep 18 09:22:08 <leptone> got it thx
- Sep 18 09:22:19 <cjohnson> >> Math.round(10.111*10)/10
- Sep 18 09:22:20 <ecmabot> cjohnson: (number) 10.1
- Sep 18 09:22:27 <cjohnson> toFixed won't round anything
- Sep 18 09:23:41 <cjohnson> Oh, I'm wrong
- Sep 18 09:24:09 <cjohnson> guess it does round
- Sep 18 09:30:49 <tcsc> ugh. my work is 3 weeks late on payroll. i feel like i should just go home at this point.
- Sep 18 09:34:20 <Torkable> yea
- Sep 18 09:34:22 <Torkable> you should
- Sep 18 09:34:42 <Torkable> and fix resume lol
- Sep 18 09:36:11 <cjohnson> uh yes
- Sep 18 09:36:26 <cjohnson> late with a paycheck definitely points to solvency issues
- Sep 18 09:36:40 <cjohnson> or insane management
- Sep 18 09:36:43 <cjohnson> either way be afraid
- Sep 18 09:36:44 <cjohnson> lol
- Sep 18 09:37:01 <graphettion> I'm struggling with this. Note: I don't want an answer. I just want to understand what to do - https://jsfiddle.net/fpmcs60x/
- Sep 18 09:39:47 <tcsc> yeah. resume is already fixed and i've already been applying for jobs, since I'm not really happy with the direction we've been taking... but i should probably get more serious about it.
- Sep 18 09:40:50 <guessx> graphettion that shouldnt work
- Sep 18 09:42:18 <graphettion> guessx: Right, my code doesn't work. I'm not sure what to do to achieve the repeated string.
- Sep 18 09:44:35 <MinusFour> well, you'll need to do your function recursive
- Sep 18 09:45:20 <Torkable> hmm?
- Sep 18 09:45:21 <Torkable> try fill
- Sep 18 09:45:23 <Torkable> lets see
- Sep 18 09:45:37 <Torkable> >> Array(5).fill('n')
- Sep 18 09:45:37 <ecmabot> Torkable: TypeError: Array(5).fill is not a function
- Sep 18 09:45:49 <Torkable> b> Array(5).fill('n')
- Sep 18 09:45:51 <babelbot> Torkable: (okay) [ 'n', 'n', 'n', 'n', 'n' ]
- Sep 18 09:45:54 <Torkable> ok
- Sep 18 09:46:17 <Torkable> so just put the number you want in the array
- Sep 18 09:46:21 <Torkable> and fill with the string
- Sep 18 09:46:28 <Torkable> and join('')
- Sep 18 09:46:35 <Torkable> b> Array(5).fill('n').join('')
- Sep 18 09:46:38 <babelbot> Torkable: (okay) nnnnn
- Sep 18 09:46:42 <Torkable> wewt
- Sep 18 09:46:43 <Torkable> done
- Sep 18 09:48:04 <graphettion> lol
- Sep 18 09:48:12 <Torkable> ?
- Sep 18 09:48:15 <graphettion> I never even heard of the fill function.
- Sep 18 09:48:20 <Torkable> now you have lol
- Sep 18 09:48:20 <graphettion> Sweet.
- Sep 18 09:48:23 <graphettion> ty
- Sep 18 09:49:00 <cjohnson> !mdn Array#fill
- Sep 18 09:49:01 <ecmabot> cjohnson: Array.prototype.fill() - JavaScript | MDN <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill>
- Sep 18 09:49:06 <cjohnson> !mdn String#repeat
- Sep 18 09:49:07 <ecmabot> cjohnson: String.prototype.repeat() - JavaScript | MDN <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat>
- Sep 18 09:49:09 <Torkable> its es6
- Sep 18 09:49:15 <Torkable> but I think its in the shim
- Sep 18 09:49:17 <Torkable> which makes it easy to use
- Sep 18 09:49:36 <Torkable> yea it is
- Sep 18 09:49:38 <ljharb> both are.
- Sep 18 09:49:42 <cjohnson> String#repeat too
- Sep 18 09:49:47 <ljharb> !es6 shim @ graphettion
- Sep 18 09:49:47 <ecmabot> graphettion: To get every backwards-compatible feature of ES6 in every browser and node, use https://www.npmjs.com/package/es6-shim ! It's heavily tested, comes with Promises, and using the !es5-shim as well is strongly encouraged.
- Sep 18 09:49:52 <Torkable> oh damn didin't know about repeat lol
- Sep 18 09:49:57 <Torkable> even better lol
- Sep 18 09:50:17 <graphettion> How do you do repeat?
- Sep 18 09:50:32 <Torkable> b> "foobar".repeat(3)
- Sep 18 09:50:35 <babelbot> Torkable: (okay) foobarfoobarfoobar
- Sep 18 09:50:38 <Torkable> lol
- Sep 18 09:50:44 <Torkable> there ya go
- Sep 18 09:50:45 <graphettion> lol
- Sep 18 09:51:33 <graphettion> Thanks. I know these are n00b questions. I just need more practice with strings. Returning arrays like .map() .filter()
- Sep 18 09:51:38 <graphettion> I'm weak at these.
- Sep 18 09:51:42 <graphettion> Thanks all!
- Sep 18 09:51:47 <Torkable> np
- Sep 18 09:53:53 * zumba_addict is still reading all the links about inheritance :p it's confusing
- Sep 18 09:55:28 <zumba_addict> anyways, let's say classA is parent of classB and classB is parent of classC. Does it mean that when a property changes in classA, classC will automatically have the new value? or do we have to execute a code to grab it?
- Sep 18 09:55:50 <cjohnson> JS doesn't have classes, so without having specific code it's hard to know what you mean by that
- Sep 18 09:56:00 <skullcrasher> is it somehow possible to "echo" a file from an ajax request?
- Sep 18 09:56:07 <zumba_addict> repasting the fiddle, one sec
- Sep 18 09:56:15 <zumba_addict> http://jsfiddle.net/dqggvjrj/2/
- Sep 18 09:56:33 <cjohnson> zumba_addict: if foo.prototype = bar, then whenever we look up a property on foo, if it doesn't exist, it will search bar
- Sep 18 09:57:01 <cjohnson> so foo = {a: 'a'}; bar = {b: 'b'}; when we look at foo.a, it searches foo for a first, and finds it, so it stops there
- Sep 18 09:57:03 <zumba_addict> it will search bar?
- Sep 18 09:57:07 <cjohnson> but foo.b, it wouldn't find it, and search bar
- Sep 18 09:57:09 <cjohnson> bar.b
- Sep 18 09:57:21 <DeltaHeavy> I have a data attribute I want to store the name of a function reference. It looks something like data-callback="namespace.modules.test.newCallback" What's the cleanest way to go about this?
- Sep 18 09:57:38 <DeltaHeavy> Was thinking of using split(.) and doing window[split[0]][split[1]][split[2]][split[3]] in conjunction with a loop maybe to support any number of children.
- Sep 18 09:58:04 <zumba_addict> is bar a child of foo?
- Sep 18 09:58:19 <cjohnson> zumba_addict: in my example, foo.prototype = bar
- Sep 18 09:58:35 <zumba_addict> cjohnson: would love to see a short fiddle on that. That would help me a lot
- Sep 18 09:59:17 <zumba_addict> ljharb: I got confused on this article - http://raganwald.com/2014/03/31/class-hierarchies-dont-do-that.html
- Sep 18 10:00:02 <MinusFour> zumba_addict, watch this video:
- Sep 18 10:00:04 <zumba_addict> today was my first time hearing class heirarchies. Is the fiddle i posted a class heirarch?
- Sep 18 10:00:05 <MinusFour> https://www.youtube.com/watch?v=PMfcsYzj-9M
- Sep 18 10:00:10 <zumba_addict> thanks MinusFour
- Sep 18 10:00:30 <zumba_addict> MinusFour: is the fiddle I posted a class heirarchy? http://jsfiddle.net/dqggvjrj/2/
- Sep 18 10:00:37 <zumba_addict> someone just gave that to me last night
- Sep 18 10:00:53 <cjohnson> zumba_addict: http://jsfiddle.net/152tt9ne/1/
- Sep 18 10:01:00 <zumba_addict> thanks so much cjohnson
- Sep 18 10:01:22 <zumba_addict> wow, so glad when I see new function names :D
- Sep 18 10:01:28 <zumba_addict> it makes me feel I'm advance
- Sep 18 10:01:29 <cjohnson> I used Object.setPrototypeOf here which is es6 but you can think of that as instance1.prototype = foo; in es5
- Sep 18 10:01:56 <zumba_addict> k
- Sep 18 10:02:12 <zumba_addict> is it also similar to this? var instance1 = new foo();
- Sep 18 10:03:04 <cjohnson> new foo is different, that calls the function foo (in my case, foo isn't a function, just an object) and it returns a new object from the function foo
- Sep 18 10:04:37 <cjohnson> zumba_addict: http://jsfiddle.net/xbLf3y8s/
- Sep 18 10:04:44 <cjohnson> this over-simplifies all the magic that "new" does
- Sep 18 10:04:50 <zumba_addict> k
- Sep 18 10:04:54 <cjohnson> but that's the gist of it
- Sep 18 10:05:13 <cjohnson> er, http://jsfiddle.net/xbLf3y8s/1/
- Sep 18 10:05:16 <cjohnson> missed 'a' and 'b'
- Sep 18 10:05:58 <EdwardIII> hrm am i going nuts? document.querySelector('input[type="submit"]').className = 'biscuits' // doesn't show up in inspect element? the classnames don't actually change
- Sep 18 10:06:27 <zumba_addict> oh, just saw you posted another one
- Sep 18 10:06:36 <EdwardIII> unnig it in the console
- Sep 18 10:06:43 <zumba_addict> i was about to say the params :D
- Sep 18 10:06:44 <EdwardIII> unning=running
- Sep 18 10:06:45 <zumba_addict> there you go
- Sep 18 10:07:06 <cjohnson> zumba_addict: one more piece I forgot, it also sets the prototype: http://jsfiddle.net/xbLf3y8s/2/
- Sep 18 10:07:33 <zumba_addict> :D
- Sep 18 10:08:11 <zumba_addict> I remember reading that using `new` is discouraged. Is it true?
- Sep 18 10:08:50 <zumba_addict> really appreciate your time helping me. I wish I was near your place and I can treat you for a lunch
- Sep 18 10:09:00 <cjohnson> no worries :) glad to help
- Sep 18 10:09:07 <zumba_addict> :)
- Sep 18 10:09:14 <cjohnson> new is... a little bit magic. it isn't exactly obvious what it does, so in that sense it's not perfect
- Sep 18 10:09:19 <zumba_addict> thanks too MinusFour, I'll download the video
- Sep 18 10:09:25 <zumba_addict> k
- Sep 18 10:09:56 <cjohnson> ljharb: I can never remember, is Object.create the better new? or do you do something else
- Sep 18 10:10:12 <Torkable> object.create is the weird one
- Sep 18 10:10:13 <Torkable> imo
- Sep 18 10:10:28 <Torkable> everything on the prototype!
- Sep 18 10:10:41 <cjohnson> well before setPrototypeOf, isn't Object.create how you set the prototype?
- Sep 18 10:10:54 <Torkable> if you want everything on the prototype, then yea I'd use create
- Sep 18 10:10:56 <cjohnson> ignoring [[Prototype]] hacks and such
- Sep 18 10:11:05 <zumba_addict> so the article tells me I should run away from class heirarchies. Is this fiddle a class heirarchy? http://jsfiddle.net/dqggvjrj/2/
- Sep 18 10:11:25 <zumba_addict> i asked it earlier to ljharb but looks like he's not available
- Sep 18 10:11:26 <Torkable> I use assign far more often
- Sep 18 10:11:29 <Torkable> Object.assign
- Sep 18 10:11:30 <MinusFour> more like a constructor hierarchy
- Sep 18 10:11:53 <zumba_addict> ok. So that code pattern is ok to use?
- Sep 18 10:12:03 <zumba_addict> or is there a better/nicer way?
- Sep 18 10:12:06 <EGreg> hey all
- Sep 18 10:12:08 <EGreg> I would like to do the following:
- Sep 18 10:12:19 <EGreg> 1) save the value of the width style in an element
- Sep 18 10:12:20 <MinusFour> I prefer Object.create but constructors do have their advantages
- Sep 18 10:12:22 <EGreg> computed width
- Sep 18 10:12:31 <cjohnson> zumba_addict: generally, trying to force classes into JS is going to lead to pain
- Sep 18 10:12:35 <EGreg> 2) set the width to what I want (essentially freeze the width, actually, in px)
- Sep 18 10:12:39 <EGreg> 3) then restore the previous width
- Sep 18 10:12:45 <Torkable> well I avoid any sort of oo in js as much as possible
- Sep 18 10:12:48 <EGreg> the problem is that I want to restore "100%" width
- Sep 18 10:12:51 <cjohnson> zumba_addict: if you *really* do want something like classes, then get yourself babel, and look at ES6 class keyword
- Sep 18 10:12:52 <EGreg> and I don't know how to get that value!
- Sep 18 10:12:59 <cjohnson> it's not really a class but it will take away a lot of this confusion for you
- Sep 18 10:13:00 <EGreg> Only by analyzing all the stylesheets and rules :(
- Sep 18 10:13:06 <EGreg> which seems like overkill
- Sep 18 10:13:11 <EGreg> any way to find out whether a width was "100%" ?
- Sep 18 10:13:13 <cjohnson> zumba_addict: http://www.2ality.com/2015/02/es6-classes-final.html
- Sep 18 10:14:06 <zumba_addict> cjohnson: wasn't really sure i was looking into class heirarchy. I just asked in so how instance C will be able to inherit properties of instance A - http://stackoverflow.com/questions/32643167/advanced-javascript-inheritance-is-failing-parent-parent-child
- Sep 18 10:14:19 <EGreg> http://stackoverflow.com/questions/324486/how-do-you-read-css-rule-values-with-javascript
- Sep 18 10:14:36 <cjohnson> zumba_addict: If you want c to inherit properties from a, then Object.setPrototypeOf(c, a)
- Sep 18 10:14:50 <cjohnson> and now c.foo will search c for foo, and if it doesn't find it, will search a for foo
- Sep 18 10:14:54 <zumba_addict> similar from your example right?
- Sep 18 10:14:57 <cjohnson> yep
- Sep 18 10:14:59 <zumba_addict> cool
- Sep 18 10:15:15 <EGreg> oh boy, that sucks :(
- Sep 18 10:15:18 <zumba_addict> i'll try to rewrite it using setProtoTypeOf and if I fail, I'll ask help here :)
- Sep 18 10:15:25 <EdwardIII> zumba_addict: well also i'd suggest reading object thinking
- Sep 18 10:15:38 <zumba_addict> thanks EdwardIII, I'll google it
- Sep 18 10:16:04 <zap0> how do i add a listener for a html <SELECT> ? i've tried 3 things and failed :(
- Sep 18 10:16:10 <zumba_addict> i hope it's geared towards JS because we know about JS's weirdness :D
- Sep 18 10:16:20 <EdwardIII> ok, it isn't, not at all
- Sep 18 10:16:30 <zumba_addict> k
- Sep 18 10:16:39 <EdwardIII> but it's about the principles by OO in an effort to create a language-agnostic way of really understanding what it's good for
- Sep 18 10:16:48 <zumba_addict> i think it will give me a good foundation on objects which is nice
- Sep 18 10:16:52 <zumba_addict> yup
- Sep 18 10:16:57 <cjohnson> zumba_addict: make sure to add https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.js
- Sep 18 10:17:00 <cjohnson> to your fiddle
- Sep 18 10:17:07 <zumba_addict> cool, thanks
- Sep 18 10:17:12 <EGreg> anyone even reading?
- Sep 18 10:17:13 <EGreg> hehe
- Sep 18 10:17:29 <cjohnson> EGreg: you have to analyze all of the stylesheets and rules yes
- Sep 18 10:17:33 <cjohnson> it's a nightmare
- Sep 18 10:17:36 <EGreg> that's what I thought :(
- Sep 18 10:17:54 <EGreg> So, what is a better technique to 'freeze the dimensions of a container while I edit its contents'
- Sep 18 10:18:55 <cjohnson> give it a fixed width and height?
- Sep 18 10:19:08 <cjohnson> you could calculate its offset width and height to see what they currently are
- Sep 18 10:19:53 <cjohnson> EGreg: https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_Model/Determining_the_dimensions_of_elements
- Sep 18 10:20:14 <zumba_addict> forgot to ask, why do I need es6-shim.js, is setPrototypeOf a polyfill?
- Sep 18 10:20:17 <EGreg> yes but then I want to restore it back
- Sep 18 10:20:19 <EGreg> after the editing is done
- Sep 18 10:20:28 <EGreg> that's the problem! the original could have been specified in units other than px
- Sep 18 10:20:41 <EGreg> My solution right now is to make an element that's 100% width inside the other element (which is not to be permanently altered)
- Sep 18 10:20:44 <EGreg> and then freeze the width of that
- Sep 18 10:20:47 <EGreg> and then bring it back to 100%
- Sep 18 10:21:00 <EGreg> or rather, I am setting its max-width and then later removing it
- Sep 18 10:22:44 <cjohnson> setPrototypeOf is an es6 method zumba_addict yes
- Sep 18 10:22:52 <cjohnson> es6-shim polyfills that method into browsers which don't support it
- Sep 18 10:23:13 <EGreg> It works now! here is the result: https://www.dropbox.com/s/79ea4ealgkx8ezk/Screenshot%202015-09-18%2012.23.12.png?dl=0
- Sep 18 10:23:18 <EGreg> in case you were wondering cjohnson
- Sep 18 10:24:26 <cjohnson> EGreg: I would do: if (node.style.width) { node.dataset.oldWidth = node.style.width; } var calculatedWidth = node.offsetWidth; node.style.width = calculatedWidth;
- Sep 18 10:24:53 <cjohnson> and when you're done, if (node.dataset.oldWidth) { node.style.width = node.dataset.oldWidth; } else { node.style.width = ''; }
- Sep 18 10:24:56 <cjohnson> something like that
- Sep 18 10:25:06 <EGreg> (I wouldn't use dataset because IE<11 doesn't support it)
- Sep 18 10:25:18 <EGreg> but the problem is, like I said, the offsetWidth would be in px!
- Sep 18 10:25:26 <EGreg> and if the original width was in %, say
- Sep 18 10:25:32 <EGreg> then it should resize with its container
- Sep 18 10:25:38 <EGreg> and after I "restore" the width, it wouldn't do that anymore
- Sep 18 10:25:42 <aib> is this a good place to ask about the DOM? I want to get the contents of a file as a string, preferably specified as a <script src="myfile.txt"></script>. Is that possible?
- Sep 18 10:25:46 <EGreg> so I would have broken the width of the element to which I applied tha tbehavior :P
- Sep 18 10:25:55 <zumba_addict> thanks cjohnson
- Sep 18 10:25:55 <EGreg> that's what I was trying to avoid.
- Sep 18 10:26:03 <cjohnson> EGreg: exactly, you *fix* the width using the calculated offsetWidth, while you're editing
- Sep 18 10:26:17 <cjohnson> and once you're done editing, restore it to whatever it was before, including its unit (% or px)
- Sep 18 10:26:23 <EGreg> cjohnson: say the original container had width: 100%
- Sep 18 10:26:30 <EGreg> "restore it to whatever it was before, including its unit (% or px)" -- there is no way to get this information in JS
- Sep 18 10:26:40 <cjohnson> .style.width
- Sep 18 10:26:41 <EGreg> unless I manually reproduce what the browser does, walking all the CSS rules
- Sep 18 10:26:42 <cjohnson> will return 100%
- Sep 18 10:26:46 <EGreg> .style.width returns in px always :(
- Sep 18 10:26:50 <cjohnson> wut
- Sep 18 10:26:52 <EGreg> try it
- Sep 18 10:27:12 <EGreg> you can write % but not read %
- Sep 18 10:27:18 <EGreg> That was the rub :(
- Sep 18 10:27:38 <EGreg> http://stackoverflow.com/questions/10624368/getting-the-width-of-an-html-element-in-percent-with-jquery
- Sep 18 10:28:05 <cjohnson> EGreg: http://jsfiddle.net/850wzznt/
- Sep 18 10:28:07 <cjohnson> returns 100%
- Sep 18 10:28:16 <EGreg> which browser?
- Sep 18 10:28:28 <cjohnson> chrome
- Sep 18 10:29:37 <EGreg> hmm, you are right in crome.
- Sep 18 10:29:38 <EGreg> sec
- Sep 18 10:30:07 <cjohnson> if the width comes form a class, that property will be empty, but that's fine too because once you restore node.style.width = ''; it will re-inherit widht: 100% form the class
- Sep 18 10:30:08 <zumba_addict> btw folks, I have a question about lines 1 thru 7 of my fiddle - http://jsfiddle.net/dqggvjrj/2/ What was the reason for writing ClassA.prototype.showFullname outside of function ClassA() { .... }
- Sep 18 10:30:22 <EGreg> cjohnson: I guess I stand corrected
- Sep 18 10:30:28 <EGreg> I was pretty sure it was coming back as a calculated Width
- Sep 18 10:30:30 <cjohnson> zumba_addict: the code inside the function is "instance-specific" code
- Sep 18 10:30:44 <cjohnson> zumba_addict: by writing on the prototype, you are creating a property which is shared across all the instances
- Sep 18 10:30:45 <zumba_addict> gotch
- Sep 18 10:30:49 <EGreg> so I can really save the old value of style.width ?!
- Sep 18 10:30:57 <cjohnson> EGreg: seems like it
- Sep 18 10:31:01 <zumba_addict> got it, very interesting
- Sep 18 10:31:02 <EGreg> nice.
- Sep 18 10:31:13 <EGreg> I already did it with the div right inside it, which I am able to mangle the width of,
- Sep 18 10:31:18 <EGreg> but for the future I will keep this in mind! Thank you!
- Sep 18 10:31:22 <cjohnson> no prob
- Sep 18 10:31:25 <EGreg> sometimes jsfiddle is great ;-)
- Sep 18 10:31:51 <EGreg> one more question then
- Sep 18 10:31:55 <EGreg> I can ask this in #css also
- Sep 18 10:32:01 <EGreg> how do I negate a border around an <input>
- Sep 18 10:32:03 <EGreg> say it has a 1x border
- Sep 18 10:32:15 <EGreg> do I make margin: -1px ?
- Sep 18 10:32:33 <EGreg> or change box-model?
- Sep 18 10:32:44 <EGreg> box-sizing
- Sep 18 10:33:08 <cjohnson> border: 0
- Sep 18 10:33:14 <cjohnson> presumably
- Sep 18 10:33:31 <EGreg> I want the border to appear though
- Sep 18 10:33:34 <EGreg> maybe I need css outline?
- Sep 18 10:33:51 <MinusFour> if you want the border to be part of the width then box-sizing
- Sep 18 10:33:52 <cjohnson> I'm not sure what you mean by negate then
- Sep 18 10:34:10 <cjohnson> EGreg: did you read that article I linked? you might not want to use offsetWidth
- Sep 18 10:34:19 <cjohnson> there are different props depending which parts of the box model you want to include
- Sep 18 10:34:20 <EGreg> I don't use offsetWidth
- Sep 18 10:34:32 <cjohnson> well...then you might want to use offsetWidth
- Sep 18 10:34:35 <EGreg> I use boundingrect usually
- Sep 18 10:34:38 <smgs> is there anyway to get GPS location of the device? thanks
- Sep 18 10:34:39 <cjohnson> I don't recall which is which by the article explains it
- Sep 18 10:34:47 <EGreg> I missed your link to the article btw
- Sep 18 10:34:53 <cjohnson> smgs: https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/Using_geolocation
- Sep 18 10:35:00 <smgs> thanks
- Sep 18 10:35:02 <EGreg> I read John Resig years writing years ago about getBoundingClientRect
- Sep 18 10:35:02 <cjohnson> 12:19 < cjohnson> EGreg: https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_Model/Determining_the_dimensions_of_elements
- Sep 18 10:35:16 <EGreg> which does everything the most correctly for you (it's what jQuery uses for is(":visible") and width() stuff)
- Sep 18 10:35:54 <EGreg> aha, transforms apparently make a difference, that's what the article mentions, ok.
- Sep 18 10:36:07 <EGreg> I usually would need boundingrect.
- Sep 18 10:38:33 <EGreg> aha I guess the answer is to have a border the whole time
- Sep 18 10:38:41 <EGreg> since I am not able to compensate for it later
- Sep 18 10:54:15 <smgs> cjohnson: thanks. it works only on that page. i tried to run it on JSfiddle, but on clicking the "Show my Location" button nothing happens
- Sep 18 11:09:32 <zumba_addict> has anyone of you ever thought about this? I just posted it. I hope you guys have encountered it before and was hoping if you can share your ideas - http://stackoverflow.com/questions/32657386/remove-dev-sit-code-when-grunt-build-is-for-prod
- Sep 18 11:10:14 <renlo> there are browserify global vars if i recall correctly
- Sep 18 11:10:38 <renlo> depends on how you are bundling your code
- Sep 18 11:12:12 <zumba_addict> k
- Sep 18 11:12:26 <zumba_addict> i don't think we are using browserify
- Sep 18 11:12:48 <hover> What would be the best way to sort by distance in this object:
- Sep 18 11:12:57 <hover> https://www.irccloud.com/pastebin/Z61CkfNw/
- Sep 18 11:14:19 <zumba_addict> hover, maybe use of underscore or lodash?
- Sep 18 11:14:35 <yansanmo> hover, first you need an array, if you want order
- Sep 18 11:15:35 <hover> Running on Node.js, so maybe something a little lighter than those libs?
- Sep 18 11:16:07 <yansanmo> Object.keys(o.couriers).map(function(a) { return o.couriers[a]; }).sort(function(a,b) {return a.distance-b.distance;})
- Sep 18 11:17:37 <yansanmo> you could put the key inside the object, if you don't want to lose it
- Sep 18 11:21:00 <Torkable> yea you guna need to change how that data is formatted
- Sep 18 11:21:45 <hover> yansanmo: very silly question, but how would I log that to console?
- Sep 18 11:21:55 <Torkable> console.log
- Sep 18 11:22:14 <palid> zumba_addict: requirejs + r.js pragmas/has
- Sep 18 11:22:26 <hover> Torkable: yes, I know. But never really used a return statement before.
- Sep 18 11:22:27 <palid> I'm using this kind of method.
- Sep 18 11:22:40 <Torkable> hover: hmm?
- Sep 18 11:23:03 <zumba_addict> palid, we use require.js but what is r.js?
- Sep 18 11:23:14 <palid> for dev server we're getting whole backbone=faux-server and mockjax + routes and stuff, which is not attached in the final build
- Sep 18 11:23:35 <palid> zumba_addict: it's a tool made by jburke to optimize requirejs modules.
- Sep 18 11:23:47 <palid> it does all the compiling magic
- Sep 18 11:24:00 <zumba_addict> so what I asked in so will be able to handle that?
- Sep 18 11:24:24 <palid> if you're not using require.js's dynamic loading in your code in production
- Sep 18 11:24:30 <zumba_addict> we are using it
- Sep 18 11:24:36 <yahkob> What is zumbaing
- Sep 18 11:24:45 <yahkob> is there a IRC #zumba?
- Sep 18 11:24:52 <palid> zumba_addict: how big is the app?
- Sep 18 11:24:59 <zumba_addict> big
- Sep 18 11:25:02 <yahkob> Zumba MVC?
- Sep 18 11:25:11 <zumba_addict> i'm building it yahkob :)
- Sep 18 11:25:17 <palid> zumba_addict: links?
- Sep 18 11:25:24 <yahkob> Zumba.Zumba.Zumba()
- Sep 18 11:25:26 <yahkob> :O
- Sep 18 11:25:43 <zumba_addict> :)
- Sep 18 11:25:48 <palid> because it cant be big if you're not using r.js with require.js :>
- Sep 18 11:25:59 <palid> it's THE default tooling
- Sep 18 11:26:02 <zumba_addict> k
- Sep 18 11:26:04 <palid> it's in docs.
- Sep 18 11:26:12 <zumba_addict> let me check if r.js is being used
- Sep 18 11:26:22 <palid> it may be for compilation.
- Sep 18 11:26:51 <zumba_addict> i don't see it in package.json nor in bower.json
- Sep 18 11:27:27 <zumba_addict> is this the one you are referring to? https://github.com/jrburke/r.js/
- Sep 18 11:27:57 <palid> yes
- Sep 18 11:28:28 <palid> you may be using webpack for building, but I advice using r.js
- Sep 18 11:29:04 <sillyslux> what a sad and insightful story https://remysharp.com/2015/09/14/jsbin-toxic-part-1
- Sep 18 11:29:08 <zumba_addict> i think i saw webpack somewhere, checking
- Sep 18 11:30:43 <palid> zumba_addict: webpack also have this kind of magic - it removes dead code on compilation automatically.
- Sep 18 11:30:51 <palid> but you have to read the docs.
- Sep 18 11:30:51 <zumba_addict> I was wrong, i dont wee webpack in package and bower
- Sep 18 11:31:01 <zumba_addict> wee/see
- Sep 18 11:31:03 <palid> ao, use r.js
- Sep 18 11:31:14 <palid> ther'es an awesome example in rjs repo
- Sep 18 11:31:16 <zumba_addict> looks like plain grunt is our build
- Sep 18 11:32:17 <zumba_addict> i heard from our last week's meeting that in the new app we are building, we are going to use webpack
- Sep 18 11:32:24 <zumba_addict> is that a nice move?
- Sep 18 11:32:38 <zumba_addict> we are also going to use reactjs and ampersand
- Sep 18 11:33:39 <Jayflux> How would you check an object is an ancestor of another? isPrototypeOf only checks 1 up I think?
- Sep 18 11:34:49 <tcsc> i think you'd just use instanceof
- Sep 18 11:36:08 <tcsc> oh, no, that only works on functions. nevermind.
- Sep 18 11:36:18 <Jayflux> tcsc, thats worked, thanks
- Sep 18 11:36:20 <tcsc> oh
- Sep 18 11:36:21 <Torkable> lol
- Sep 18 11:36:50 <tcsc> i thought you wanted to know like, x = {}, y = Object.create(x), z = Object.create(y), x instanceof z
- Sep 18 11:37:07 <tcsc> err, vice versa, z instanceof x
- Sep 18 11:37:17 <tcsc> which would be pretty weird tbh.
- Sep 18 11:41:01 <sillyslux> >> var x = {}, y = Object.create(x), z = Object.create(y); z instanceof x
- Sep 18 11:41:02 <ecmabot> sillyslux: TypeError: invalid 'instanceof' operand x
- Sep 18 11:41:35 <sillyslux> chrome says Expecting a function in instanceof check, but got #<Object>
- Sep 18 11:43:22 <zap0> how do you indicate arguments to a function are optional ?
- Sep 18 11:48:23 <yahkob> I make a options hash
- Sep 18 11:48:36 <yahkob> (arg1, options) then document it =D
- Sep 18 11:48:39 <yahkob> maybe not the best way
- Sep 18 11:50:26 <step1step2> Look at this formatting by Visual Studio/ReSharper: https://gist.github.com/step1step2/7d8d34232ae3e02940ee It looks like a rocket :-§
- Sep 18 11:51:13 <yahkob> translation rocket
- Sep 18 11:51:21 <yahkob> that would be a terrible rocket
- Sep 18 11:51:21 <ggggthomas> hey
- Sep 18 11:51:33 <yahkob> I wouldnt leave the planet on that
- Sep 18 11:52:05 <jacob___> will javascript ever implement operator overloading
- Sep 18 11:52:25 <ggggthomas> no
- Sep 18 11:52:28 <step1step2> I'm no Astronaut :c
- Sep 18 11:53:46 <yahkob> someone asked me how to implement logic for a javascript powered motor cycle with tessel.io
- Sep 18 11:54:00 <yahkob> It made me very scared for the pilot of the motorcycle
- Sep 18 11:54:00 <yahkob> lol
- Sep 18 11:54:11 <yahkob> while( notBrake ) { ... }
- Sep 18 11:55:21 <hashtag___> hi
- Sep 18 11:55:43 <hashtag___> Could one tell me what the "window variable" of this script would be?: https://github.com/diazemiliano/googlemaps-scrollprevent/blob/master/dist/googlemaps-scrollprevent.js
- Sep 18 11:56:33 <yahkob> type in window to your console :)
- Sep 18 11:56:46 <yahkob> window is the top level object in Javascript
- Sep 18 11:59:48 <hashtag___> yes
- Sep 18 11:59:56 <hashtag___> but what does that given script add to window (itself - variable?)
- Sep 18 12:03:26 <fooey> good old JetBrains, they realize they screwed up and pissed off all their customers, so they work hard to come up with a way to piss them off even more
- Sep 18 12:04:55 <MachinShin> fooey? what'd they do now?
- Sep 18 12:05:09 <fooey> http://blog.jetbrains.com/blog/2015/09/18/final-update-on-the-jetbrains-toolbox-announcement/
- Sep 18 12:06:05 <hashtag___> nyone? :/
- Sep 18 12:06:16 <fooey> they admit their screwed up and no one likes their new model, but if you don't like it you can have your software rolled back to a 1 year old version
- Sep 18 12:06:29 <yahkob> do you know how bind works?
- Sep 18 12:09:25 <hashtag___> yes
- Sep 18 12:09:33 <hashtag___> https://github.com/dolox/fallback
- Sep 18 12:09:51 <hashtag___> the fallback js seems to download one by one - I guess the reason is that the code failed to load in eyes of fallback
- Sep 18 12:11:27 <dude_> what does that mean by int [a] = {2, 3}
- Sep 18 12:12:16 <tcsc> that doesn't look like js
- Sep 18 12:14:44 <dude_> is there anything like "int" in javascript?
- Sep 18 12:16:40 <dude_> or something like "int [] a"
- Sep 18 12:17:41 <hover> Anyone know how I can sortByAll with lodash and still preserve the parent keys?
- Sep 18 12:17:43 <RLa> dude_, there are no integers in js
- Sep 18 12:18:04 <bosnian> looking for a job in Germany... anyone here with such opportunities? thanks!
- Sep 18 12:18:43 <fooey> someone has to give me a job in Denver first ;p
- Sep 18 12:19:28 <bosnian> denver is good
- Sep 18 12:19:30 <bosnian> denver is reliable
- Sep 18 12:19:32 <bosnian> if it doesn't work
- Sep 18 12:19:33 <nettoweb> folks, yesterday I received many replies about my question but my pc turn off nd I couldnt see... is there way to see a log of that conversation?
- Sep 18 12:19:38 <bosnian> you can always hit him with it
Add Comment
Please, Sign In to add comment