« first day (752 days earlier)      last day (4421 days later) » 

00:16
0
Q: Simple DOM mutation abstraction

DaveRandomBackground: I need to use mutation observers to watch for nodes being added/removed under a specific element. The code below is an attempt to implement something re-usable that uses MutationObservers where available and falls back to mutation events where not available, providing a simple unifie...

 
1 hour later…
01:44
I'm looking for a list of JavaScript books with excellent reviews (not Amazon.com reviews, but real JavaScript experts). Beginner level. Can anyone point me to a list, or to two or three great books?
Some books:
http://eloquentjavascript.net/
Maybe Professional JavaScript For Web Developers - Nicholas C Zakas, the reference I used to find it: reddit.com/r/javascript/comments/e54i9/…
This link has some more recommendations / discussion: reddit.com/r/javascript/comments/12igi7/…
@wrhall Thank you.
02:00
@DiscreteGenius no problem! I hope that helps!
@wrhall Eloquent JavaScript looks promising, I'm sure I will enjoy that one.
02:47
Don't forget Crockford's Javascript: The Good Parts
03:25
@DiscreteGenius also, you might find these lectures as good supplement for that book : yuiblog.com/crockford
 
1 hour later…
04:40
Hello
04:59
@Zirak I'll tell you how I got to the conclusion after you tell me if I was right :p
i want a top navigation menu for mobile. That should scroll like normal slider horizontal for mobile website. Is there such one in jquery mobile
will this always work?
 <div>last inserted div</div>
 <script>$('div').last().css('color', 'red');</script>
05:53
any one knows Binary Subtraction
???
 
2 hours later…
07:39
-3
A: How to get variable from the json response in javascript?

Kir IvlevYou need to use the eval function to convert json to object: responseText = {'page':'2','endOfPage':'yes','content':'abc'}​​​​ var responseObject = eval(responseText); alert(responseObject.page);

so many bad answers in there.. (including at least one candidate for just being crap/bad and thus not really fit for a mod delvote)
08:00
@Zirak I have seen it :p
08:18
@ThiefMaster with 3 close votes and an obviously bad question, you can't close?
o/
ah well those votes weren't there earlier
@GNi33 o/ how are you?
fine, thanks. How about you?
fine too
@ThiefMaster might interest you github.com/Ralt/vim-modes
08:28
have been shown yesterday that you can map your scss files to your css-files so they are shown in the dev tools in chrome canary
the mapping part is still pretty ugly, but other than that i think that's just great
yeah, I might finally start it :p
I just released a vim plugin, I need to work on it to use it now :D
@ThiefMaster I might be interested in contributions for this project :x like, new modes
hm, i usually simply use a single autogroup line for that
an autogroup line?
08:35
au FileType python	setl expandtab smarttab sw=4 ts=4 sts=4 tw=100
etc
ah... all your python projects have the same settings then
08:47
true, but i could also set stuff by path
... or you can simply use my plugin! :D
well, not yet.
it kinda sucks right now
anyway, that's something i'd certainly expect in something like your plugin: either a config file or another easy way to specify the mode
enabling it manually is not really a good option
but at some time, just place a .project file at the root of your project with the name of it and bam
yeah
45 secs ago, by Florian Margaine
it kinda sucks right now
^^
Won't .project collide with eclipse? Maybe .vimmode or something like that.
yeah maybe, haven't really thought about it yet
.mode might be simple enough
well
vim scripting feels like bash
in worse
09:03
-1
Q: How to print array value ('value1', 'value2' ) in php for javascript

SaleemI have array with month and i need to print only values as 'Oct', 'Nov' echo implode(', ', $months); I tried implode but got the values as Oct, Nov I need these to be like 'Oct', 'Nov' Any idea how can i go this?

oh my. does nobody know about json_encode anymore?
anyone with bright ideas? :)
fix the typo and actually call the function that binds the event
grr typos will be my doom. Thanks champ
Hello, I am trying to use the Amazon API for searching for prices given category and a name (which could even not be exactly the same) without using PHP
I could consider having a client-side page which just redirects the result of a query if the API returns a JSON object, so that I can use jQuery for getting the info
09:19
@AndersMetnik you might like this jsfiddle.net/Ralt/anFzH/1
Thanks wasn't sure :)
Btw @Florian, is there a way to get the dom object from jquery object? :)
@AndersMetnik jqueryObject[0]
Opera 12.10 went final yesterday... hm, well i'll give it a try
guys why if([] == false){ // this code runs} this code runs ?
[] is an array
where can i read about this /
ECMAScript specification.
I think it uses its string representation which is the empty string
an even better WTF is that [] == ![] is true
this is easy. the [==] operand doesnt work on falsy / truthy
only the [!] affect here
09:32
== calls the internal toString - method of the Array if i'm not mistaken
it's a WTF anyway
as there's no content in the array, this results in an empty string which is false by spec
so []== (not (true))
[]== false
(and here im asking the question again)
:>-)
an array is never true in a boolean context though, even if it's empty
+1 GNi33 thanlks
09:33
!![] === !![1]
ah nevermind, misread @GNi33's message
thanks Thief master and Gni.
wait , [0]==false //true
if its toString so its '0'==false which is true
hm, let me check that
gni - if it always convert tostring so it is ok
In Chrome console:
[].toString() == [].toString()
true
[] == []
false
09:37
Boolean([]); // true
!![]; // true
Boolean([1]); // true
!![1]; // true
Seems to always be true...
@FlorianMargaine now im completely lost
what the hell, now this is weird
(sorry for asking you such dumb questions but it is interesting me)
hi
Karnaugh Map Manipulations HELP
anyone ?
-1
A: Too many clicks jQuery

Paramaeleonjavascript provides an eval() function. This is untested, but it should be something like: for(var i = 1; i <= 5; i++){ eval("$(\".click" + i + "\").click(function() {$('.input').attr('name', 'name" + i + "'); });"); }

09:39
@FlorianMargaine hm, i'm pretty sure .toString should be called there, but this puzzles me now
piccardfacepalm.jpg
@GNi33 heh..
He provided an untested answer using eval. I'd be willing to bet if javascript allowed gotos, you'd see those in his answer too
@FlorianMargaine explain !!!!!!!!! :-)
13
Q: Conflicting boolean values of an empty JavaScript array

Matthew ManelaCan anyone explain why the following two statements both evaluate as true? [] == false and !![] This question is purely out of curiosity of why this happens and not about how to best test if an array is empty.

09:41
no , i want to know why []==[] is false
the linked document example dosent say so
yes, but it gives a little more insight on the topic
waiting for florain......
If Type(x) is the same as Type(y), then
09:42
:D
Return true if x and y refer to the same object. Otherwise, return false.
so ({}) == ({}) also returns false
thanks Florian :-)
but it's the last case, there are many other things to do before that
var a = [];
var b = a;
a === b; // true
so, it depends if it's converted to String or Number
09:44
Javascript basically doesn't do equality testing for objects?
I mean, it does, but it tests by reference I suppose?
yep :)
@GNi33 nah, it depends on the types of the two objects
yes, that's what i meant to say
me and my english...
javascript tests arrays though, doesn't it?
09:46
11.9.3 is pretty well written
@Neil what do you mean?
that is simply a short-circuit test for equality.. if a[0] == b[0] and a[1] == b[1] etc.
If x is +0 and y is −0, return true.
If x is −0 and y is +0, return true.
hahaha
I just realized that I don't know the answer to that question.. now I'm going to have to test it
@Neil ah, there is no quick way to check whether two arrays are exactly the same
same elements or same reference ?
09:48
you have to use some recursive function, taking all the cases into account
@RoyiNamir same elements. same reference is shown with ===
or even ==
why not using JSON.stringify(arr1)==JSON.stringify(arr2) ?
@FlorianMargaine jsfiddle.net/wkchb
That seems counterintuitive to me
apparently javascript tests by reference like objects
yes, for objects
not for primitive values
Array.prototype.compare = function(subject) {
  for (var i in this) {
    if (this[i] == subject[i]) {
      return false;
    }
  }
  return true;
};
[].compare([]); // false
Why doesn't that work ^^
09:50
@Neil there is a quick way jsfiddle.net/Ralt/wkchb/1
I see why you wouldn't test equality of objects, but testing equality of arrays seems like you'd always want to test an array's contents and not reference
> Opera now supports Flexbox
@DaveRandom this[i] != subject[i]
Oh duh.
@Neil well, an array is an object
@DaveRandom but that only works for simple arrays
09:51
@FlorianMargaine Smart. I wonder if that's faster than comparing each item one at a time
@FlorianMargaine JSON.stringify(arr1)==JSON.stringify(arr2) wont be good ?
probably not though now that I think about it
@FlorianMargaine As in only works with scalar values?
@DaveRandom ([{}, 2, 3]).compare([{}, 2, 3]) won't work
09:51
@RoyiNamir it won't stringify functions
were talking abou arrays no ?
yes... so?
[function() {}] is perfectly valid :)
first-class functions...
why you are always right :-( ?
:-)
and it's very much used when using deferred object for example
but yeah, that's why I said this v
5 mins ago, by Florian Margaine
you have to use some recursive function, taking all the cases into account
@FlorianMargaine Actually even by flipping the comparison type it doesn't work if subject has more elements that this, you'd have to check .length matches as well.
09:55
1
A: Async template loading - How to load it only once?

ManaguPerhaps keep a backlog of work that needs to be done once the template is loaded? Basically a queue to smooth over the impedance mismatch caused by asynchrony. var template; var backlog; function render(note) { if (template) { // Template already loaded, just display. displ...

@DaveRandom yeah that'd throw an error, but well at least it doesn't return true :p
room topic changed to JavaScript: If you have a question, just ask it. No need for pinging or asking if you can ask. Best regards, Horse Lime. #wtfjs [] == []; // false [crystal-ball] [git] [javascript] [why-is-git-here]
0
A: Too many clicks jQuery

Florian Margaine$(".click1, .click2, .click3, .click4, .click5").click(function() { $('.input').attr('name', this.className); }); Or the fun way (not recommended) if you have an unlimited number (and for whatever reason, don't want to add another class): [1, 2, 3, 4, 5].forEach(function(e) { var f = '$(...

fun way :3
Hah, with javascript there is always a fun (and usually horrible horrible) way of going about it
@FlorianMargaine Just a stupid question from me. Why does he have .click and not #click? :)
heh, downvoted
I didn't do it
although the answer is perfectly legitimate, and even a valid/performant way to do it.
10:08
there, compensated :P
I'm not using eval :(
assisted then :)
haha overcompensated
haha thanks :p
Now answer my question then and earn the overcompensation ;-P
@AndersMetnik #click?!
# is the css selector for id, not classes
10:10
You mean why didn't he use id="click1" id="click2", etc.?
Ohh so it's classes he is adding the click methods to?
2
A: Too many clicks jQuery

icrewHtml: <a class=".clickable" href="..." rel="1">...</a> <a class=".clickable" href="..." rel="2">...</a> .... JS: $('.clickable').click(function(){ var _id = $(this).attr('rel'); $('.input').attr('name', 'name' + _id); });

Well no, he's adding the click methods to the objects, but he's using classes as a handle to do so
anybody sees why it's wrong?
didn't know that . was class selector :)
10:10
(2 upvotes...)
which incidentally, would have been far better to use class="clickable"
if you use classes like ids, it loses it's advantage
nah
the html is just plain wrong there
So jquery can multiselect ?
hello everyone
multiselect?
10:13
@AndersMetnik Yeah, that's one of its biggest features :P
can anyone help me with a problem i got with my radiobutton in my asp.net site
danm need to edit my code again...
how do i set an item "checked" in my radiobuttonlist
Well I mean you don't strictly have to multiselect
so $(#mainBtn,#profileBtn).click(...method); works?
10:14
yes, that works
Sweet going to change my code to reflect and make it easier on the eye then :)
i'd not exactly recommend it, but oh well...
@SaiefAl-Faour $('input.myradiobuttonoption').attr('checked', 'checked');
Muhaha awesome :)
<Script>
input.radiobuttonlist).attr(checked) ?
10:15
isn't it checked, true ?
@AndersMetnik I would suggest you use ids when you need to select individually and classes when you need to select many objects
@AndersMetnik I may be wrong about that, but I think it has to be checked
Yeah I agree Neil, but first I need something general then I need it specified
@Neil why slow selectors? :(
@Neil why attr()? :(
@FlorianMargaine What would you suggest? :(
$('.myradiobuttonoption').prop('checked', true)
10:18
@Neil Neil it's the radiobutton is a servercontrol
@SaiefAl-Faour Not sure I know what you mean by that
$('.myradiobuttonoption')[ 0 ].checked = true; :(
you rebelz
that was the worst confusion jQuery ever brought up
prop and attr
@jAndy okay, how slow are we talking about?
10:20
Neil, i want the either the first or second item checked from the radiobuttonlist
@Neil: micro, still we totally can avoid unnecessary function call overheads
@jAndy no... it was worse before they brought prop
@jAndy well, .attr is great for shimming data-attributes for grandpa-browsers though
.attr('checked') returned true or false in jquery 1.4...
now it returns "checked" or ""
I guess I would just never use jQuery to access any node property
10:21
<script type="text/javascript" language="javascript">
$('.RadioButtonLis1').prop('checked', true);
</script>
@jAndy it normalizes quite a lot of stuff across browsers though
@FlorianMargaine: give me a headsup
properties like checked, disabled, etc. should not need any normalization
Properties which are NOT safe to access through the DOM directly:
tabIndex (get)
selected (get)
value (get/set, differs a lot between node types and browsers, .val() is really useful here)
innerHTML (quite minor problems, source: quirksmode)
innerText, outerHTML, outerText, textContent (quirksmode)
rowIndex, rows (Opera, source quirksmode)
The rest of them should be perfectly safe.
@jAndy I think good code style has more importance than micromanagement
unless we're talking about thousands of radio checkings
well this one is not working either, what's the problem?

<script type="text/javascript" language="javascript">
$('.RadioButtonLis1')[0].checked= true;
</script>
</asp:Content>
10:24
@GNi33 use data() for this :) way more performant, jquery caches data() as a custom js object instead of using the dom
tried to, had major problems on IE7 with it
major problems -> not working at all
@SaiefAl-Faour: you can't access a dom node directly in script tags, you need to wait until the DOM fires a DOMContentLoaded event (which says, its accessible)
@SaiefAl-Faour: use .ready()
but yeah, checked disabled are safe
10:25
not sure if I screwed up though ;)
@GNi33 really? :/
yep, couldn't get it to work
I think you did yeah :p
looks weird
worked perfectly with .attr
I think I was using 1.7.2 at that time
should work fine :|
10:27
@FlorianMargaine: do you know what they mean with "unsave"
what happens if you directly access tabIndex for instance
don't really know, let me dig into jquery source :p
@FlorianMargaine hehe, just found a comment regarding that in the code
//Bad Internet Explorer, BAD!
@FlorianMargaine: no don't, if you need to lookup yourself don't worry, I'm just curious whats the big deal about it
You're right, I have to hand it to you
never really got why they implemented .props() at all
10:29
It's roughly 10 times faster
// elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
// fluidproject.org/blog/2008/01/09/…
who would have thought there would be such a huge difference?
(jQuery source)
@Neil: well.. 100000 is quite a lot and its still micro optimization
I'm just the kind of guy that thinks like.. "well, why not"
@jAndy Well of course, but logically, it's still a scale of 10 even if I'm performing that operation once rather than 1000000 times
If it's on the order of 2 or 3, I usually don't care unless I'm calling it often
@Neil: it adds up tho.. if you do what we call "micro optimization" to your whole codebase of about couple of thousands lines and/or operations
I'm still standing there and say.. "why not", just do the optimized call if it doesn't harm anything
@jAndy Meh.. the javascript programs I write never have a noticeable slowdown
@Neil that's not the order of magnitude that matters, rather the number of times it's called
gEBI is 20 times faster than $('#')
are you going to use gEBI?
@FlorianMargaine In fact, if it gets called once every 30 seconds, we're talking about something on the order of microseconds gained
10:32
@FlorianMargaine: I doubt that number
@jAndy And you're right, in this case it makes no difference
since jQuery('#') should directly link to gEBI
But what if I selected it using a generic selector, such as with a class
If I was ultimately pulling 1 object, the end result is the same
but the day I add another object with the same class, my code breaks
@Neil: unless you're using some fancy selector, jQuery always tries to query by native methods
otherwise, it kicks in Sizzle which is the showstopper
10:33
solved the problem like this
So that's reason enough, imo, to use the other syntax
@jAndy Well for me, that's like rewriting methods to avoid one having to call the other
ahh lol, was still about the other topic :)
@Neil every 30 seconds? that's like a year worth for a computer...
10:35
@FlorianMargaine Not for a human being though
RadioButtonList1.Items[1].Selected = true;
if (RadioButtonList1.Items[0].Selected == true)
{
RadioButtonList1.Items[1].Selected = false;
}
else if (RadioButtonList1.Items[1].Selected == true)
{
RadioButtonList1.Items[0].Selected = false;
}
In Java, if you have two methods with similar actions and different parameters
Bah, I really hate my university's infrastructure. Switched rooms (i.e. no proper disconnect from the 8021.x wifi ap) => can't login anymore for ~10 minutes because the old session is still considered active
You can have one call the other, adding default parameters
Technically that's slower, since it is another function call
@Neil that's called overriding :-)
10:36
But the alternative means to have two copies of the same code, one with an extra parameter and one without
or overloading?
@FlorianMargaine No, that's not called overriding..
yeah, overriding is for reimplementing the parent method
overloading it is then
Suppose you have methods "printObject(Object obj)" and "printObject(Object obj, String... params)"
no overloading in ecmascript
10:37
@Neil that's called overloading...
you can have two copies of the same code or printObject(Object obj) can call printObject(Object obj, String...params) with params null
@FlorianMargaine no, that's called one method calling another
Overriding is implementing a method from an inherited class
OVERLOADING, NOT OVERRIDING
Ah ok, it's called overloading.. I didn't even know there was a term for it
My point is the same
10:39
did you read the link I just showed? :)
> “Short, concise, and uses obscure JavaScript features” — is that your epitaph? :-)
hahaha
I don't see anything wrong with that
nothing, it's just fun :)
lol.. Resig is a "little bit" out of line by licenzing simple lines of code
saw that somewhere else too
roflmao...
give me the tripple facepalm please
the "somewhere else" was copied from resig? :D
(also, see the comments, it's mentioned)
overloading basicly adds a new method(with the same name) that takes another set of parameters and then does something else/similar.
Overriding is changing an existing methods body.
10:45
7 mins ago, by Florian Margaine
yeah, overriding is for reimplementing the parent method
7 mins ago, by Florian Margaine
@Neil that's called overloading...
but thanks :p
Ahh well :P
Finally I thought I could contribute with something :/
uh, well, don't worry, I can't name the primitive types in obj-c
NSString?
or something like that...
Never worked with IOS and really don't want to, it's soo... weird ;)
ah, thought you had, my bad
what's the language you're really good at?
java?
Android is probably my best
So Java language yes, android environment :9
But I'm in the early stages of my career, sucking out all the marrow I can of everything (except iOS) ;-P
10:54
I want to learn AspectJ
that's like reflection cubed
No idea what either of those are ;)
why are java project websites so ugly?
Because Java is ugly, too!

« first day (752 days earlier)      last day (4421 days later) »