« first day (25 days earlier)      last day (4941 days later) » 

4:01 AM
Or you mean you found another way, but also don't know what you're setting the ID as?
..Which really complicates things :P
 
do you have control on all the other IDs in the page?
build a list of expected IDs and ignore those
 
422
back, still fiddlin.
 
kinky
 
@422 welcome back, fiddle away. let us know if we can break something for you (we're good at that one)
 
422
:)
still cannot grab the value of that input field, i think because it is generated via the backend js, it has no value. Or I am looking in the wrong bloody place lol
 
4:07 AM
nope
you're looking in the wrong bloody place
if you're generating it dynamically, then you need to add an attr('id') that's unique so you can get it
but if you know where you added it you can still get to it
 
Ideally you would keep a reference to the node when it's created
 
@david there may be reasons that that's not an option, but yeah, I agree
 
422
could you please have a look at it again, as i am going cock eyed here
apologies its not lazyness
 
@TimStone, I was trying key.id instead of just key. Oy.
 
link 422?
 
which input?
 
422
the field id: titled Latitude / Longitude needs to grab the lat and long from the very top input box, so that it can be added to the db on form submission ( the very top ) input bx, propagates after the first3 fields are filled in
 
@rchern Ah ha. ;)
 
422
the uneditable field is the one that needs propagating with the result found in latLng input
 
if you already have the result in latLng then why do you need to move it? for postback?
 
422
4:13 AM
gets confusing, so landlatlong need the value from latLng
well latLng is created dynamically, so on form submission it wont get posted to the db will it ?
 
is there a reason it's disabled?
 
huzzah!
 
@rchern huzzah!
 
I went into an endless loop teehee
 
422
yer just so ppl dont accidentally think its a field they need to fill in
 
4:14 AM
but it's hidden right?
display:none?
 
422
yer
 
visibility none?
 
422
disabled
can switch it
 
so don't disable it, just hide it
 
422
erm.. i have it disabled
latLng hasnt got a value as it is generated from the values of field1+field2+field3
 
4:16 AM
ok, but they aren't going to care about the lat long, and users get antsy with fields they don't need/know what it is, in my experience ... I'm just one guy
 
@rchern Ah, with the redirects? I take it that it's working then, hoorah! \o/
 
422
yer gottya, when it works I will hide it
 
$('#landlatlong')[0].value = $('#latLng')[0].value; works well enough for me
even disabled
 
422
im bewildered to what those values represent
 
because they have ids you can do it faster than using the jquery selectors, but that's simple enough
 
422
4:18 AM
shouldnt they echo the lat and long values that generate the geocode target
 
@TimStone thank you SO much for your help!
 
huh?
 
@rchern I'm sad it had to come to that, but glad you've got something workable! :)
 
422
k... landlatlong should have as value 1,992932.00,-152,75757 example
 
yes
I concur
 
422
4:19 AM
< dense
;p
tell me if i am doing your heads in and i will politely piss off
 
nah, you're fine
you have working code :p
which part am I not explaining well enough and I'll start over
 
422
yeah its taking long enough
k
 
you asked for code to move the value from one input to the other
 
422
top input field is autogenerated: its code is <input type="text" class="latLng" name="latLng" id="latLng"/>
 
that's what my code does
albeit my code could be faster
yes, I am with you so far
 
422
4:21 AM
the one that was disabled is where i want to parse the value of the result within that input field
that input is: <input id="landlatlong" name="landlatlong" size="50" type="text" class="medium" value=""/>
so when user submits form, it passes landlatlong value of the geo coordinates to the db
< happy to pay anyone to make it better
as it is it will need to handle upwards of 30,000 submissions per week
 
ok, so when do you want to update the textbox "landlatlong"?
 
422
adoesnt matter, but after fields 1 2 and 3 are filled, cos they obviously create the lat and longitude values, but this element will be hidden anyhoo
so was gonna trigger it when field 4 was focused
 
so that will work, so when you focus on field 4, or when you press the submit button, you should put my one line of code at the start
$('#landlatlong')[0].value = $('#latLng')[0].value;
want me to break that one down for you?
 
422
please lol ( i have a strange bemused effect facially )
 
lol, ok, sorry for the delays as well, chatting in two rooms
the other I'm trying to bail out a sinking ship and it's not working
$('#landlatlong') selects ALL elements that match the selector, so effectively it returns an array. You can't set the value of an element in an array till you select it, so take the first one [0] but since it's an id selector, there shouldn't be more than one. There can be, of course, but there shouldn't.
 
4:28 AM
So, goal for tomorrow: get vendor to include this in their login page.
if (self != top) for (var el in top) if (el.indexOf("url=") >= 0) top.location.replace(el.substring(4));
 
So that takes care of $('#landlatlong')[0]
 
422
k
 
by the same token, you want the value of the first $('#latLng')[0] element here
and you're assigning one value to the other
quite straightforward once you know what the $( selector ) is doing
 
Shouldn't affect any of their other clients.
 
@rchern As simple as that should be....I'll cross my fingers. ;)
 
422
4:29 AM
k
< not sure how and where to plonk that code tho
 
doing the url= is good because it'll just do nothing if there's no match.
And who besides me is gonna be ridiculous enough to call an id url=<url>
 
422
lol
 
Yeah, it seems relatively safe to me, at least.
 
@422 you put that assignment statement anywhere you would put a similar assignment statement.
 
@TimStone which means surely they'll protest.
 
4:31 AM
you said in textbox4 onblur?
and in the submit button onclick if you have one
 
422
k.. will have a look. Thanks
 
@rchern I'll prep Rovio.
 
haha
with the death rays?
 
Of course.
 
10-4. standby.
 
4:33 AM
Heheh
 
Hi, I have a question ... can we use encryption on javascript code ?
 
hmm, i wonder how cool that jsfiddle thing is...
 
@david how could you find out?
 
by dumping death into it
 
...
 
4:38 AM
ahahaha wow, i'm impressed
draw in the black shit
aw, only works on chrome
 
@422 did you make any more headway?
@david oh holy shit
@HotTester can you elaborate at all?
 
422
nope lol < not sure how to add that stuff, i am a bit crap with this stuff.
< will keep trying tho
be back soon
 
ok, break it down into chunks
where do you want to add the code to copy?
in textbox4 onblur?
when they focus?
@422 did you leave already?
 
422
could you look at my html, and do a snippet of where to add yours mingled in with my code
< sorry was on fone
 
it's fine
 
422
4:46 AM
I apologise for not getting into this quicker, its all quite alien to me
< i really have to nip out, brb asap
 
take your time
 
heh, jslint doesn't love my code...
that's okay, I know better now
 
@422 when you come back, I have a question for you ...
 
i'm off, catch you all later
 
night @david
 
422
5:16 AM
Back sorry, had to pick son up from station
 
no it's fine
how do you know that the field is populated with good data on the field latLng
the user has to click the button, right?
what do you do if they don't click the button?
 
422
thats true.. they do have to click the button to generate the lat and long
would prefer to auto generate the lat and long, dont know a way of doing it
ideally soon as they clicked into field 4, it would generate the lat and long, then optionally they could click the button to show the map
 
you don't have a good way to force it to be generated. You could put an onChange on each of the three boxes and if the others are generated then calculate the field, but idk
 
422
yer i was thinking that
 
so consider that.
 
422
5:23 AM
my issue is the more persistent one of propagating that (was hidden ) field
 
anyways, you can't populate the one value till that's calculated
 
422
yer
 
how are you calculating that field?
 
422
using the google maps api
 
has it got an ajax?
 
422
5:24 AM
no
afaik it hasnt lol
 
ok, well you're using the googlemaps api
 
422
its a script we have mashed together to solve an issue
 
do you pass the textbox to the script or what?
attach an onchange to that textbox and when it doesn't contain a + then it's a valid latlong
then you can copy the value out
 
422
no it automatically senses it, probs on keyup i suppose, the script is here: webcoda.co.uk/2010/10/the-jquery-location-picker
 
what happens if you don't get a valid latlong for the database?
 
422
5:26 AM
then it wont plot the position correctly, which was always going to be an issue
but one we can overlook
we need the geo target for the address, for other applications within the site
 
reading the script
 
422
k
just grabbing a coffee
 
is your group writing the code for this locationpicker control?
 
422
group?
 
are you in charge of this script?
 
422
5:32 AM
yes
 
or are you filching someone else's script?
 
422
no lol
< tis me
 
ok, so in your options you should allow to pass in a element to get the value for your form
or rather, you would pass in a selector
 
422
k but
 
make it another option
 
422
5:33 AM
the location picker doesnt work within the form elements
 
422
it sits outside
 
does it occur "in the DOM"?
 
422
that input box if you look, is outside of the <form> tag
 
but is it in the HTML?
 
422
5:34 AM
yes
 
does it show up in the browser window?
then who cares?
 
422
not me
 
the form is only important "on submit"
 
422
exactly.
 
aside from submission the form element is nonexistent
so ignore it
 
422
5:35 AM
and we need to grab as much info from that form session as poss
 
yes, I agree
 
422
k
 
look, all I'm saying is, pass another selector to the locationpicker
 
422
plus needs to be simple
 
it can be null normally
 
422
5:35 AM
ok
 
when you get the location geocode back from google
 
422
yes it will have a value which can be parsed back?
 
put it in the $(selector) if selector <> (null || empty) (pseudocode)
 
422
k
 
so in your options: "formSelector"
then later: if (formSelector != null && formSelector != "") { $(formSelector).each....
 
422
5:37 AM
okies
 
also, I'm sure that if (formSelector != null && formSelector != "") has a better version in JS, just not sure what it is off the top of my head
as my boss says "get the car on the road, then fix up the engine"
until you have four wheels and a motor, don't try and optimize it
brute force is usually more readable than elegant
 
422
lol
 
so if you do it in the locationPicker then you know that as soon as the value is returned from google that you're putting it where it belongs
 
422
good advice, i am the plod along and refine type
ok will go and have aplay , appreciate your help
 
so you don't have to think about it anymore and you can remove whatever method you have on textbox4
 
422
5:40 AM
makes sense, and keeps it clean
 
yeah absolutely.
 
422
thanks mate
 
also, don't be afraid to change it up, I'm only suggesting a place to start
you're liable to come back in a few hours and have like 15 more suggestions from others to be more elegant and faster
 
422
yeah thats cool, well refinement comes after invention
 
I'm just looking for works
:D
ok, I'm gonna go find a pillow while you play with JS
have a good day mate and type at you later
 
422
5:41 AM
lol aint we all. K im gonna go fiddle again >>> cheers buddy
 
enough bezier crap for now -.- time for things that are way more fun: AI
 
 
4 hours later…
9:27 AM
Code review! This time, it's a funky userscript that reverse the order of comments on Vimeo video pages. Source: userscripts.org/scripts/review/90148
I'm pretty darn sure the code can be optimised somehow. It seems rather inefficient and inelegant
 
9:48 AM
@YiJiang is there any need to create a script node there?
 
Morning
 
mornin
 
@NickCraver The comment loading function is defined in the page itself, so other than unsafewindow script injection seems like the next best thing
 
what are the arguments for and againts wrapping javascript code in an onready block? (Ignoring jQuery overhead)
 
@Raynos - DOM ready is way too long to wait
 
9:50 AM
@Raynos You basically have to do it if you're going to work with the DOM
Otherwise, if you're just going to do erm... say... math, go ahead and do it outside the DOM Ready handler
 
@NickCraver really? I thought the difference between dom ready and end of body tag was small
 
could be minutes man, wayyyyyyyyy to slow
real men don't use document.ready
3
 
@NickCraver what are the real arguments for and againts?
 
umm, well, why does it exist really?
some are still hardcore "scripts much be at the bottom of the page"
if doing this your DOM should be ready, and there's no need for it there
 
Ok fine. Let me rephrase. what is the difference between a piece of code running after adding an object to the DOM and wrapping that piece of code in document ready?
 
9:54 AM
so its existence denotes not loading your scripts there, meaning it's overhead by definition
 
so there are no advantages of wrapping script at the bottom of the page in document ready?
 
@NickCraver so true
 
nope, not if they're the very last thing, unless of course your scripts themselves are injectors loading additional stuff
e.g. delaying document.ready via readyWait in 1.4.3
remember that your scripts, all of them have loaded in document.ready
at the end of the body you're running a script, but the ones after it haven't loaded yet
so I take that back, there could be some advantage yes, if your dependency order is off...but kind of a different issue
 
I use it two document.ready's for page ordering
Should I avoid adding functions to global namespace?
 
if possible yes, though a few won't hurt anything
the main factor there is do you control the page? If not then conflicts ahoy, steer clear and namespace
e.g. a portal/widget environment you're only one piece in.
Disclaimer: I have no idea what I'm talking about
4
 
10:01 AM
@NickCraver Need to pin that, Nick
 
annoyingly I have no choice with asp controls on the page referring to public functions
This is ridiculious
<% asp if %>
script
// few lines of code
/script
<% endif %>
Ok apart from not being able to write <script> in chat. Is there any danger in refactoring about 6 or 7 of those into one script block with asp if statements inside the script block?
 
nope, as long as they're in order and no variable scope issues
 
@NickCraver Tell me, does the slider here: jsfiddle.net/yijiang/KMF2v work on Firefox for you, and more importantly, should it work?
 
yup, works off the mouse drag so doesn't matter if the handles leaves
 
@NickCraver The OP here tells me it doesn't work on his Linux Firefox 3.6 (Which is what I'm on right now)
Which is why I need a second opinion
0
A: jquery Draggable DIV with slider inside

Yi JiangAssuming you're using the jQuery UI Draggable and Slider components, this shouldn't be a problem - the two should not conflict with each other by default. However, you can still explicitly exclude the slider with the cancel option: $('.draggable').draggable({ cancel: '.slider' }); See thi...

 
10:18 AM
ah, dunno about FF, but it should the way UI works
i tested in chrome...which is a bit better at rotation at the moment
 
@NickCraver I'm working in Firefox, and it works. The OP says that in the same (maybe different distro) OS and version it doesn't
 
possible, though that shouldn't be the case, since that won't be hardware accelerated until FF 4
 
@NickCraver I'm confused, what does hardware acceleration have to do with this?
 
would introduce OS related issues more often I'd imagine
yay got my morning glare already!
0
Q: Jquery .each() including a delay looking for clean code

user256888To be short, I am looking for a jQuery loop that will select each div with a class (approx 10 small divs in a line) then execute some code on each div specifically fade out and in the image contained in the div and then pause and move on and do the same to the next div. This loop fades out/in a...

 
Can we upvote pst solution to annoy nick?
 
10:26 AM
i would
accepted answers > upvotes :)
 
I often wonder why people post solutions that are more or less exactly the same as those posted 5 minutes earlier.
 
I understand up to a minute, you may not even see the bar, but several minutes...
 
objectConstructor = function SomeName() {
    // code
}.prototype.otherFunction = function() {
   // more code
};
is that valid?
 
@Raynos: no
objectConstructor just becomes anonfunction.prototype.otherFunction
 
yup
 
10:29 AM
just like a = b = 3
 
Bah.
 
+1 for creativity, even though it ended in failure :)
 
using SomeName.prototype.bla = bla would work right?
 
yup
 
can I make it neater? :(
 
10:30 AM
a while back someone proposed wildcard prototype matching, that would have been interesting
SomeThing.prototype.* = function() { alert("Not a valid function"); } as a catch-all for any functions that didn't match
same for SomeThing.prototype.prefix* = ....
 
@NickCraver Object.prototype.* = function() { while(true) alert("Guess who found malformed code"); };
 
heh yeah
 
That would be incredibly annoying on every existing website.
 
I think brendan was on crack when he put this into the language, but hey whatever
 
@NickCraver Firefox has a catch-all for functions, doesn't it?
 
10:34 AM
@NickCraver would you prefer self
 
IMO the example on that page is terrible.
 
oh yup, though I've never once seen it used
 
@AndyE It is pretty horrible. Why not just alert('No such method') and leave it at that?
 
.createTextRange is ie only right?
 
@YiJiang: another example might be case-insensitive function names
-3
Q: how to include javascript funtion in the end of url

22francishow to include javascript funtion in the end of url so after loading the page javascript funtion will work

^ amazing how people just click straight through the ask-advice page.
 
10:43 AM
doh, missed the obvious problem at first:
0
Q: Simple MVC/JQuery problem

arame3333... but it is bothering me! I have 2 checkboxes, and I want to stop then both being checked. So if I check one, the other must be unchecked. This might look like a toggle. However they can both be unchecked. However the real problem is that the click event on the Checkbox is not being picked up....

@AndyE I think he speed clicked through it
 
@AndyE I thought the retag button said retard and I was about to mark it as retard
 
@NickCraver Doh, I think I know why my fiddle fails for the OP of that question on sliders in draggables. I had an debugging console.log() left in there.....
 
ahh yeah that'll do it
 
I'm being rather easily annoyed today. First was a question with "can any1 plz" in the title, and now that. I just can't bear the ignorance of sum ppl! ;-)
 
@AndyE SO should reject questions that does not start with a capital letter. Notwithstanding words like jQuery of course
0
Q: jquery css using arrays as values

user499846Hi, I am creating a function that I need to pass in values from an array, one of the values I need to add in is a series of values for the jquery css array essentially I need to do the following myArray = new Array(); myArray[0] = ""{'float':'left','-webkit-border-top-left-radius':'20px','-w...

That is not how you declare an array of objects!
 
10:51 AM
:D
@YiJiang it is. he just set the value to be a malformed string
 
@YiJiang updated, happier? :)
 
I just noticed @NickCraver got an announcer badge for this:
14
Q: jQuery: but what about all the children!?

Josh SmithI feel like I have to use way too many .children() in some of my jQuery functions. Here's my HTML: <div class="goal-small-container"> <div class="goal-content"> <div class="goal-row"> <span class="goal-actions"> And here's my jQuery: $('.goal-small-conta...

Hehehehe...
 
Is there any way I can set the caret position in a text area?
 
negative
those are different links
 
11:00 AM
@NickCraver That explains why she got so many votes!
 
hehe yup
 
Whomever used the variable "RaiseJavaReport" instead of "RaiseJavaScriptReport" is going to get shot. I spend an hour looking for java applets
 
Why not just RaiseJSReport?
 
howdy
:p
kinda mixed your suggestion along with a little jquery magic
 
@jAndy: huh, didn't recognize you with the new grav. What's with the try/catch? :-P
 
11:11 AM
@AndyE: well that call throws an error on IE
 
check for IE and don't make the call? :)
 
shoot jAndy for empty catch block
 
@NickCraver: buuuh feature detection for the rescue, you know that :)
@Raynos: yay.. kinda don't like it either, but what can you do...
 
I didn't say check for the IE user agent...I mean check if it'll break
 
@jAndy is the purpose of that function to see whether .textContext or .text is valid?
 
11:12 AM
an if statement for all browsers is far cheaper than a try/catch anyway
 
I can't understand why it would break. IE should just see it as an expando property on a DOM object.
@jAndy: I don't get an error when setting textContent to a script element in IE. Are you sure that's the cause of the issue?
Math.max.apply(Math, elements.map(function(){
   return parseInt($(this).css('z-index'), 10);
}).get());
^ @YiJiang
although I guess it would break your chain.
 
@AndyE Okay, thanks. Not entirely sure if this is better, since I'm not very sure what you're doing with the Math.max.apply part
 
@YiJiang: Math.max returns the highest number value passed to it via its arguments, so you would assign it
e.g. max = Math.max.apply(...)
it's a couple of lines shorter than your solution, even though it breaks the chain.
btw, +1 for your answer.
@YiJiang: should have an || 0 in there too.
run this in your console on the SO homepage:
Math.max.apply(Math, $("*").map(function () { return +window.getComputedStyle(this, null).zIndex || 0; }).get());
 
11:41 AM
var row = x();
var value = row.getVal();

var row = x(),
    value = row.getVal():
Apart from style is there any advantage for the latter?
 
@Raynos: no real advantage, any difference in speed would depend on the compiler. Crockford recommends one var statement per scope.
 
@AndyE merely for the purpose of not being tricked into thinking block scope exists?
 
You know, testing the script with $('*') has some really weird effects
I didn't know that the html element can receive styles too
Hmmm... apparently this method of cleaning HTML doesn't work
var uncleanHTML = 'Stuff like <script>alert("Hello world");</script> need to be <div>Hi</div> cleaned <strong>Yes!</strong>',
    container = $('<div />').html(uncleanHTML).find('*').unwrap();
The script tag will actually be executed, even though the container isn't actually attached to the DOM
@AndyE I've got 3 more upvotes since I updated my answer... I think they were because of the Mathmax.apply method you used to find the max z-index :P
 

« first day (25 days earlier)      last day (4941 days later) »