« first day (126 days earlier)      last day (4825 days later) » 

9:00 PM
0
A: Backbone.js versus Express versus Ext JS ...and JSPP?

RaynosThere all very different. backbone.js is a client-side MVC framework. JSPP is a javascript pre processor. Express is a node.js specific server-side framework for web development. Ext JS is a framework for making web applications and widgets. There all very different. There isn't any point in...

What the hell is the correct answer?
Maybe a close vote for not beign a question
 
9:10 PM
First ever half-decent script: jsfiddle.net/Mutant_Tractor/F3keA/11
awaits flames
 
@MylesGray what did I say about onclick in HTML files :P
Did you just extend the String.prototype?
 
umm umm umm they are.. the devil?
yesss.....
:P
is that bad?
 
onfocus="this.value=''" That's surely not inline JS in your HTML is it?
 
umm umm umm nooooo :D
@sdleihssirhc lol
 
9:14 PM
for (var c in "foo") {
     if ("foo"[c] === "function() { return this.replace(/^\s+|\s+$/g, ""); }") {
          alert("Why is your trim function in my string!");
     }
}
 
@Raynos is inline JS bad?
 
Also your hardcoding in the id's
Rather then getting the element by ids traverse
 
is that bad?
 
I would say so
 
I don't understadn why it would be bad...
 
9:15 PM
I might be pedantic
If I change the id your code breaks :D
 
well.. its good to be pedantic
well that is true.. but why would I do that?
 
So remove any reference to JS from the HTML.
Someone else might
its not portable
Codes like this.parent.children[0] hard codes to dom structure instead. DOM Structure is less likely to change then id's of elements
<div>
   <input someVal>
   <input click>
</div>
 
Oh okay that makes more sense
 
best to assume that there is a input with some value in it next to the button then to assume that the input with someValue has an id = "someName"
That way you can also have multiple ones on the same page. Id's have to be unique
And I personally like seperation of JS from HTML
 
So calling JS functions from onClick is okay?
 
Neo
9:21 PM
@sdleihssirhc what do you mean good stuff? the question made me laugh my ass off. are you serious?
 
No
element.onclick = function() { ... }
 
Hi again! :)
 
or element.attachEvent(name, f) or element.addEventListener(name, f, false)
use those
 
@Raynos thanks, I appreciate it :)
 
function bind(el, event, f) {
    if (el.attachEvent) {
         el.attachEvent("on" + event, f);
    } else {
        el.addEventListener(event, f, false);
    }
}
Just use that :)
 
9:23 PM
so for element I have to use DOM relations?
 
function addEvent(obj, eventType, eventHandler) {
	if (window.addEventListener) {
		obj.addEventListener(eventType, eventHandler, false);
	} else if (window.attachEvent) {
		obj.attachEvent('on' + eventType, eventHandler);
	} else {
		obj['on' + eventType] = eventHandler;
	}
}
function removeEvent(obj, eventType) {
	if (window.removeEventListener) {
		obj.removeEventListener(eventType);
	} else if (window.detachEvent) {
		obj.detachEvent('on' + eventType);
	} else {
		obj['on' + eventType] = undefined;
	}
}
 
attachEvent("onclick", f) It expects an "on" where as addEventListener doesn't
 
@Raynos yeah, fixed
 
That else block at the end will never be called :P
it's dead code
I mean it might get called in NN4
 
9:26 PM
So it isn't needed?
 
Yep. Only ancient browser's don't support either
@MylesGray you might like this one var get = function(id) { return document.getElementById(id); };
some call it $. That's what $ in prototype does
 
but then im basically making a JQ clone :P
 
Yes. That's what I've been saying all along. I end up abstraction away the DOM and writing a subset of jQuery. Except mine is 10 times slower and buggy
You want to know native JavaScript but you shouldn't really care about which particular browser version of the DOM API your using.
By all means write a jQuery clone. It's a great excercise
 
@Neo I laughed too.
 
@MylesGray You can use document.querySelector() and document.querySelectorAll(), too, but don't try to use jQuery selectors like :eq(n) with it. If I remember correctly, that doesn't work in IE < 9.
 
9:31 PM
Correction: the best stuff.
 
@sdleihssirhc :S ?
 
Neo
@sdleihssirhc I was amazed how the guy knew that much to write all that but knew nothing at all
 
Which question :)
 
@Neo Exactly!
 
Neo
0
A: php code inside javascript intervaled function?

NeoThat result from the php will never change after the page has loaded! you are wrong about it working, if you look at the source code you will see. I think it might be a little too soon for you to work on server-side and client-side at the same time, and definitely stay away from ajax until you l...

 
9:32 PM
@Nyuszika7H thats not cross browser.
@MylesGray to put it blunty. The DOM API's are a bitch. Use an abstraction. Write your own.
 
@Raynos I think I will...
 
@MylesGray whilst your at read the dailyjs how to make a framework series. It's good stuff
 
I have it bookmarked allready
 
Can someone hope into the jquery chat?
:D
or take a jquery question?
 
@phil GOGOGO
 
9:36 PM
okay :D
 
Neo
I didnt wanna hurt the guys feeling but he was too confident on what he was doing
 
@Phil link the jQuery chat
 
How do I do that?
haha, sorry :
I mean, how do I link the jQuery chat?
 
@Neo In programming, as in dating, confidence is always more important than hygiene.
 
@Phil just dump the url into the page
 
Neo
9:38 PM
@sdleihssirhc lol
 

jQuery

All things jQuery
 
@sdleihssirhc that never worked for me. I'm a smelly confident guy and it never works
 

JavaScript

Topic: Anything JavaScript, ECMAScript including Node, React, ...
 
@Raynos But I'm a clean, self-deprecating guy, and I never get dates!
 
Neo
@sdleihssirhc In programming as in anything balance is more important, so take a shower on your next date and be confident
 
9:39 PM
6 messages moved to jQuery
 
I think @Neo has it.
 
@sdleihssirhc I think we need both
 
Neo
I think I'm better at dating than programming, most girls dont have any input validation!
 
@Neo The fact that you make programming jokes makes you better at programming then dating
 
Neo
lol
 
9:41 PM
@Neo That's probably why DDoS attacks are so feasible.
Maybe that's too far.
 
Neo
@sdleihssirhc depends if you're doing after authorization or not
 
@Neo Is that like cuddling, or something?
No. Screw that.
 
Oh dear this isn't JS anymore its just pure double entenres
 
@MylesGray They're getting to be just entendres.
 
@MylesGray whats entenres
 
9:46 PM
@Raynos
A double entendre () or adianoeta [http://rhetoric.byu.edu/Figures/A/adianoeta.htm definition of Adianoeta] at rhetoric.byu.edu. Accessed on 2009-08-06 is a figure of speech in which a spoken phrase is devised to be understood in either of two ways. Often the first (more obvious) meaning is straightforward, while the second meaning is less so: often risqué, inappropriate, or ironic. The Oxford English Dictionary defines a double entendre as especially being used to "convey an indelicate meaning". It is often used to express potentially offensive opinions without the risks of explicit...
 
Thank you :P
 
Neo
@sdleihssirhc no, sometimes a hand shake will do.
but wait for her to say ack before you penetrate her
 
@Raynos what is wrong with extending prototype?
 
@Neo I can't keep up.
 
@MylesGray seriously. Do I ahve to say it again? It breaks for in
 
9:49 PM
You win.
That is now my new motto.
 
isn't for in a bad practise?
 
Array.prototype.WhatDoYouExpect = function() { };for (var i in []) { alert(i); };
Copy and paste it into the console
 
Neo
it wasn't a competition
 
@Neo
 
@MylesGray yes it is. THe problem is you break everyone else's for in on the page. It breaks any badly written 3rd party code.
1 message moved to Sandbox
@sdleihssirhc because I'm no fun!
 
9:52 PM
:(
 
Neo
is the sand box where you send things to be forgotten?
 
Where is wetzel
@Neo I treat it as a bin. It's actaully just a play pen. You can do anything you want in there so I can just dump messages in there
 
Neo
cool
 
Actually. I wonder whether I can get away with creating a locked room called "bin"
 
Neo
9:54 PM
@raynos do you recomment the hash method for tracking page changes with ajax, or I was thinking of using html 5's url change feature
 
1
A: Is defining every variable at the top always the best approach?

pst"Should they really all just be plopped on one line?" I don't think so. Here is how I would write that (ignoring names): function something(){ var a var b var c = 1 var d var e // Do something } This only looks silly in the above because 1) the names suck 2) the varia...

 
Neo

Sandbox

Where you can play with regular chat features (except flagging...
 
He doesn't use semi-columns ;_;
1 message moved to bin
That makes me happy :)
 
Oh dear.. a bin room
F&()&*G DOM MANIPULATION
 
@MylesGray How's that library going?
 
9:59 PM
..... >.>
 
Neo
It wasnt what I wanted
 
elem.appendChild(elem2) ... Wait what? IE doesn't have appendChild? IE has append? F&()&*G IE
 
I want to bury the DOM structure in a deep deep ditch
 
For the record appendChild is pretty cross browser. Just couldnt think of a good example
 
good thing I dont have IE to test on :O
Hmm.. beginning to think using JSFiddle as my IDE wasn't a great move
 
Neo
10:02 PM
is anyone familiar with changing the window.history , I want to if possible add a new element to the object instead of changing the last one
will that work?
 
0
A: Execute js code, using JQuery.

Raynos$.eval = function(str) { eval(str); } $.fn.eval = function(str) { eval(this.selector); } $.post(url, function(data) { $.eval(data); //$(data).eval(); });

Are joke answers frowned apon?
 
Neo
how do you write code in the chat?
 
@MylesGray use cloud9ide and jsdom
 
my take:
0
A: Is defining every variable at the top always the best approach?

ircmaxellI'd highly suggest giving Code Complete 2 by Steve McConnell a read. His argument is that you should neither declare all of your variables in one line, nor should should declare them all at the top of a routine. So, don't do this: function foo() { var a, b, c, d; ...

 
@Neo use "`"
 
Neo
10:04 PM
`foo=bar;`I see @Raynos tnx
 
@Raynos - already firing it up
 
@ircmaxell thats exactuly what I meant with "logical scope"
declare a variable at the start of it's logical scope
What's a good word for logical scope?
 
yeah
 
user1385191
I'd like MSDN's js documentation a lot more if it was labeled properly
 
@Neo make sure you have a space after "`"
 
10:05 PM
@Raynos cloud9ide seems broken on chrome
 
Neo
@Raynos ok
 
@MylesGray Your broken in chrome Try
 
ahh, that's what you meant by that scoping bit, it was a bit hard to understand
 
@Raynos your face is broken in chrome :D
 
Neo
@theGuyWhoWantedToCloneJquery check out this link raynos showed me a while ago: keyframesandcode.com/resources/javascript/deconstructed/jquery
 
10:06 PM
@Raynos im on that - it's stuck on "loading"
 
@MattMcDonald I'd like MSDN's documentation in general a lot more if it wasn't organized like garbaged
 
@MylesGray im in chrome9 ubuntu it works fine
 
user1385191
everything js is under "DHTML"
 
user1385191
which is hilarious
 
@MylesGray you know that you need a git repository for cloud9ide to work with code right?
 
10:08 PM
@Raynos - Already have one
 
Can people try this
 
The errors on the C9IDE page
@Raynos 403
 
@MylesGray what version of chrome? Mine works on 9.0.597.98
 
9.0.597.84 beta (its the mac beta)
 
Try the mac stable. Try FF. Else try forked the cloud9ide chat program
 
10:11 PM
@Raynos still borked in mac stable but works in FF
weird
 
Neo
@MylesGray does drop box mount a folder on your computer or is it all webbased?
 
@MylesGray file a bug report. You are in the beta of c9ide so file it as a bug
 
@Raynos cleared cache - all is well
 
weird
 
10:23 PM
ARGHHHHHHH C9IDE is going to make me rage... @Raynos style
 
@MylesGray whats wrong with it
Its lovely :)
 
can't bloody rename files without it going and creating 2 ones called untitled.js >.>
 
just hit the refresh button
on the view
it does that sometimes for me
 
.... >.>
 
Its a beta. Its a bit buggy
 
10:27 PM
someone needs to put a setTimeout on that :D
 
user1385191
reminds me of flex compiling the same file over and over again with different code. it needed me to rename the project.
 
@Raynos when does it commit to GitHub?
It isn't commiting on save?
 
@MylesGray use git on the command line
git add filename
git commit -m "first commit :3"
git push origin master
 
oh you have to do it manually
 
@MylesGray it'd be a nightmare if it commited on every change without any kind of commit message
 
10:32 PM
night :)
 
ughhhhhh i dont understand this shit RAGE
how do I add a file within a folder
surely that is an easy thing to do
but no
:P
 
right click on folder. New -> JavaScript file
Alternatively you can call newFile on the command line
 
no no i have the file made and named
i want to commit it
but i cant ;(
 
oh git add FolderName
git add .
git*
use git status
 
"."?
 
10:39 PM
git add . // all think regexp
 
i tried get add .
 
You probably just want to git add FolderName which adds anything in the folder
did you commit it?
 
ahh okay :)
 
did you push it?
 
tried to
 
10:40 PM
like I said git status will tell you hwats commited, whats waiting to be commited and whats waiting to be added
@MylesGray do you know how to use git ? :P
 
nope :)
i use svn
 
then read
Also dont try the command line for anything but git. something as simple as cd & ls are broken :)
 
now it works!
... i tried cd
i borked the world
what the hell is that stupid white line for in the middle of my IDE >.>
im gonna go out killing
 
Thats the 80char limit line :D
Cause pros dont go over 80 chars
 
my arse
 
10:45 PM
go into settings (ctrl + -) and turn it off. Its a bit buggy. If you change the number then turn it off it should work
 
man I need a coffee
 
Yeah it needs work.
The lack of block collapsing makes me rage
I need it for my code reading ;_;
 
why don't you just use eclipse then?
@Raynos wahey:
 
@MylesGray that has no JS :D
You hid the src!
 
but it works ;)
 
10:52 PM
@MylesGray I recommend setting up gh-pages rather then linking it into a jsfiddle
I have a gh-page set up to run my unit tests in the browser
 
you mean hosting on gh?
New whitespace trimming function:
//White space trimming
function trim() {
    return str.replace(/^\s+|\s+$/g, "");
}
Usage: trim(string);
should work shouldn't it?
 
Might want to pass in a str as an argument and call str.replace
Right now it calls window.replace then crashes :D
window.replace = function() { return "42"; }
 
how's that?
 
@MylesGray what's str ? let's try window.str Oh not there. Ehm let's call .replace on undefined. CRASH.
 
10:56 PM
I'm not a JS interpreter or debugger! Stop using me as one.
 
what the hell is this
error: pathspec 'Array and API Testing.js' did not match any file(s) known to git.
yes it is... i can see it, its the only damn file there is arggghhhhh
 
did you not escape whitespace in your name?
git add Array\ and\ API\ Testing.js
Why do you think no-one uses spaces in their names of files?
Naming convention tend to be routed by logic and reason rather then pedantic random choice
 
@Raynos I am trying to trim this element: trim(tempArray[i]);
but when i do that i get string undefined
what the hell do I have to define before .replace
it worked fine as this.replace
 
@MylesGray because tempArray[i] === undefined :)
 
but it's not undefined it has a value as it is in a for loop?
oh man im thick
 
11:09 PM
//White space trimming
function trim(string) {
return string.replace(/^\s+|\s+$/g, "");
}
You forgot that string paramater
 
yep
just realised that
 
I only told you 3 times :D
 
such a face palm moment
:D
now start validating tags against the API :D
how would i go about getting the JSON response from a URL? I have my URL constructed with the tags in the array being looped into it but I can't work out how to actually get the data
 
@MylesGray what are you using to get it? jQuery?
 
Raw JS
 
11:21 PM
If not you need an XHTMLObject
 
the whole purpose of this exercise was to get it functional so i could port it to android easily
would i be best just to use JQ?
 
xhr: window.XMLHttpRequest && (window.location.protocol !== "file:" || !window.ActiveXObject) ?
                        function() {
                                return new window.XMLHttpRequest();
                        } :
                        function() {
                                try {
                                        return new window.ActiveXObject("Microsoft.XMLHTTP");
                                } catch(e) {}
                        }
XMLHttpRequest is the none IE one. If you can drop IE support its easier :)
No, it's good to learn how XMLHttpRequest objects work rather then just relying on jQuery
I havn't got round to learning it yet though
 
Okay ill try it
 
IMHO this stuff is black magic :D
 
hmm.. async or sync
 
11:30 PM
async
synchronous request makes me murder. It blocks the browser completely.
 
Hmm...
XMLHttpRequest cannot load api.stackoverflow.com/1.1/search?tagged=php. Origin fiddle.jshell.net is not allowed by Access-Control-Allow-Origin.
 
@MylesGray Ah yes cross browser access. Use JSONP
I think
 
no that doesnt make sense
 
cross domain even.
 
its a JSON response and I cant pull it from another page?
JSONP = JSON with Padding?
 
11:38 PM
JSON (an acronym for JavaScript Object Notation ) is a lightweight text-based open standard designed for human-readable data interchange. It is derived from the JavaScript programming language for representing simple data structures and associative arrays, called objects. Despite its relationship to JavaScript, it is language-independent, with parsers available for most programming languages. The JSON format was originally specified by Douglas Crockford, and is described in RFC 4627. The official Internet media type for JSON is application/json. The JSON filename extension is .json. Th...
 
I use the last.fm API on my own blog site
it works fine
 
Of course. Theres the cross-domain restriction to protect you
 
and its not JSONP
 
Try using jQuery.ajax
 
All I did on last.fm was this in the HTML:
<script type="text/javascript" src="http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=mutant_tractor&api_key=6b85edc3841f3d0935d9dfed9c556634&limit=4&format=json&callback=lfmRecentTracks"></script>
 
11:41 PM
@MylesGray thats JSONP
 
then in the JS had the function's input as: function(JSONData)
 
lfmrecentTracks is a function?
 
yep
 
Thats how JSONP works.
 
im just checking if I can add a callback to the SO API
 
11:42 PM
You can
 
Ah good stuff, sorted then
 
jsonp paramater
jsonp=functionName probably
 
Ahhh... wait problem occurs
 
the user inputs the tags into my tagsArray - this is then looped through to query the API multiple times
 
11:44 PM
it wraps the JSON object with foo( + json + );
 
thus I need to change the URL in the script tags
and I don't think that can be done programatically :/
 
You create a new script tag
inject a script tag with a specific src
It will be loaded and the function will be run
If you must you can delete the script tag from the dom after your done
 
so just run a eSpan = document.createElement("span");
eSpan.src = URL;
 
@MylesGray create a script not a span
 
sorry that is what i meant
//Plug tags into API URL
function tagLookup() {
    for(i=0;i<tagArray.length;i++){
        var URL = "http://api.stackoverflow.com/1.1/search?tagged=" + tagArray[i] + "&amp;callback="tagQuestions"";
        var createScript = document.createElement("script");
        createScript.src = URL;
    }
}
Hmm I may have problems with all the callbacks
actually I could just do it in one URL request with the +or+ operator
//Plug tags into API URL
function tagLookup() {
    var URL = "http://api.stackoverflow.com/1.1/search?tagged="
    for(i=0;i<tagArray.length;i++){
        URL += tagArray[i] + "+or+"
    }
    URL += "&amp;callback="tagQuestions"";
    var createScript = document.createElement("script");
    createScript.src = URL;
}
better :)
 

« first day (126 days earlier)      last day (4825 days later) »