« first day (586 days earlier)      last day (4360 days later) » 

7:00 PM
does it do the same as insertBefore
.after, .before, .prepend, .append are higher level methods actually worth implementing
I don't see any point trying to wrap insertBefore
 
Oups, not insert, move.
But insert as well, heh.
I don't want to create a plethora of methods.
 
well insert and move are really the same thing, if the element is attached somewhere else it will be moved
 
It's not just about dom elements.
 
Just make sure that by avoiding making enough methods you aren't making ones which require workarounds to do what the excluded ones do. For example, having a flag that you pass into Insert to convert it into Move
 
I have a document with pages.
 
7:05 PM
Sounds familiar. I called them panels.
 
A user can insert/(add)/remove/move pages.
 
I also found that making the "plethora" was rather useful.
 
yep there is a lot of boilerplate in doing what those methods do with just insertBefore
 
?
Sorry, I don't get you.
 
elem1.after( elem2 )

vs

elem1.parentNode.insertBefore( elem2, elem1.nextSibling )
 
7:10 PM
As I said, a *page*.nodeType !== 1; // true
 
what is page node
 
Besides, elem.after(elem2); is not semantic, but that's imho.
 
I prefer to have a moderator which maintains the elements instead of having them do the work on themselves.
 
page.wrapper.nodeType === 1; // true
 
elem.after(elem2) tells you immediately what it does
where as that hacky boilerplate needs processing if met in the wild
 
7:12 PM
What, it triggers an event after elem1?
Or does it appear after elem1 has disappeared?
 
I think that it calles fter on the anchor tag.
 
Anchor tag?
 
sure you could say elem1.insertNodeAfterThisNode( elem2 ) but both express intent just as clearly
 
I was being facetious sorry. The fter() function is called using the a element nested in elem
 
where as elem1.parentNode.insertBefore( elem2, elem1.nextSibling ) doesn't express anything, you have to analyze it what it does unless you know the pattern
 
7:15 PM
.after is pretty good. I like more verbose names though.
 
We have $elem.on today. It means "on triggered event".
I suppose $elem.after would mean "after triggered event" (post-factum)
 
InsertNodeAfter(Node) makes more sense to me than after(Node)
 
it doesn't exactly say insert node after
 
Look, how semantic this is: button.before('click', alert('Not enough data!'));
 
which is why it deserves it's own method
 
7:17 PM
@TravisJ insertNodeAfter is too verbose
 
Why are you trying to cram a method name into as few characters as possible? Make it verbose and then minify it.
 
You are already operating on a node, so no need for "node" once again
 
Unless people like you misconstrue it into an event.
 
elem1.insertAfter( elem2 )
is ambigious
which one is inserted after which?
 
lol
 
7:18 PM
i would think elm1 is inserted after elm2 reading it left to right
 
@rlemon +1
 
in jQuery elem1.insertAfter( elem 2) inserts elem1 after elem2, where as elem1.after(elem2) inserts elem2 after elem1
 
Anyway, we went off-topic here.
 
@Esailija well then the latter method is fucked.. the first is semantic. I wish DOM methods were semantic.
 
7:20 PM
but my original point is that trying to cram .prepend, .append, before and after into insertBefore sucks because doing those operations with insertBefore is very inexpressive
 
Write your own DOM manipulation API?
 
My point was that I had a method doc.pages.insert(aPage, atPosition);
I believe having just one insert it's more than enough.
 
@TravisJ no need. the DOM API works.. just is not semantic.. if anything i'd wrap everything up in a pretty little bow and call is DOMantic
 
	element.insertAdjacentHTML(position, html);
	position is the position relative to the element, and must be one of the following strings:

	beforeBegin
	Before the element itself.
	afterBegin
	Just inside the element, before its first child.
	beforeEnd
	Just inside the element, after its last child.
	afterEnd
	After the element itself.
are those names any better then
I prefer before, prepend, append, after respectively :P
 
I use: MoveBeforeElement: MoveBeforeElement,
MoveAfterElement: MoveAfterElement,
ReplaceElement: ReplaceElement
 
7:23 PM
you are missing prepend / append equivalents
 
newElement.insertBefore(referenceElement);<- insert newElement BEFORE referenceElement
newElement.insertAfter(referenceElement); <- insert newElement AFTER referenceElement
currentElement.after(); <- I would just be nextElementSibling??
currentElement.before(); <- I would just be previousElementSibling??
 
Since append is so easy I didn't need to do anything with it. MoveBefore will prepend
 
currentElement.after(); <- I would just be nextElementSibling?? I like this one.
 
then there is insertAfter, insertBefore, prependTo and appendTo
 
before/after should be properties.
element.appendTo(target); is the same as target.append(element);
so why expose them both and clutter the API
 
7:25 PM
if MoveBefore will prepend (Wtf is with the PascalCase?), then what will moveBefore? :d
 
but .next is also good
Because after calls for action.
 
just because I wanna repeat myself.
 
hurro mens and menettes
 
@rlemon they are pretty useful in jQuery
 
Instead of dealing with the elements directly, I chose to wrap them and then hold all the wrappers in memory. So that all I had to do was manipulate the wrappers and then re-render in order to change the dom.
 
7:26 PM
element.appendTo(target); is the same as target.append(element);
so why expose them both and clutter the API
 
.on, .after, .before < event binders (from the semantic perspective)
 
but they are the same thing! just in a new order?
 
no they're not
well in jQuery at least
there are a few subtleties in play
first, append can take multiple arguments
 
@TravisJ I find that convenient too.
 
.append( elem1, elem2, html1, html3 );
but append cannot create elements the way jQuery constructor can
 
7:27 PM
$([elm1, elm2, elm3]).appendTo(elm4);
 
$( "<ul>", {click: function(){}).appendTo("body")
@rlemon what about html1 and html3 (lol)
 
@Esailija - can you send selectors to appendTo? appendTo("#elemId")?
 
it's a sad case of: we made this library so people would be able to write more code faster (and presumably know less) now we're going to make it even lazier! One line ALL OF THE THINGS!
 
append can take functions, dom elements, jQuery objects, html strings and so on
appendTo can take a selector yes
and the jQuery constructor can take element name and properties
so they are really different
 
append($(elementCreation)); was too hard for some.
 
7:30 PM
@rlemon Do you have any ideas why I can't post to d3 boards? My avatar is my old WoW char, and all I see is:
This account has limited posting access due to the following condition:
This game license has expired or been frozen.

Forums that you have permission to post in are marked as [Limited] on the forum list.
 
@Esailija i understand they do have subtle differences... but to me the uses for them are so easily worked around why include that function for everyone
@TomShreds have you activated D3 on that account?
 
@rlemon jQuery is one person's whim.
 
@rlemon yeah that's the account I'm playing with
 
sometimes it's also cool not to have to rewrite the code because only append is available
 
@TomShreds email them. idk, i never got into WoW
 
7:31 PM
you'll create an element and then think, fuck
 
Oh by the way.
 
I'll have to do it the other way around
 
@Esailija I would like document.getElementById() to forevre be byId() but I know that parsers will never expose both.. I have to write it
 
but appendTo to the resque
 
then reuse it where I want to
 
7:31 PM
@rlemon good idea
 
container.insertBefore(elem, elem); // invalid argument
 
it's just another silly part of jQuery imo.
same with having like 9 different methods for event handling.
they just frikking confuse the shit outta people then they use the wrong ones.
 
there is really no wrong one here, it's just convenience
 
I have to use jQuery in my current project. It has made certain things a lot easier... but the more and more I read through the source code... the more and more I see redundant shit like this.. I just don't agree with it.
 
you can turn your code around to use append
but really it's not its own code even
it's like .click and .mouseover
wrappers for .on ("click", ..
 
7:34 PM
yes
redundant stupidity
for the lazy devs.
i don't agree with that.
that is why the API is such a bloat.
 
I don't think so, fuck stringly typing
when you mistype .clikc , you get an error
 
i think the .click stuff is backwards compatibility for when there was no .on
 
when you mistype "clikc" you don't get shit
 
i'm going to remove all the redundant method calls which should have been removed and release jQuery 2.0 lemonator version.
 
when you forget a ; your code is "insanely stupid"
 
7:35 PM
lemonaid
 
@Esailija well you could use .onclick ... :)
 
Or you could save yourself the effort and just don't use jquery
 
^ cross browser
 
or use something like zepto
 
DOM API for the win!
 
7:36 PM
@adscriven yes because that has all the same features
 
.on adds an event listener iirc?
 
luls
 
@Esailija It has more!
 
no it doesn't :<
 
You can use function composition.
 
7:38 PM
and it doesn't add an event listener, just the first time on that element ever
no I can't really use anything else other than rewrite the jQuery event library
 
doesn't jQuery use some custom even model?
 
to get the features, of jQuery event library
should be pretty intuitive? :P
@rlemon yes
 
so it's anti polygot mindset?
 
@adscriven also writing .onclikc = wouldn't cause an error either
 
my vanilla js has no clue that the jQuery even fired.
 
7:40 PM
though it's not stringly typed so that's a win
 
@Esailija well yes that's true.
But you can use .onclick with function composition/AOP to get the same feature (I think).
 
@rlemon no it's that the regular event system is a piece of shit and anyone wanting useful features must use a custom event system
 
@rlemon nvm
 
did you just tell yourself to nevermind?
 
Obviously that doesn't stop other code from overwriting your .onclick function. You need a certain degree of cooperation.
 
7:44 PM
even if you're not using jquery you should still never use .onclick
 
I always use .onclick. It just works.
 
that's not the right attitude at all
 
Enlighten me!
 
use .addEventListener and you won't have any trouble with code overwriting your handler
 
.onclick = alert;
with addEventListener all your handlers are swallowed by some black hole
they go in but they don't come out
 
7:47 PM
:384206 undefined = 'foo';
 
!!> undefined = "foo";
@Esailija TypeError: Cannot assign to read only property 'undefined' of #<DedicatedWorkerContext>
 
Ooh!
 
addEventListener is a bad idea unless you intend to ignore everyone pre IE9.
 
Well, that's how it should be.
 
"In Internet Explorer versions prior to IE 9, you have to use attachEvent"
 
7:48 PM
.onclick just works, however.
 
Does jQuery use onclick underneath their .click?
 
addEventListener API has one thing going on for it over jQuery event system, that is it can take object as handler which is useful
 
@Esailija No they're not :S you can just call removeEventListener
 
@TravisJ no
@david yes they are
 
explain?
 
7:50 PM
well, where does your handler go?
in chrome you can probably see it in web inspector
but not programmattically
 
o_O
it doesn't 'go' anywhere
are you complaining that you can't get a list of the handlers for a particular event?
 
well it does go somewhere but it's not available to you, it's not even available when removing it
removeEventListener expects you to keep reference yourself
so that you can unbind them one by one
 
okay... you're weird
in that case setTimeout is a black hole too
 
well I can easily just cancel the setTimeout
 
7:53 PM
so is var x = function(blar){}; x(Stufff); where did it ggo!?!!! it's a black hole function!
 
the setTimeout doesn't except me to keep reference to the function for that
 
you can't cancel the timeout function without keeping a reference to the number it returns
 
I don't need any reference to cancel a timeout
nope, the number isn't magical
it's just a number
 
you still need to know what the number is
 
@Esailija That's a very good thing.
 
7:54 PM
it's no difference to keeping a reference to the function
 
besides I have never had the need for namespaced timeouts or anything like that
 
var x = setTimeout("");
for (var i = 0 ; i < x ; i++)
clearTimeout(i); // Look Ma! No more timeouts!
 
@adscriven how is that "just a very good thing" without explanation
 
Needing a reference to unbind.
 
yes, how is that a very good thing?
 
7:58 PM
Is that not a good thing for the same reason that local variables are good and global ones are bad? Maybe I've misunderstood.
 
no you're right @adscriven
 
> "Make it idiot-proof, and someone will make a better idiot."
 
it helps move people away from throwing anonymous functions around
 
does it really help people not to do that
I don't have anonymous event listeners
and I still think it's not that good thing to require keeping function references in the element as well as client code
and what relevance to local and global variables does this even have, if anything it will probably cause someone to use a global just because he must carry the reference around everywhere
 
I don't know. But I think that only code that sets a listener should be allowed to unset it.
When would you ever need a function reference to be stored in an element?
 
8:02 PM
well that's what it does
the element has reference to the listener somehow unavailable to javascript code
 
Okay, I need to read about this more, obviously. Sounds like a mess though.
 
@adscriven don't put too much stock in what Esailija is saying :p
 
Well, that's my default position.
 
I mean, if you pass an anonymous function to addEventListener, it will still work even if you have no way to access it from client code
so that function is stored somewhere
inaccessible to you
 
And? if you want access then don't pass it anonymously
 
8:08 PM
that's not my point
 
So your point is you want to be able to do stupid shit?
 
the point is that you said not to give too much stock in what I'm saying about elements needing to keep a reference to listeners
 
I was being more general about not putting too much stock in ANYTHING you're saying
 
Well the reference doesn't have to be stored in the element.
 
oooooo dems fighting words.
 
8:11 PM
well no, but it doesn't really make any difference. somehow the lost function must be referenced and found when an event is triggered on that element
 
And you don't want that?
 
@Esailija Yes.
That's no different to publisher-subscriber.
 
it comes down to associationg that event, element and function together
whether you do that by storing the function in element somehow is pretty irrelevant
 
@Esailija They don't need to be stored together.
 
hahaha if anyone was keeping up on this. @Neal meta.stackoverflow.com/questions/133533/…
8 upvotes on my answer, 8 upvoted on my comment :P
 
8:17 PM
yeah I know that and already said it doesn't make any difference
when the element goes out of scope, so do the handlers. They are associated with it
(assuming our situation where we don't have any reference to the handler in our code)
 
When the element goes out of scope? what?
And that's the stupidest assumption ever
 
when nothing references the element anymore, it "goes out of scope" or "gets gced"
 
The fuck
no it doesn't
Unless you've removed it from the DOM
 
yes, when you remove it from the DOM, its siblings and parents lose references to it
so if you don't have any other references, it's gone
or "out of scope" or "gced"
 
So, to recap, you've got an element, you've added a listener and decided not to keep a reference to the function. And then you remove the element from the dom, and decide not to keep a reference to that either. And now you're complaining that you can't access the listener function anymore, and you're blaming this on addEventListener being a black hole?
 
8:21 PM
If an element fires an event, and noone's in the forest, does it make a sound?
 
now, you might append it somewhere else after removing it, in which case some other nodes will have references to it and it's not gone
 
Did anyone elses github hosted pages all suddenly crap out and need rebuilding?
 
it really has nothing to do with that, I'm just answering to stuff like "the fuck, no it doesn't"
 
So you've given up on your original argument and are now just trying to score cheap points by making up weird scenarios where you might possibly be right?
 
no the original argument was that it expects you to do tedious manual bookkeeping
 
8:24 PM
Why did noone tell me it's Troll Thursday?
 
when it could have been done at the event listener api level
 
You know I can't keep track of what day it is.
 
tedious manual bookkeeping? what the fuck, you keep a reference to the listener, it's not tedious at all ><
Maybe you're just bad
 
a reference? :P
 
yes. a
 
8:26 PM
ok if we only have 1 event listener ever maybe it's not so tedious to keep a reference to that
 
Local to the function that sets an event listener, there is effectively only one. Is that what you mean David?
 
and pass it to removeEventListener when the time comes
 
@adscriven I meant that if you add a listener, you only need to keep one reference to the function you added.
 
Yes, that sounds right to me.
 
If you're adding more than one, you will need to keep more than one reference, but that should be trivial if you've architected your code correctly
 
8:30 PM
That's what you get if you use function composition and .onclick.
 
by architected correctly you mean created an event bookkeeping system yourself
 
@Esailija no, that's not what I mean. If you need to do that then you've architected it incorrectly
 
There are no books to keep if you have local references.
 
@adscriven the difference is that anyone could come along and go .onclick = "lolpenis"; and your code breaks
 
Well, yes, that's a given. You could do that with a lot of things.
But if the code is all yours, that's not really an issue.
 
8:32 PM
No, but if you're working with other people it can be. If you use addEventListener it won't be a problem full stop
 
I know what you're saying. You could get around that by modifying JSLint for example.
 
If you use addEventListener you are not supporting at least 10% of your clientele if that control is necessary.
 
You have to follow coding standards and build processes or all kinds of craziness will break loose.
 
@TravisJ w3schools eh?
 
8:36 PM
@TravisJ Well my background is specific IE6 support. Thankfully I don't have to worry about that any more.
 
@david - If you are incompetent it really doesn't matter how many "best practices" someone provides for you. You are still going to fuck it up.
 
@TravisJ There are different degrees of fucking shit up.
 
@adscriven - That's rough. IE6 is a real pain
 
And incompetent people can still learn
 
you must know a lot of tricks :D
@david - Then get to it. Stop proposing the use of a broken approach.
 
8:38 PM
man, almost 20% of the people who visit w3schools are still using IE... Just goes to show the sorts of people that site attracts
 
here is actually article about that teddziuba.com/2011/12/process.html :P
 
@TravisJ Who says it's broken?
 
It doesn't support IE8 and below
 
@TravisJ Actually no. You have to know too many tricks. The trick is to just leave stuff out that doesn't work.
 
@TravisJ I don't care. If you want to support those then you shim it
 
8:39 PM
@adscriven - Graceful degradation is important in those scenarios
 
@TravisJ Handicapping yourself because some people still use outdated tech is stupid
 
@david - If I? lol. Not about me. It is about good business.
 
Sometimes business needs a kick up the arse.
 
@david - If you want to code to ignore millions of users then go for it.
I will gladly take them.
 
do you even have millions of users altogether
 
8:41 PM
Okay then, you take your millions of users, with your shitty codebase, and I'll take my billions, with a clean codebase
 
@Esailija - What do you suppose 10% of internet users accounts for?
 
I think Travis meant your billions + his millions.
 
Obviously you are not going to get 100% of that.
Yes ad, but it is obvious when you are dealing with people who are not used to business to have their numbers off.
 
It's all a balancing act.
 
It's also obvious when you're dealing with someone who has no idea about programming
 
8:43 PM
I agree. That is why I don't use canvasing even though it is awesome.
@david - All you deal with is front end.
No wonder you miss the whole picture
 
(c). All of the above.
Changing the subject ...
Has anyone here used PhoneGap?
 
No, although I have heard this works (untested) <input type="file" accept="image/*;capture=camera">
And that will work from a browser on supported devices
 
Well, I've heard lots of things! I was wondering if anyone has used it in anger though.
I suppose a better question is how easy is it to deliver mobile apps with a roughly native app feel using a browser.
I guess I'm talking from a UX perspective. I know what PhoneGap is capable of in terms of geolocation, storage, camera, etc.
 
That suggestion I pasted was the only option I got from a bountied question. However, I was working on a different project by the time it was made.
 
Oh okay.
 
8:56 PM
I always wanted to go back and implement it to try it out, but haven't had time.
 
And yes, I didn't really mean PhoneGap. I meant libraries such as Sencha and jQuery mobile.
 
jQuery mobile is a joke...it is the same as <input type="file" />
never tried Sencha
 
<input type="file" /> is epicly awesome .
 
I'm not that bothered about jokiness, just the end result. Is the browser viable for native-feel apps, or is there too much pain involved and should I just go native?
 
it would be even more awesome if it worked like it should.
 
9:01 PM
@rlemon - I agree. It works really well when it isn't breaking.
 
having used jQM... I don't really see the benefit. it's like a designer lib for mobile. "Hey! you don't even need to write Javascript anymore! Everything is instantiated on load and parses the entire DOM for attributes (Which is effing epicly slow) "
 
Hrm.
 
@adscriven - I feel the same way, I have made a couple native apps to couple with a web app and not been that satisfied at the time it took to make the multiple creations versus just one centralized web app. The hardest part to me is the picture capturing.
 
jQM is a horrible hunk of crap. even if I take the position that jQuery is not bad... I would still think jQM is garbage.
 
Well, I need to target multiple platforms and be fast. That's why I've had a look at PhoneGap.
 
9:03 PM
anyways. time to go home and Diablo III away my days worries.
 
@rlemon what level/class are you?
he's gone... i bet he is playing a witch doctor
 
9:22 PM
@rlemon You speak here all day long, and at 5:20pm ' time to go home '. Can you tell me again what your job is ?
 
Professional troll
 
someone give me a javascript thing to do, a game anything text based.
I wanna see if I can do it
:-)
 
text based? no canvas?
 
@david alll text based
just something different
 
can it be graphical text? When I was in my teens I made an ascii game where letters would fall from the top of the screen and stack on top of each other
and you controlled a smiley face, and you had to dodge the falling letters
and jump on top of them
 
9:33 PM
@david lol did u look at my baseball game? :-P
 
nuuu i missed it
 
I want to make another self playing game
i just need an idea
 
ohhh okay
 
doesnt have to be a agame
just something that goes on its own that is different every time
 
make something that spits out random words
that are pronounceable
 
9:34 PM
@david oooo I think ill make wheel of fortune
or hangman
ill make it playable, but all with native javascript
NO LIBRARIES
w00t
I shall be successful :-)
Here is my starting code: jsfiddle.net/maniator/H5LKy
This is where it will diverge -- all who want to fork it -- go for it ^_^
 
i made hangman! it was fun
 
@david hence I am making Wheel of Fortune (and you can too :-D)
 
I am having mega problemos with innerHTML in IE
Trying to replace a read-only </tr> field
Anyway around it?
 
I refuse to acknowledge ie anymore
 
9:49 PM
Im at that point
 
I'm lucky that I work in mobile, the device browsers are pretty conformant
 
I built amazing solutions that work seamlessly in Chrome, FireFox etc, but never in I.E, just neve.
 
apart from position:fixed ><
 
 
1 hour later…
11:06 PM
@DieVarDump i like to keep the chat open in my second display
 
It was a troll.
 
11:49 PM
Everything is a troll
Like this: dev.twitter.com/discussions/8067 "if i am aloud can i please have the twitter html folder."
 

« first day (586 days earlier)      last day (4360 days later) »