« first day (1004 days earlier)      last day (3959 days later) » 

J L
12:07 AM
best way to change CSS hover element with jQuery? If I have a class .btn, can I do this: $(.btn:hover).css('color',newColor)
 
function lCom(id,delay,callback) {
	this.startTime = Date.now();
	this.id = id;
	this.delay = delay;
	this.callback = callback;
	this.listen();
	this.to = null;
}
lCom.prototype = {
	constructor: lCom,
	listen: function() {
		if(Date.now() - this.starTime >= this.delay ) {
			var item = window.localStorage.getItem(this.id);
			if( item ) {
				this.callback.call(this, item);
			}
			this.startTime = Date.now();
			this.to = setTimeout(this.listen.bind(this), this.delay / 10);
		}
	},
	stop: function() {
@TroyCosentino won't work with IE8
untested.
.
(false facts)
shit. the this.to = ... should be outside the if statement
it needs to fire regardless.
anywho
@JL it's annoying I know. but why not do it in CSS?
 
J L
I'm dynamically determining what color to change to with jQuery
 
live? or once on page load?
 
J L
once i page load
and also in a click() handler
 
do you control the page?
sorry for all of the questions. i'll get to an answer I promise
 
J L
12:16 AM
as in developed it?
i have full control over the site
 
can you modify the code for it
ok
what properties control the page load colour scheme?
as in, can you do it on the server at all?
 
J L
i have a jQuery UI widget that the user can select between six available colors, and the page dynamically changes certain CSS elements based on the selected color
 
ahh. ok
 
J L
so it is client side
is there no way to change :hover elements with jQuery?
 
i'm always cautious of client side UI "fixes" because of their unperceived latency.
no you can.
 
J L
12:18 AM
i think that'd be best
 
J L
ok so...the settings I make in the hover() call will override what
what's present in bootstrap.css for .btn:hover?
 
it is more verbose than your approach. but if you look into how jQuery handles it internally it does the same thing with less 'decisions' in the way.
javascript modifies the style property, which is like inline 'style' attribute for the element.
it generally has the highest specificity.
it will override all.
 
J L
yes, ok
thank you
 
np
 
12:22 AM
Got a brain tickler for ya; is there a way to sample the hex value of a portion of an inline image client-side?
 
in other news, I don't know if my mom has a cell phone virus or is just bit by the 2004 bug. For the past week and a bit she has sent me daily chuck norris quotes.
@monners canvas.
so long as the image is on the same domain as the hosted page
 
@rlemon I was kinda hoping to avoid that...
 
J L
what if the hex values of the pixels in your portion are all different
 
Yep, image is hosted on the same domain
 
J L
you want average value or something?
 
12:23 AM
proxy the image on a server and use php gd, or node canvas?
sorry, afaik canvas is the only api capable of this
I can give you the code ;)
 
@rlemon It's in a .NET environment with an antiquated CMS
 
ahh, well.
i'm sure .net has server side image processing stuff for that
 
But I'd appreciate the code :)
I'm sure it does to. I'm trying to achieve what would be a fairly simple effect using a framework my company has fallen in love with (and so we're being forced to use)
 
J L
 
1
Q: Ajax - Responding business errors

DesorderThis might sound like another of those questions with "best way" or "best practice" but I couldn't find anything related that could give me some light. The scenario... I have some ajax calls. Everything works alright. I make the calls, get the results back, change fields, values, colours. Nothin...

 
12:27 AM
var image = context.getImageData(0, 0, width, height),
    data = image.data;
for( var x = 0; x < width; x++ ) {
  for( var y = 0; y < height; y++) {
    var i = (x*4)+(y*4*image.width);
    data[i] = ..; // I am the red
    data[i+1] = ..; // I am the green
    data[i+2] = ..; // I am the blue
    data[i+3] = ..; // I am the alpha
  }
}
constrain x/y accordingly.
 
@rlemon context being the canvas environment?
 
assumes :
var canvas = document.createElement('canvas');
var img = .. get the image;
var context = canvas.getContext('2d');
var height = canvas.height = img.offsetHeight;
var width = canvas.width = img.offsetWidth;
 
Snap, beat me to it
 
and then :
context.drawImage(img, 0, 0);
but remember to always wait for img.onload = fn;
 
@rlemon Cheers mate. Really appreciate it.
 
12:30 AM
this is ofc only if canvas is supported
otherwise I fail to see anything aside from flash or server side stuff from doing it
 
12:42 AM
hey does it make sense to check if an element exists before executing a function or will jQuery just do ignore that block of code anyway if the element doesn't exist?
 
sarcasm, because, well....
 
I appreciate the response

I already knew it worked, but what is the best practice?
 
always check.
 
thanks doe
 
really you should know about the elements you are manipulating
 
12:51 AM
http://cl.austin.pe/text/140k2v202Y2E

This is what I am doing in the JS that runs on each page. If the contact form is on the page (jekyll template is set to include the contact form) then listen for it's submit
don't think it makes sense to waste another HTTP request breaking that out into another JS file
 
while (true) { fixBugs(); } // can't argue with that logic // because you're stuck in an infinite loop
@AustinPray Dude, build stuff.
 
wut
 
compile it all into one big honkin' JS file
 
Foundation?
Any particular reason you chose that over Bootstrap?
 
12:57 AM
I wanted to try it out
 
fair enough
 
it's kinda cool. Dunno if I like it better than bootstrap
 
we use it at work. It's ok.
 
I like that foundation is native SASS
 
They also have the greatest docs typo ever:
"in many cases developers will still need to be fired programatically" Freudian slip much? http://zurb.com/playground/reveal-modal-plugin
 
@AustinPray 10 min loop, of course.
 
wow reveal modals are awesome - perfect time for that link too, was looking for just such a thing
 
yeah the datatag model for firing those modals is really great
 
i've never seen that method used before - makes sense though
 
1:46 AM
wth , it seems so easy but i cant get it to work lol .. jsfiddle.net/Tb2WT/1
 
dunno du seems borked
 
m59
My brain is tired. Can you pull in a whole html/js app via ajax?
 
@m59 Yeah. Specific use case?
 
m59
should just be an html file with script src's
the js will get executed when attached to the page, right?
wait yeah, that's what's hurting my head. When the ajax call visits the page, js gets downloaded and runs, but then it is already downloaded in the browser so the new page already has it, and it runs again?
 
0
Q: Providing a Protected Global API to Third-Party Widgets

Jimmie LinI am creating a Web Application which provides a global Javascript-based API (in the variable System) and it includes methods that will be provided by frameworks (stored in System.Frameworks[name]). This System API will be provided to third-party "Widgets" that have limited access to frameworks ...

 
2:03 AM
anyone knows much about lisp?
 
@FlorianMargaine does
 
I got interested because I have seen it mentioned few times here.
I am doing some reading and youtube watching, and I am wondering what is the use of it at these days
do you know ? :)
 
2:21 AM
@Badger Girl thank you I am reading throuh this now, could you give me soem example use case scenario where lisp would be useful?
 
I don't know, Florian gave me that. You should ask him.
 
This text is really inviting to read the book but doesn't really give much of real life use case examples :)
 
@phenomnomnominal Oh yay, I always wanted Dexter to have a partner, now him and Lumen are doing fun things together, I'm so happy!
 
I was watching crockford youtube.com/watch?v=dkZFtimgAcM and got a bit lost on this video but the lisp thing completely killed me now :)
 
2:30 AM
@Irfan Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
@Badger Girl thank you I will try to catch Florian next time and ask him what is all that about :)
@Gacnt instead of watching this crap maybe do some comments on this video youtube.com/watch?v=1e1zzna-dNw
I really don't understand why this Brandon Wirtz guy, he must be getting paid for it
 
I'd rather not watch that idiot and give him anymore adsense than he ever deserved
He doesn't have a clue what he's talking about
 
hahah
 
I agree node.js is just a waste of time.
I believe mixing PHP and JavaScript is the best recommended.
Not just 100% JS or 100% PHP.
Each language has specific rule just like a tool from a toolbox.
This comment makes me want to just end it all
right here
instead of living in a world filled with people like the above
 
2:41 AM
hhaha
it is sooooo sloooooooooow
 
why cant view html5 data tags in chrome web tool?.
maybe it saves it to html5 storage..
 
@Gacnt I am going to waste few hours of my life now, thank you :)
 
2:58 AM
> I wonder how many shots they had to do before they finally got it XD.
> Probably as many likes as there are on this video.
:D
 
Quick, don't like it! Then they have to do more work!
 
lol
My wife is not happy when she is ironing I will have to show her this and tell her to work harder
good night
 
3:16 AM
wait, what was the name of JS library for managing multiple modules?
oh, require.js
 
@Qchmqs Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
@Qchmqs oh, hey
welcome to Javascript chatroom
 
Caprica six he is a bot or something ?
 
yes, he is a robot
 
welcome dude, don't worry i have no questions, or any thing, just feels bored
 
3:21 AM
Welcome to the future
 
i don't see future when IE6 is still in use
 
is there a way to check if an event listener such as click has already been assigned to a given div?
 
yeah
 
that brings to me another question, where assigned listeners are stored ?
 
i have the issue of multiple listeners being added which i need to solve
 
3:23 AM
just check it by
typeof div.onclick == "function"
 
@Overmachine Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
or div.onclick != undefined
 
.onclick is inline ain't it ?
event listeners are a little different.
 
what?
 
well lets say it was mousemove
 
3:24 AM
then
 
.mousemove wouldn't hold the listener right?
 
div.onmousemove
 
then div.onmousmove != undefined ?
 
yeah
 
when i see onclick im thinking thats to do with <div onclick=""> which i thought event listeners approach assignment differently to inline
 
3:25 AM
just learnt a new thing :)
 
damnn, I taught you a lesson man!! fuck...
 
div.onclick =

is not the same as

div.addEventListener()
 
i'm a bit noobish on JS ,and it always confuses the fuck out of me
 
@Qchmqs Damn really?
 
@Qchmqs did you start with jQuery
 
3:27 AM
I started Javascript with AS3 and I realised AS3 is 10 times more advanced language than Javascript
 
actually when i started using js from a C++ background, i was confused by how scopes work, and how the ligne by ligne thinking just mess things up
 
im surprised you find JS more confusing than C++
 
C++ is not confusing it is complex
 
which can also be confusing :P
 
it is annoying, hard to understand, and painful still not confusing
if you do something wrong the compiller will throw 97954 errors, and you will try to solve em all
 
3:29 AM
thin line between hard to understand and confusing
 
is there something wrong with using this type of selection: $("element.class") example $("input.error").removeClass(".error");
 
what confuses me in JS is that what i write actually works, but gives different result which confuses me
 
i dont follow @Qchmqs
 
@AustinPray i guess there is JQuery chat channel separated from this , no ?
 
oh there was jQuery stuff in here earlier
 
3:30 AM
jQuery is just JavaScript so it goes in here.
 
i'm not sure, i have'nt came here for more than a year
 
@AustinPray are you trying to select element like $("damn.class")
 
@phenomnomnominal is div.onclick the right thing to check if you have added event listener 'click' ?
 
because on this webpage
http://api.jquery.com/category/selectors/
 
@Dave depends on how you added it?
 
3:31 AM
it says there is a selector (".class") ?
 
@O0oO0oOO0ooO yes, and it works I am just wondering if that is the ideal way to do things
 
addeventlistener('click' etc
 
well, it means you need to say (".className")
 
$('input.error') will select all <input>s with class 'error'
 
if you mean that you want to remove the class after using as a selector, it works, i've used it quadzillion times, on .active .inactive classes for navigations
 
3:32 AM
@Dave nope, that won't get assigned anywhere
 
so how do you best check a div has or has not got a 'click' assigned already?
if you are using event listeners via the above means
 
why do you need to?
 
because its adding two of them i want it to skip over it if its already assigned
 
@AustinPray In that case, you can also do

$("input").hasClass("error")
but it's upto u
I've always been using hasClass approach
 
3:34 AM
@O0oO0oOO0ooO i don't think he have a problem selecting it, he asks whether it is a bad karma to remove the class that you used to select the element
 
@O0oO0oOO0ooO that's wrong.
 
@O0oO0oOO0ooO simplified html <form><input class .error /><small class .error /></form> i only want to remove the error class from input and leave the small.error alone. i know $("input.error").removeClass("error"); and $("input").hasClass("error").removeClass("error"); will work, but which one will have you guys laughing at me?
 
^ that will return a boolean
 
oh wait
 
$("input.error").removeClass("error"); is fine
 
3:35 AM
yeah, my jQuery memory is little rusty
 
If you're going to use jQuery, it's fine
 
but a kitten will be slaughtered
in the process
 
lolz
 
@Dave, if you add the function using a reference to a function, it won't get added twice.
 
using zepto ;)
hehe
 
3:36 AM
@phenomnomnominal im making a fiddle to show you what its doing a moment
 
if i understand it correctly, when you assigne a listener to click , it will be assinged to the attribute onclick, which means you can't assigne more than one handler ?
/me confused again
 
@Dave sweet, ping me when it's ready
 
Are there any other movies like The Social Network?
 
@Qchmqs that's true if you assign to the property
 
how's that different from using addlistener ?
 
3:37 AM
But that's often a bad idea, namely if you want multiple handlers
addEventListener can add any amount to any event on any element, it just calls all the handlers
 
that brings me to my earlier question, where do those get stored ?
 
I guess there isn't any movie then?
 
Have a look at the shim at the end of that ^
that give you an idea of how it can be implemented without native support
But presumably it gets added somewhere behind the scenes
 
behind the scene : means no way to access it in JS ?
there is removeeventlistener, but that assumes one is sure there is a handler, what if I'm not sure and want to check ?
 
Tickle tickle, here comes my pickle.
 
3:43 AM
wut ?
 
is there a way to get an array of every assigned event listener?
 
Sometimes I like to take peoples questions from here, and input the direct sentence into google, this is what I found for you @san.chez stackoverflow.com/questions/446892/…
 
@phenomnomnominal jsfiddle.net/5DKGf/1 once the box is blue border click the button below it
 
thanks Gacnt :)
 
@Gacnt sorry , i was already reading about it when i stopped writing
 
how come it works when assigned to a var ?
was it counting function(){ as a different one each time
 
yes
it looks for a reference to the function, not the content of the function
 
ah ok
thanks :)
what if you needed to parse data to clickHandler
 
blendernation.com/2013/07/15/… @phenom is this good stuff or what
 
very good
 
3:59 AM
@phenomnomnominal if i want to pass data i have to use anonymous functions
 
looks good, yet i have no interest in 3D stuff apart from watching 3D po**
 
@Dave if you want to pass data you're probably doing it wrong
 
couldn't express it better
 
even if the event itself is part of the calculations i want to use i gotta pass the base numbers to do the calculations with
 
there will be a better way
 
4:03 AM
hmm
 
@Gacnt thank you again, I have a quick question. Inputing my question exactly how it was into google doesn't bring the link you given make. It is not on the first page. What did you change? I am not a native english speaker. I am asking because it would really help me to improove my searching in future I think
 
ill try think of a way to do it
 
@dave, you should think of a better way, this will be cluttered
 
im trying to think of a way that works firstly :P
 
:p
 
4:07 AM
Quick question
 
create an object that handles the calculations, and just use callback to call methods, that will do it, add handlers just to get the values and then call the methods to do the work
 
why do you think JSHint is arguing
function getInstruction() {
        return (memory[registers.PC] << 8) | memory[registers.PC + 1];
    }
 
@san.chez I put a space at the end followed by the word, Javascript
 
    Unexpected use of '<<'.
and
Unexpected use of '|'.
 
@san.chez lmgtfy.com/…
 
4:08 AM
@O0oO0oOO0ooO because you missed the ')' ?
 
@Gacnt thanks for googling it for me ;)
 
like where?
 
i take that back , i just saw it, that's why i said js is confusing as fuck
 
jshint is a crying baby
 
with jshint it told me memory is not declared, maybe something is wrong inside memory declaration ?
i don't really know jshint and never used it
 
4:11 AM
dude that's because memory is not declared
 
i meant with no jshint it told me..
my intention was to check if chrome would cry about the syntax, but instead he said memory not declared
 
1
Q: Code and concept correctness with CSV writer in node

SmartLemonA friend of mine wanted an array to CSV string function for node, so I came up with this, basically it can take in a single object, a 2D array or an array of objects. If the children or parent is an object then the object properties become the headers, if the children are arrays then the first ...

 
dafuq ?
 
dafuq
 
da fudge
 
4:14 AM
a drunk monkey raping a cat for not being a good dog
 
If a quiz is quizzical, then what does that make a test?
 
damn it
didnt work
 
@O0oO0oOO0ooO that basically make it potatoe
 
TESTICLES
 
if testicles then why not zoidberg ?
 
4:23 AM
can you add event listeners to an object prototype?
 
i guess just assing something to .onthing ?
 
hi all
Good morning
 
what time it is ?
 
10 am
 
it is 4 am here GMT
 
4:32 AM
its 5:31 GMT because its actually BST :P
 
1:32 pm
here .. =D
 
@Dave actually in my pc it is 5:34 , i read it wrong , and i'm sleepy currently
 
Stahp
 
HAMMAHTIME!
 
4:39 AM
i'll go watch some anime
c ya
 
some guy is having hypersemicolonitis (suffering from too many semicolons)
 
lolz
 
4:55 AM
why can't you add event listeners to prototyped objects?
fuckkk
nevermind I misspelled something
didn't need those thirty minutes anyway
 
@phenomnomnominal here it is: jsfiddle.net/dexD2 move slider then click the button it will show you how many eventlistners it added i used a variable yet it still doesn't remove
 

« first day (1004 days earlier)      last day (3959 days later) »