« first day (370 days earlier)      last day (4594 days later) » 

5:36 AM
Well, doesn't this suck. Can't assign a name property to a function...
 
6:07 AM
how can i set the values of select tag i have this two values $("select#Gender").val() and $("#Gender option:selected").text()
iand i have this select tag <select id="gender_new"><option></option></select>
so i have to set it to this tag
how can i do this?
 
@Sparkx Have you tried reading an introduction to javascript? Do you actually know, even just a little bit, how js works and how to use it?
 
i know javascript but not really jquery
 
I'm doubtful, but ok. Read up an introduction to jQuery and use the manual
Your questions so far have been the absolute basics
 
for now just give me solution i will read it 2day itself....
 
No, I enjoy fishing, not feeding people fish
 
6:41 AM
How the hell does cowbell make the returned value look like an array?
It's damned voodoo
 
6:57 AM
@Zirak , if you know javascript you don't need to "learn" jquery
 
Yeah, but it's still interesting. I'll most likely never use it, but such strange voodoo is always enticing (proof of point, perl)
I mean...it's an array-like object, that's easy to do. But to make it look like an array? le fu?
 
@all hello
Look i want to open window browser at click event... it opens fine but i at each click it opens new browser,
 
Remove the listener after the first click, simple as that
 
menas?
 
You added the event listener, right?
That's how a new window pops up when you click. You did that inside the click event listener
So, now just remove it. If you did el.addEventListener then you el.removeEventListener and so forth
 
7:14 AM
my code:
function Validation(){
var i=0;
if(document.netsim.emulatorNo.value=="")
{
alert ( "Please Fiil Emulator Number" );
netsim.emulatorNo.focus();
i=1;
}else {
var emu = document.netsim.emulatorNo.value;
var serverUrl = document.netsim.Apply.value;
window.open('http://localhost:8080/SMSSimulator/NewEmulator.jsp?emulator='+emu+'&ServerUrl='+serverUrl,'mywindow','width=400,height=350');
}
if(i==1)
return false;
}
 
Again, I'll repeat: You added the event listener somehow. You made it so that when the user clicks, Validation is executed.
Now, you want that to only fire once, right? So that when you click the next time, nothing'll happen
 
@Zirak sorry but in jsp how can i maintain onclick event ? if you suggest me or hekp me it will be very fine for mn
me*
 
This has nothing to do with jsp. How do you add the event listener?
0
Q: How does jQuery make the returned value look like an array?

ZirakjQuery(); //[] jQuery("#footer"); //[<div id="footer">...</div>] I know that you can do something like this: function kablam(tag) { var els = document.getElementsByTagName(tag); els.isKablam = true; return els; } var body = kablam("body"); //[<body class="ask-page"&g...

 
how to apply $.fancybox.close on submit button
 
7:38 AM
can i check whether user pressed back button on "onbeforeunload". i have looked on SO but no luk yet
hi @Zirak any idea
if i can catch the back button?
 
but that is when i want to move back through js . i want to know if user pressed the back butoon or moved back someway(using backspace on windows)
 
The answers are in that page
 
ok
 
7:52 AM
@Zirak i m having trouble figuring out. can u give some hint?
 
window.onpopstate
 
ok
 
@Zirak Easy.
var ret = [];
ret.push(shit);
return ret;
 
I'm all ears
 
Hmm you may have a good point though
 
8:02 AM
Yeah, jQuery doesn't do that
jQuery returns itself, or a different kind of Object (by calling find or merge or toArray)
 
Woh what?
 
It isn't that important, as array-like objects and array-look-alike objects function the same...but still
 
Of course it's not an array, it's array-*like*
 
I presume it creates a jQuery object
and copies the array methods in
 
8:06 AM
As said, making array-likes is easy...all that qualifies is .length and numeric indexes (for for loops). But how the blippin hell to they return something that when you console.log it, you think you're looking at an array?
Damned gypsie black magic voodoo. calls John Resig
 
@Zirak is popstate event depracated because i dont find this event in firefox 7
 
Oh that
 
@lovesh The popstate event is an html5 api. The even listener is window.onpopstate (which, of course, defaults to null)
 
jsfiddle pisses me off
 
@Zirak yes i found that working in chrome
 
8:12 AM
I dont know, I dont care why jQuery does that
@Zirak maybe toString hacks?
 
Nope, look at the source
 
No string hacks :(
 
It's ridiculous. I've been staring at the source code for the past two hours, trying to figure out how a plain object looks like an array. f u, jquery, f u.
 
in firebug or chrome?
 
I'd assume everywhere
IE would off course fuck it up, but that's because the IE dev tools are outmastered by a kindergarten's sandbox
Happens in firebug lite, so it'll also be in firebug
 
8:22 AM
@Zirak onpopstate is not fireed when i press the back button or i open some other url but only when i open the page on which the script is present
can u help me a bit more with this
?
 
insertAdjacentHTML
DOM Y U MAKE ME SAD
 
Live example of it
 
@Zirak this is cool thanks
 
@Raynos It was invented by the same guy who invented innerHTML. Blame him!
 
f0x
yay! heres to 10 years of trying to get people out of insertAdjacentHTML
 
8:28 AM
FF8 added console.dir
 
FF finally has Firebug in its core?
 
Well not properly
 
zirak u know how to apply $.fancybox.close on submit button?
 
@Sparkx I'm assuming you attach an event listener to the submit button, and call $.fancybox.close in it.
 
i just write <a id="various1" href="#inline1" title="Lorem ipsum dolor sit amet">Inline</a> for link but i want it on button
 
8:35 AM
Stupid site I sometimes visit started showing an add that scrolls with the page. You can close it but it reappears on the next page. Thank you, user stylesheets! #annoyingAd { display:none; }
 
I would like to have an <ad> tag
Then we can just have ad { display:none; }
 
@Raynos: yeah, they should have had it in HTML 5
 
Which advertising engine in their right mind would use that tag?
 
@Zirak the nice ones
 
ad { text-decoration: blink !important; }
 
f0x
8:38 AM
the stupid ones
 
@Zirak lol
I don't mind ads so much, as long as they're unobtrusive and don't interfere with me browsing a site.
I don't like it when they follow you around though.
 
f0x
hover over the small problem?
their view on adblockers
 
cool. I like this one trolldad.com/comic/5zg48, I'm not chauvinistic but it made me laugh.
 
surprised there isn't a troll dad comic generator yet
It'd be just...4 textboxes. And that's it.
 
already had 70 rep on SO when I got here... might take it easy until this afternoon ;)
 
208
A: Get query string values in JavaScript

Andy ESome of the solutions posted here are inefficient. Repeating the regular expression search every time the script needs to access a parameter is completely unnecessary, one single function to split up the parameters into an associative-array style object is enough. If you're not working with the H...

^ got a mod to un-CW this yesterday
 
@Zirak how to know about fancybox event listener
 
lol stackoverflow.com/reputation shows my rep at 1800 higher than it is now.
 
@Sparkx You obviously don't know how to use event listeners. So, learn about it. This chat isn't the place to.
 
8:49 AM
o
k
 
Seriously @Zirak I ignore these people, why don't you?
 
Because each time I don't, the world is a 1^10^pico better.
 
Why?
 
Because they learn a bit about fishing, and they don't annoy any more people.
 
f0x
except @Raynos :P
 
8:52 AM
And all it took was me saying "lrn2event"
@f0x Yeah but, who cares about Raynos? :D
 
They annoy me to hell >_>
Its like. Here DOM and ES, go and read, then come back.
 
lol
 
You REALLY expect people to learn anything from specs?
 
real men don't read specs
 
If I were to read the specs a bagillion times, I'd had excellent knowledge of how the language works, but couldn't write squat in it. ahem CS classes ahem
 
8:55 AM
I'm implementing Node by reading the DOM4 spec.
 
Specs are great to understand the language, not learn it
 
You may have a point
 
That's what she said!
</trollface>
 
Especially 350 page long specs.
 
@AndyE Real men use their biceps to punch the knowledge out of the language. Together with Old Spice odor blocking body wash, it'll make for 16 hours of odor-free code!
 
9:06 AM
@Zirak look at your code. Back to mine. Now back to yours NOW BACK TO MINE! Sadly, it isn't mine. But if you use Old Spice body wash it could be.
 
@Zirak > How the hell does cowbell make the returned value look like an array?

I can answer this, if you're still interested.

I don't know what cowbell is, but if you're talking about what I think you are, I've done it in the past (for a jQuery-like javascript library) by copying the properties of whatever would normally be returned onto an array. https://github.com/dpth/dpjs/blob/master/src/core.js#L55
 
@SimonChester Yeah, I know it can be done that way. But jQuery doesn't do that (look at m question for even more details!)
 
@SimonChester Cowbell is jQuery. For whatever reason it isn't fashionable to mention jQuery in here (don't ask), so they invented a new name for it
 
@SimonChester jQuery doesnt do that because jQuery doesnt return an array
it returns an object which looks like an array but has jQuery.fn as [[Prototype]]
@YiJiang because jQuery is no good :\
 
Ah, okay
 
9:10 AM
@AndyE Look down. Back up. Where are we? We're in a repository, with the code your code could look like. What do I have? It's a file with that library you love. Now look again. The code is now diamonds!
 
@Raynos Depending on how you got the jQuery object you can get back an array using get()
 
Herp derp question link with explanations: stackoverflow.com/questions/7846193/…
 
-8
Q: How to make a banner out of a javascript?

user1004878I have this script I want to make a 480*60 banner link out of this script. The script is provided below. Is that possible? //************************************************* "body"<BR> "script type="text/javascript" src="http://ity.im/adserver_remote/adserver.js"""/script" "script type=...

 
@Raynos Depending on what you're going to do. If you need DOM abstraction, ajax and effects all at the same time I'd say jQuery is a pretty good fit
 
f0x
hmmm first time ive seen it dip down -5 :p
> Lol, are all the downvotes because this guy is trying to write an ad script?
 
9:13 AM
@YiJiang I guess so, I just think there are better possibilities
however I cant give you a good answer for "effects"
me default answer for effects is y u no css3
 
@Raynos Yeah, but CSS3 still doesn't have enough
 
I've opted out of JS for basic effects, like fading.
 
I tried to implement fading in and out submenus the other day using CSS3, using only JavaScript to switch around classes
 
@YiJiang effects are meh.
 
@YiJiang: yeah, that's what I mean.
 
9:14 AM
Why emulate them in non compliant browsers
effects are just bells and whistles use css3 and dont use the effects in non css3 browsers
 
Still felt extremely hacky - I can't fade out by changing the display property, so I opted to set opacity to zero.
But then the elements are still around, and clickable, so I set their z-index to -1
This sucks. There must be a better way to do something simple like that
 
I dont know, I havnt done any css3
 
jQuery.fn.init.prototype == []
true
 
fff
Thats what they did.
 
Quite clever, really
 
9:17 AM
@SimonChester lies
jQuery.fn.init.prototype just prints as []
its not equal
 
No, it is. I tried it.
gah
I pasted in "true" after the statement
In the chrome inspector
Oops.
 
jQuery.fn.init.prototype = [] so that they can get the array methods to work on it. $().push("I'm on a horse")
 
@AndyE not really. im pretty sure they write the array methods manually
 
[] == []
false
 
9:25 AM
hmm my mistake. They must copy toString also...
 
I think this was what you wanted anyway:

> ta = function() { this.m = true; }
function () { this.m = true; }
> ta.prototype = []
[]
> new ta()
[]
> new ta().m
true
 
@SimonChester Use the fixed font button for code formatting
 
or maybe it's Chrome's dev tools that recognizes it as an array
 
Ah, thanks
 
9:31 AM
@Zirak: yeah, I saw that :-)
$() in Chrome's dev tools gives [], so I figure Chrome's probably just looking at the length property and assuming an array.
 
@AndyE Nope, tried that.
 
@Zirak what if firebug and chrome feature detect for jQuery >_>
 
If that happens I'll personally murder the developers
 
"Hey jQuery returns arrays right, so lets make them look like arrays!"
 
9:37 AM
> $() instanceof Array
false
> [] instanceof Array
true
> new ta() instanceof Array
true
 
I wonder if I should email Paul Irish. He seems decent
 
@Zirak just go to #jquery-dev
and ask there
 
Why do you have to do it the exact same way as jQuery?
 
Is this web irc any good?
@SimonChester Just curious, actually. Don't intend on doing anything with that knowledge.
 
Yes, that works well.
Ah, okay. As it happens, paul_irish is in #jquery_dev as well
 
9:44 AM
@Zirak good enough
@SimonChester not the same way.
But we want to understand why the console logs jQuery objects as arrays
 
Ah, okay
 
and I still think the answer is "hurr durr firebug feature detects jQuery"
 
It'd be very sad if that's the case
 
0
Q: How can I save or capture or print the whole scrolling area of this dynamic webpage?

MartinI'm trying to save a table view from this car site: http://cc.volkswagen.at/nwapp/nws/ICC3/LNF!de!!!L!!!/?MGN=220&AUVN=&rel=statBanner_Konfigurator&rel=statCc_Caddy It's german, but it's not very difficult to navigate, just click on the Vergleichen Sie die Ausstattungen link, and it...

 
Well, this is interesting. Try this:
 
9:52 AM
@Raynos nope
 
qqq = function()
{
return new jQuery.fn.init();
}

qqq.fn = qqq.prototype = {
constructor: qqq,
init: function( selector, context, rootqqq ) {
},

// Start with an empty selector
selector: "",

// The current version of qqq being used
qqq: "@VERSION",

// The default length of a qqq object is 0
length: 0,

// The number of elements contained in the matched element set
size: function() {
},

toArray: function() {
},

// Get the Nth element in the matched element set OR
// Get the whole matched element set as a clean array
> qqq()
[]
 
test = function () {}
Object.getOwnPropertyNames(Array.prototype).forEach(function (v) {
    if (v != "constructor") test.prototype[v] = Array.prototype[v];
});
new test();
//-> []
They're obviously just checking to see if an object is "array like"
 
I've stripped it down to this, which still works:

qqq = function()
{
return new jQuery.fn.init();
}

qqq.fn = qqq.prototype = {
constructor: qqq,
init: function( selector, context, rootqqq ) {
},

// For internal use only.
// Behaves like an Array's method, not like a qqq method.
push: [].push,
sort: [].sort,
splice: [].splice
};

qqq.fn.init.prototype = qqq.fn
Okay, dw
typo
 
Holy shit, it might just be the array methods
 
@Zirak I tried those :(
 
9:55 AM
Unfortunately, I forgot to replace the jQuery right at the start
 
Wait, no. Your test fails. You're just returning jQuery ~_~
So, you're returning what jQuery is returning...back to square one.
 
Yeah, a typo :(
 
Thus far, the jquery-dev channel doesn't know
 
@Raynos stick a length in and it does.
 
This works:


qqq = function()
{
	return new qqq.fn.init();
}

qqq.fn = qqq.prototype = {
	constructor: qqq,
	init: function( selector, context, rootqqq ) {
	},

	// The default length of a qqq object is 0
	length: 0,

	// For internal use only.
	// Behaves like an Array's method, not like a qqq method.
	push: [].push,
	sort: [].sort,
	splice: [].splice
};
 
Holy mother of Old Spice Guy
 
So it was property detection after all
 
Well, that's the end of that chapter then
 
f0x
9:58 AM
>_>
 
Andy E, I love you.
 
That's because I smell like Old Spice and not a lady. I'm on a computer.
 
Post that answer and get reppies
 
what answer
there was a question?
 
awake!
at 12am!
 
10:00 AM
I thought we were just dicking around
 
@IvoWetzel yes. Feels good to be late for work
 
but only because we gotta stay in the office until 1am today >_>
 
3
Q: How does jQuery make the returned value look like an array?

ZirakjQuery(); //[] jQuery("#footer"); //[<div id="footer">...</div>] I know that you can do something like this: function kablam(tag) { var els = document.getElementsByTagName(tag); els.isKablam = true; return els; } var body = kablam("body"); //[<body class="ask-page"&g...

 
stupid quarterly event
 
We were just dicking around, based on my dicking around :P
 
10:01 AM
stream starts at eleven pm our time..
 
@Zirak: I just up voted Raynos' answer instead :-p
 
 
So that's how they "crack" captchas
Outsourcing the captcha entry to people in exchange for the next part
 
THIS IS OUTSTANDING: trolldad.com/comic/17xaj
 
@SimonChester didnt you know how that worked?
captcha has two words because the first word is for authentication and second word is for you to tell the computer what the word is.
hence there was this whole always default the second word to "fuck" or some other silly word thing going a while back.
 
No, I know how recaptcha works. I meant, making people enter the result of captchas to be used for spamming or whatever
 
Oh, yeah, that's a known method
Where do you think tons of Indian kids work?
 
At sweatshops entering captchas. I had heard about that too :)
like this place: decaptcher.com
$2 for 1000 CAPTCHAs
I guess any anti-bot system could be beat in the same way
 
f0x
cough
 
Of course they can
 
10:17 AM
$0.002 per captcha, each captch takes ~10 seconds, that's $0.72 dollars per hour.
 
@f0x Then they'd just change it to have whoever wants the captcha solved send the image directly
 
$0.72 USD is 36.07 Indian Rupees. I think that's considered decent pay
 
anyone running latest Chrome dev? Just found a bug in webkit.
 
I have canary installed
This would be hilarious to serve to hotlinkers: github.com/kitcambridge/evil.js/blob/gh-pages/evil.js
2
 
hmm... does it in Opera too. But not Firefox.
lemme check IE 10 PP3
 
10:23 AM
What is it?
 
just a sec jsfiddle's going really slow
jsfiddle.net/AndyE/Jx8YB/show/#3 - 3rd span transitions to orange, but I don't think it should.
it doesn't in Firefox but does in Opera and Chrome
 
I get that in both chrome stable and chrome canary
It looks like expected behaviour. What exactly is the bug?
 
Weird, that doesn't happen in the regular jsfiddle page
 
@SimonChester That is the best
 
@Zirak: it needs the fragment identifier
 
10:29 AM
I dont see the animation
 
@Raynos You're probably not using a browser that supports css3 transitions.
 
im using ff7
 
@SimonChester perhaps it is. But I think it's more likely that this is a grey area of the spec and that's why they differ.
 
If equal in priority, highest specificity wins.
 
@Raynos: yeah, Firefox behaves how I thought they all should.
@Simon: yes, and the target has higher specificity, but why does it transition from green to orange when orange should be overriding green?
 
10:31 AM
Interesting that its grey
It really depends whether it gets the span style and then the span:target style
 
Because styles are inherited.
Well, not quite the best choice of words
But least specific is evaluated first.
 
hmm... so you think Firefox does it wrong?
 
Yes. Not sure exactly what the spec says, though.
 
IE 10 does same as Firefox.
 
I also think FF is wrong
 
10:34 AM
:target isn't a normal selector though.
 
however is firefoxs or chromes logic more useful?
 
@Raynos: Firefox's makes more sense to me and it's what I was going for.
I think it's a bug in webkit and presto. If I increase the specificity of span to div#outer > span, then all elements start green and stay green. The :target doesn't start orange and fade to green.
 
Well yes, I agree firefox behaviour is more useful
 
Hmm.. you may be right
The only reason the differences in the application order are apparent is because of the transition property
Otherwise, nobody would ever notice them
So I guess this is a bug then
 
Not sure what to label the bug in the report lol
 
10:42 AM
"CSS transition order difference"?
 
hmm yeah i guess.
btw - I was trying to reproduce SO's "temporary highlight the anchored answer" with CSS3 transitions.
 
@Zirak ai-class is becoming harder :(
 
@Raynos The 3rd unit has a lot of math (<3) in it, but the 4th one is a little more relaxed
Sadly, it's the ugliest side of Math: statistics (probability).
@Incognito @Raynos Should the dom object just offer tree-traversing methods, or also other dom sugar (like getting/setting attributes or adding things to the tree)? How can they not conflict (attribute selectors vs. attribute getters/setters for example)?
 
What dom object?
Define dom.
to be honest I'm just going to say use the DOM4 api and stop writing abstractions!
 
What we talked about yesterday dom.tag = document.getElementsByTagName
 
10:57 AM
What are you absracting?
 
We talked about why people began using jQuery, it's because they complained that the DOM is too verbose.
So I mocked up a simple object, called it dom, and simply made one-word names for the "lengthy" DOM selection methods.
And now thinking about making more.
 
Well watch out what your doing
I recommend you create aliases instead
Or better yet, create a large application
and DRY it out.
 
Whadya mean?
 
Dont create abstractions, use abstractions as and when you need them
Its better to identify the need for abstractions through code.
I.e. write code, identify sources of verbosity
 
Oh, that's pretty obvious. There are tried-and-proven points where the DOM gets verbose
((I don't think so myself, but you know))
As in, "hurr durr why is document.getElementsByTagName so long"
 
11:03 AM
meh.
 
I agree, meh
This is neat. jQuery does $("something", "context") -> $("context").find("something"). I wonder what's the use of the context argument...
 
11:20 AM
This gets my goat.
0
A: How to find duplicated values in an Array

Soner Gönülvar arr=['manager','manager','employee','manager','director','employee','manager','operatives'] var sorted_arr = arr.sort(); // You can define the comparing function here. JS default uses a crappy string compare. var results = []; for (var i = 0; i < arr.length - 1; i += 1) { if (sort...

3000 rep and posts someone's answer from a duplicate question...
 
Maybe that's how he got to 3k rep
 
11:56 AM
@Oddant Y U HAVE 6 FINGER HAND>?!?!?!?!
 
12:11 PM
@Zirak context is el.getBy...
compared to doc.getBy...
 
@Raynos ?
 
I was aboe the skeet once
$(id, thing) === thing.getById(id)
 
oh
Well yes, but if all that jQuery is doing with the context is turning it into its own query and making stuff on that, why use it?
NNNNOOOO, my rep is 2221
 
f0x
downvote raynos's answer - edit a question = 2222
 
But I have a perfect no-downvote history
 
12:21 PM
@Zirak Pffft. Wimp.
 
It's really not about the rep! It's because there aren't any stupid questions, just stupid people...
 
@Zirak I downvote stupid people
 
No actually, you downvote "stupid" questions. The people remain intact
 
I guess so
 

« first day (370 days earlier)      last day (4594 days later) »