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

3:00 PM
Raynos is the tough lover teacher
first he breaks you down, then builds you up
like a JS drill instructor
 
@Loktar say waaat?
 
@rlemon you should be using requestAnimationFrame() ;-)
 
@Loktar Raynos will bitch hard core about == vs === even when used properly however will leave ; out of his code :/
 
ewwww
 
3:02 PM
@Alnitak I should... but for the purposes of the example I did not to be a little more transparent about what is happening.
 
and you are of course redrawing the entire circle for each frame...
 
yea
dude 2 minute quick example of animation :P
I just c/p'd your code into a function
 
Hi everybody!
 
:p just teasing
Hi, Doctor Nick!
 
@Zirak what?
 
3:04 PM
@Alnitak I was expecting that :D
 
only works with "Hi Everybody"
 
close enough
 
'close' only counts in horse shoes and hand grenades
 
@Loktar You're the pwner. I drool some stuff with foam coming out of my mouth, you actually do shit
 
lol whatever dude
ive used your code many a times
well once I can perfectly recall
the extend
 
3:05 PM
I've stared his trolls many a time
 
haha
 
Really? People use my stuff? What on earth is wrong with you people!?
 
Found another reason to hate jQuery - it can't even return valid css style values...
 
@Killah what is the case?
rgba colours in chrome?
 
Wasted 1h to saw that it's wrong ;/
Nah
Width/Height
 
3:07 PM
of?
 
Table ;p
Misses for about 4-5px
 
whats your code ? tables suck for this btw - and what browser
 
Table with border + cells with border.
Like <table style="border: 4px solid black"><tr><td style="border: 2px solid white"></td></tr></table>. Google Chrome
 
and it's leaving out what? the table border?
 
I don't know :D It's like it was guessing the values. The bigger the width/height of table is the bigger the error is.
It was pretty easy to solve: delete whole jQuery crap and replace with good old style.width and style.height ;p
 
3:13 PM
elem.getClientRects()[0], tada
You have positions and dimensions, in the same package! Isn't that wonderful Wanda!?
Wanda: Yes! And for just an extra 99.99, you get a FREE vacuum cleaner!
2
 
@Killah element.outerWidth()
 
@rlemon hmm... another reason to hate it - billion of functions to do the same thing...
But a little different
 
not at all the same. :P
i agree that that is an issue with jQuery - however for this case... i think these functions serve their purposes well.
 
Ok. But I used .css('width') and it returned different that I saw in Chrome Dev Tools ;p Like it was still doing the count, instead of returning css value.
 
@rlemon 92
Sorry i came in in the middle of a convo...
 
3:20 PM
Eeeh, if it wasn't the jQuery plugin I'm making I would be glad to delete it completely ;/
@Neal no problem at all ;p
Just saw it returns 92 for me too
 
Since I'm about to use it, I thought I should ask. Why shouldn't I use for x in y?
 
@Neal pedantics for the sake of??? obviously box model applies differently for different browsers. Killah you just don't mix css + js for style manipulation. I did for a hard coded example.
for( var x in y) {

} // better
 
@SomeKittens only use it for objects. not arrays
 
ah. What should I use for arrays?
(I don't need a new array, so foreach and map aren't needed)
 
You should avoid large loops in any case - however with that said it doesn't really matter - some will argue semantics, some performance, I say do what you like - if it is a bottleneck we can discuss alternatives then
 
3:22 PM
@SomeKittens for(var i = 0; i < arr.length; ++i)....
 
@neal aw, that's boring
 
@rlemon but I applied the css with .width() ;p It even returns different values just after they were set.
 
@SomeKittens wth r u talking abt?
 
@Killah what are you doing?
can you show me?
 
@SomeKittens try for (var i = 0, k; k = arr[i]; i++) {
 
3:23 PM
@Killah oy....
 
@Killah that won't work at all...
 
@Neal Wrong; for( var i = 0, l = arr.length; i < l; i++) { Y U NO CACHE ARRAY LENGTH?!?!?!?!
 
@SomeKittens yea it will
@rlemon :-P
 
@SomeKittens it will, I personally use it all times
 
You all had it wrong
 
3:24 PM
Yeah
 
you need to define i and l then cast the length to l then set your condition
@Killah had no condition
 
var i = arr.length; while (i--) { ...
 
^ that would work
s/vat/var
 
k = arr[i] is a condition ;p
 
@Killah backwards....
 
3:25 PM
But faster ;)
 
But backwards.
 
So do var el = arr[arr.length - i]; ;p
 
var i = arr.length; while(i) { i--; }
 
@rlemon that's exactly what I wrote ;p
 
no
 
3:26 PM
@rlemon yes
think abt it.
wait.
no @Killah ur wrong
 
@Neal yes, just was about to write that
 
no he wrote var i = arr.length; while (i--) { lol
his works. i'm being a bitch.
 
@rlemon ;)
 
@rlemon no it doesnt. bc the i inside the loop is decremented!
IT IS WRONG
:-P
 
@Neal if you have the edge case that this would fuck up then clap clap here is a cookie. otherwise IT IS RIGHT albeit ugly.
no go back into your corner and play with these matches. :P
if how you write your loop has any effect on the performance of your page (not caching, for vs et al, caching is just prudent) then you have bigger problems
loops should be reduced at all costs... they are expensive in any case.
 
3:30 PM
ehhh
 
@rlemon agree, an ugly look will surely cost more time to debug than it will cost in runtime
@rlemon loop * *
 
Try running while and for 1kk times. Then argue.
 
hello, i am having trouble with this question
0
Q: Odd error with Ustream JSON API and jQuery

Jason AxelrodI am trying to run the following jQuery: var query = 'http://api.ustream.tv/json/channel/masaiblog/getValueOf/status?jsonp=?'; $.getJSON(query, function(data) { if (data['results'] == 'live') { alert('ITS LIVE!'); } }); Very simple, right? It goes to the Ustream API, ge...

 
Another jQuery question and I'm leaving
 
can you give me an example of how to use this
 
3:32 PM
19
Q: Why does $($) crash my page?

NealDisclaimer: Do not try this at home Why, if I am using jQuery, does $($) freeze the page? Inspired by this Area51 question

 
thehe
 
@Killah Ideally you should never have to do millions of iterations in javascript.. if it's HUGE, let the database do it
 
;p
 
opps sorry
 
@Fred when you are running javascript on the server, sometimes you have to.
Ofc it's an edge case ;p
 
3:35 PM
@Killah you should never be running million of iterations.... if this is the case chunk it out and run a few at a time. remember the illusion of performance is much more powerful than performance itself.
 
@Killah there is some nice tricks here that may interest you : developers.google.com/speed/articles/optimizing-javascript, didn't try them all but in theory it's faster
 
ofc this is just my "best practise" speech.... I would never show any of you my production code when i'm under a deadline :P
 
@rlemon anyone of us wouldn't either :D Under deadline I do scary things
 
ugh... really google concatenation vs join topics? because 14 million ops vs like 15 million ops should be the first note in their guideline
#fail
 
I don't use it too much personally.. when I do it's to prevent concatenation issues
 
3:38 PM
@rlemon first paragraph starts with IE6/7. That should explain everything
 
var s=["Answer :", x+y*10/Math.sqrt(,,,)].join("");

vs

var s="Answer"+(x+y*10/Math.sqrt(,,,)); // looks ugly
 
Google you fail so hard.
@Fred no... smashing strings into an array then joining them is ugly. and hacky
also according to js perf slower in modern browsers
 
woa, just got my cisco powerlines
they're pretty o_o
 
... slow
:p
 
@Alnitak , @FlorianMargaine ? how about that notebook ?
 
@rlemon And who cares for small strings? The difference in their "very long string" will hardly be noticeable
 
i'm just saying... if they want to point it out they should point out that their examples will not reflect what they are talking about
 
@Abhishek nice toy
 
@rlemon lol, your benchmarks results: contact: 5,461,611 ops/s, join: 920,431 ops/s.
 
3:45 PM
@Abhishek too much expensive
 
too much expensive ?
 
Also, yuck, why do people butcher their property names with underscores?
 
for 16 gig ram , 3 Gig GPU , i7 3rd Gen ?
 
Does javascript include a point struct, or do I need to declare my own?
 
do you need so much?
 
3:45 PM
point.x, point.y
 
@Moshe no
 
@FlorianMargaine maybe XD
 
@Moshe lolwut? You meant, var point = {}?
 
Ah, guess so.
 
What the fuck do you need structs for? :P You have objects!
 
3:46 PM
nah. but thats the same price for a macbook air .
 
Dynamic objects! They're fun!
 
@Zirak I bet he is C++ guy ;p
 
but then macbooks stay uber cool and this one will burn like petrol
 
@rlemon ok I didn't test on latest browser versions, but at least it saved my some debug time a couple of times :P haha
 
@Moshe @moche
you can do stuff like this.
 
3:47 PM
Here, have 4 of them for testing purposes, see how generous they are: var points = [ {}, {}, {}, {} ]
 
var point = {
x:10,
y:20
}
it will be perfectly valid.
or you can also make it via function.
function point(){
this.x = 0;
this.y = 0;
}
var p = new point();
 
I just love json :)
 
@Abhishek function Point()*
 
?
 
@dievardump he missed the point...
 
3:48 PM
Camelcase* for the function declarations when meant to be used with new
 
function point () {
    return { x : 0, y : 0 };
}
//look mah, no need for new!
 
(well, it's what i always read and heard since today)
 
Thanks guys.
/afk
 
Every time you don't use new, a Tibetan is granted true freedom
 
Hahahah
 
3:50 PM
@Zirak What's the problem with new ?
 
It hides the beauty of objects with the ugliness of fake classes.
 
I always see people saying to avoid it, but I don't know why
 
how does concat vs join work for memory use? I just (testing) with uber large number of values and got call stack exceeded with 10000 strings
 
@dievardump because an object created like that has the baggage of an additional prototype chain
that's good, if you happen to want to attach additional methods to that chain, but for a "plain old struct" it's overkill
 
Not even for performance concerns, just the way you think of code. new introduces bureaucracy. Free-range objects give you freedom.
 
3:54 PM
@Alnitak actually new Point and { x: 0, y: 0 } will have the same prototype chain
just tried in Chrome Console
 
@Killah my Chrome console disagrees with your Chrome console...
function Point() { this.x = 0; this.y = 0; }
undefined
p = new Point();
Point
x: 0
y: 0
__proto__: Point
constructor: function Point() { this.x = 0; this.y = 0; }
__proto__: Object
q = { x:0, y : 0 }
Object
x: 0
y: 0
__proto__: Object
unless I misunderstand you
 
Midst the top-ranking js stupidities is the naming of func.prototype. They could not have chosen a worse, more off-the-mark and confusing name.
 
Oh, right. I missed the constructor. The rest is the same
 
@Killah no, it's not just that
 
__proto__: Object will be the same ;p
 
3:58 PM
@Abhishek my bros gf has a imac... that bitch gets HOTTTT! like... too hot to touch the back of it.
 
@Killah the Point object has an extra __proto__ of Point, and then that has a __proto__ of Object.
 
@rlemon What the fuck does your brother do to her?
 
@Zirak lol
 
Hmm, in my console it doesn't
 
@Killah you're not doing it right, then ;-)
 
3:59 PM
@rlemon i am talking about a Mac Book Air with no overclocking no extra stuff and solid state drive
 
`new Point
Point
x: 0
y: 0
__proto__: Object`
 
those cant get hot , right .
 
@Killah the Point object by definition must have an additional prototype, since that's where any extra methods will get attached
how did you define Point() ?
 
imac with no over-clocking, ssd, and no extra stuff === uber uber uber hot. idk about the laptops... but anything with that much hardware (esp the display) and that little room + fans will get hot
 
@Alnitak function () { this.x = 0; this.y = 0; }
 
4:00 PM
Also, press Ctrl+K before sending a message to codify it
 
or for single line code snippets wrap them in ``
 
@Zirak didn't know about that ;p
 
right - you didn't give a name to the anonymous function
 
5
Q: Chat Easy Input Tools - Provides keyboard shortcuts for common text formatting commands

rlemon About Provides keyboard shortcuts for common text formatting commands, reducing the dependency on mouse usage. Current version does not have a configurable set of hotkeys but later versions will. How to use. All of the following commands are run if the user has focus in the chat input area. ...

 
@Alnitak oh, right. I did var Point = function ...
 
4:02 PM
@Killah somehow that didn't attach a new prototype. Not sure why - I didn't know it did that.
ah, it did attach a new prototype, but it didn't name it
 
@Zirak I once read that defining additional methods for a js "object" outside of its definition was using less memory (ie: outside=method is allocated once and used by every instance, inside=method is copied inside every instance), do you know if it's still the case ? I personnaly never care too much about that but just curious
 
so in fact your two __proto__: Object lines are not the same object
 
@Fred You've read that in Google link you sent us some time ago ;p
 
0
Q: How to dispatch a double click event on an element?

SuseiI can dispatch a simple click event (without any optional parameters) with: var clickEvt = document.createEvent("MouseEvents"); clickEvt.initEvent("click"); element.dispatchEvent(clickEvt); But how do I dispatch a double-click event?

i just can't believe that this has never been asked before
 
@Fred yes, AFAIK that's still the case
 
4:03 PM
@Fred Of course, declaring something once is faster than declaring it every time. Ever heard of Object.create?
 
@Zirak no :P on a prototype doc
 
@GNi33 uh, isn't that just clickEvt.initEvent("dblclick")?
 
yep
 
oh, already answered. picks up violin, plays a sad tune, cries a bit, resumes as usual
 
@Zirak not yet, bu I just taked a look
 
4:05 PM
hi please help me in dynamic file upload in asp.net
0
Q: How do i create custom file upload control in asp.net?

ashuthinksI'm creating custom file upload control in asp.net my code : I have code which uses java script code: <table width="100" > <tr> <td id="tdFileInputs" width="100" valign="top"> </td> </tr> <tr> <td...

 
@ashuthinks Does this look like the ASP room?
....
 
@Fred If I need to make something heavier, which is once in every other century, I put the "prototype" as its own object, and call Object.create. It's easy to add in a "constructor" function
 
i know friend but my code is in javascript too
thats why
 
You didn't even tag your question as JavaScript
Is your problem a JavaScript one or an ASP one ?
 
sorry for that i need asp solution
should i quit then :( no1 here can help me?
 
4:08 PM
Look at the name of this room
 
Then back to me
 

C#

General discussions about the c# language, Squirrels | gist.gi...
 
I don't read ASP code, so can't help
 
seems like uploading a file is more likely a asp.net problem
than a javascript one
@Zirak ok, thanks for the hint
 
4:12 PM
 
:D
 
@Neal lol that's a funny question xD
 
....
 
@Zirak he/she answered it himself
that's why i was wondering
 
4:32 PM
None of the code I write bugs has.
 
hai i have one doubt how to pass value in html format
 
4:49 PM
new Javascript user here, is there a way to use an IF and IF statement (as in both A and B are true)?
 
if(a == true && b == true){}
 
thanks :)
 
np
 
if(alert($shipa.indexOf("Fill This If Using Your Own Shipping Account") != -1 && alert($shipb.indexOf("Fill This If Using Your Own Shipping Account") != -1)
correct syntax?
 
if( a && b) {
     // if both a and b are truthy
}
alerts return nothing.
if( confirm("are you sure") && confirm("are you super duper sure?")) {
   // do something
}
the easiest way is to include jQuery and use the hide method api.jquery.com/hideCamoy 1 hour ago
LOL fucking insane...
 
4:56 PM
if (a*b) { // short ugly way
// if both a and b are truthy
}
 
"You need to toggle the visibility of one element?!?!?! jQuery!"
 
I need to toggle the visibility of 1 element based on 2 other elements containing content, and I have 0 experience with Javascript ><
 
@Fred ?
 
steam sales are over in 2 minutes guys omg
 
@dievardump it actually works, it's ugly.. but fun to use it in "1-line" js challenges
@NRGdallas are you using jQuery or want to do it in pure js ?
 
4:59 PM
@NRGdallas be more specific... i read your question - it was confusing
 
I am using Jquery, I have something kinda close so far (I think) - just noticed my class name was wrong; updating it now to see if it works right
<script>
var $shipa = $("#FormField_25");
var $shipb = $("#FormField_26");

if(alert($shipa.indexOf("Fill This If Using Your Own Shipping Account") != -1 && alert($shipb.indexOf("Fill This If Using Your Own Shipping Account") != -1)
{
$(".ShippingProviderList").hide();
}
</script>
is what I have
 
@NRGdallas I don't understand the point of having an alert box into a if block
 
I read that it should work to return false? or am I mistaken?
 
alert doesn't return values
if (alert('something') ) is always true
and there is a missing parens somewhere
there is a syntax error
 
You don't want the alert wrapping over the indexOf call, and someJQueryObject.indexOf is undefined.
 
5:05 PM
@Zirak unfortunately, that is mostly greek to me at this point
 
@NRGdallas I think that you want to do something like this, am I wrong ?

<script>
var $shipa = $("#FormField_25");
var $shipb = $("#FormField_26");

if ($shipa.indexOf("Fill This If Using Your Own Shipping Account")!=-1 && $shipb.indexOf("Fill This If Using Your Own Shipping Account")!=-1) {
$(".ShippingProviderList").hide();
}
</script>
(just wondering, how to insert formatted code blocks ? :P )
[code]
if (1) {
test++;
}
[/code]
 
@Fred
<script>
var $shipa = $("#FormField_25");
var $shipb = $("#FormField_26");

if ($shipa.indexOf("Fill This If Using Your Own Shipping Account")!=-1 && $shipb.indexOf("Fill This If Using Your Own Shipping Account")!=-1) {
$(".ShippingProviderList").hide();
}
</script>
is my updated script, in which case the entire page is doing some wierd stuff
its basically taking the entire div that that script is in and not loading it (or hiding it)
 
you don't need jQuery to hide some random elements
seriously.
if you don't know js at all jQuery is not a big help
you still need to know the language it is a toolkit for before you can really use it.
 
@NRGdallas is Louis Mcdonald you or your boss?
 
Louis Mcdonald? no clue @somekittens
 
5:13 PM
Ah, ok
Out of zero test cases, I got one failure. Such is my life.
 
2
Q: Is there a fancier way to get a previous item with the same class?

NealI have table rows like so: <tr class="parent0 row3" data-parent="0"> <td>...</td> </tr> <tr class="parent3 row7" data-parent="3"> <td>...</td> </tr> <tr class="parent3 row12" data-parent="3"> <td>...</td> </tr> <...

 
for anybody looking for a more in-depth idea of what I am trying to do, and why I am using jquery;

http://stackoverflow.com/questions/11615681/javascript-change-content-of-a-page-based-on-2-if-statements
 
lol dude
Look at my code
works
no jQuery
it is silly to include 30kb of code (minified and gzipped) just for hiding elements.
 
I got yours rlemon, but the form itself is significantly more complex then your example
 
so?
it still will work regardless. I tried to make my example as verbose as possible.
 
5:17 PM
Hi hi.
 
ill try to play around with it rlemon, see what I can do
 
People really have to start reading before they go all trigger happy to vote as a duplicate... when it isn't...
 
is there a timer in javascript
 
you can make one
 
5:25 PM
so every time i want to do a function, i can do it every second?
 
you can use setTimeout or setInterval
although I suggest setTimeout
var timeoutid = setTimeout(functionHandler, timeInMiliseconds);
 
hey folks. is there a trick to aligning a static table header with dynamic columns? There are 3 headers and 3 columns. but all columns get shoved under header #1
 
can you give me an example
please
 
@rlemon I am working with the script you provided just now, actually got very similar via your jsfiddle from earlier; however I am unable to actually modify that button. the best I can do is encase it within a div IE
<div class="ML20">
<input type="submit" value="Continue">
</div>
 
@MikeS. ummmmm. what?
 
5:27 PM
thanks
 
var to;
function run() {
     // some code
    clearTimeout(to);
    to = setTimeout(run, 1000);
}
run();
 
@rlemon is that all i need?
 
html table. 3 headers, 3 columns
 
@EliteGamer the kicker is... setTimeout executes the code... then starts the timer...
so if the code takes a second to execute... well now you have two seconds
 
@rlemon to = setTimeout( run, 1000 );
 
5:27 PM
@Esailija denied :-P
 
LOL
 
@FlorianMargaine oops, my bad
 
probably too tired :d
 
all 3 columns are getting stuffed under header #1
 
@NRGdallas change class to a id... then document.getElementById('ML20').getElementsByTagName('input')[0]
 
5:30 PM
code looks like this pastie.org/4307402
 
@Neal did you try the .index() function ? this should work, but I'm not sure if it is exactly what you want to do :

var prev = $($(this).prop('tagName')).eq($(this).index()-1);
 
still selects all siblings then filters.
he wants to only select immediate siblings (with same class) no?
 
@rlemon yep
I don't want to select all... that is basically what prevAll does....
 
what confuses me is that there is no common classes for each nodes
 
@Fred lol why does there have to be?
 
5:33 PM
 
@Neal to use $(".common") as a selector instead of $(".parent"+parentId)
 
@Fred i think the idea was to minimize the number of elements returned with each DOM call thus resulting in less memory consumption
 
@Fred oy.... I only want a small # of elements. not all rows
 
however unless thousands upon thousands were collected each time... I do think this is a micro optimization - @Neal I would be curious to see some performance data between the two methods on 1000+ elements.
 
@rlemon which 2 methods?
 
5:35 PM
selecting all then filtering using something like prevAll and the method provided prevFind or w/.e
 
@rlemon I dont have the time to make a test for it...
 
ahh but you do have the time to concern yourself with it... but no actual idea which is faster?
 
I was just mainly curious. I am making a tree node table management system and I wanted to be able to move an element before or after its siblings
 
that is just silly neal... silly.
 
I prob will stick with prevAll and nextAll unless I see there is some great reason to switch over.
 
5:41 PM
50k ops is still ok (1000 elements)
but 170K for prevFind
so yea... here it might actually be worth it :/ I stand corrected.
 
@rlemon what is it ?
 
@rlemon these perf things always freeze my browser...
 
@dievardump look at his licence plate
@Neal that one is big. 1000 rows in that table :P
 
@rlemon hmmm so his prevFind function miiiight be the better option then?
 
@Neal are you the FF result?
 
5:45 PM
FF results were me on my crappy work PC
 
@rlemon I just switched to FF now and the perf ran
 
maybe yours might be slow because you are using Firefox 7.0.1!!!!! time to upgrade dude...
ahh
 
I was using chrome which perf crashed...
 
not you neal.
@Collecter DUDE!!!! Upgrade your FF man!
 
It is a government PC, I do not have access to upgrade it... So much red tape here.
 
5:46 PM
hrm.. does the government not realize newer browser closed off a lot of security vulnerabilities. it would actually be safer and easier on them if they upgraded.
 
@rlemon It does not really matter a ton for this PC. There is nothing of import on this PC or network.
But i agree.
 
Like the pseudonyme
 
Just started the test on my other crappy browser.
 
5:50 PM
its open now
 
w00t
 
jQuery.fn.prevFind = function(selector) {
    return this.pushStack(this.map(function() {
        return jQuery.dir(this, "prevSibling", selector);
    }), "prevFind", selector);
};
 
sections on the website:
news
products
links
foobar

each with their own controller for 'sub-functions' (most have only a few)
and then one Admin controller with add/edit/view/delete functions for all as well... the admin controller is just frikkin huge now. Should I a) lump all admin functions pertaining to the specific sections in their 'section' controller. or have an admin-X controller for each section.
 
@Esailija AHHHH this while loop i sgetting stuck and going forever!
WTF
 

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