« first day (133 days earlier)      last day (4814 days later) » 

5:02 PM
it would return the instance
 
Hi again! :)
 
How do I check to see if a form field contains at least 1 number and letter?
 
@GnomeSlice /[a-z]+\d+/.test(document.getElementById('myField').value), maybe?
 
@Nyuszika7H I'm still learning. I'm not really sure what the first part of that even means.
 
@GnomeSlice /test/ is regex literal, but my code is wrong, still experimenting with it…
 
5:15 PM
...Like I said. Just learning... o.o :(
I know how to check length at least.
 
@GnomeSlice I'm learning, too, but probably I know more things than you… I have 513 rep :)
 
I've got my .onblur listener, and once that happens I call a bunch of functions.
 
@CodingKitten Do you have any ideas?
 
var s = '1212sd23';
!!(s.match(/\d/) && s.match(/\w/));
 
@Nyuszika7H Ya, one project I worked on wound up to speed on modular layout.
 
5:18 PM
Two regexs should do
 
One to check that it's at least 10 characters long, one to check for at least one letter, and one to check for at least one number.
 
@YiJiang \w catches some other characters, too, not only letters…
 
@YiJiang I'm not even sure what that means.
Heh...
 
@Nyuszika7H Hmm, well it matches digits too
@GnomeSlice It's simple, those are two regexs matching against the string s
 
@YiJiang And underscores.
 
5:22 PM
@YiJiang I'm not even familiar with that term.
I'm basically taking a beginner's course in college for this stuff.
 
In computing, a regular expression, also referred to as regex or regexp, provides a concise and flexible means for matching strings of text, such as particular characters, words, or patterns of characters. A regular expression is written in a formal language that can be interpreted by a regular expression processor, a program that either serves as a parser generator or examines text and identifies parts that match the provided specification. The following examples illustrate a few specifications that could be expressed in a regular expression: * The sequence of characters "car" appearing ...
 
function validate(field) {
    return (/[a-z]/i.test(this.value) && /\d/.test(this.value) && this.value.length >= 10);
}
Usage: validate(document.getElementById('myField'));
 
@Nyuszika7H !! for booleans I think, can't remember what test returns
 
@YiJiang test returns a booleans.
 
test returns a boolean
 
5:24 PM
My code is much messier.
 
I think the professor is trying to make us stretch it out so much because we're still learning.
I just have separate functions for everything, lol.
@Nyuszika7H Well, I don't have any code for that one yet.
 
@GnomeSlice What?
1 min ago, by GnomeSlice
My code is much messier.
My code... so you have some code.
 
@Nyuszika7H Oh, I thought you meant for that particular validation.
I have other forms I've already validated.
 
@IvoWetzel by Instance you mean it returns swing?
 
5:26 PM
@MylesGray What do you learn there?
ninjaA and ninjaB are instance of Ninja
 
Yep
 
this inside of swing is one of these instances
 
and I want to add extra functionality to them using the prototype of Ninja
 
so in case swing() return this, it returns one of these instances
 
oh god im confused, by instance you mean ninjaA and ninjaB?
 
5:29 PM
yes
 
how can the stuff inside swing be one of those instances?
I don't get that
 
OH!
This = the object currently being worked on
so as it traces over ninjaA, this becomes equal to ninjaA?
 
more or less, yes
exactly
 
oh it's clicked now! thank you so much
So if we want to chain we always return this?
 
5:35 PM
yes
 
cool i've got it now
 
5:50 PM
 
Kev
if i'm doing $("#container a").click(function (e) { alert(?.attr("class"); }); how do I reference the current item being iterated over i.e. ?
 
@Kev this is the 'current' DOM element, so $(this) will get you the current DOM element wrapped with jQuery, thus is the ? in that code
Although in this case it would be easier to use this.className instead of attr('class')
 
Kev
oh bloody hell of course
thanks yi
 
@IvoWetzel in the code you did here:
function API(site, key, ...) {
    this.site = site;
    this.key = key;
    this.schedule = new Scheduler(this);
}
In new Scheduler(this) does this pass the variables site and key to Scheduler?
 
@Kev You don't need to pass e as an argument to event handlers, because it's already there: event.
 
Kev
6:03 PM
@Nyuszika7H thanks for the tip :)
 
@Kev So unlike in vanilla JS, you could do this:
$('#myInput').keyup(function() {
    console.log('Key pressed: ' + event.which);
});
In vanilla JS:
 
@YiJiang I thought that was the whole language?
 
function addEvent(obj, eventType, eventHandler) {
    if (window.addEventListener) {
        obj.addEventListener(eventType, eventHandler, false);
    } else {
        obj.attachEvent(eventType, eventHandler);
    }
}

addEvent(document.getElementById('myInput'), 'keyup', function(e) {
    if (!e) e = window.event;
    console.log('Key pressed: ' + e.which || e.keyCode);
});
How do I trigger IE9 Standards mode in IE9?
 
Kev
@Nyuszika7H thank god for jQuery :)
 
6:08 PM
@Nyuszika7H There's a <meta> tag to do that I think
 
@YiJiang Could you add a stop button to the wheel?
 
@Nyuszika7H Why would you need that? Anyway, add one yourself, the code's all there
 
@Nyuszika7H that defeats the purpose of the randomness of the wheel :P
 
6:24 PM
Look at this edit war! Closed, reopened, closed, reopened… and not to mention adding and removing so many times.
Updated to jQuery 1.5, added background and border to C# to make it look like an image, added John Resig, Jon Skeet, Joel Spolsky and… you. Yes, It's your fault! jsfiddle.net/Nyuszika7H/AYPpF/26
 
7:10 PM
Anything interesting happening
 
@Raynos trying to get my head round prototyping
I have never been so confused in my entire life
this is doing my nut in really can't understand it:
 
@jsfiddlesupport alternative solution: IE9 drops it's engine in favour of webkit - world rejoices ;)
 
@Nyuszika7H I wish
 
@Shaz yeah me too
 
7:34 PM
@MylesGray its a bitch ;)
@MylesGray thats not prototyping. Prototyping requires Constructor.prototype
 
No but this is:
//API Handling for asynchronicity
function API(site, key, ...) {
    this.site = site;
    this.key = key;
    this.schedule = new Scheduler(this);
}

API.prototype = {
    lookup: function(resource, callback) {
        // build the url etc here
        this.request(url, callback);
    },

    request: function(url, callback) {
        // build a request here and send it
        request.on('finished', function() {
            callback();
        });
    }
};

function Scheduler(api) {
    return function(method, options, interval) {
Scheduler is just part of it
 
user1385191
holy hell is jQuery over 200kb now? wow.
 
@MattMcDonald If you look at the pretty version, yes… but the minified one is only 80 kB.
 
user1385191
yes, and the gzipped is 30kb. I was remarking at how giant it's become.
 
@Raynos Ivo wrote the above code for me to demonstrate prototyping and how I can condense my multiple API constructions into one, do you understand how the Scheduler function works? - I don't get how the return function can have parameters passed to it, like where do i pas those vars in from O_o
 
7:46 PM
@MattMcDonald I feel bad for people with dial-up.
 
@Shaz Huh?
 
Dial up is usually around 50kbs
 
@Shaz but if you use the minified+gzipped version…
 
Lol JSFiddel already added a link to jQuery 1.5.1 :P
 
@Shaz It wasn't there some mins ago…
 
8:19 PM
Wow, Chrome doesn't allow redirects to data urls. Hmm
Or at least in the dev version.
 
@Shaz location.href = 'data:text/html;charset=utf-8,<p>hello</p>' seems to work in Chrome 11.0.672.2 dev.
 
@Nyuszika7H Try loading this: tinyurl.com/4qxt4fm
 
@Shaz Hmm.
 
On the error page, click the address bar and press enter
 
@Shaz Yeah, I see.
 
8:22 PM
It will show up then, but not on the redirect :/
 
!kitten wisdom Nyuszika74
 
@CRoss 7H…
 
!kitten wisdom Nyuszika7H
 
Guess you're out of luck with Nyuszika7H. Yawn I nearly fell asleep when checking their answers.
 
:kitten wisdom Nyuszika7H
:kitten wob
 
8:24 PM
:kitten quote Java
 
Kitten is broken…
 
not me
 
@CodingKitten Are you working?
<?php
    header('Location: data:text/html;charset=utf-8,<p>test</p>');
?>
This redirects to the data URI as excepted, but if I also add a 301 Moved Permanently, it won't work.
 
Yeah :/
 
<?php
    header('HTTP/1.1 301 Mover Permanently');
    header('Location: data:text/html;charset=utf-8,<p>test</p>');
?>
 
user1385191
8:33 PM
anyone here worked with DOMDocument in PHP?
 
anyone here worked with DOMParser in JS?
> var parser = new DOMParser();
> var para = parser.parseFromString('<p>test</p>', 'text/xml');
[object Document]
My problem is that it returns a Document object. Any ideas how could I get the newly created node inside it?
Hmm, I think I got it:
 
Bloody Aperture.. who invented that >.>
 
var parser = new DOMParser(),
    myText = parser.parseFromString('<span> — this was inserted using JavaScript</span>', text/xml');

myText = myText.getElementsByTagName('*')[0];
document.getElementById('hello').appendChild(myText);
 
So that's basically a version of eval() of javascript for HTML?
 
You would get a similiar result with document.createElement:
var myText = document.createElement('span');
myText.innerHTML = ' — this was insertes using JavaScript';
document.getElementById('hello').appendChild(myText);
Or jQuery:
$('<span>', {
    'html': ' — this was inserted using jQuery'
}).appendTo('#hello');
 
9:36 PM
anybody with a good way to create XML using JavaScript?
 
@AlexanderN Yes.
var parser = new DOMParser(),
myXMLdoc = parser.parseFromString('<p>test</p>', 'text/xml');
 
not parse, but create properly formatted XML
 
9:57 PM
Hmm, it's a real hassle to catch parse errors with DOMParser.
document.body.innerHTML = new DOMParser().parseFromString('<p>hello', 'text/xml').getElementsByTagName('p')[0].getElementsByTagName('parsererror')[0].innerHTML
 
10:12 PM
BAM:
0
Q: Prototypes and nested return functions, help!

Myles GrayIntro: I know that "How does this code work?" type questions are frowned upon and I'll look about as clever as a brick reading "The Sun" for asking such a question but... here goes. I am trying to understand prototyping in JavaScript, now this isn't the problem, I understand the basics of the...

 
10:32 PM
No-one wants to read a question that long :P
 
@MylesGray viewed 22 times
 
Yep, everyone goes looks at post, sees how long it is and says "well... I'll just go answer some questions on JQuery"
 
11:11 PM
night :)
 
@Nyuszika7H night man
still no answers an hour on ;)
 
Hi! Seems there a small edit war happened in around the link to dev.opera.com (JavaScript Core Skills). I think that the article contains too many inaccuracies and thus is not appropriate for beginners. I had removed the link, but Yi Jiang reverted that. Yi Jiang, do you really think this article is OK?
 
@thorn Yes I do, would you mind pointing out which part of the article contains inaccuracies?
 
11:29 PM
See the code examples for object or array creation. "new Object", "new Array"... Such code is bad style.
 
True, but the rest of the fundamentals are well grounded
 
And you have to remember - it's not a single article, rather it's a collection, and it takes a rather slow approach to teaching the language
Looks like each of the article comes with a discussion forum, should bring this up there: dev.opera.com/forums/topic/265636
But gosh, it's asking me to create an account :(
 
I read it more carefully. And I have to agree with you.
 
11:58 PM
@YiJiang Could you lend any advice as to my above question please?
I've spent the last 4 hours taking bits in and out of that code trying to understand it but I just dont get anything except the initial API function
 
user1385191
@MylesGray Funny, I was reading it not too long ago
 
user1385191
What do you know about OOP terminology?
 

« first day (133 days earlier)      last day (4814 days later) »