« first day (134 days earlier)      last day (4800 days later) » 

12:01 AM
It is what I am talking about! I don't like that this collection of articles while pretends to be an introduction to JS, doesn't touch such subjects as functions-as-values and closures. There is no much to do with JS without this ideas.
 
@MattMcDonald Is it really THAT badly written? :P
 
user1385191
where did I imply that?
 
user1385191
it was a generality
 
@MylesGray it just needs too big answer
 
user1385191
I'm commenting your code as we speak.
 
12:06 AM
or simply a reference to a good JS book
 
@MattMcDonald I just assumed I had conveyed myself badly if you were asking, but I am fairly OOP savvy
@thorn Maybe it needs a bounty to entice people :P
 
like Eloquent JavaScript by Marijn Haverbeke
 
user1385191
regardless, I'm going to go over basic OOP stuff in my comments
 
@thorn I am currently reading "The Good Parts" by Crockford
 
maybe :)
 
12:08 AM
I have "Definitive JS Guide" lined up
as well as "Code Complete 2"
@MattMcDonald Thank you sir :)
 
@MylesGray just one chapter: eloquentjavascript.net/chapter3.html
 
@MylesGray Which, oh that question, sure I'll take a look
 
@YiJiang thanks very much :)
@thorn I'll take a look
 
Well Ivo wrote the code for you, why not ask him?
I thought from last night's conversation that you understood the code
 
@YiJiang He was explaining prototypes
I get how basic prototyping works
but now it's just that whole combo of code he has, with returns and references i've never seen before just wrecks my mind
I dont want to ask him because he'll get annoyed at me
I think I ask him too many questions
 
12:13 AM
but you don't get closures
 
user1385191
I still don't like anonymous functions
 
user1385191
do you understand how they work?
 
it's just another type of value
like strings or numbers
 
@MattMcDonald no that is one of the most confusing things
 
user1385191
it's just a function without a name
 
user1385191
12:18 AM
that's called immediately
 
oh so it doesn't need any outside triggers?
 
such value consists from two parts: function body (code) and context
 
why bother writing a function that is executed immediatly though?
why not just do inline code?
 
@MattMcDonald They doesn't have to be called immediately. You are wrong.
 
user1385191
oh ok
 
user1385191
12:20 AM
right, I've seen them used as listeners
 
hmm... confused
 
user1385191
now this line I'm not sure about
 
user1385191
function(method, options, interval) {
 
user1385191
you're returning it and starting the closure, but I can't find any values for the parameters
 
values for parameters are passed into the function when it is called
 
12:23 AM
@MattMcDonald Exactly!
That is the one line that threw me off completely
@thorn from where!
there are no global vars of that name
The functions inside functions = scoping right?
so you can emulate scope as Java has different var classes?
 
parameters are local variables of the function
Myles, no. It's a completely different idea.
called closure
 
I tried to follow your scoping link thorn but SO is down for maintainance atm
 
just read the book, eloquent js
 
@thorn:
People who have experience with other programming languages might expect that a block of code (between braces) also produces a new local environment. Not in JavaScript. Functions are the only things that create a new scope.
this is lexical scoping?
 
yep, but there are plenty of other funny related subjects
 
12:27 AM
I wish I was back in .net... ahhhhh heaven
 
welcome to the club :)
 
user1385191
okay, that's as far as I'm getting for now
 
user1385191
 
Oh dear jesus, thanks Matt!
 
user1385191
as has been the case lately, I'm bound to be wrong on some part of it.
 
12:38 AM
Haha, it looks great I'll get reading, Post it up as an answer to the question if you want a few points :)
 
user1385191
like I just said, I've been wrong a good amount lately. I'll let you guys pick it apart for now.
 
user1385191
quick question: are closures JS exclusive, or do they apply to other ECMAScript implementations as well?
 
they are part of the ecmascript standard
 
@thorn according to that book chapter you sent ECMA4 was meant to implement some type of local scoping
 
user1385191
they don't seem to work in as3
 
12:55 AM
maybe. i don't know much about ecmascript 4 and actionscript
 
user1385191
you have to specify a return type
 
user1385191
so in this case, as soon as you do return function, it expects the return type to be Function
 
@thorn AS3 is based off ES4, which is deprecated according to Wiki because of difference of opinion on how it should be developed
Which leaves AS3 in a weird sort of position, in my opinion
 
@MattMcDonald and why can't return type be Function?
@YiJiang i know
 
user1385191
it's weird because it has support for classical OOP as well the as prototype chain.
 
user1385191
12:58 AM
@thorn It can, just as soon as you type 'return function(){}', it returns that function without being executed.
 
@MattMcDonald it was one of main ideas behind ES4
 
user1385191
the difference from js being nobody that I've read actually uses the prototype chain in as3
 
because its bloody hard to understand
 
@MattMcDonald so why do you state that closures don't work in AS? (i have no experience with AS at all)
 
1:39 AM
Stack overflow:
function chicken() {
  return egg();
}
function egg() {
  return chicken();
}
print(chicken() + " came first.");
 
 
2 hours later…
3:25 AM
RT @dalmaer: "The Big Block Framework renders pixel art, pixel fonts and particles using DOM manipulation" http://t.co/T4VUUhX
RT @balmer: I guess since I'm an HTML5 fan I'm supposed to hate Flash, but I don't. Developers should use whatever tools they like.
 
@Feeds Disappointed that this isn't the Balmer
 
3:59 AM
Hey, all.
 
user1385191
4:12 AM
0
Q: How to change the color of the links with javascript?

MaxxonI want to know how can I manipulate all the links on a page with javascript. I can get elements by id's with document.getElementById(id), but how can I get the links? And also how can i get all elements with a certain classname? I mean these links: <a href="http://www.google.com">This is ...

 
user1385191
this question might have the worst answers I've ever seen.
 
@MattMcDonald Definitely (gets his downvote finger ready)
 
user1385191
How does the wrong answer have 3 upvotes?
 
4:34 AM
wow @MattMcDonald pretty much everyone suggests jquery..
i upvoted you
i never give a jquery answer if the question doesnt have a jquery tag in it
 
user1385191
bingo
 
user1385191
when I first started up in the js section, I tended to post pure js solutions to questions that suggested jQuery.
 
user1385191
I've backed off since.
 
@MattMcDonald Actually, since getElementsByClassName isn't supported in IE8, querySelectorAll would actually be better than that
 
Yeah I dont hate JQuery or anything but people just want to use it for every little thing..
someone had a great pic
 
user1385191
4:37 AM
Yeah, I figured it isn't well supported.
 
user1385191
Man, I feel all stressed out and my fingers are almost shaking when I type.
 
cant find the image now, lol but its along the lines of "I want to change some text" and everyone says use jquery
I get the same way, trying to get the answer before anyone else
 
user1385191
it's an image by bobince.
 
@Loktar It's actually 'I want to add two variable together'
 
ha yes
just found it
cracks me up due to how close it actually is to the truth
 
user1385191
4:40 AM
my first js experience was with jQuery believe it or not
 
user1385191
I was working on an app with a backend guy for Staples. I was so overwhelmed and I wrote terrible code.
 
my first js exp was making stupid preloaders for buttons way back
 
user1385191
it's definitely a lot more fun in my opinion to try and replicate what's under the hood.
 
yeah I agree
i find it easier to teach new devs about JS using jquery though
 
user1385191
I can definitely respect what Resig and co. have done with it, but the marketing they've used has just been silly.
 
4:42 AM
well to at least get them used to the syntax etc.
 
user1385191
yeah, I've been going through David Flanagan's JS book and reading back on some legacy code.
 
user1385191
It's really interesting just how far Javascript has evolved since then.
 
yeah
I never imagined people would make full fledged games with it
 
user1385191
the rendering speed for JS is really inconsistent though.
 
or just how far webpages in general have come in usability due to it
 
user1385191
4:45 AM
As a Flash dev, browsers need to come a long way before HTML5 is really viable.
 
I agree, but I think they are making leaps and bounds
 
user1385191
I wish they had a bitmap manipulation API
 
user1385191
that's where you can really cut down on memory usage
 
what do you mean?
 
user1385191
Flash has a bitmap API where you can draw vector shapes and textboxes to bitmaps
 
user1385191
4:47 AM
and you can do all sort of crazy things with it
 
ah
yeah people do some really cool stuff with flash
i havent done too much with it
for games, and especially monetization of games its still the best choice
 
user1385191
hahaha 7 new comments on my answer
 
user1385191
@YiJiang QSA is the function where you pass a selector string, right?
 
@MattMcDonald document.querySelectorAll, yes
 
user1385191
thanks
 
user1385191
4:56 AM
I knew jQuery ran it with their builds over the last few years.
 
@MattMcDonald Yeah, it's hugely efficient compared to trying to parse out a selector string with Sizzle and then doing the traversal using traditional methods
 
user1385191
5:11 AM
Ugh, Adobe really screwed up with the 10.2 security update. Sites with Flash content are freezing my browser often because they don't have a crossdomain.xml file.
 
6:50 AM
@MattMcDonald How is canvas not a sufficient bitmap API?
 
user1385191
7:21 AM
@gsnedders Sorry, I haven't played with canvas yet. I'm open to documentation if you have links.
 
 
2 hours later…
8:53 AM
Hi! :)
 
 
1 hour later…
10:16 AM
Hrump... I got the menu working again in the garden: dl.dropbox.com/u/1722364/Garden/index.html
 
@YiJiang less collapsing?
 
@Nyuszika7H Yeah, it tries to expand as much as possible
 
@YiJiang nice :)
 
10:31 AM
@YiJiang Looks good, although there seems to me a small problem with the highlighting missing a a correction offset
 
@Loktar lies! Flash is not the best choice for games! (Hates flash).
Seriously though.. if you need ie8 support you need flash :\
 
solution, don't support it :P
 
not your decision to make
 
well in that case, it sucks
anyways I certainly won't have to deal with flash anytime soon
 
:D
 
10:39 AM
in fact, my job is to get rid of flash
 
"Hey Ivo, JavaScript is cool and all. But can you port our games to flash? Awesome thanks"
 
so the video stuff finally works
I remember the stuff being horribly buggy when they first released it
nice to see that it finally works
And hey, it needs less CPU then flash, so I'm happy
 
and is stable on linux!
 
!!!
In fact on the netbook, flash is unusable
 
10:44 AM
Anyone knows how chat determines if I'm mentioned? I want to make an userscript which uses HTML5 audio instead of Flash, because Flash is a real resource hog.
 
@Nyuszika7H Just watch the document.title, should be good enough
 
@YiJiang nice :)
someone ping me please
 
@Nyuszika7H whiile(true) { traverseDOM();}
 
@Raynos thanks :)
wait what? jsFiddle removed jQuery 1.4.3?
 
@IvoWetzel Is it okay if I erhm... replace your original code with mine here?
 
10:58 AM
sure
but I would use active classes for the highlighting etc.
 
@IvoWetzel Well, I've got animation doing that, hmmm...
Not a lot of point adding and removing a class on animation complete since animation is going to add inline styles that will override the CSS styles
 
hm, right, although some fancy css transitions could do the job way easier
also, I liked the highlight of the ul
 
@IvoWetzel True, true... hmmm, should be interesting
Firefox 4 is coming out real soon
 
And chrome safari already have them
and IE opera... uh
 
I thought you might be doing a short intro to each section, that's not happening any more, right?
@IvoWetzel Opera has this weird thing going on with position: fixed which I want to ask @gsnedders there but he's gone now I think
 
11:02 AM
I can't come up with something that adds value
unless a "THis section covers X Y Z" overview is ok
 
@IvoWetzel Maybe for the large sections, but for those with only one or two articles, meh
Oh, and I'm happy to say that the new HTML is valid HTML5, unlike the old one
Which means we can put a HTML5 badge on the site XD
 
lololololololol
 
@Nyuszika7H Hehehe
Who's created a Russian room anyway?
 
@YiJiang IDK, but its description translates to Programerskaya tusovka. :D
 
Wait does IE9 support most of ES5 ?
I mean with ff4, ie9 & chrome can we start throwing Object.create and Object.defineProperty into our code?
 
11:08 AM
yes IE9 supports most of it
 
@Raynos Not really a lot of point in doing that IMO, because there are no obvious replacement for those for older IEs
 
@YiJiang theres always degrading to no JS :P
Start serving your no-JS content to IE<9
 
@YiJiang There's the @gsnedders ask him
 
ping me in that room please
 
11:11 AM
@gsnedders Hey, I've noticed a very weird position: fixed problem on Opera; are there any known bugs associated with it?
 
@YiJiang the honest answer is as with almost any feature I expect there are /some/ known bugs
So, uh, more specific as to what your issue is?
 
11:27 AM
Aloha all
:)
 
@MylesGray Hi! :)
 
Whats up?
 
 O/
/|
/ \
@MylesGray Look!
 
\0/
 |
/ \
 
uh design decision
imagine an array
[1, 2, 3, 4, 5]
 
11:34 AM
@MylesGray don't try manual editing, I'm doing it with an userscript :P but there are some delay between the Ajax requests
 
to get the 5, use index -0 or -1 ?
 
@IvoWetzel negative zero?
 
0 is sign independant?
 
@gsnedders Scrolling quickly with js garden's position: fixed would result in the thing glitching, it's position moving around even though it's position was never changed
 
there are both values in JS, but here it's easy since the number is parsed from string anyways
speaking of glitches in Opera
 
11:39 AM
 
11:56 AM
\oy/
 ||
/  \
 
@IvoWetzel - Could you review this please?
Trying to understand that code you helped me with yesterday
 
/* This is a recursive function. Recursive functions
            * call themselves a set amout of times before completing.
wrong
the function is called by the event loop
 
@IvoWetzel use -1.
@IvoWetzel depends. in nodejs yes
 
also having scheduler return setId(foo, bar, 20)
@Raynos In browser to, it's wrapped with a setTimeout
 
Oh. Fair enough
 
12:00 PM
will not work as I originally intended it
scheduler will now return {
stop: function(attribute) {
clearTimeout(id);
}
}
it should simply return the setId function though, since it's a factory
 
6
Q: Choosing Mobile Web HTML5 Framework

SarfrazHey For the new project, I have been searching for a framework with support of HTML5 and runs on mobile, that is IPhone, IPads. I found out these: Sencha Touch M-Project jQuery Mobile jQTouch Titanium NimbleKit Wink Toolkit The main thing for me is HTML5. Although I went over the features th...

Hurr durr use jQuery mobile. 7 times. 7 answers for jQuery mobile -.-
 
therefore the new can be omitted from the call to it
all that Scheduler does is to return a "bound" version of setId
also setId is a kinda bad name for the thing
 
Why do people do that? But its stupid. Duplicating answers that already exist
 
@Raynos they want points
 
6x -1 :)
 
12:05 PM
@Raynos epic
I need to vote on some more answers
 
@IvoWetzel thank you :)
 
@MylesGray the hell :P dont undo my -1's . jQuery fanboy -.-
 
Hahaha, I meant negging
not +1'ing
 
Oh.
 
12:07 PM
I don't ever use JQuery... thought you knew that ;)
 
Someone else upvoted them all :\
 
Could be the chain voting thing
it detects chain voting and disables the votes
 
@Raynos 6x +1 :)
 
@IvoWetzel If i understand this correctly:
API.prototype = {
    /* This is a method, and a public one at that. That means this is accessible
    * from any API instance.
    * Example syntax: api.lookup(resource, callback);
    */
    lookup: function(resource, callback) {
        // build the url etc here
        this.request(url, callback);
    },

    request: function(url, callback) {
        // build a request here and send it
        request.on('finished', function() {
            callback();
        });
Each of the internal definitions is the same as doing:
 
@Nyuszika7H hate you.
 
12:12 PM
API.prototype.lookup: function(resource, callback) {
// build the url etc here
this.request(url, callback);
}
@Raynos I would neg them... but I only have 4 rep to spare or I lose edit
wait there is a 100 bounty on that!
wtfffffff
 
@MylesGray Correct. Although I would phrase it in a different way
0
A: node.js express require?

Ivo Wetzelexpress utilizes connect under its hoods which gets installed along with express. In this case, you want to access the uid function of connect: > require('connect').utils.uid(40) '3DQD2XfAd19uL1r7LK6ZkIrFooSOGGVkGePI36HL' Since: > require('connect') { version: '0.5.5', utils: { m...

What's so hard about require("../support/express/support/connect/lib/connect/utils").uid
why can't people see that uid isn't part of express, but connect?
 
@IvoWetzel okay makes sense now :)
 
why doesn't JS allow for m.1 m.2 etc instead of m[1]
I hate having brackets all over the place
 
@IvoWetzel to have a constant definition of an identifier
@IvoWetzel Also if you want to allow m.1a as well, it would mean adding more context sensitivity to the lexer
 
12:30 PM
what would m.1a access?
m[1].a or m['1a']?
 
I presume you would want it to be m['1a'], as otherwise it'd be counter intuative
What would m.1e1 match though?
 
well all I "want" would be to have obj(dot)(number literal) be a shorthand for m(get)(index)
@gsnedders Nothing, \d literals are more than enough :P
but meh, just my crazy thoughts
 
@IvoWetzel That would be inconsistent with what's allowed as a number literal elsewhere in the language though.
Language design is hard. :P
 
@gsnedders Don't tell me of JS and inconsistency :P
 
@IvoWetzel Hey, the whole web platform is inconsistent, but it's nice to keep what consistency there is :P
 
12:33 PM
Especially since keeping "nothing" is easy :P
OK, it's not that bad
But it's getting close
 
/me grumbles something about adding modes to JS (strict mode, Harmony, etc.) adding inconsistencies
 
@IvoWetzel Do functions within functions emulate local scoping?
 
as the only scoping is by functions
 
what do you mean by "emulating"
scope exists, functions provide it
 
12:35 PM
so if a function is within a function does it create an equivalent of the Java private variable?
 
if you return that function in some way, yes
did you ever read the freaking garden!?!?!
:P
Closures can emulate private variables
 
0
A: Javascript Function not Called onClick()

Nyuszika7HYour code has several issues. Syntax errors 1. It's better to avoid putting braces on their own lines, or automatic semicolon insertion will get you at some time. So instead of this: function sayHello() { alert('Hello, world!'); } You should do this: function sayHello() { alert('He...

 
:P I read it, doesn't mean I understand it, same as books, I read them but it is not until I actually code the stuff that it clicks with me
 
There will be more and more answers like this… I really should make a template. :)
 
@Nyuszika7H +1
 
12:40 PM
Yep +1 excellent answer
 
@MylesGray there is no equivelant of a java private variable. There are no private varaibles
You just have scope
local scope
and local scope isnt accesible outside a function
 
and stuff hidden away in closures
 
Local scope can be maintained after the function ends by closures
 
function MyClass() {
    var test = 'You can\'t access this from outside';
    this.getPrivate = function() {
        return text + ' – Unless you have a function that returns it.';
    }
}
 
@Nyuszika7H Reference error : text is not defined
 
12:47 PM
typo is a typo
 
@Raynos Oh yeah, it was meant to be test. But I can't edit it anymore…
 
@YiJiang We could add a little "Resources" section to the garden
 
@Raynos Okay cool, my point was that because of the lexical scoping implemented in JS the local vars act in the same sort of way as a Java private var
 
you know, crockford talks and the like
and of course a recursive reference to the garden itself!!!
 
@IvoWetzel If you want to
 
12:53 PM
would be handy, and we'd have yet another reason to point to the garden
 

« first day (134 days earlier)      last day (4800 days later) »