« first day (382 days earlier)      last day (4583 days later) » 

7:01 PM
wow... I could replace start.childNodes with start.getElementsByTagName though if I know the tag name correct?
 
Hello kind people. Perhaps this is impossible, but if I have a palette of colours - something like this - colourlovers.com/palette/1836486/ReVisions_Pallete_1
using javascript, how I would be able to tell which color is the darkest
 
user1385191
1 message moved to bin
 
@user597264 looks like u stopped mid-sentence there.
@user597264 whatever has the lowest HEX value is the darkest.
 
of course, that make sense
 
FF00FF is lighter than 00FFFF
(wrong!)
FF00FF and 00FFFF are the same lightness
 
7:05 PM
Whatever has the lowest average hex value?
 
@RyanKinal lol yep ^_^
at least that is my opinion
 
Maybe...
 
000000-> black
FFFFFF->white
somewhere between is plain grey
 
user1385191
there
 
7:06 PM
Hmmm. Some research may have to be done.
 
@RyanKinal lol naaaah
 
@RyanKinal agree on the research, but thought I might be missing something obvious
thanks people
**goes off to google hex principles
 
user1385191
a hex is R * G * B
 
user1385191
with each chunk being make of two base 16 numbers
 
user1385191
7:09 PM
from 0-F
 
what I would do is use one of the rub to b&w algorithms freely available on the net
*rgb
 
thanks matt, I understand that. I'm beginning to to wonder 'light' and 'dark' colours are objective anyway.
 
then sum up r, g and b
 
user1385191
"F" is equal to 15, since it's the 15th, and last "digit" in base 16
 
7:10 PM
for instance, which is lighter - pure blue (0000ff) or pure red (ff0000)
 
user1385191
>>> 0xF
15
 
are they the same?
 
no
 
user1385191
the difference is hue
 
**sorry, thinking out loud here
 
user1385191
7:11 PM
red, blue, and green are as "bright" as white
 
@aydinch That's a really good idea
 
there are algorithms available and one very good canvas tutorial on net tuts, teaching how to convert an rub image to black and white
let me search that article...
(lame autocorrect: rub => rgb)
 
user1385191
as soon as a chunk (R, G, or B) has a value of 255 ("FF"), it's as bright as it can be
 
user1385191
see: red(0xFF0000), green(0x00FF00), blue(0x0000FF), yellow(0xFFFF00), white(0xFFFFFF)
 
user1385191
7:14 PM
note how at least one "chunk" is 255 in all cases
 
@aydinch thanks
@MattMcDonald yep
 
and this is the algorithm: 0.3*red + 0.59*green + 0.11*blue
 
user1385191
there's no difference in brightness between 0xFFF000 and 0xFFFF00
 
user1385191
only hue
 
@MattMcDonald why is node.data = "some text" ok but elem.textContent = "some text" is bad?
 
user1385191
7:17 PM
example a means you're acknowledging the existence of text nodes and manipulating one
 
user1385191
example b means you're either ignorant of text nodes or want a quick fix
 
@Raynos I think you have multiple text nodes inside the element?
@Raynos Did you try and normalize the nodes?
 
@Incognito agreed.
@MattMcDonald not that.
 
I personally see `elem.textContent = "some text" as remove all child nodes and adding a text node
 
7:20 PM
@Raynos Ah, but elements contain nodes, not text. Text is like a normal element without any tags around it.
Imagine how 1 + 1 is actually ((1) ((+) (1)))
 
user1385191
@Raynos you're not removing all child nodes
 
@Incognito I understand how it works
 
user1385191
you're just overwriting text nodes
 
@MattMcDonald Oh ..
 
user1385191
text is text, html is html
 
7:22 PM
Isn't it fun how you're stepping into the boss battle of your friggin life, and in the middle your keyboard batteries run out?
 
Heh, I just had a "boss battle" start up today at a client
No batteries needed to get the hell out of there as quickly as possible :)
 
It's even funner since I always use Escape key for the menu, so I couldn't find how to pause and replace batteries. Of course, I was beaten to death.
 
@MattMcDonald you lies
.textContent removes all child nodes
.textContent DOM4 says remove all descendants.
Again, I know how this works.
All I'm saying is given elem contains one child node text
Why do text.data = "some text" instead of elem.textContent = "some text"
 
Not sure what you guys are talking about, but I don't understand why you'd use textContent over innerHTML, if you're just going to blast over a node's contents with a string
 
@Zirak I feel that way about Prince of persia sands of time, I got to the final level with no special swords and half health, with no way to go back and get more of those things.
 
user1385191
7:26 PM
wow, really?
 
user1385191
it's even more avoidable than I originally thought
 
@Chris :(
 
@Incognito I hear ya. Hate it when games make content unavailable to you without even hinting abut it stares intently Final Fantasy: Crisis Core and many other FF games
 
Because .textContent sets text and .innerHTML is a dirty hack
 
user1385191
innerHTML is the DOM's version of eval
 
7:28 PM
@MattMcDonald again for the simple case where you have a single element and one text node. Why use .data over .textContent ?
 
@Raynos I think he's saying that, just asking why you'd bother using .textContent over innerHTML if you're set on textcontent anyway.
 
Also, I once made a complete and perfect playthrough of Tales of Eternia, but accidentally forgot to inspect the Siren (which is a boss), so it's a 99.999999999...% game-completed save. Rage for the rest of my life.
 
I guess .data is more efficient
 
user1385191
we've just seen the harm, haven't we?
 
user1385191
it wipes the slate clean
 
7:29 PM
Well yes. Its supposed to remove all chidren
If you don't want that, then don't use textContent
 
@Zirak OCD u mad?
 
user1385191
I have a method called getFirstWholeTextNode in my article
 
@MattMcDonald The harm is pretty logical, though. I'd be surprised if it didn't do that.
 
user1385191
I was deluded into thinking it only manipulated text
 
7:30 PM
// fast remove all children
el.textContent = ""
// old (given el.childNodes.length === 0)
var t = document.createTextNode("text");
el.appendChild(t);
// new
el.textContent = "text"
 
@Incognito rage train
 
@MattMcDonald you probably want to normaliz the node instead
 
user1385191
IIRC, that's got crappy support
 
DOM shim fixes that.
 
@Raynos You should probably normalize nodes almost always when dealing with a single element's text contents.
 
7:31 PM
For some value of fix
 
user1385191
a "shim" would be to iterate over the text nodes and set data to the collected string
 
There's cases when you wouldn't want to, mind you.
 
Exactly.
 
user1385191
well, and to remove all the others
 
Looking at the MDN article on textContent, it says something that does not make sense:
"innerHTML returns the HTML as its name indicates. Quite often, in order to retrieve or write text within an element, people use innerHTML. innerText should be used instead. Since the text is not processed it's likely to have better performance. Moreover, this avoids an XSS vector attack."
innerText should be used instead
 
7:34 PM
@Chris fix it
 
user1385191
MDC is mediocre at best
 
What seems to be the problem?
 
user1385191
specs are all you need, really
 
I don't know what they're saying... innerText is an existing (though non-standard) property
 
user1385191
it's basically saying use innerText because it doesn't expose the HTML parser of the browser
 
7:34 PM
0
Q: Updating the Game Client about the World

ScánUsing socket.io, I have a communication similar to that of other MMORPGs, a steady connection with messages. In my design so far, the client sends the player's position and animation frame with every update frame. When the server gets that message, it broadcasts it to all the clients, which will...

 
They're saying that to retrieve text, instead of doing .innerHTML, you should be doing .innerText.
 
user1385191
that too
 
Look up innerText on MDN and see what that says
Oops. there's no article for it :P
 
I think I found how I'm going to talk about innerHTML in my Quality JS slide-show.
Basically: if you innerHTML, you're a cat killer.
 
@MattMcDonald specs are confusing
 
user1385191
7:36 PM
better: innerHTML is the eval of the DOM
 
I found the MDN docs on NodeIterator better because they had examples
 
ok that was a bit too much and too loud music >_>
at least my brain's free now xD
 
innerText does not appear to exist in firefox
 
@Chris it doesnt
 
7:36 PM
Why are algorithm books are always so expensive? :/
 
Its an IE thing
 
textContent === innerText, but one is standard and one isn't, something like that. Can't remember which...
 
Right
 
textContent is standard
@Zirak Y U NO KNOW SPECS OF HEART
 
textContent != innerText
 
user1385191
7:37 PM
yep
 
user1385191
browsers vary on implementation
 
user1385191
some keep whitespace, some don't
 
At least they're going to drop layerX / Y
 
@Raynos Specs of heart? chuckles ominously
 
I was actually just looking for justification on your statement about innerHTML being the eval of DOM and came across that inconsistency.
 
7:38 PM
bringing us a bit closer to "not so many" custom stuff implementation things
 
@Chris the main issue with .innerHTML is that you don't want inline HTML in your javascript
We dont want inline javascript in your HTML either.
 
I avoid innerHTML because I prefer to use DOM objects to add content, but I wouldn't go throw out the baby with the bathwater
 
It's pretty clear, actually. innerHTML takes a string and magically produces a DOM tree. How can it do that without calling the html parser?
 
user1385191
yes
 
So that's why I was saying that if you're going to use textContent, you may as well use innerHTML. I see there is some justification in that textContent will avoid the parser
 
7:39 PM
innerHTML is slow, period.
 
@Raynos I keep a copy of dom3 next to my heart and a copy of rfc 2616 under my pillow at night.
 
So, basically: innerHTML = callDOMEval;
 
@IvoWetzel unless your IE.
 
So you've made a believer - I won't use that method that I don't ever use anyway. :) Now I just need to see a justification for using the node.data method vs. textContent
 
@Chris .textContent only has two use cases as mentioned above.
 
7:40 PM
@Raynos Not even sure about that in IE9 anymore, but well if you are faster on 95% with DOM nodes, who wants another implementation?
 
I personally think .textContent is sugar
 
@Zirak Imagine the server was sending you a bunch of cats that play with eachother. Normally, to have a cat do something you'd come over to that cat and nicely ask it to stand a specific way. With InnerCat you're slaughtering all the cats with a a meat grinder, and gluing them together in some new order just to tweak the wiskers on one of them.
3
 
Everyone celebrating 20 years of VIM?
 
@IvoWetzel Saw that, but I'm waiting for epoch diff to line up in true nerd fashion.
 
@Incognito So every time someone uses innerHTML... a kitten gets slaughtered? :(
 
7:42 PM
@IvoWetzel All the kittens get slaughtered.
And gluing them together takes a long, long time.
 
@IvoWetzel PPPPPAAAAARRRRTTTTYYYY!!! tries typing party to see what happens
 
So I found an annoying bug in Firefox, wondering if you wizards could reproduce or shame me into admitting I overlooked something
If you copy some HTML off a page and paste it into a contentEditable element on the same domain as the page you copied from, Firefox is changing the URLs within that copied content from absolute to relative
 
user1385191
this is the best discussion we've had in this room in a while
 
user1385191
great stuff
 
@Chris Not sure what version you're on. I haven't updated my FF since 4.
 
7:46 PM
Yeah, we haven't discussed cat genocide in quite a while.
 
7.0, but I found a bug that seems to discuss this, going back to 5
DOM: like herding cats with an infrequent and totally accidental feline genocide thrown in for spice.
 
HAI
CAN HAS STDIO?
I HAS A VAR
IM IN YR LOOP
   UP VAR!!1
   VISIBLE VAR
   IZ VAR BIGGER THAN 10? KTHX
IM OUTTA YR LOOP
KTHXBYE
What APIs are in the browser?
DOM, XHR...
anything else?
Window?
 
user1385191
yep
 
Duh, people are raging against BEichs Class private proposals :O
 
I just thought of a cool "demotivator" image: A screenshot of this (Java) line of code JButton button = (JButton) event.getSource();, and under it in big letters is written "Defiance"
 
7:57 PM
I feel like I've successfully described HTTP, HTML, why separation of concerns and knowing the DOM API are important... using cat metaphors.
I'm either an idiot or a genius.
 
Or an idiotic genius
 
@Zirak So genius I'm an idiot.
 
user1385191
this JS class stuff reminds me of PHP's OOP
 
So smart it hurts the brain and fries it to stupidity.
 
user1385191
that @ crap needs to go
 
7:59 PM
@MattMcDonald What's your issues with PHP's OOP?
 
user1385191
I never said it was bad
 
user1385191
it was just rushed
 
Ohh. But that's all PHP ever is.
That's why you have code with _ in front of "private" methods.
 
Why would I use classes instead of prototypes?
 
user1385191
the more alien you make the class-based OOP, the bigger the bar to entry
 
8:01 PM
@Zirak In case you want to use classes.
 
Like...? When would classes be better than prototypes?
This seems like a way to say "look, it quacks like Java! Love it! Acknowledge it! Prove your ignorance in js's real nature!"
 
@Zirak Well, a prototype is really a way to work with an object, a class is a way to model an object.
 
Prototypes can be used to model objects. Object.prototype is a perfect role-model.
 
If you think of the memory in a computer...
 
user1385191
the ES.next proposals reek more of ruby than java if you ask me
 
8:03 PM
An integer, like, 32 bits, that's basically:

int blah;
 
@MattMcDonald Yay! Someone agrees with me! <3
 
A class is like

someSortOfDuck blah;
 
__
nobody cares about your prefixes in real life
 
user1385191
that's no coincidence either
 
It creates that object. A prototype is more like

object duck.quacks;
 
user1385191
8:04 PM
mr. coffeescript's pet language is ruby
 
@MattMcDonald No kidding :P
 
Except that Ruby is actually slightly better. You can actually sorta know what's going on, since it does have a def or braces structures. CFS has...nothing.
 
@Zirak This is probably the best summary: developer.mozilla.org/en/Core_JavaScript_1.5_Guide/…
> Class definition specifies all properties of all instances of a class. Cannot add properties dynamically at run time.
> Constructor function or prototype specifies an initial set of properties. Can add or remove properties dynamically to individual objects or to the entire set of objects.
 
if happy and knowsIt
  clapsHands()
  chaChaCha()
else
  showIt()
//How am I to know where the if statement ends?
 
@Zirak I hate the whole idea that we don't need braces. Hate. Whitespace is supposed to be harmless, not define flow of the program because some programmers are too lazy to indent.
 
8:08 PM
helo
 
@Incognito I know that. But the question remains. Why in the name of Odin's great beard would I prefer to use classes in my scripts? I see classes as a lazy excuse for optimizations. Type-safety is for weaklings
 
@Zirak Immutability?
 
LOL, __slice is a reserved word in CFS
 
Im completely clueless when it comes to javascript, however im trying to update a autoclick userscript that uses jquery, but it goes into a click loop if there is an error and the button is displayed again... how would i add a timeout or make it to where its only clicked once?
$(document).ready(function() {
document.getElementById('submitContinueBtn').click();
});
 
Why would I want immutability? I like my things dynamic.
 
8:10 PM
uhhhh Chrome's slow :(
code generator sucks
 
@Zirak I don't really have anything to say beyond preference. It might be useful in some places, like working on large teams, maybe.
@RyanCooper I don't know what to say to this.
 
When working with idiots, you'll have bigger problems than them overwriting your precious methods :P
tl;dr js is concise and conflicted enough, no new syntax as possibly can, kthxbai
 
@IvoWetzel That reminds me of Octonions... anything to do with square roots does.
In mathematics, the octonions are a normed division algebra over the real numbers, usually represented by the capital letter O, using boldface O or blackboard bold \mathbb O. There are only four such algebras, the other three being the real numbers R, the complex numbers C, and the quaternions H. The octonions are the largest such algebra, with eight dimensions, double the number of the quaternions from which they are an extension. They are noncommutative and nonassociative, but satisfy a weaker form of associativity, power associativity. Octonions are not as well known as the quaternions ...
 
@RyanCooper The code you have there does not adequately explain the problem you describe. I suggest you start a new question on the site with all the pertinent details - this is the best forum to provide the level of detail that would be needed to help. :)
 
@Chris Thanks, i think im close to finding the answer but im not sure how to implement it, is it not possible to alter any of that code to use .one ?
 
8:21 PM
hi all is there any body to help me pls? stackoverflow.com/questions/7985822/…
 
@RyanCooper That code is, in itself, a bad approach. It would not, however, cause the results you describe - another factor is at play that you haven't mentioned. Chat isn't the best venue to provide the details that one would need to troubleshoot; that is why I suggested you create a new question.
 
Okay, thanks for your help. :)
 
@drlinux You're abusing $(function() {, and putting script tags all over the place. Script tags go in one place, and contain your code.
And how do you hope to maintain something like this? var html = '<div id="input'+num+'" style="margin-bottom:4px;" class="alternate">Name '+num+': <input type="text" name="the_name'+num+'" id="name'+num+'" class="textbox" /> From :<input type="text" id="date'+num+'" name="from'+num+'" class="textbox" /> To :<input type="text" id="datep'+num+'" name="to'+num+'" class="textbox" /> Photo: <input type="file" id="photo'+num+'" name="photo'+num+'" class="textbox" /></div>';
 
but şt works excellent?
 
@Raynos y u goto bed?
 
8:26 PM
Wut?
 
@drlinux I'm sorry dude, I'm too tired to argue. There's just really big things you could do to make better code but you'll fight me every step of the way and I'm not up for it. Basically, you need to think about your coding style.
@Raynos Eh, nevermind. I'm going to chug some more cold medicine and goto sleep.
 
I'm gonna defeat that boss bitch with my new batteries
 
@Incognito ok there is no fight for something. are sure that my problem coming from my coding style?
@Incognito so just want to learn...
 
@drlinux - Yes, coding style. By having a messy codespace, you invite this kind of problem
 
@Chris can ushow me how to clean or do right that? Or where i'm coding wrong?
 
8:31 PM
@drlinux Yeah, you should really just have one set of script tags with all your code in it, and open the $(function(){ thing one time. You shouldn't be making one long HTML string like that, there's issues with that, basically it kills kittens. Also, the way that string is designed I'll never be able to work with it. Also, style="whatever" should never exist, you have CSS files for a reason. The rest of it needs to go through jshint.com until it passes.
 
@Incognito hmm many thanks ;)
 
Alright bed time now
 
@drlinux okay
 
8:49 PM
2
A: Best way to pull out a section of a string with JQuery?

Senad MeškinYou don't need jQuery for this, you can split it and get an item like this var itemId = "item_2445_205".toString().split('_')[1]; this will return item id

var itemId = "item_2445_205".toString().split('_')[1]; - toString()... really?
 
user1385191
good old String.prototype.toString
 
user1385191
> Returns this String value. (Note that, for a String object, the toString method happens to return the same thing as the valueOf method.)
 
user1385191
mm, stringy
 
user1385191
kind of sad nobody fixed the OP until now
 
I’ve got a (I think) very simple question regarding jQuery,
I’m using hide() on a few things, but you can see the elements briefly before jQuery kicks in on a page load.
Is there any way to make this faster?
 
user1385191
8:57 PM
use CSS for default states
 
I’m just using $(document).ready(function(){
 
user1385191
.hidden{ display: none; }
 
user1385191
then remove the class when you're done hiding it
 
I can’t do that, because it won’t degrade when JS is off....
 
user1385191
uh...
 
8:59 PM
You can put the code that hides the elements in a plain <script> section without using ready()
 
user1385191
what am I missing here?
 
I have not done that before (sorry if that is SUPER nub)
what’s different about doing it that way?
 
user1385191
add hidden class to elements in HTML, remove in JS if desired
 

« first day (382 days earlier)      last day (4583 days later) »