« first day (23 days earlier)      last day (4925 days later) » 

3:00 PM
-.-
@YiJiang # It's Yi Jiang's fault!
 
We need to get balpha to give us embedded fiddles :-P
 
Some people got too much time on their hand.
 
@AndyE you fix the security holes.
 
@Chouchenos It's 11pm here and nothing on the tv appeals to me
 
@YiJiang Exactly what I was saying.
 
3:05 PM
@Raynos: I don't see any security holes - embedding would be done via iframes, there's no x-domain access.
It's just not the sort of thing to prioritize - JS, HTML and CSS are just a small area of what SO applies to.
 
@AndyE there arn't security holes as such. but still you can do very annoying things with embeded js.
 
evidently their internal chat has more features, some of them amazing
 
true, true.
 
i really want to see a video of the wheel of blame
 
@NickCraver what's the wheel of blame?
 
3:11 PM
balpha worked all night and made a wheel of blame that takes the avatars, spins them around, wheel of fortune music, assigns blame afterwards
i haven't seen it personally, but it's pretty elaborate
 
var value;
if (row) {
    value = row.attr("value");
} else {
    value = "";
}

vs

var value = row ? row.attr("value") : "";
Is there an argument that the second is "too compact" and "not readable" ? or is the second always preferred?
 
there's nothing unreadable about the second.
 
i prefer short circuits but in either case i don't find the second line to be unreadable
if someone doesn't understand a common language feature .. that's not a problem with the author of the code
 
the less-readable version is: var value = row && row.attr("value") || "";
 
(my preference)
 
3:17 PM
readability is in the eye of the beholder (like beauty) :-P
 
@NickCraver thats rather annoying :P
@NickCraver does the && operator return the second object? and the || return the first object ?
 
nah, it's not too annoying, i prefer it because in some instances it's more compact anyway
 
it's functionally equivalent to your conditional statement
 
i hate things like row = row ? row : foo when you can just row = row || foo
 
@NickCraver at least make it var value = (row && row.attr("value")) || "";
 
3:19 PM
@Raynos: the && operator returns the right operand if the left operand evaluates to true or undefined otherwise
 
it's actually a shame there isnt something like row ||= foo in that case
 
@Matt theres a difference between a single || and a nested one
 
@Matt: I think those were suggestions for ECMAScript 4
&&= and ||=
 
@AndyE i think it's available in coffeescript but i dont feel like adding another translation to my build scripts :)
@Raynos i dont think anyone is nesting anything ... ?
 
@Matt (row && row.attr("value")) || ""; the && is nested a level down or is nested the wrong word?
 
3:22 PM
> **“&&=” and ”||=” operators** ES4 introduces assignment operators for the logical “&&” and “||” operators. These assignment operators
are short-circuiting; if the value of the left-hand-side determines the value of the result then the right-handside
is not evaluated.
damn quoting
 
thanks for info though
 
maybe they'll re-appear in ECMAScript harmony
 
@Raynos if im not mistaken, && and || have same precedence so it's just a matter of what gets evaluated first .... though i could be wrong
 
@Matt left to right evaluation
otherwise yes, which gets evaluated first
 
@Matt they do but its a pain to remember what the precedence for the particular language your using
 
3:23 PM
@NickCraver am I the only one that feels that it's fun to mess with people but bad for maintainability? Surely not. But it's perfectly legible to me.
 
I prefer using brackets, it requires less thinking and less edge cases
 
my opinion on quotes is you should use them if they help you. t hey cant hurt you
er, not quotes .. parens
 
The concept that logical expressions return anything but T or F is still a bit strange to me
 
Oct 28 at 13:09, by Nick Craver
undefined = true;
 
@Raynos .. well.. truth or false-y
!foo is true for 0, undefined, false, null ...
 
3:27 PM
@NickCraver oh that's just evil
 
I think i remember Nick saying something similar in C
#define true 0
 
0
Q: jquery: delay() + window.location ?

lauthiamkokHi, I know that we can delay the url redirection easily with plain javascirpt below, setTimeout(function(){ document.location = 'http://stackoverflow.com/';}, 2000 ); what if I want to use jquery's delay()? $(window.location).delay(4000).attr('href', 'http://stackoverflow.com/');// fail to...

is there a valid reason to put the window functions into something like jQuery?
does a framework or framework add-on need to exist for the window element?
 
@drachenstern $(func) === $(document).ready(func) but its a bit silly unless you use a paramless window function
 
3:40 PM
@Matt hehehe yeah, that was a great gag
 
@Nick unfortunately your undefined trick shows you should always be checking typeof for 'undefined'
</crockford>
 
3:57 PM
@Matt: typeof for undeclared variables, redeclare undefined for declared variables that may be unassigned.
var undefined = true;
(function () {
    var undefined, b;

    if (b === undefined)
        alert("Nyaah!");
})();
 
aha, clever
nice tip thanks
another good reason to wrap your code in its own function block
 
jQuery uses an unused argument.
var undefined = true;
(function (window, undefined) {
    var b;

    if (b === undefined)
        alert("Nyaah!");
})(this);
whoops, got there in the end.
 
interesting they curry this as window. i actually tend to do that just to make jslint happy
 
Not a good idea for non-self-executing functions though.
@Matt that was from memory, I can't remember if they use this or not, but I know the first argument passed is window.
 
it would make sense. this is window at the time of self execution
which defines window for your scope, which will make jslint happy
 
4:03 PM
yeah. It also very slightly improves speed by declaring window in the current scope - less distance to travel through the scope chain to find it.
 
4:27 PM
@matt I just use /*global window */ to make it shut up. I quite like the declaring externing globals in files
 
for JSLint just check "Assume browser" I think it is
 
@NickCraver yeah, like I said I wasn't sure :-) I just thought it odd that you would pass window, the only gain is a very slight speed micro-optimization. At least this avoids var window = somethingElse; unpleasantries.
I wonder if MS will have Web Workers in IE9 beta 2
 
if they have working closures i'll be impressed :)
 
lol
 
@AndyE var window is invalid in Firefox
 
4:40 PM
on success I have fadeIn(response), but i only want this to happen if the response is not empty. Should i do if(response.length) ? my request is HTML
 
@AndyE never mind you can overwrite window in ie :(
 
@Raynos: of course you can :-P
 
@AndyE I keep assuming ie is not shit :(
 
@Raynos: my father always told me "never assume, it makes an ass out of u and me"
hmm... I wonder if gracefully degrading web workers would be possible...
 
@AndyE I prefer to quote the steven seagal movie "assumption is the mother of all **** ups"
 
4:48 PM
bump
 
@AndyE sure just emulate time splicing
@Johnson yes if (response.length > 0) would work. assuming response is a string
 
@Raynos I was thinking more along the lines of creating an instance of a window to handle JS processing in IE 6+
 
response is not a string, its a function for the success
 
@Johnson: data.length ?
 
@AndyE I was thinking more along the lines of :
<!--[if lt IE 9]> redirect google.com <![endif]-->
 
4:51 PM
lol
 
ie9 has web workers right? Please tell me they implemented them
 
5:02 PM
<!--[if IE]> window.location.href = "http://google.com/chrome"; <![endif]-->
 
:)
 
oh cmon, you can at least alert('your browser is woefully out of date and underpowered. click ok to find a more competent alternative');
and I'm a staunch IE supporter for newb users, so long as they have no privileges to install add-ons and so long as all add-ons are removed from the system before they're allowed to use it the first time.
Additionally, they must be restricted to only ever using Microsoft Corporation developed tools. Ever.
In those cases, I find that they run into fairly few bugs. Its pretty nice actually.
 
unless you wanted things like CSS3 (or most of CSS2) :)
 
ah but what I really want is less whining
 
How can i redirect to index.php? Right now I have this for redirecting:
header("Location: index.php");
die();
echo '<script>';
echo 'location.replace("index.php");';
echo '</script>';
But if you were on standby and comes back, and it redirects you on focus, the previous page gets under the new one, how can i prevent this
 
5:17 PM
you might think things like CSS3 would be nice, but the users are doing things like hotmail and yahoo search and facebook. CSS3 isn't all that important
@Johnson what does this mean: "the previous page gets under the new one, how can I prevent this"?
 
@drachenstern I have an ajax call, that runs on focus, if you have been onblur. It checks for new stuff. If youre session has been runned out it runs the header, So when you get back to the site, and just have been without internet it doesnt redirect you to a fresh index.php, like it should, but shows index.php above the previous page you were on. I think its because i have the header(that redirects) inside the url i request, and so it prepends whole index.php above it
 
@johnson without more code I'm not sure I understand what your problem is. I can guess, but I'm not in a guessing mood today.
 
so how can i prevent this and on focus make a php and check if(session...){run ajax} else then header
 
I believe you just put the pseudocode in your comment there
 
haha
Still not getting me?
 
5:27 PM
I do get you, you already put the code you need in your comment
what more do you need someone to do? write all of it for you?
can I have your paycheck too?
 
stop that's not what i ment
I dont need someone to do that for me, only the first part. Is it possible to do:
$(window).focus(function() {
<?php if(session....) ?>
ajax
<?php }else{
header('');
?>
only thing i need to know
Is there a jquery function that can make you go to #name, like you can if you make a link to href="#name"
 
5:43 PM
wht are modern day techniques to profile javascript code?
 
6:12 PM
@deostroll: FireBug and the Webkit Code inspector perform pretty well on that task
@deostroll: there are even more sophisticated plugins like Google's "Page Speed"
 
@jAndy What's that really cool thing for IE8? I used to have it installed but I had to rebuild my VirtualBox machines and lost it
 
@Pointy: I never really measured with IE's, but I hope that will change (in a manner that in makes finally sense) on IE9 and above
 
Hmm well there is/was some 3rd-party thing that was really sophisticated "DynaTrace" maybe? I'll google that
Yes that's it, "dynaTrace ajax edition"
 
ok right, I heard about it
 
6:55 PM
So, I'm going to guess that in an iframe on a different domain, I can't set window.location ? >_>
 
Can't you just find the iframe element and set its "src" attribute?
 
other way around.
I need the iframe to refresh the parent page
meh, I'm gonna have to fudge the iframe size and add my own link to refresh that a user will have to click. and make it look nice and grrr
 
Well an iframe can reload the top page (window.top.location = foo)
That's how "frame buster" code generally works
 
7:13 PM
When i added live "hover" the function stop make it hidden at blur stopped working:
$("[name=WallEntry]").live("hover", function(){
$(this).find('.delButton').css('visibility', 'visible');
}, function() {
$(this).find('.delButton').css('visibility', 'hidden');

});
Why?
 
Well "hover" isn't really an event
 
.live() doesn't have an overload that takes 2 handlers
 
Try setting up separate .live() or .delegate() for "mouseover" and "mouseout"
 
@Pointy mouseenter and mouseleave
 
Ok, what should i use for making it disappear, should i use live blur?
 
7:15 PM
Oh ok I forget stuff that I don't code every day
 
Or is mouseenter more recommended
 
what is name=WallEntry?
 
@Johnson well "blur" is only relevant for stuff that gets focus
 
an message
div element
 
you have a <div> with a name attribute?
 
7:17 PM
yes
as the id="" is taken
 
Don
Hi, I've a very easy JQuery question. I have a wrapped set that I want to iterate over, and add 200 to the value of the 'top' css style
 
why not a class?
 
Yes could do that too
does it matter?
 
@Don - .animate({ top: '+=200' }, 0)
yes, why not have valid markup? prime example: I was confused just by looking at your code why you'd be doing a .find() inside something with a name
 
Don
Thanks Nick, I didn't think of using .animate
 
7:19 PM
it works well with a 0 duration for adding properties like that :)
 
Don
@Nick, so assuming all my elements have a class of 'foo' I can do:

$('.foo').animate({ top: '+=200' }, 0)
 
yup
 
Don
awesome, thanks a lot
 
I haven't tested in 1.4.3, it was on the table to make += work with .css() as well, need to see if that ever made it in
 
Ok will do class. So i am making:
$('.delButton').live('mouseover mouseout', function(event) {
if (event.type == 'mouseover') {
}else{
...
}
});
Is this right?
 
7:21 PM
nope
 
hmm. is there an event for the location changing? specifically the hash changing?
 
Don
surprisingly there doesn't seem to be any way to change all properties in a wrapped set, both .css and .attr both only work with the first element
 
onhashchange, but it's not 100% cross browser
 
I don't really want to have to have a timer going every 5 seconds for hours |:
 
google it, there's a plugin for a timer if the event isn't there
 
7:21 PM
IE7/8
 
@Nickcraver what should i be doing then?
 
2
Q: jquery - hash change event

Ian HerbertI am using: $(window).bind( 'hashchange', function(e) { }); to bind a function to the hash change event. This seems to work in IE8,firefox, and chrome but not in safari and I assume not in earlier version of IE. For these browsers, I want to disable my javascript code that uses the hash and ...

 
The hash change stuff is a popular duplicate on SO, heheh. :P
 
@Don they work on all items in the set, it's just the += part that animate handles inside
 
7:24 PM
$('.WallEntry').live('mouseover mouseout', function(event) {
if (event.type == 'mouseover') {
$(this).find('.delButton').css('visibility', 'visible');
}else{
$(this).find('.delButton').css('visibility', 'hidden');
}
});

Doesn't work on my appended stuff.
brb making question
 
hmm, that plugin seems heavily tied to ajax history issues. seems like it might still work. if i can get them to change the hash (which they won't like, we aren't the only company using this vendor), then i can listen for that and refresh my page.
 
@Johnson - are you at all trying to solve your problems (e.g. even looking at the console) before posting questions?
 
@NickCraver no he's not, he can't be. He asks if he can insert php into his javascript, and he asks if he can run SQL from the javascript ... I don't think it's a language issue
 
Hmm, comment auto-complete is more of a pain than I thought, provided I want it to adhere to the comment reply rules...
 
@dranchenstern why are you answering for me?
 
7:34 PM
he was making an observation, the same one I am
I have some experience answering questions, and it's not hard to tell when the OP isn't putting much if any effort into solving the problem themselves before posting.
 
wow.....
 
I don't have that experience, so I like watching your techniques @NickCraver
sometimes I tend to spit stuff out that I should bite my tongue on, other times I manage to keep quiet (like in the past two minutes)
 
I am putting effort in, else I wouldnt be here
 
@NickCraver, what makes you think 5K answers is enough to say you have experience answering questions.
 
@Johnson - you're not posting the complete question, the markup, what you've tried, any details...you're not even putting effort into the question that you're asking others to answer
 
7:36 PM
geeeeez.
 
@rchern - thought I was at like 3k
 
4936
 
whoa
 
I rounded up, so sue me. (;
 
i don't check most of the site's stats often, sweet
 
7:37 PM
@Nickcraver I am
 
Don
Hi Nick
 
lol, nice @ 5k there @NickCraver
 
Don
and everyone else
I tried your suggestion $('div.callout_main').animate({ top: '+=100' }, 0); but I'm seeing some weird results
 
@Johnson you're not, let's take the latest question:
 
Don
The page in question is rivieravaleting.com/price.html
 
7:39 PM
0
Q: live() mouseenter/hover

Johnson$('.WallEntry').live('mouseover mouseout', function(event) { if (event.type == 'mouseover') { $(this).find('.delButton').css('visibility', 'visible'); }else{ $(this).find('.delButton').css('visibility', 'hidden'); } }); .delbutton Won't appear in appended stuff that has .delbutton inside their...

 
What do i need there?
teach me, so i wont make the mistake again
 
no details, no markup, one tag - and look at the first comment, we're not the only ones
provide your HTML that goes with it, CSS if applicable (e.g. if it's hiding it)
 
Don
There are some callouts that appear when you hover over the table column headings
At the moment the callouts don't diappear when you mouseout, but that's just to make debugging easier
 
@Don - I'm following, what's the issue?
 
Don
The callouts are setup using this JQuery code

$(function() {
applyCallout($('th.small'), 'Smart, Toyota Aygo');
applyCallout($('th.medium'), 'BMW 1, Audi A3, Clio, VW Golf 3dr, Mini');
applyCallout($('th.large'), 'Merc C, BMW 3, Audi A4 , Porsche 996/7, VW Golf 5dr, VW Touran');
applyCallout($('th.xl'), 'Merc E & R, BMW 5, Audi A6, Bentley Continental, Ferrari, Lamborghini, Maserati');
applyCallout($('th.xxl'), 'Merc S, BMW 7, Audi A8, Rolls Royce, Bentley Arnage, Range Rover, X5, X6, Hummer, Merc ML&G, Large estate, 4X4s');
 
7:41 PM
Ok nickcraver
 
Don
Now, the last commented out line was an attempt to shift them down the page
 
@Johnson I'm not trying to be mean, I want you to stop and learn how to learn, it's b far the best skill of any programmer
 
Don
But oddly, they don't appear at all, if I uncomment that line
But if I execute that line in the Firebug console it works perfectly
 
im too fast, i think sometimes that everyone are in my position and know exactly what i am talking about thats why i shorten it so much
 
Don
I'm stumped...
does any of that make any sense?
 
7:43 PM
looking now
 
Don
thanks nick, really appreciate it
 
first let's clean things up a bit, make applyCallout a plugin:
$.fn.applyCallout = function(text) {
  var htmlText = "<span class='bold'>Examples: </span>" + text;
  this.callout({ show: false, msg: htmlText, delay: 0 });
  return this.mouseenter(function() {
    $(this).animate({ top: '+=100' }, 0);
    $(this).callout("show");
  }).mouseleave(function() {
    $(this).callout("hide");
  });
};
 
Don
nice idea, doing it now....
 
matching calls:
$('th.small').applyCallout('Smart, Toyota Aygo');
$('th.medium').applyCallout('BMW 1, Audi A3, Clio, VW Golf 3dr, Mini');
$('th.large').applyCallout('Merc C, BMW 3, Audi A4 , Porsche 996/7,  VW Golf 5dr, VW Touran');
$('th.xl').applyCallout('Merc E & R, BMW 5, Audi A6, Bentley Continental, Ferrari, Lamborghini, Maserati');
$('th.xxl').applyCallout('Merc S, BMW 7, Audi A8, Rolls Royce, Bentley Arnage, Range Rover, X5, X6, Hummer, Merc ML&G, Large estate, 4X4s');
I think the issue is here:
$(this).animate({ top: '+=100' }, 0);
$(this).callout("show");
this refers to the element you're on, the <th>, not the callout, don't you want to animate that?
 
Don
yes, I want to animate the callout, not the header
 
7:50 PM
0
Q: live() mouseenter/hover

Johnson$('.WallEntry').live('mouseover mouseout', function(event) { if (event.type == 'mouseover') { $(this).find('.delButton').css('visibility', 'visible'); }else{ $(this).find('.delButton').css('visibility', 'hidden'); } }); CSS: .WallEntry{ width: 300px; } HTML <div class='WallEntry'> Me...

 
Try this instead:
this.callout[0].animate({ top: '+=100px' }, 0);
it stores the callouts are direct DOM properties like that
 
+1 for a better question this time @Johnson
 
Don
I'll try that now, thanks a lot Nick
 
@Johnson +1 from me as well, much better question
 
smiling thank you sorry you too i understand how fast i were before
 
Don
7:54 PM
@Nick I tried your suggestion, but still the same results
@Nick I've uploaded the modified code, BTW
 
yup, I'm seeing a JavaScript error, one sec
 
@drachenstern still nothing in the appended html
 
oo you're using it in the main function
 
@Johnson ??
 
you'll need to use a .each() in that case, .callout is on the DOM element, not the jQuery object this is
 
7:56 PM
@drachenstern reffering to your answer
 
for where you're using it: this.each(function() { this.callout[0].animate({ top: '+=100px' }, 0); });
 
@Johnson what do you mean "still nothing in the appended html"? Also, use the first codeblock on my answer, let me edit the intro block on the second one
 
@drachenstern Yes, tried both, second answer was no results
@drachenstern I have a limit 10 on my query with messages, after 10 messages you press "More" and with ajax call on response it appends to the messagelist
 
Don
@Nick No JS errors now, but no callouts either :(
 
@drachenstern the 10 first does it works fine with the delButton appearing on mouseenter, but the rest, that comes in the response, doesnt.
 
7:59 PM
This code has nothing to do with appending new messages
 
@Don - I'm seeing them in chrome
 
ahhhhh
 
which browser?
 

« first day (23 days earlier)      last day (4925 days later) »