« first day (646 days earlier)      last day (4285 days later) » 

6:00 PM
what
 
@Esailija it is going forever!
it is never exiting ht ewile loop!
 
what whileloop
 
$.fn.dirFind = function(selector, dir) {
        var elems = [], item;
        this.each(function() {
            while (item = this[dir]) { //<<<HERE
                console.log(dir, item, this[dir]);
                if (item.nodeType == 1) {
                    if ($(item).is(selector)) {
                        elems.push(item);
                        break;
                    }
                }
            }
        });
        return(this.pushStack(elems, dir, selector));
    }
 
oh right
 
wth....
 
6:01 PM
:P
it should be
 
why isnt it ever stopping?
crashed my browser...
its not.
 
var item = this;
while (item = item[dir])
 
???
It keeps ketting stuck in the while loop!
 
just do the change I just did
 
@Esailija what change?
 
6:05 PM
var item = this;
while (item = item[dir])
$.fn.dirFind = function(selector, dir) {
    var elems = [],
        item;
    this.each(function() {
        item = this;
        while (item = item[dir]) {
            if (item.nodeType == 1) {
                if ($(item).is(selector)) {
                    elems.push(item);
                    break;
                }
            }
        }
    });
    return (this.pushStack(elems, dir, selector));
}
 
@Esailija I dont see a change there///
 
item = this;
while (item = item[dir]) {
versus
 
whats the difference
 
while (item = this[dir]) {
the assignment and the while condition
 
@Esailija arrrg that still has the same issue.
$.fn.dirFind = function(selector, dir) {
        var elems = [], item;
        console.log(selector, dir);

        this.each(function() {
            console.log(selector, this[dir]);
//            return;
            item = this;
            while (item = this[dir]) {
                console.log(dir, item, this[dir]);
                if (item.nodeType == 1) {
                    return;
                    if ($(item).is(selector)) {
                        elems.push(item);
                        break;
Thats my current code and the issue in the console...
 
6:08 PM
while (item = this[dir])
s/this/item
 
I have now pasted the while condition 4 times
you still have it wrong
:D
it should be while( item = item[dir] )
 
oo crap....
 
ur right
@Esailija better:
this.each(function(i, item) {
            while (item = item[dir]) {
                console.log(dir, item, this[dir]);
                if (item.nodeType == 1) {
                    if ($(item).is(selector)) {
                        elems.push(item);
                        break;
                    }
                }
            }
        });
 
yeah lol
no need for this at all
 
6:09 PM
awesome.
I am going to update the answer. bc it is flawed!
awesome ^_^ thanks @Esailija
 
^^
 
@Rlemon still around by chance? just got back from break and am having a few problems with the code you provided, was wondering if you might be able to help
 
@NRGdallas depends. ask and i'll see if I can help
 
oh man 20 non answers, as I click them there is Deleted by @ThiefMaster 15 seconds ago :D
so close
 
6:20 PM
it was spam
 
oh you're quick again
 
@rlemon ive got the script you were working with me on mostly right (or so I think); however when pressing submit on the form just prior to the one which needs to be validated, it acts like it completely is locking the final form. its hard to explain
 
Hi guys,
what are the reasons to adopt js template engine..?
 
What is the naming convention for Javascript constants?
 
@Artha laziness
 
6:21 PM
@Moshe YOU_MEAN_THESE_THINGS?
 
yup
 
@Moshe var TROLOLOLOL_constantName
 
@Artha They were born without parents in a rough town
 
In Objective-C we use kSomeCamelCAseConstantStartingWithTheLetterK
 
They have no choice but to resort to crime. But deep, deep down they're good things!
 
6:22 PM
@NRGdallas jsfiddle.net can you try here? copy and paste your rendered HTML and the js function
 
i did something equivalent to template engine which statisfies my web app needs
 
Adopt a JS templating engine today, and give it a second chance.
@Moshe HINT_HINT_THIS_SHOULD_ANSWER_YOUR_QUESTION
 
k
Also, does the const keyword work the way it should?
Are there any gotchas there?
 
no
 
Non-standard, don't use it
 
6:23 PM
@rlemon http://screencast.com/t/Pz7XTLnu8M8l

working on the JSfiddle for you now
 
oh?
 
145
Q: Are there constants in Javascript?

fuentesjrIf not, what's the common practice for specifying variables that are used as constants?

 
Proposed in ES4, adopted by FF when Mozilla was on crack, and spread a little. Constants are a lie and stupid to begin with.
 
combine vbscript and defineproperty and you have constant in any browser?
 
<script language="VBScript">
 Const IE_CONST = True
</script>
<script type="text/javascript">
 if (typeof TEST_CONST == 'undefined') {
    const IE_CONST = false;
 }
 alert(IE_CONST);
</script>
LOL
 
6:25 PM
but many suggesting to go with some handlebar dust mustache.. engines
is that much worth..?
 
I am personally using my own templating engine github.com/petkaantonov/attemplate.js
 
@Artha @rlemon made a nice thing, forgot the name, turns plain objects into elements.
 
@Artha I also use my own. based on simple json input strings. I however needed to also pass my templates and not just the content to the templates
 
I like the thought of merging the data and the language, like you have in Lisp
 
there are bugs (I didn't smooth it out for public use) but it works.
 
6:28 PM
what are the pros and cons on template engine adoption...
 
> Using a template engine on the server is nothing new. Client side templating on the other hand is a relative newcomer and some high profile websites have used it for some time now. The basic idea behind this is to not only offload the server from rendering the template, but also to easily leverage existing web service APIs while un-cluttering JavaScript code with markup.
FragBuilder aims to meet this need by efficiently converting your JSON or HTMLString input into a DocumentFragment which can then be inserted into the DOM.
 
@rlemon im unable to get the jsfiddle to properly run the page; it uses alot of php to generate the pages and whatnot; and jsfiddle is unable to actually change the forms
 
that's a cute intro
 
yea client side templating has its wins... but then you are limiting your accessibility and SEO abilities.
@NRGdallas ugh.
 
will that make any huge change in performance ...?
can that improve speed and js performance...
 
6:34 PM
the point really isn't performance at all..
and improve speed compared to what?
 
Depends on what you're templating, how, on what scale, why, and so forth. There's no silver bullet.
 
compared to pure js implementation as it is now
 
see??
also why are you setting the value on the input's you want changed.
<input type="text" value="" placeholder="The not real value you want to be displayed when the user has not values present" />
 
im looking at that; and its basically an exact duplicate of the javascript ive got; the only difference is that when implemented, its acting like its blocking the entire div from even showing; let me see what I can figure. as for the values instead of placeholder, I have no control over that
alot of the form itself I have my hands tied on; most of it is PHP generated from the ecommerce platform we use, they just suck
 
try to open up the rendered source... dump the entire body contents into the fiddle.
let me see what you are working with
because that code works. you can see it working - there is another conflict somewhere
 
sure; the rendered code itself doesn't function at all in fiddle; but ill get it goin for ya
 
yea I don't need it to function - I need to see it :P
 
@Esailija
 
oh dear god
console.log does work; however, I'd like to notify the user that, say, their password is incorrect, rather than displaying a message on the server... Is there any way I can do this? — gtm 1 min ago
 
6:43 PM
...
 
@Esailija LOL
 
how do you even start to explain something to someone with these beliefs
 
best ever!
 
@NRGdallas so all the inputs you are linking against are on different forms?
 
Ok, why won't this work?
 
6:52 PM
different forms, that are each still available on the same page once completed
 
It's supposed to draw polygons.
 
ahh then document.forms[anything].onchange will not work
 
In this case, a 3 sided poly.
 
its an f'ing mess rlemon, our ecommerce platform fails pretty bad on customization
gotchya, what would be the best alternative?
 
yea that code looks like crap... sorry
the js is a mess and so is the html
 
6:54 PM
I believe it haha
 
@Moshe learn to use jsfiddle correctly
 
@Neal I just copied my entire file in.
 
will js template engine make my webapp work even faster...?
 
@Neal, fine: jsfiddle.net/AynWJ/2
 
is your webapp slow somehow
the slowness comes from network I/O which you cannot fix with anything
 
6:58 PM
@Esailija Not sure if trolling or helping
 
@NRGdallas check this out
var radio = document.getElementById('shippingCheck_500d6aa9a300e'),
    input1 = document.getElementById('FormField_25'),
    input2 = document.getElementById('FormField_26'),
    btn = document.getElementById('ML20').getElementsByTagName('input')[0];

btn.onclick = function(e) {
    if( !radio.checked && input1.value.length <= 20 && input2.value.length <= 20 ) { // ok so you know this only will pass if the inputs have MORE THAN 20 characters in them. better validation is a recomendation.
        alert('some error');
 
1
Q: Node.js Alert Causes Crash

gtmI'm trying to create a node.js app and alert('Sample Alert'); is causing my program to crash. Node says ReferenceError: alert is not defined and then quits. I can use the alert function when running javascript on a regular html page, so I'm at a loss to understand why this is... Is this ...

KILL HIM EFFIN KILL HIM
:(
 
@FlorianMargaine already laughed at
 
yeah saw that
 
you are so slow
 
6:58 PM
just booted my pc :(
 
:(
 
oh boy
 
and this pointy gets 6 upvotes for his answer? seriously?
 
they come in that stupid forms ?
cv-pls
 
yeah is full of noobs not getting it
but sometimes they're worse than others...
 
6:59 PM
thanks rl, going to try that now; as for better validation; better validation for sure is required, but the problem that this is fixing happens VERY rarely, and only because of user stupidity, if they actively TRY to be stupid, they deserve it at that point.
 
some are fine, really
like this one:
1
Q: Namespaces in node.js with require

Miles McCrocklinI am playing around and learning about vows with a personal project. This is a small client side library, with testing done in vows. Therefore, I must build and test a file that is written like this: (function(exports) { var module = export.module = { "version":"0.0.1" }; //more stuff ...

but others... heh.
 
it's either noobs or sick fanatics like raynos
 
(not to mention, but this question had a great answer.)
 
@Esailija i wanted to make it even more faster, which ended up in adopting js templates
 
7:01 PM
whats with pornos and me ?
 
0
Q: indexOf() + 1 vs indexOf() != -1

iambriansreedWhen checking for existence of a substring I have been doing this: var that = "ok hello cool"; if( that.indexOf('hello') + 1 ) { } Instead of: if( that.indexOf('hello') != -1 ) { } Am I overlooking something or is there a reason not to do this.

 
now even on facebook -.- -.- -.-
 
posted a porn tab on facebook?
 
no
 
dude didn't you learn your lesson last time?
 
7:02 PM
people are asking me to send em pornos XD
 
ohh so you are bigdirtyabhishek.com ....
 
good idea for a website (hmm)
 
0
A: indexOf() + 1 vs indexOf() != -1

Florian MargaineHere is the most seen way: if ( ~that.indexOf( 'hello' ) ) { } The ~ operator does some magic and transforms only -1 in 0, thus it's the only falsy value.

"does some magic"
:D
@Esailija too late :p
 
my comment was earlier than yours ;d
 
@rlemon what's this togglefrog thingy?
 
7:05 PM
anyone who says ~indexOf isn't clear is fighting against everything javascript stands for... :D
 
"everything js stands for"?
 
if (!that.indexOf('hello')) {
@Esailija why not just this?
@FlorianMargaine just me pointing out dumb plugins
 
because
it return -1
 
@rlemon !1 === false
so if it finds something at index >= 1, you're not going in the if? :-)
 
guys.. help me chose
 
7:09 PM
ahhhhh kkk didn't think about that
 
chose what
 
@rlemon looks to be almost right; only thing is that clicking the button is not actually starting the function; code is as follows:
<script>
var radio = document.getElementById('shippingCheck_500d6aa9a300e'),
input1 = document.getElementById('FormField_25'),
input2 = document.getElementById('FormField_26'),
btn = document.getElementById('ML20').getElementsByTagName('input')[0];

btn.onclick = function(e) {
if( !radio.checked && input1.value.length >= 20 && input2.value.length >= 20 ) {
alert('some error');
e.preventDefault(); // we all stop the submit from happening.
e.stopPropagation();
return false;
}
// otherwise do something or nothing and let the submit happen.
 

Learn Javascript Videos

Apr 27 at 15:10, 1 minute total – 7 messages, 1 user, 0 stars

Bookmarked Apr 27 at 15:13 by rlemon

 
Button Code:
<div class="ML20" id="ML20">
<input type="submit" value="%%LNG_Continue%%" />
</div><br />
 
damn, such a great answer and nobody notices it :|
 
7:11 PM
@NRGdallas you changed the less than or equal to to greater than or equal too
 
correct; it should have been the opposite way - would that have made it not work?
 
yes
 
(obviously I am testing the opposite way as well)
 
that code is saying
IF the radio is NOT selected AND the inputs are both 20 chars or more.
you want IF the radio is NOT selected AND the inputs are LESS than or EQUAL to 20 chars.
 
@FlorianMargaine I upvoted but comeon.. how hard is it to understand require and module.exports lol
 
7:12 PM
the correct logic would need to be that the radio is selected, and the inputs are greater or equal to 20, to error
 
for newbies, it's a nice introduction to how it works
I don't think most new people get it :|
 
@NRGdallas well you can play with some alerts() and that if statement conditions
 
got it working Rlemon, the !radio.checked - when I was testing, I didn't get that ! was not checked
 
:P
 
removed ! from that and it works properly
 
7:14 PM
good stuff.. now back to refactoring all my controllers :<
 
thanks again man, really helpful
 
ever write yourself into a spaghetti mess ?? welcome to my life.
 
@rlemon some times I use mvvm parts when mvc is still messy
maybe it could help relax some controllers
don't know if it could apply well in your situation
 
heh, visited old work place, where I did Java stuff. My workstation is like a shrine. Everything is as I left it...
 
i'm just going to dump the admin function in the applicable section controller. four functions per section.. not that bad.
class products_controller extends ci_controller {
    public function index() {
        // display the main page
    }
    public function add_product() {
         $this->authenticate(); // if this fails it redirects to the login page
         // admin code stuff.
    }
    // view, edit, delete as well.
}
 
7:26 PM
add_product() :((
 
I used to have them all in one big ass admin_controller
@dievardump if you cannot tell that was a semantic example :P
damn people - always assume over semantics for example purposes.
 
@rlemon Having that method do the redirection may not be the best design
 
@Zirak yea I just got out the trusty pen and paper and am going to write this all out before I code any more :P
 
I'd make authenticate return whether the user authenticated or not, and based on that do the redirection
 
rlemon Well, it's the "_"case that made me ':(('
 
7:29 PM
I got to the spaghetti code spot here where I have a tonne of good code - just organized very very poorly.
@dievardump y u no like _
 
Cause I have to "Shift+TheEffingKeyBetween0And="
 
yea i'm just so used_to_it I don't even notice the added efforts.
I try to only use this-type for element class names and id's. and this_crap for functions and variable names.
that screws with me from time to time
var my_button = document.getElementById('form-submit-one');
that kinda crap - I get hated on for it... but ohh well :P
 
Well, honestly I don't really know. It's an habit. I sometimes find underscores easier to read, but ugly.
 
style choices are subjective and usually fine so long as you don't switch it up half way down.
 
And the coding convention at every job I worked at was the camelCase
 
7:36 PM
var foo_bar,
    biz_baz,
    helloWorld; // ugh
 
Except for css.
 
I use camelCase for classes only
 
For some reason, I manage to accept every naming convention...except PascalCase for everything. That just drives me mad.
Whenever I see "proper" .Net code (where the convention is PascalCase) I wanna hit the person who wrote it.
 
i'm kinda fucked with my naming that way - i'm consistent with myself... but I have very strange 'rules' for how and where I apply the naming conventions
 
@rlemon in CSS, I allow only the '-' case.
 
7:38 PM
@dievardump sorry classes as in real oop classes.
not css classes
4 mins ago, by rlemon
I try to only use this-type for element class names and id's. and this_crap for functions and variable names.
 
camelCase for PHP/JS, underscores case for SQL column name, '-'case for CSS
*new debat semi troll*CSS can be real OOP
 
camelCase for OO classes, _ for all else, - for element id's and class names
 
as long as you keep the same naming convention everywhere it's easy to read.. but I hate PascalCase too, looks like Microsoft shiny and perfect things
 
We all agree on the fact that PascalCase must die.
.NET developers too, but it's not politically correct to say.
 
7:41 PM
which sucks when you have to read.
class FooBar extends HelloWorld {
     public function get_out($ugh_names_suck) {
           echo "<li id='my-li-item'>" . $ugh_names_suck . "</li>";
     }
}
at least (in a few hundred lines of this) you will start to see the pattern.
 
haha, I can't count anymore how many .Net Applications I tried that crashed with an unhandled exception
 
The best style guide I've ever read: lysator.liu.se/c/pikestyle.html
 
easy coding = lazy coders
 
@dievardump Eh sorry? PHP is whatever-the-fuck case!
 
        /**********************************
         *                                *
         *          Add one to i          *
         *                                *
         **********************************/

                       i=i+1;
 
7:43 PM
It's impossible to conform to PHP style.
 
@xtal I was just telling the conventions I Use/learned at my jobs.
 
@dievardump Oh right, gotcha!
Yeah .NET-case is brain damaged. Why would you capitalise every word in a sentence and think it's easy to read?
 
xtal: Well, when you see ZF and Symfony (which for me are the best fmk) conventions, sure you can't conform, they are quite differents.
 
@rlemon Don't joke.
@dievardump Zend studio does some crazy automatic formatting out of the box.
 
@rlemon That's how XDoc looks like :P /** @private string name */ private string name;
 
7:46 PM
@Zirak :-D
 
one naming convention that I used in my first job was to put a "_" before private variables so that in a constructor you have : _name = name;
still what I use in java
 
@dievardump When you look at php's stdlib you can't conform. It's a mixture of styles right out of the box.
@Fred Oh dear lord I hate that style
 
@Fred Why?
 
It drives me mad to see this._foo( this._bar, this._ohQuitTheFuckingPrepending )
 
It's almost as bad as $.
 
7:48 PM
@xtal with privates starting with a special char, there's no way a private will be accessed where it isn't supposed to
 
It's just noise you can't avoid. It flashes before your eyes unnecessarily. Besides, I'm an advocate of non-privacy. Getters and setters are blegh
 
@Fred What about privates that don't start with a special char? (Btw, what's a special char? I quite the letter 'm'.)
@Zirak I like Smalltalk-style privacy: all methods are public, all variables are private.
 
If you don't trust the API users (who are other developers), then everyone's fucked anyway.
 
Yep. DbC. Break the contract and you might get away with it, or you might end up at the bottom of a river.
 
I've always been frustrated when an API is made inflexible by contorting it into privacy. Yes, I get it, you thought this would fit, but it doesn't fit my case, and I've seen your code, I know what I'm doing!
 
7:52 PM
that's for visual purpose and to allow the use of the same name for privates and in-scope variables
at my first job they preferred "_" to "this."
 
@Fred It's not the same name.
 
A locked-down design is only as smart as the developer designed it to be. An open design allows you to be smarter.
 
@xtal no, exactly, it looks the same but its not
 
@Fred It's foo and fooo.
 
@xtal it's actually "_foo" (private) and "foo" (in-scope), I know that good practice would suggest "this.foo" instead but somehow they wanted to get rid of "this" lol
 
7:55 PM
And, state should be a noun, and functions a verb. They shouldn't be the same word.
 
/* * * * * * HERE BE A FUNCTION * * * * * * * * * * * * * * * * * * * * *
 *                                                                         *
 * name: SimpleAddingFunction                                            *
 * @param int arguments are unlimited. strings are converted into ints.    *
 * @return int sum of all values                                        *
 *                                                                         *
 * * * * * * * * * * * * * * * * * * * * * * * * *  * * * * * * * * * * */
 
Use foo and getfoo.
 
@xtal, then, insted of having "foo" and "fooo", "_foo" is easier to read
 
Beautiful.
 
RGB
7:57 PM
i.pittyDaFoo
 
what that isn't how you all code as well?
 
I'd find a proper English paragraph easier to digest however.
 
:-)
 
I hate that comment block so much. But I've yet to find a way to make it go away. It's a programming failure
 
7:59 PM
@rlemon sum += value_to_add_to_sum :-P
 
@Zirak If you don't think about what it means, it makes sense.
 
@Neal wow - you are now being ignored for the rest of the week (seriously) for thinking you had to improve on that obviously trolling code.
 

« first day (646 days earlier)      last day (4285 days later) »