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

12:39 AM
Hi. How can I surround any matching word with html tag. For example I have a paragraph <p>this is a paragraph</p> and if the keyword is 'paragraph' it's going to replace the content to be like this <p>this is a <span class="highlighted">paragraph</span></p>
 
 
1 hour later…
1:57 AM
Hey guys would you know how I could get the same result as the code

xmlhttp.open("GET","Distributome.xml",false);
xmlhttp.send();
if (!xmlhttp.responseXML.documentElement && xmlhttp.responseStream)
xmlhttp.responseXML.load(xmlhttp.responseStream);
xmlDoc = xmlhttp.responseXML;

Using the HTML5 files API. Instead of reading from the server I wanted to read from the user
 
 
2 hours later…
4:06 AM
can some one explain why this:
		alert(result);
		if(result){
                   document.write='true';
                }

writes true when i alert it - it says 0
 
is result === "0"?
 
that mean non numeric?
wouldn't that equal false?
 
a string containing the character 0 would be true
 
ah
ok its in string format
 
if you do "0"*1 that would be false
 
4:09 AM
so PHP always returns data as string ?
 
im not sure, been a while since I used php, but I think you can return numbers
using "123"*1 will give you numeric 123
 
//Browser Support Code
function call_data(url,data){
  if (window.XMLHttpRequest) {
    AJAX=new XMLHttpRequest();
  } else {
    AJAX=new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (AJAX) {
  querystring = "?dta="+data;
     AJAX.open("GET", url + querystring, false);
     AJAX.send(null);
     return AJAX.responseText;
  } else {
     return false;
  }
}
thats the function that returns the php result
im guessing it defaults to strings and not numbers by default
 
ah yes, respone text will always be a string, I had assumed you were using some form of json parsing
i mean AJAX.responseText
 
i dunno google found me that function ^
would json_encode(0); in php return numeric?
 
is it always a numeric value that you are wanting?
 
4:14 AM
no
some times i send back json encodes of arrays
 
is there a reason you are not wanting to use jQuery?
 
trying to achieve this without a library
i learn more that way
 
you could check if result is a number using isNaN(result)
//Browser Support Code
function call_data(url,data){
if (window.XMLHttpRequest) {
AJAX=new XMLHttpRequest();
} else {
AJAX=new ActiveXObject("Microsoft.XMLHTTP");
}
if (AJAX) {
querystring = "?dta="+data;
AJAX.open("GET", url + querystring, false);
AJAX.send(null);
return AJAX.responseText;
} else {
return false;
}
}
oops
was trying to edit that
result = AJAX.responseText
 
i just used parseInt
 
return isNan(result) ? result : result*1
 
4:20 AM
for when i need the reply as a int
hmm.. is your way better than parseInt(result); ?
 
parseInt("abc") gives you NaN
 
well yeh but the php script it calls - only returns boolean 1 or 0
also is NaN == false?
 
yes
 
thats okay then :P
 
if you are using a generalize function to hit multiple end points which may return a numer string of a JSON array it may be better to use my method, otherwise you can use your approach after you return your result
 
 
1 hour later…
5:35 AM
hi
anybosy is there?
anybody*
 
5:51 AM
@rlemon , @FlorianMargaine so far :-) [though i feel i should somehow mark what the heck is each meter showing ]
 
6:44 AM
hi everybody
why does almost noone answer with event bubbling? stackoverflow.com/questions/10726063/…
 
dk
and hi Florian
am dwnloading git atm on windows :-)
 
cool :)
 
do you mean event delegation ? :P
 
Florian / Esailija any suggestions on how to show whats the circle meter showing in the image ?
 
6:50 AM
i tried to write em but doesnt looks good :-( , the top circle shows the Ram usage the bottom one shows battery life
 
battery life in degree celsius?
 
Nah that temperature
lol its dual display
 
it's kind of verbose to do without library
 
the central value is different :-)
 
you need to do .closest() and then check tag name
or well, .closest("li")
 
6:52 AM
uh?
what are you talking about?
 
The 1st - inner blue circle shows Ram usage , the text inside shows CPU usage
2nd - Inner Blue circle shows battery usage , the text inside shows core temp
 
event delegation being verbose without any library
 
oh
well if you know the ul's id, not so much
@Abhishek how does jarvis do it? :p
 
You really dont wanna see it (XD)
 
here is what you need to do at very minimum
onclick = function(e) {
var ev = e || window.event,
	target = ev.target || ev.srcElement,
	elem = target;

	while( elem && elem.tagName !== "li" ) {
		elem = elem.parentElement;
	}

	if( elem ) {

	}


};
 
6:55 AM
It assumes Tony understands everything
and just shows circles and circles
 
why don't you do the same? :)
 
Good idea :-)
thats what i am doing (xD)
 
@Esailija parentElement? Is that cross-browser?
 
I don't think so
 
then why do you bother with cross browser target? :p
 
6:57 AM
I dunno
 
and I'd rather check for === "ul" than !== "li"
 
By the way
Windows - Git is awesome!
 
well yes it would save some looping time
but it's not robust
you want to check if elem === this then you have looped too far and the target didn't match
 
yeah, but btw this can be avoided with proper html (an id on the ul)
that's what I was originally thinking about
 
function delegateListener( selector, fn ) {

	return function(e) {
		var elem = e.target;

		while( elem && !elem.matchesSelector( selector ) ) {
			elem = elem.parentNode;
			if( elem === this ) {
				break;
			}
		}

		if( elem === this || !elem ) {
			return;
		}

		e.currentTarget = elem;
		return fn.call( elem, e );

	};

}
Element.prototype.addDelegateListener = function( selector, type, fn ) {
	return this.addEventListener( type, delegateListener( selector, fn ), false );
};
I will make a jsfiddle :P
 
7:04 AM
I was just thinking about something like

ul.onclick = function( e ) {
    var target = e.target;
    if ( target.tagName === 'LI' ) {
        // do something
    }
};
 
hmm
the e.currentTarget is read only
so I'd need to make custom event object anyway
if I'm making custom event object, I might as well normalize all the properties
 
remaking jquery?
:p
 
If I'm doing that, I'm reinventing a popular library you might know about...
:D
 
lol
 
looks like ajex is becoming a common term stackoverflow.com/questions/10732826/…
 
7:16 AM
:D
 
o/
 
here's the jQuery loop for event delegation
jqcur = jQuery(this);
jqcur.context = this.ownerDocument || this;

for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {

    // Don't process events on disabled elements (#6911, #8165)
    if ( cur.disabled !== true ) {
        selMatch = {};
        matches = [];
        jqcur[0] = cur;
        for ( i = 0; i < delegateCount; i++ ) {
            handleObj = handlers[ i ];
            sel = handleObj.selector;

            if ( selMatch[ sel ] === undefined ) {
                selMatch[ sel ] = (
 
 
it's mostly optimizations it seems
 
7:21 AM
my brain isn't working properly yet, cleary time for coffee -.-
 
in my naive version, If I add 2 delegation listeners to an element, the loops will be done twice
if I have 20, I will have 20 loops
while jQuery will do all the delegations for one element in that single loop
good to know
 
yup, jquery has some nice quirks.
 
see also this optimization
handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel )
if the selector is .className tagName or #id , it can do very quick check if it matches
where as if your selector is something like ".lol.troll:nth-child(E=MC2)" it will use .is()
I imagine that is also a lot faster than doing .matchesSelector on everything
so there is 2 substantial optimizations in jQuery event delegation
 
hm, interesting
is .context something lying in the prototype-chain of a jQuery - object?
 
it's a direct property
like if you do $( document ).find( "div") the context is document
 
7:35 AM
yep, but why are they setting it in your code-snippet?
 
probably because of is() might be called
	is: function( selector ) {
		return !!selector && (
			typeof selector === "string" ?
				// If this is a positional selector, check membership in the returned set
				// so $("p:first").is("p:last") won't return true for a doc with two "p".
				POS.test( selector ) ?
					jQuery( selector, this.context ).index( this[0] ) >= 0 :
					jQuery.filter( selector, this ).length > 0 :
				this.filter( selector ).length > 0 );
	}
 
mhm.
there's this one thing that I'm sure is absolutely trivial, but i can't get my head around it right now
you got a jQuery-object with all it's functions and properties like, f.e., context
how is it possible then to access elements like you would do in a array?
 
f.e ?
 
for example
 
well they are just properties with a number for the property name
$("div")["context"] === $("div").context
$("div")["0"] === $("div")[0]
you cant do $("div").0 though
 
7:40 AM
@Esailija , seems like a really bad idea
 
hm, i already guessed they do it like that
 
the return statement should not take up more then two line ... it becomes really hard to read
 
@tereško which one exactly
oh yes the ninja style of code
 
thanks @Esailija :)
 
I agree that the ninja style has gotten out of hand in that method
 
7:42 AM
and the "force boolean" is kinda bad too
@Friend, your caps-lock key has stuck
 
!!selector && should be same as selector &&
as anyone writing !! should understand
but it's really a minor brain fart imo
:P
 
@tereško hehe Yeah
:P
 
return result == null ?
    type === "!=" :
    !type && Sizzle.attr ?
    result != null :
    type === "=" ?
    value === check :
    type === "*=" ?
    value.indexOf(check) >= 0 :
    type === "~=" ?
    (" " + value + " ").indexOf(check) >= 0 :
    !check ?
    value && result !== false :
    type === "!=" ?
    value !== check :
    type === "^=" ?
    value.indexOf(check) === 0 :
    type === "$=" ?
    value.substr(value.length - check.length) === check :
    type === "|=" ?
    value === check || value.substr(0, check.length + 1) === check + "-" :
return statement taking 20 lines ^^
 
and unreadable...
 
"man this is gonna be some ugly else ifs, I need to hide it under unreadable terseness"
"ah, no else if soup, much better"
WAAIT
 
7:49 AM
#wtfjs https://github.com/jquery/sizzle/blob/master/sizzle.js#L864-884 #wtfjquery
 
can i has switch(result) ?
 
it's a fucking parser, it should have a lot of else ifs / switches whatever
 
i find switch statements at least readable
 
@FlorianMargaine it's actually wtf sizzle but yes :D
funny coincidence that raynos tweeted it 3 days ago
 
7:51 AM
it can also be replaced with an object
{
 "!=" : function(){},
  "^=" : function(){},
etc..
}
 
it can be replaced by a lot of more readable things
now, maybe the reason is performance?
 
true, but is that really necessary?
 
I doubt ternary operator is significantly faster than alternatives
it's still if elseif logic but in a terse form
 
have you heard of Yahoo Axis?
 
It's a browser within a browser.
We have to go deeper!
 
7:56 AM
it's standalone on mobile devices?
 
Not sure, but surely seems so.
 
peeks into the room
 
Who's there?
 
@OctavianDamiean o/
 
'ello there.
 
7:58 AM
how are you?
 
Fine fine. How are you guys?
 
in twitter, can I see all replies made to a tweet
 
tired, at least until the espresso starts to kick in. but other than that, fine
 
entered summer mode
Hence me being online just sporadically.
 
Turns on Air Conditioner
with cryophysics addons
 
8:03 AM
I wonder how many thousands of libraries of this kind there are github.com/rassie/jessie
 
so, what exactly is Linux Mint?
it's Ubuntu with some added bling ?
 
Sam
Morning guys
 
@GNi33 it's ubuntu without unity :)
 
I can't figure out if justusejquery.com is meant as a joke... Seems to be.
 
ah, so they just replaced the UI ?
 
8:10 AM
basically yeah, they're following ubuntu updates and replacing unity with gnome 3
 
@freeall make a guess
> Don’t want to use that pesky CSS?
what do you think?
 
Sam
I hate css :p But there is no way around it
 
CSS is just great
 
you hate css? why are you web developing then?
 
there's a way around it, it's called flash -.-
 
Sam
8:13 AM
@FlorianMargaine CSS is is only a small part of developing a site
 
or even silverlight
 
only a small part?
 
depends on which end of developing a site you are working
 
Sam
Mainly backend personally
 
@Sam explain why you hate css
before i annihilate you
 
8:15 AM
then CSS is very small for you, just like JavaScript I guess ;)
 
Sam
The cross browser inconsistencies, and the vendor prefixes mainly @Abhishek
 
@sam thats no reason to hate CSS
seriously no reason
 
cross browser inconsistencies is more a reason to hate JavaScript and the DOM :D
 
talking about cross -browser incosistancy try the <audio> element its highly inconsistent among nearly all browsers
 
highly inconsistent?
 
8:16 AM
so then you will end up hating JS & DOM & HTML 5 & CSS
 
you just don't use audio that often
 
it's crap at the moment, i can't say it any different
 
way less often than the dom, for example
 
@freeall , yes , it is a joke
because most of serious web developers are aware oh how bad the jquery community is
 
@FlorianMargaine did you work with the audio-api ?
 
8:17 AM
nope
 
@GNi33 -::

iOS :: runs as quicktime , no volume bar control via JS
Android :: Does work on 2.3.6 but has no codec support
3.0.0+ works but can hang
WindowsPhone :: You know it :P
CHrome :: supports most
Firefox :: I dont understand wtf is mp3
IE :: Supports everything but see the memoryusage
Opera :: Supports
 
it's just acting insanely stupid, really
 
@GNi33 which audio api? moz-Audio , web-Audio or the Jussi's AudioLib.js ?
 
it's different on every browser
 
Sam
@Abhishek That is not true, using the jQuery library takes care of most(all?) of the JavaScript problems, and yes, html 5 i agree with but i don't use it at the moment because of the cross browser problems
 
8:18 AM
@Abhishek that's the main problem
there's not even a consistent API, not talking about implementation
 
@GNi33 i ended up with using <audio> element
and generating audio at node.js server
kinda very bad solution but best at my turn
and also @GNi33 the funniest bug in webAudio api , when you load a song via audio element it will never load the samples :P
 
soundManager is good for that, but it mostly falls back to Flash wherever it's available
 
all buffers will be empty
 
@Sam there css frameworks for that too
 
Gni33 is there a way i can get audiobuffer from soundmanager ?
 
8:19 AM
you know, bootstrap.
 
and encode it to mp3 ?
@FlorianMargaine are you kidding me ?
i thought jQuery UI was good
 
for cross-browser css stuff? bootstrap is good come on
 
i'll have to say that I really don't know
 
[/joke]
 
oh come on
 
8:20 AM
I didn't say anything about the js lib it uses, just the css parts
 
cross-browser - css isn't that bad
 
yeah i know i was just picking on you bro
 
when we'll drop IE7 support - yes
 
@GNi33 its okayish unless you create a masterpiece in Chrome and your boss opens it on IE 8
 
IE7 is a dick
 
8:21 AM
you are disrespecting males
 
axis looks cool
 
but I worked a lot with it up to now and most problems can be resolved pretty easy
a lot of problems occur because of bad markup
unless you are doing right-to-left - layouts
that stuff is crazy on ie7
 
yep :)
IE7 just sucks with floats
 
elements jumping around wildly
yep, it sucks with nested floats
IE8 is a lot better regarding this (did i just really say that?)
 
seriously, IE8 about css is ok
and about js, IE9 is really ok too
 
8:25 AM
yep, but putting IE and lot better in one sentence, it just feels weird
 
once we'll drop IE8 support, this will just be awesome
so much available...
 
yes, in 30 years /o/
 
starting and Element stuff, addEventListener, etc...
 
IE9 sucks too because of it's lack of CSS Transitions
 
css transitions are not essential
 
8:26 AM
ie9 is still pretty lacking
 
but okay.... no fancy animations for IE - users, sorry. i'm not going to fallback to js again
 
The only good thing by microsoft for internet is
nothing else
IE 10
 
no file api, no transitions/shadow, no websockets
yep not using javascript animations either
 
JS animations sucks!
 
yes, it's a half-finished browser without auto-update -.-
 
8:27 AM
yea chrome's auto update is brilliant
 
@GNi33 its half-finished versions are very great
 
you basically never worry about earlier chrome versions
2
 
:-)
 
it cannot be said for any other browser
 
init
chrome rocks!
Firefox has something like that aswell now
 
8:28 AM
yes. i believe auto-update is one of the essential features that drive the web forward
 
opera shows a message to upgrade when needed
 
so even if chrome is ie6 of 2010 decade, in 2020 people aren't stuck using the 2010 version
 
Firefox is very okay regarding this
 
firefox is now dieng :P
recent versions of firefox are highly slow with transforms :/
 
but with firefox you still have people using firefox2, 3, and 3.5 :/
 
8:29 AM
3
Q: Which algorithms are available to solve Tic Tac Toe?

silentbangWhat algorithms are available to solve Tic Tac Toe? Especially with board size 4 * 4 or bigger instead of 3 * 3? I tried 4 * 4 with Minimax & alpha-beta pruning but the pc seems to hang and throws exceptions on stack overflow. I saw these source code written in javascript but I don't know wh...

 
oh gods
FF2/3 is the opensource IE6
 
teresko ?? whut up ?
oh yes
 
they where even worse then FF1.5
 
yes, they were bad, really bad
but usage statistics are so low, i really don't care about them
 
yes , we usually dont
its like with Opera 8.x or IE 5.5
the userbase numbers are so low, that they can be put down as statistical error ( caused by bots which fake user agents )
 
8:34 AM
probably the next gen web developers will read / be taught legends about how developers survived the era of the internet explorer
 
G'mornin' errrrrr1! \o
 
\o
 
how to add more than one break in css code is here pastebin.com/HVb3GGRg
 
@Relax , that looks like a list
 
replace p with ul
 
8:36 AM
ans should be marked up as such
 
and span with li
 
ok will try
 
I mean that doesn't solve the problem I think, I don't understand your problem
what is a one break in css
 
@Esailija I want to print like this pastebin.com/Sgjw8Y3F
 
8:40 AM
@Relax , do you want as specific space under each item , or do you want a fixed height ( not influenced by how many lines of code you have ) ?
 
@Esailija Thanks
not a specific space, but according to my requirement
 
what ?
 
@tereško means space between Li is not fixed
 
0
A: convert a string to javascript object

Esailijavar str = ":All;true:Yes;false:&nbsp"; var listItems = str.split(/[;:]/g).map( function(v, i, arr){ return i % 2 === 0 ? {itemValue: v, itemText:arr[i+1]} : null; }).filter( Boolean ); Result: [ Object itemText: "All" itemValue: "" __proto__: Object , Object itemText: "Yes" it...

wow wow wow
@Esailija you're in fire today :p
 
@Relax , then you should be setting a height, not a margin-bottom
 
8:47 AM
@Esailija what's the .filter(Boolean) for?
 
it returns null from the mapped array
I mean removes
because every other item will be null
 
every other item?
 
!!> var str = ":All;true:Yes;false:&nbsp";str.split(/[;:]/g).map( function(v, i, arr){ return i % 2 === 0 ? {itemValue: v, itemText:arr[i+1]} : null;});
@Esailija SyntaxError: Unexpected identifier
!!> var str = ":All;true:Yes;false:&nbsp" ;str.split(/[;:]/g).map( function(v, i, arr){ return i % 2 === 0 ? {itemValue: v, itemText:arr[i+1]} : null;});
@Esailija [object Array] [{"itemValue":"","itemText":"All"},null,{"itemValue":"true","itemText":"Yes"},nu‌​ll,{"itemValue":"false","itemText":"&nbsp"},null]
 
@tereško but this time i want fix gap in between li
 
8:50 AM
!!> var str = ":All;true:Yes;false:&nbsp" ;str.split(/[;:]/g).map( function(v, i, arr){ return i % 2 === 0 ? {itemValue: v, itemText:arr[i+1]} : null;}).filter(Boolean);
 
but this not works for me
 
@Esailija [object Array] [{"itemValue":"","itemText":"All"},{"itemValue":"true","itemText":"Yes"},{"itemV‌​alue":"false","itemText":"&nbsp"}]
 
code
 
see, no nulls :)
 
where are they from?
 
8:51 AM
it's same as filter( function(v){
return !!v;
});
from the mapping funtion
the original array has 6 items, we need 3
so every other is null
 
oooh since it's 1/2 ok ok
heh, nice technique to remove null from an array
 
@Esailija your code is not work for me any other idea
 
the problem is that map always results in same length array
so we mark empty items by null and filter by Boolean
 
yep yep, map performs calculation on every member
but that's good to know arr.filter(Boolean) === no null
 
it removes all falsy values from array, it's very useful yes
in the series of map( Number ), filter( Boolean ), map( String ) :D
 
8:55 AM
map( Number ) only returns number?
(trying it...)
oh no, it parseInt() every member
or rather, new Number()
 
it's parseFloat on every item
!!> ["0.5", "0.235", "5"].map( Number );
@Esailija [object Array] [0.5,0.235,5]
@Relax what code
 
!!> [ '0.5', '3', '3h', 1, 2 ].map( function( n ) { return new Number( n ); } );
 
@FlorianMargaine [object Array] [0.5,3,null,1,2]
 
12 mins ago, by Relax
@tereško means space between Li is not fixed
8 mins ago, by Relax
@tereško but this time i want fix gap in between li
@Relax , please , make up your mind
 
8:59 AM
!!> [1, 2, '3', 'hi', 3.4, '3h'].map(Number)
 
@FlorianMargaine [object Array] [1,2,3,null,3.4,null]
new Number and Number are very different though
 

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