« first day (102 days earlier)      last day (4850 days later) » 
00:00 - 14:0014:00 - 00:00

<?php
    $foo = 'foobar';
    echo <<< EOD
This is PHP's <i>heredoc</i> syntax. You can use 'single' and "double" quotes there, because you don't need to put your text in quotes. Heredoc acts like as if you'd use double quotes, so you can put variables inside it. Foo is $foo. You'll see <i>Foo is foobar.</i> in the output. Closing the heredoc in the next line.
EOD;

    // heredoc end
?>
 
@DanielGR I'm not sure if I see anything wrong with that
 
:)
theres nothing wrong
sorry...
Now it works
 
You can put anything in the place of EOD. If you don't want $foo to become foobar in the previous example, you can use the nowdoc syntax. It's the same, just use 'EOD' (inside single quotes).
 
I don't know what I'm does bad
last time
thanks
 
2:05 PM
@DanielGR Wait a minute!
 
tell me
@Nyuszika7H
 
@DanielGR jsfiddle.net/6kxcp/1 added comments with tips inside
 
@Nyuszika7H thanks
 
@DanielGR np :)
 
@Nyuszika7H ;)
 
2:25 PM
Anyone here know ajax?
 
@David19801 yep
 
@David19801 ajax? (hic) I 'ardly knew 'er!
 
lol, I am trying to send a form
then once the form is sent, the form is removed to stop people sending it again and again
I have the ajax part done
and the basic form in html
 
@David19801 Are you using jQuery?
 
no jquery, raw
 
2:28 PM
hmmm
 
for the state change bit I have: if(ajaxRequest.readyState == 4){
document.time.innerHTML = ajaxRequest.responseText;
}
is that correct javascript?
then in the html part their is: div id="time" name="time">

</div>
 
@David19801 Ah, you should be using document.getElementById('time') instead
 
@David19801 This won't work in IE.
 
you could have IE problems
@Nyuszika7H beat me to it
 
@MylesGray Huh?
 
2:30 PM
:277287 tab to autocomplete
 
why would it not work in ie?
 
@Nyuszika7H I was just done typing youll have IE problems when you posted it
@YiJiang Thanks ;)
 
@David19801 Because the time variable isn't defined. Non-IE browsers support using someID for <div id='someID'>test</div> (not only for DIVs, but all elements), but that's bad, you should use document.getElementById() instead.
 
how can I correct for this?
 
@David19801 Like I said, use document.getElementById
 
2:32 PM
@David19801 Just use document.getElementById('time'). That will work in IE, too.
 
@David19801 remove the name="" attribute and use doument.getElementById()
beaten to it again, damn
 
@David19801 If you want cross-browser comatibility (i.e. for events, IE uses attachEvent, others use the W3C standard addEventListener), use a JavaScript library like MooTools or jQuery.
 
does id have to be capitalized?
 
@David19801 I is capital, but d isn't.
 
@David19801 No - my mistake getElementById()
 
2:34 PM
How do I convert an array-like object to an array?
 
Its not updating...My code is now:
<form name='myForm'>Name: <input type='text' name='username' /> <br />
<INPUT TYPE="submit" onClick="ajaxFunction();" VALUE="SIGN UP!">
</form>
<div id='time'>test</div>
 
@Raynos So you have 0: 'foo', 1: 'bar' etc. in your object?
@David19801 Ask a question on SO, and post its link there.
 
@Nyuszika7H yes
 
quicker here I think, i'm nearly done! (I guess)
 
@David19801 Then press CTRL+K after typing your code.
 
2:36 PM
@Raynos you could use a for loop to iterate through them and place them into an array?
 
This is the ajax code: document.getElementById('time') = ajaxRequest.responseText;
 
@David19801 document.getElementById('time').innerHTML = ajaxRequest.responseText;
@Raynos
var myArr = [];
for (var i in myObj) {
    if (myObj.hasOwnProperty(i)) {
        myArr[i] = myObj[i];
    }
}
 
@MylesGray I can do it manually but I wanted some kind of easy method.
 
@Raynos You can put it in a function.
 
Thanks! It seems to be updating now...but it just returns the same value...(test) how can I make it update with what php returns...
 
2:39 PM
@David19801 location.search.replace(/?/, '').split('&'); maybe?
 
okok, I just realised I don't want to update it...I just want the form to disapear after the button is pressed...how can I just make the form vanish?
 
@David19801 document.body.removeChild(document.getElementById('time'));
@David19801 Anyway, try out [api.jquery.com](jQuery). It simplifies code. You can use CSS selectors with it:
Example: $('#el') => document.getElementById('el')
 
eh, its not working :(
ok, i'll check out jquery...but will that slow my code down?
 
@David19801 I don't think so. Just include this code above all other <script> tags:
 
Ah. i want to call _.reduce(object, function(memo) { return ++memo; }, 0) That's so much better then for looping over it.
 
2:43 PM
<script src='http://code.jquery.com/jquery-latest.min.js'></script>
Since it's pointing to the minified version, it won't slow your down your script much.
Check out its AJAX functions first, these are very powerful. Also, you can do event handling cross-browser: $('.obj').bind('event-without-on-prefix', function() { event handler goes here });.
Two more examples:
Vanilla JS
var para = document.createElement('p');
para.innerHTML = 'Hi there!'
document.body.appendChild(para);
jQuery
$('<p>', { html: 'Hi there!' }).appendTo('body');
This was the creating. Now the removing…
Vanilla JS
document.body.removeChild(document.getElementById('el'));
jQuery
 
wow, jquery looks pretty powerful, i'm reading it on the site now...
 
$('#el').remove();
 
I'm going to try it the hard way first, then move to jquery in a few minutes...thanksN7H!
 
@David19801 Yes, and it's very easy to learn. Just make sure you know enough vanilla JS, because you can't replace every JS function with jQuery. ;)
 
easy to learn, hard to master :p
 
2:49 PM
@jAndy jAndy = jQuery Andy? :P
 
Anyone who could know the issue here..? Tried figuring out for some hours now without luck -.-
http://stackoverflow.com/questions/4804304/valums-ajax-file-upload-handle-the-up-file
 
@Nyuszika7H: unfortunatly "Andy" is used like a zillion times, so I needed some prefix there :p
 
Waking @Raynos up..
 
@Nyuszika7H In jQuery I can target a class with:
$('.someClass')
If I have multiple instances how to I target $('.someClass')[0] for example?
 
@Karem If you're lucky, Valums might come around and help you :P
 
2:53 PM
@YiJiang is valum on here?
 
@MylesGray If you want to pass it to vanilla JS, this is the correct way. Otherwise use $('.someClass:eq(0)') or $('.someClass').eq(0).
is leaving for a hour
 
oh nice although may not be big chance hes on when im on
 
@Nyuszika7H Thanks, my script is a muddle of vanilla and JQ.. not good to look at :/
 
and you cant pm on SO -.-
 
2:56 PM
@Karem If you're really desperate you can drop a comment on one of his posts to your question. But it's really not nice to do that, so...
 
@YiJiang okay.. it's just that not even the demo there is are handling the file in php so i dont know how to do it, im not receiving anything very annoying, shouldnt the upload 'form'/button send ajax call with an "multipart/form-data" thing, it doesnt..
@Nyuszika7H did you remove your answer or?
 
3:14 PM
Still not working...
<div id="tt">
<form method="post"><input type="text" name="c"><br><INPUT TYPE="submit" VALUE="givetime"></FORM>
</div>
and : if(ajaxRequest.readyState == 4){
document.getElementById('tt').innerHTML= ajaxRequest.responseText;
}
any ideas?
 
Can anyone here see this page?
http://mutant-tractor.com/tabtest.html
Not a plug just my hosters are being crap and sometimes I get 404's but others I can see it.
 
3:43 PM
An element on my page grows when content is placed into it ... is there a way to use jquery animate to make the element's growth smooth, but automatically (without calculating the width/height each time)?
 
4:01 PM
Hi there! :)
@Karem Yes, I removed my answer because it was wrong. Your JS code is correct.
 
Quick Question.
Does anyone have any idea why I can't attach a working onmousemove event on a SVG embed element?
        <embed id="foo"
                   src="example2.svg"
                   width="800" height="620"
                   type="image/svg+xml"
                   pluginspage="http://www.adobe.com/svg/viewer/install/" />
            <input type="text" id="x" /> <input type="text" id="y" />
            <script type="text/javascript">
                var foo = document.getElementById('foo');
                var x = document.getElementById('x');
                var y = document.getElementById('y');
arg
 
@ircmaxell First, why do you need an <embed> for that?
 
What would you suggest that's cross-browser for displaying a SVG element?
 
@ircmaxell Hmm, it isn't supported cross-browser?
 
is it?
 
4:14 PM
@ircmaxell IDK
 
Nope
IE7 won't display a SVG image
(broken)
 
<img src='data:image/svg+xml;base64,…' /> maybe?
 
From wikipedia:
 
Maybe use html5shiv and the <svg> element?
 
Is ther an easy way to determine if a JS object is an Array?
 
4:17 PM
@edoloughlin ES5 has a new method: Array.isArray(myArr);
@edoloughlin To support older browsers, you could do this:
 
As of 2010, only Opera, Safari and Google Chrome supported embedding via the <img> HTML element. Mozilla Firefox and some other browsers that can display SVG graphics currently need them embedded in <object> or <iframe> elements to display them integrated as parts of an HTML webpage.[47] However, SVG images may be included in XHTML pages using XML namespaces.[48]
 
A CSS hack for IE8 quirks mod please. Wait CSS hacks are stupid. Ill stick to conditionals
 
function is(class, obj) {
    return Object.prototype.toString.call(obj).slice(8, -1) === class;
}
 
@Nyuszika7H Thanks!
 
Usage: is('Array', myArr)
It returns either true or false. So you can use it in an if statement like this:
if (is('Array', myArr)) {
    …
} else {
    …
}
 
4:20 PM
@Nyuszika7H Gotcha. Excellent.
 
Another way:
function class(obj) {
    return Object.prototype.toString.call(obj).slice(8, -1);
}
Usage: class(myArr) === 'Array'
if (class(myArr) === 'Array') {
    …
} else {
    …
}
 
@Karem what do you want?
 
@ircmaxell can you use <object> ?
 
@Nyuszika7H Hmm. This returns 'Object' in Safari...
 
4:24 PM
@edoloughlin Hmm.
 
@Nyuszika7H My bad. Wrong object! It works.
 
I love SVG images!
 
I dunno
 
@Nyuszika7H So do I, until I saw noone follows the same specification on it.
 
> hoverIntent adds two custom attributes to every DOM element it's assigned to. For example: <li hoverIntent_t="" hoverIntent_s="">
Oh, why not just use jQuery's .data() method?
 
 
2 hours later…
6:30 PM
are users still active in this room?
 
@ryan yes, vaguely
 
@ryan yes. This is one of the more popular ones. What do you need?
 
6:46 PM
@Raynos not much, apparently
 
7:11 PM
ok ill just go ahead and ask since i can't seem to find an answer to this..
Within jquery, is there a way to pause/store an event handler for a specific element and only to execute that handler when needed?
Example:
$('a#lets-do-it').click(function(){ alert('hola!') });
but in another file, id like to override temporarily that handler with..
$('a').click(function(e){
alert('lets login user first');
// once user has logged in (for instance)
// then carry our original handler
});
oops, last line comment should've read: then carry out* original handler
 
Simplest thing I could imagine is to delegate the events to some other function which then decides based on some state if the click is valid
Everything will be a giant mess with event setting
 
thats what i wanted to avoid
it would be much simpler if i can just override all the elements
 
@Karem -.-
@Karem see above.
@ryan namespace events
 
7:28 PM
@Raynos
 
$("a#foo").bind("click.foobar", function() {});

var f = $("a#foo").unbind("click.foobar");
$("a#foo").bind("click.foobaz", function() {
      // do stuff
      if (success) {
            f();
            $("a#foo").bind("click.foobar", f);
      }
});
 
let me try that
 
Also $(obj).unbind(".foobar") which unbinds all events namespaces as foobar might be useful.
you can also call things like e.stopPropogation on your "newer" handler to block the "older" handler.
 
@Raynos both++
lol
sorry for being little nonserious
 
@Karem nonserious is fine. non-proffesional just looks bad on you :)
 
7:34 PM
true
 
@IvoWetzel is @NickCraver really locked in the basement?
 
yay remove some string checks and performance goes up by 10x
 
// just doing some string checks
if (input.match(new RegExp(" MONSTER OF A REG EXP ")) {
     isValidHtml = true;
}
Your suprised you get 10x performance gain? :)
 
@Raynos The legends tells... although it speaks more of dwarfen "basement", so you might as well call it a bottomless abyss
 
how do i list handlers that were attached to an element with the live() method?
 
7:38 PM
@ryan you don't use live and instead use delegate
 
@Raynos
        function clas(args) {
            if (is('Object', this)) {
                ctor.apply(this, is('Arguments', args) ? args : arguments);

            } else {
                return new clas(arguments);
            }
        }

-->

        var plain = false;
        function clas() {
            if (this !== global) {
                plain ? (plain = false) : ctor.apply(this, arguments);
                return this;

            } else {
                plain = true;
                return clas.apply(new clas(), arguments);
 
@IvoWetzel out of context and meh. Btw I gave up on custom class objects. Its a stupid idea :)
 
:P
Refactoring my class thingy
 
Relying on mixins, closures & ownership is better
 
ill try and use delegate for now on. but is there no way of obtaining a list of handlers that was bound by the live method?
$(document).data('events') ?
*oops no quotations
er nvm i thought i had quotations wrapped around document
 
 
1 hour later…
9:01 PM
@Raynos sorry, didnt know it got taken that professionaly in here, that my account got blocked.
 
9:57 PM
Another site to add on the "no go" list
Public Beta of CodeReview just started! codereview.stackexchange.com
 
10:20 PM
Hm
 
Vin
10:47 PM
Anyone using knockoutjs here?
 
nope
 
Vin
any other MVVM js library anyone wd like to suggest?
 
11:04 PM
Can anybody explain why my jquery tabs are doing this out of the blue? I just upgraded to Jquery UI 1.8.9. In addition - its showing all of the tab frames in a large column, and its just not working properly at all.
 
@IvoWetzel heh, first line: var intValue = 1;
 
00:00 - 14:0014:00 - 00:00

« first day (102 days earlier)      last day (4850 days later) »