« first day (313 days earlier)      last day (4631 days later) » 

3:03 PM
@JeffHodge Do you think Java is kinda like JavaScript?
 
not at all
 
I'm abandoning ship, I'll be back later...
 
0
Q: Is it possible to create a drop down of some sort in a textarea?

Jeff HodgeIt might not be possible but I think its worth a shot so I am asking. Servlet API is basically a ticketing process/script which searches through a form to find form fields that it recognizes, it has a list of names and those names are the only form fields it recognizes, anything else it wont pic...

 
@JeffHodge ... you want to put a dropdown inside a text box?
facepalm
 
yeah
Ive seen some client sided forms where a user clicks an option thats only viewable by the client and when they click that option it enters the text they clicked into a textbox
 
3:15 PM
Okay, that's different.
 
even that would help
the pain in the butt is the lazy users not wanting to type stuff in so i have to provide drop down or radio buttons or some easy input for them
 
0
Q: Is it true constructor's prototype cannot overwrite public members?

KittyExample 1: function Cat(){ this.color = function (){ return "Green"; }; } Cat.prototype.color = function(){ return "Blue"; } var kitty = new Cat(); alert(kitty.color()); // Green Example 2: function Cat(){ var color = function (){ return "Green"; }; } Ca...

Noobs y u no understand there is no "private"
 
$('#myselect').change(function(e) {
	var $tb = $('#mytextbox');
	$tb.val(tb.val() + $(this).val());
});
 
@RyanKinal what if i had a form with drops down textboxes etc where they are suppose to be and once the user chooses an option in say drop down or types in a textbox, using AJAX the option chosen in drop down is appended inside the textarea?
what you have works too I think lemme run it on fiddle
 
3:33 PM
I want to suggest relaxing object literals to drop the value requirement for keys, but can't find a link to register on the ECMA-262 harmony wiki
Anyone got any ideas?
 
@JeffHodge THATS what u wanted?
....
 
0
Q: How can I make this Javascript (jQuery, jQuery-UI, AJAX) code better?

VarLogRantThere's things I know about Javascript and jQuery, and things I don't. I know that this works, gets and stores what I want so that, when I need to do stuff, I don't have to wait for it. Functionally, I like this. But I'm the only Javascript guy in my shop, and so I don't see Javascript I didn't w...

 
user1385191
...can we drop the "dropdown" and "textbox" nomenclatures?
 
user1385191
they're <select> and <textarea> elements, respectively
 
user1385191
or is textbox a silly alias for <input type="text">?
 
@AndyE are you looking for weakmaps?
 
@MattMcDonald yer right :)
 
@AndyE I would also recommend you join es-discuss and send out an email first
 
@Raynos: Yeah, that sounds something like what I'm suggesting. Basically relaxing the syntax to allow something like { prop1, prop2:true, prop3 }
 
Oh wait, you want to drop the value requirement for keys
So the default value is undefined ?
 
user1385191
3:42 PM
yes, python has this
 
user1385191
and I quite like it
 
Interesting.
 
@MattMcDonald the user in the form inputs the form fields in an actual textbox but the append occurs in textarea
 
Use case?
Send an email out to es-discuss with a solid use case
 
user1385191
I believe they're called sets
 
3:44 PM
@JeffHodge is this what u want?
 
@Raynos: I find it useful to sometimes use objects as "lists". For instance, var allowedTags = {B,I,EM,SPAN,A,IMG}; if(element.tagName in allowedTags) { /*do something */ }
 
user1385191
yes, I've done the same with nodeTypes
 
well yeah that is the new solution i thought of. That works great. Is it possible though that if the user changes options in select and textbox that it should apply those changes in the textarea?
 
Of course, I could use arrays and indexOf, but I would expect that to be slower (since it requires searching the array).
 
right now if i change the option it will keep adding to the textarea
 
3:46 PM
@AndyE lazy
 
@JeffHodge ?
@JeffHodge isnt that what u want?
 
yeah
 
@Raynos: I'm british, it's in my nature :-P
 
thats it
 
var allowedTags = ["B", "I", "EM", "SPAN", "A", "IMG"];
if (allowedTags.indexOf(element.tagName) > -1) {

}
 
3:47 PM
but what if u change your option like 5 times
it will keep appending it into textarea
 
user1385191
yeah, but you don't get the quick accessor that way
 
user1385191
the boon is being able to fetch the key directly
 
@Raynos Checking if something exists in a map is O(1), checking if something exists in an array is O(n)
 
@JeffHodge ok? that is what u wanted...
 
@Neal can you post your solution with the changes Ill accept your answer
 
3:48 PM
@JeffHodge and plz reply to me. not just write...
@JeffHodge i posted the soln already
 
Yeah thats what I wanted
a question for you though
if the user keep changing the drop down value
 
yes?
 
@Raynos Like I said, I could do it that way. I don't at the moment because it requires a compatibility shim for older browsers and I would expect it to be slower than property in object.
 
how would it replace old value by new, it cant empty the entire text area
 
@JeffHodge you cant. bc u can still type in the text area
 
3:50 PM
@AndyE 17% slower for arrays
Micro optimising devil
 
@Raynos Think large, think worse-case.
If you need to check something against all possible tags, then it makes sense.
 
@Zirak I understand but not for this use case
 
user1385191
here's a bit on sets in Python: books.google.ca/…
 
0
Q: What are some use-cases of when `delete` has been very useful in JavaScript?

IncognitoWe have some questions here that discuss delete in a more abstracted way, but I'm looking for practical examples of when use of delete could be used, versus doing something such as setting the property to null or undefined. The delete operator deletes a property of an object. What's a case of a...

 
In this case it might also be a coding preference.
 
3:52 PM
hmmm so then the user has to manually delete an option from the textarea if they want to change options
WHAT IF, a js script that stores for the previous option chosen so when a user chooses a different option or changes their option it will search that previous stored option's value and replace it in the textarea by new value
 
@Incognito whats delete?
 
@Raynos what about scaling. 100 array elements vs 100 object properties :-p
 
@JeffHodge stop im done.
 
@AndyE yeah I know
 
@Neal Basically :P.
 
3:54 PM
@Incognito huh?
 
@Neal Oh. It's something in JS that you basically never find in the wild.
It deletes a property from an object.
 
@Neal kk one final last question :P can I choose the location in the text area to place the text from drop down? like 3rd column 5th row?
 
NO
you are being muted
 
@Neal var JustinBieber = {}; delete JustinBieber; now JustinBieber will throw a ReferenceError if you try and access it
 
Hey got a simple quick question:
Why does this always print 0?
var setup_array = new Array();

eval(
"setup_array['username'] = 'user';setup_array['points'] = '380';setup_array['cynicism'] = '50.00000000';setup_array['votes_cast'] = '38';setup_array['avg_vote_speed'] = '0';setup_array['votes_missed'] = '0';setup_array['trusting'] = '47.36842105';setup_array['level'] = '1';"
);
document.write(setup_array.length);
 
3:55 PM
ahhhh so much better
 
@AdamLynch MY EYES MY EYES
 
@Incognito Should that question maybe be community wiki
 
@Neal Oh neal, you are the best
 
@RyanKinal SO's been all rabble raused about the future of CW... blog.stackoverflow.com/2011/08/the-future-of-community-wiki
 
user1385191
WHY ARE YOU EVALING IT
6
 
3:56 PM
@Zirak I'll delete it once you answer it:P
 
@MattMcDonald +1
 
> We removed the ability for users to make a question community wiki, but left the ability for users to make an answer wiki.
 
@Matt it's coming from a POST request. I mean a PHP -> mysql connection
 
@AdamLynch because you're not adding any elements to the array, you're just setting object properties.
 
@AndyE what do you mean?
 
3:58 PM
I can't look at it. The screams of a million flesh-eating succubi tearing away at their victim's flesh accompany your message.
 
@RyanKinal can you post your solutionyou gave me in my post as well? you were the 1st to tell me of it so id like to atleast +rep you for it
 
@Incognito rly? wth
 
@Adam: you're one of many individuals that has an incorrect understanding of javascript arrays
 
@MattMcDonald Nah bro, don't worry. onclick="javascript:document.this.innerHTML(\"<a href=\"\javascript:eval(\"alert(\"I like cheese\");\")">\"")
 
user1385191
@AdamLynch what does the responseText look like?
 
3:59 PM
 
@Andy Yeah I probably do. But in this case I used this: stackoverflow.com/questions/3288709/…
@Matt I'm using jquery.post so I handle the response like:
..... , function(data) {
alert(data);
alert(setup_array.length);
}
 
@AdamLynch dont do that
 
@Adam: that example uses numeric indexes, which is different to yours
arrays don't support named indexes - per se.
 
@AdamLynch return a json and then use it in js
 
@AndyE Oh ok, I thought associative arrays existed in JS
 
user1385191
4:01 PM
PHP's double arrow operator (=>) will give your arrays string keys
 
@Neal How do I parse the JSON then?
 
user1385191
there is no such thing in JS
 
@AdamLynch huh? with javascript
or if you are using jQuery parseJSON
 
@MattMcDonald or $array['hello']=world'; (almost like my JS)
@Neal parseJSON will do. I wasn't sure if you were suggesting regex or what
 
@MattMcDonald got paamayim nekudotayim?
 
user1385191
4:03 PM
$superhero::staticshock
 
user1385191
nobody's going to get that joke
 
I'm worried I'm doing something really wrong because I want to try something differnt.
 
user1385191
 
@MattMcDonald I saw the cartoon when I was growing up.
 
user1385191
yay
 
4:06 PM
@Neal I know now what you mean by "ugh with javascript" but it would have been only fair to explain
 
@AdamLynch :-P
 
I've got some jQuery going on (so the plot thickens), and I'm trying to create a popup entirely isolated from variables, basically I just want to use a bunch of internal references. Should I stop what I'm doing and use variables like a big boy, or does this make sense?
        $( "#addTravelsWith" ).button({
            "icons": {primary:"ui-icon-circle-arrow-e"}
        }).click(function(){
            $('<div title="Add person" class="profileBox">').dialog({
                width: 625,
                height: 425,
                modal: true,
                close: function() {
                    $("#LLDialog").detach();
                }
            }).append(profileDOM.cloneNode(true)).find("button").click(function(){
                $()
            });
        });
Yeah, this is insane. I don't know what's in this coffee... I'm doing it wrong.
 
user1385191
use json2.js
 
JSON.parse anyone?
 
user1385191
4:11 PM
it's included with json2.js
 
JSON support is already implemented natively in some browsers
 
how on now people I was just going to use var x = ~JSON response~
 
Anyone based in england?
 
is that not universally supported?
 
user1385191
4:12 PM
var foo = JSON.parse(xhr.responseText);
 
@AdamLynch ~JSON response~ is a string, not javascript
 
Er, wait, I think that's going the wrong way.
 
huh? if I send this back from my PHP "{
"name": "Jack (\"Bee\") Nimble",
"format": {
"type": "rect",
"width": 1920,
"height": 1080,
"interlace": false,
"frame rate": 24
}
}"
and store it in a variable
is that going to work?
 
No, because it's a string
 
@AdamLynch IE6/7 dont support anything of value
 
4:14 PM
@Zirak but sure how can I send anything else but a string back over HTTP?
 
You can;t. You need to parse it on the javascript side.
If you intend to use it
 
ok. What do you think is the best solution for parsing then? I will only have a simple JSON object with one level
 
@Tom FAIL
 
Tom
@Raynos what..?
 
4:17 PM
JSON.parse, if you're using a library/framework there's oughtta be a JSON parsing method, and for backward compatibility Crockford's json2 someone linked to earlier
 
Did you really use the v string in your version number?
ffffffffffffffffffffffffffffffffffffffffff
 
If you have a variable thats got these values "val1, val2, val3, val4"
 
Y U NO DO IT LIKE EVERYONE ELSE
 
whats the easiest way to put them into an array?
 
@Zirak so both JSON.parse and Crockford's json2?
 
user1385191
4:18 PM
String.split(delimiter)
 
Crockford's json2 implements JSON methods for older browsers
 
Thats the one :
thank you
 
Tom
@Raynos you talking to me about the v?
 
@Tom yes
 
Tom
@Raynos v is supported by NPM
 
4:19 PM
@Zirak Ok. Which browsers don't support JSON.parse? I'm already using a whole load of stuff which isn't supported. not sure this matters that much
 
user1385191
tons
 
@Tom no-one else does it. It's really annoying
 
user1385191
Crockford's got you covered
 
It's like those people who use capital letters in their npm package name
 
Tom
@Raynos I was one of those, too. :)
I like CamelCase
 
4:20 PM
@Tom FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
Seriously can we stick to de factor standards
 
@Tom PascalCase, thisIsCamelCase, underscores_suck
 
and not turn my package.json file into a piece of spaghetti
@Tom and you mean PascalCase. It's called PascalCase. camelCase is camelCase
 
Tom
@Zirak yeah, you're right it's actually PascalCase.
I know.
@Raynos let me remove the v.
 
Devs y u no understand layers of things and how they connect?

PHP runs in A, JS runs in B. A can only send raw text to B, B does whatever magical spells it wants to the raw text. There's no such thing as objects being persistent via transmission, only expressed in ways that can be imported/exported neatly.
2
 
@Raynos: wrote a larger test for you - jsperf.com/lists-indexof-vs-in-operator (hasOwnProperty ftw)
 
4:23 PM
@Tom see pull request
 
user1385191
...and that's why objects are so awesome
 
For lunch, I think I'll go eat a roti.
 
@MattMcDonald: yeah... that object literal is a bit unsightly though - hopefully that will strengthen the case ;-)
 
@Zirak @Matt @Ryan how do I use json2.js? Do I just include it and store the json in a varaible? I can't see a function to call
 
Tom
@Raynos fixed. Now some real feedback :D github.com/tommedema/ExpressArchTest
 
4:28 PM
@Tom I'm shredding your code in my fork.
 
user1385191
<script src="./json2.js" type="text/javascript"></script>
 
@AdamLynch JSON.parse
And to turn something into JSON, JSON.stringify
 
stupid connection
 
typeof(a) vs typeof a
 
@Raynos They're exactly the same
 
4:34 PM
I meant style preference
 
oh, then the latter - less things that distract your eye
 
@Zirak what? so I receive my response from the PHP and pass that into JSON.parse() ? then what?
 
Then an array/object is returned from the function, which is the array/object that JSON is representing
 
@Tom as mentioned follow my fork. I'll let you know when I'm done shredding your code ;)
 
Like, if your JSON is "[{\"answer\": 42}]" (notice that it's a string), then calling JSON.parse on it will return [{answer: 42}], a legit javascript array
 
4:40 PM
@Zirak so where's json2.js being called?
@Zirak sounds good. but do I need json2?
 
json2 is for backwards compatibility, providing these functions for browsers that don't support them
 
Tom
@Raynos I definitely prefer typeof(a). And I will check out the fork. Thanks :)
 
@Zirak so do I just include json2.js and do nothing with it?
 
user1385191
L O L
 
What do you mean by "do nothing with it"? It's like any other file
 
user1385191
4:43 PM
he thinks it will automagically transform a string into JSON
 
Oh. Nooooo.
 
@Zirak No. You're saying call JSON.parse. Is that a function from json2.js?
@MattMcDonald Well done. You're cool
 
JSON.parse is provided by modern browsers. What json2 does it define it when it isn't present, see "older browsers".
 
@Zirak yes. So to provide it when it's not present, I do nothing but include it. thanks
I'm gone. Thanks
 
heh so this is a first... a "developer" I work with just raged at me...
because I did the work faster than she could :?
 
Tom
4:59 PM
holds tongue
 
user1385191
eh, hold your tongue
 
ohhh low blow lol
 
Tom
I could not resist :(
 
no man its just frustrating they claim I am so much "better" because I do this at home.. and then they insult me by saying they would rather spend time with their families :?
rant over
 
user1385191
how much of an age gap is there?
 
5:02 PM
Im 28, shes 31, the other dev is like 38
 
user1385191
a simple "while you were out partying, I was honing my craft" tends to work
 
hah actualy thats a great response
 
Tom
holds tongue once again
 
LOL
 
user1385191
eh, you're teetering on a dangerous precedent
 
5:03 PM
yeah id never say that
this is the workplace afterall
 
Tom
I'm not being serious, and I do apologize. =)
Although, there might have been a certain, slight truth.. somewhere.
 
lol @Tom yeah I figured you were messing around
 
Tom
@Raynos did you give up?
 
user1385191
the amount of people my age that go out and binge drink is ridiculous
 
yeah these two still do as well its pretty sad honestly.
since they both have kids
I have 4 kids so I just hang out at home with the fam and wife
heh but theyd think it was sad that I was sitting at home on a sat night answering SO questions, or working on pet projects :P
 
Tom
5:09 PM
Different interests.
 
user1385191
lol, jsbin totally has big XSS holes
 
user1385191
type this there and watch the havoc:
 
user1385191
var xss = <script>alert("HACKED!!!");</script>;
 
lol
 
user1385191
interesting to note that newer browsers escape innerHTML calls
 
5:19 PM
Hmmm. I was wondering if your above "hack" would work with a remote script as well. It does.
 
Tom
@MattMcDonald they do? How are we supposed to dynamically load scripts then?
 
@MattMcDonald Is that w3 or vendor decided?
 
user1385191
innerHTML is non-standard to begin with
 
user1385191
you load scripts with document.write
 
user1385191
(which isn't valid in XHTML, so pick your poison)
 
5:25 PM
so... dynamic loading of scripts just doesn't happen with valid XHTML?
 
user1385191
synchronous script injection doesn't
 
user1385191
you have to append an element node otherwise (asynchronous)
 
Huh... I didn't realize that was asynch. I guess I just don't inject scripts that often.
 
user1385191
it's a big, BIG topic among the JS community
 
script = document.createElement( "script" );
script.src = s.url;
 
5:37 PM
@Tom I took a shower
 
Tom
@Raynos heh alright ;) no worries
 
@Loktar falcon punch?
 
haha, if only
 
@RyanKinal i like ur site
 
@JeffHodge Thanks. I mostly don't.
There's some good info, but it needs work
 
5:47 PM
unique layout
 
That's the part that needs work, IMO
 
Here is mine's or atleast the homepage, its in progress...
 
I've been messing with ryankinal.com/oocss
 
mine def needs some work :P
 
@JeffHodge Not bad... seems very corporate. Very application-like.
 
5:48 PM
Oh god... we left the office... with a working trunk!
 
what do you think i should improve on?
 
@IvoWetzel O_O
 
my coworker and I are competing on making the best one :P
 
@JeffHodge It really just seems like there's nothing I'd be interested in on your site. It's all "requests", "approvals", "forms", and "incidents"
Very generic terms, I suppose is what I mean
 
this is a section, the homepage is different
 
5:50 PM
Ah, gotcha
 
but even this section, what do you think it could improve on? i really like urs because of the simple layout n flow
 
@RyanKinal @MattMcDonald -.- You inject script tags and set the textContent of the script tag
 
btw: Happy Birthday Linux
 
@IvoWetzel Woo!
 
@Raynos and @Incognito , I know this is a rookie quesiton - but does anyone have a link to the standard ajax error handler function ? (Perhaps a jQuery implementation). I sort of want to check for error text == "" or http code like 0 when the server isn't reached
Or anyone else, for that matter - if you've got a link to share
Nevermind, I think I found it. Feel free to comment, but I think I'll use this method: stackoverflow.com/questions/866771/…
 
6:17 PM
@BrianL Did you read api.jquery.com/jQuery.ajax ?
 
Tom
Is it possible to detect all subfolders and files (on the server) on the client-side with javascript? I'm trying to setup a client-side module system in which modules are automatically loaded.
 
With some backend stuff... and some security concerns, sure
 
Tom
Meh, yeah
 
@Tom Do you mean server-side running JS, or from the client's browser?
 
Tom
@Incognito from the client's browser
 
6:19 PM
@Tom Where does JavaScript get executed?
 
Tom
client-side
 
@Tom How does it get sent to the client?
 
Tom
@Incognito using HTTP
Anyway, Ivo is right
 
@Tom ...
 
Tom
@Raynos how is the fork going?
 
6:26 PM
@Incognito Well, I scanned it of course - didn't see the functionality I was looking for in their error handling examples though
 
who needs kittens
 
@Tom I was eating
 
Tom
Anyone here is against dynamically loading scripts on the client-side? Basically I'd like to prevent putting lots of tags in my HTML and have a bootstrap.js deal with the loading.
@Raynos alright. I'm currently trying to get the same architecture working on the client-side
 
Its on the todo list
Heh the client
the client side is easy
 
Tom
@Raynos huh? who's todo list?
 
6:38 PM
use browserify
 
Why not concatenate files? Also, what's wrong with lots of tags?
 
Ill hack away at my fork of your code in a bit
 
Tom
@Zirak concatenating everything into one bulky file will make debugging a pain
@Raynos last time I checked browserify was way too complex and did too much for my liking
something like this should be light-weight
 
I mean on production. On developing it doesn't really matter
 
0
Q: Move 4 iframes/elements at the same time?

Liso22I'm trying to move 4 iframes simultaneously, however I have a problem when they get out of the screen. You can see the misbehavior here: (I used a small div to make it easier to see the problem) http://chusmix.com/test2.php And this is the code that moves the iframes: // Move iframes setInterv...

 
6:41 PM
You already minify files (or at least I hope), so concatenating makes sense.
 
@Tom all it does is packages all your files into one
 
@Zirak Speaking of, what minify-er do you use?
 
adds the ES5 shim
Minifies it. And emulates require
 
Tom
@Raynos too much for my liking
 
6:42 PM
@Zirak Cool, I'll have a look- I've been out of JS for a while. @Raynos Do you use the same minify-er ?
 
@Tom meh I recommend that
@BrianL I dont use one, but when I will I will use browserify
 
Tom
@Raynos I really do not like shims like the ES5 one, because they are imperfect.
 
But thats node specific
@Tom so you use ES3 instead?
 
@Raynos Cool, thanks for the tip
 
@BrianL whats your serverside stack? Java right?
 
6:43 PM
Closure is written by (ha - and warranted I suppose) Google, right ?
 
Tom
@Raynos I just use whatever each browser supports
 
@Raynos Yep :) Good memory
 
@BrianL Yeppers
 
@Raynos I checked out your blog last night - pretty cool. Though, I was hoping for an RSS feed!
@Raynos Hah, hope that didn't sound like a complaint, I meant it in a nice way - that I'd read your blog
 
6:45 PM
@Raynos Should I submit a ticket? :P
 
@Tom meh then your coding for IE6. I dont do this "code for the lowest denominator" thing
I use shims to make shit browser emulate standards
But yeah google closure is a good minifier
uglifyjs works aswell
 
@Raynos Word, tell 'em.
@Raynos Haha, uglify. I love web buzzword-ish names
 
Oh this is so awesome. My friend set the password on his main server to sudo rm -rf, and a minute ago the telnet login bugged out and executed it
 
@Zirak \o/
 
Oooh... not good
Whoa... Closure has a web service? Is that so you can auto-include it in your build ?
 
6:50 PM
Yes
 
@Raynos Hey in other good news, I got objective (?) JS working as a jQuery plugin. Pretty good too, includes some state and the user of setInterval / clearInterval that I expose as public methods like this.run and this.stop
 
Ok
 
what kind of image would you associate with production?
 
Tom
@Raynos does browserify cache the files?
 
@Tom "cache" ?
It sends all files as one package
the browser caches it
 
Tom
6:56 PM
@Raynos right, but it only generates it once during startup
 
@JeffHodge Maybe better for web design chat .... but ... Maybe some gears ?
 
Tom
@Raynos so I read about browserify, but it does not specify how to require "normal" javascript libraries.
 
Yeah, docs in general never cover use-cases in depth
(then you have PHP.net, which is the blind leading the blind), it's somewhat upsetting. But it's all there, right? :P
 
@Incognito Yep - Haha re: PHP.net -- truthfully I prefer it to MSDN
 

« first day (313 days earlier)      last day (4631 days later) »