« first day (1014 days earlier)      last day (3937 days later) » 

1:00 PM
oh... jQuery.noConflict()?
or simply use require.js to grab jQuery ? / also wont that be loading 2 huge libs when i want one ?
 
@RobW sometimes SO makes me sad :P
 
there are so many RobW on SO
google can't find the good one
 
Hmm
 
@FlorianMargaine (that was the scope of discussion)
 
1:04 PM
14.7 kb require.js
just to load jQuery...
might aswell remove jQuery completely from login page...
 
How about not using require.js then?
 
@Zirak nah too ugly
 
...pardon?
 
Too many script files
 
@BenjaminGruenbaum We really get this question too often... Yesterday I gave up on the same one because I was tired to see it...
 
1:05 PM
But if you're just using require.js to load jquery...
 
The way i am doing it is, All the dynamic/static pages rendered by my app for (posts,photos , even login ) have a file added to them which is the require.js entry point which loads the rest of the app asynchronously. giving an omg so fast feeling on first load, and then all redirects are interrupted.
 
@dystroy Honestly I haven't seen it before, I've seen 'how do I do contains' but OP in this question didn't have an array to begin with.
 
I've seen it exactly like this often, and yesterday. Thinking about a way to find it
 
@Darkyen you can use browserify.
its overhead is 100 bytes.
 
@dystroy Did you comment on it?
 
1:07 PM
?
I didnt see feeds I have it blocked
what did it say?
 
@BenjaminGruenbaum good idea but no
 
YES! Medium badge acquired. Goodbye game!
4
 
Can we search "yesterday's javascript questions with indexof in an answer" ?
 
@FlorianMargaine i will try them both and find out the best solution, though i find myself more familiar with browserify.js
 
@dystroy I think you can in the querying interface but not in the normal search
 
1:09 PM
...why is that starred?
 
Because you said it, and everyone likes you
2
 
Other people starred and I want to fit in so I star
 
I starred the one saying everyone likes you, not the one I did not understand
 
Someone should write a lib to inline the underlying jQuery code.
:->
 
1:12 PM
@Darkyen I don't get what you mean. Why do you want to inline jquery's code ?
 
@dystroy if i just use 2 features of it :P loading whole lib is madness but its still faster to write jQuery code
for example
 
what's the link with inlining ? You want to modularize it, no ?
 
$("#omg_pop").on('foo',fn); -> document.getElementByChild('omg_pop').addEventListener('foo',fn);
nah just realized its a pain to convert jQuery code to pure DOM.
 
oh, boo fucking hoo
 
:P
 
1:15 PM
@Amaan is that just DLC?
 
its just a thought off the head @Zirak
 
Speaking of that, I wrote some non jquery code yesterday for my web site, just 10 lines but I'm not really happy with it. How would you write this without these [].forEach.call things ?
[].forEach.call(document.getElementsByClassName('opener'), function(opener){
		var open = false;
		opener.onclick = function(){
			open = !open;
			opener.className = open ? 'closer' : 'opener';
			[].forEach.call(opener.parentNode.getElementsByClassName('more'), function(e){
				e.style.display = open ? 'table-row' : 'none';
			});
		}
	});
(it's for dystroy.org)
 
@rlemon Borderlands 2? Nope. It's the game!
 
i already got it
 
@dystroy forEach = [].forEach.bind(Array.prototype);
 
1:16 PM
@dystroy ^
@Zirak how fucking fast can u type
i barely read his code.
 
7
 
user1125394
what's more expensive, making several ajax requests doing basic sql each, or one, that will do more heavy sql?
 
@Zirak I thought about that but I'd rather keep it even simpler, without function definition.
 
@cx its all about latency
when u do multiple ajax requests everytime u request u add latency
 
@dystroy You may be able to use event delegation
 
1:17 PM
also sql's are optimized for bulk transitions
 
@Zirak you lost me there
 
@dystroy What's wrong with a plain old for loop?
 
@BenjaminGruenbaum the problem is that I use the closure to store the open variable
 
user1125394
1:18 PM
anyway as using apache, a not very good server, I think one request will relieve it
 
@rlemon Ah, okay
Tell me when you start playing it
 
Then yeah, just do foreach = Array.prototype.forEach at the top of your code instead of slapping [] in front of it every time.
Where are opener elements added anyway? can't you attach the behavior when adding them? That makes much more sense.
 
BTW, it's all zirak's fault : he made me decide to link to Venise2012 from my home page so I had to code those drawers.
 
@Amaan already have :P
 
NOOOOO!
 
1:19 PM
0
Q: Add a br tag in between of the text

Mr_GreenIn my project, I am trying to add a <br> element inside a element div. So, that I can show ellipsis on second line. Here is the fiddle in which I hardcoded the br tag. <div>hellohel<br>lohellohellohellohellohellohellohellohellohellohellohellohellohello</div> I am trying to add the br tag at ...

 
@BenjaminGruenbaum I didn't think about adding it in code because not all the four sections had one at first... I could do that...
 
@Zirak I don't think your .bind will work
 
@dystroy It's your DOM, you shouldn't query it most of the time. I usually only query the DOM when scraping (and when I use third party code that makes me)
 
@Alnitak durr, you're right
var forEach = [].forEach.call.bind([].forEach);
Or var forEach = contextify([].forEach)
Man do I love that function...
 
1:22 PM
@BenjaminGruenbaum It's a static page made of few HTML (and .less) lines. I don't build the DOM so I have to query it
 
@BenjaminGruenbaum what did you think was wrong with that Battleships algorithm?
It only takes 7 or 8 attempts on average to place the 5 ships
 
@Alnitak The logic, it's not a while(true) conceptually and it's not a break LOOP conceptually.
 
@Amaan, @copy You might like this one kongregate.com/games/keybol/pretentious-game-3
 
yeah, I could have used a flag and said while (!found) instead of while (true).
 
12 hours ago, by rlemon
http://www.extremetech.com/extreme/162289-light-stopped-completely-for-a-minute-inside-a-crystal-the-basis-of-quantum-memory
 
1:27 PM
It seemed that using a continue LABEL was actually cleaner than using some sort of state variable and test to abort the inner loop, though
 
@Zirak This is good. I won't use it because it's too verbose for my simple page but I like it.
 
I thought your complaint was about the algorithm as a whole, rather than just the looping constructs
 
@Alnitak Oh, no the algorithm looks fine, the looping constructs are pretty bad imho.
 
@Amaan I was hoping for more Connor theories.
 
@rlemon Oh, didn't see that!
Hahaha
That was so funny
 
1:30 PM
Wow, that question has two completely wrong answers with upvotes..
1
Q: How do I prevent accidental global name space pollution with javascript eval?

SukimaI am writing a simple REPL (Read, Evaluate, Print, Loop) implementation in JavaScript. I am able to isolate code and calling context like so: var sandbox = { // Allow the input code to use predefined helper functions // without the preceding use of the this keyword. helper_fn: function() {...

" You could unfreeze it again after running the user-defined code." - No, you can't - there is no such thing as Object.unfreeze in JavaScript. — Benjamin Gruenbaum 1 min ago
 
@BenjaminGruenbaum lmao
 
@Connor What was that yesterday that I missed with the conspiracies ?
 
@BenjaminGruenbaum You missed a debate about ignorance.
 
Who said what? I don't feel like reading the whole thing
 
1:35 PM
still no helpful answers
 
@BenjaminGruenbaum That would just re-start the convo though. and i got banned because people couldn't handle it, so id'e rather not.
 
Ok
@Mr_Green create a div with code, put the text in it letter by letter, detect when height changes.
 
We just can't handle the truth
2
 
@RobW's answer is good though
 
ha
that is nice
but long process I suppose
anyway, I need to make it work
 
1:38 PM
I'm here, but do not show up in the side bar.
 
any other suggestion?
 
@RobW Yeah you do.
 
@RobW Yeah you do
 
@RobW Yeah you do
 
You both forgot a period.
 
1:39 PM
@RobW I want to fit in
 
I'm weak. Don't judge me.
STOP JUDGING ME
 
hi Rob
 
Heya
 
I can't understand your last comment
@RobW
 
1:42 PM
text-overflow applies to text that is, well, overflown
When all characters are wrapped, text doesn't overflow
 
yeah
 
That's why there's no ellipsis
 
yeah I know that
but if I add br tag
in html
then there is ellipsis
 
@Mr_Green one second, I'll write you something.
 
ok
 
1:43 PM
How do you determine where to add the br?
 
yeah that is what confusing me
I thought it is easy with jquery
 
VanillaJS suits well in this case
Use the splitText method once you figure out when to split
And insert a br between the new text nodes
 
ok
 
"figuring out how to split the text" is the hardest part :p
 
once if I get to know how to add br I will be on rocket
yeah
 
1:45 PM
@Mr_Green Is this what you want? jsfiddle.net/cUwvu (<- updated)
 
No ellipsis here (Chrome)
 
in highcharts, is there a way to enable downloading a graph as a png?
 
ya no ellipsis in chrome
 
And a glaring XSS hole
 
Why XSS?
(Not saying it's a good idea)
 
1:47 PM
I saw .innerHTML = .textContent, though I didn't look at what you did before that
 
0
Q: Is it possible to cut off the beginning of a string using regex?

Golo RodenI have a string which contains a path, such as /foo/bar/baz/hello/world/bla.html Now, I'd like to get everything from the second-last /, i.e. the result shall be /world/bla.html Is this possible using a regex? If so, how? My current solution is to split the string into an array, and join i...

Why would people use Regex for that...
 
@Mr_Green Here ellohellohellohellohel jsfiddle.net/zmJVv , I'll add that as an answer if you'd like.
 
because they can, obviously
 
@dievardump If only there was a path module, oh wait :P
 
I think they got most of the languages they used in StarGate from Russian
 
1:49 PM
@BenjaminGruenbaum if I resize, the ellipsis is also visible on first line
 
@Mr_Green What do you mean?
 
If I resize the page
the ellipsis is visible on first line also
I mean on both lines
 
@Mr_Green Of course, it's a JavaScript solution, it runs once. If you want it to work on resize you can attach it to the resize event.
 
ohhhhhh
sorry
@BenjaminGruenbaum window.onresize = appendBR(container);
 
Does that work?
 
1:52 PM
nope
 
Wanna tell me why?
(That is, why assigning a function invocation to a handler does not work)
(Or why window.onload = alert('hello') doesn't work for that matter)
 
@BenjaminGruenbaum umm... what? alert doesn't return a function
 
@JanDvorak Which is why @Mr_Green 's code does not work :)
 
yeah working fine
Thank you Benjamin
 
0
A: Add a br tag in between of the text

Benjamin GruenbaumFirst of all, you should check out Rob's answer. JS is a really extreme mean to solve these sort of issues. I wrote a short utility function for you that does what you want, it will look cut the first line of al emenet an add a <br> after it. This will let you keep ellipsis on the second line....

 
2:01 PM
@Darkyen I figured out why it still looks blocky...
 While the length of the side of the squares
 is greater than zero {
 Pass through the array and perform the diamond
 step for each square present.
 Pass through the array and perform the square
 step for each diamond present.
 Reduce the random number range.
 }
^ solution
 
waits for people to figure out I used pop instead of shift
 
@dievardump because it's fun to look at the various ways to do it :)
 
@BenjaminGruenbaum your fiddle solutions are showing the ellipsis in one line instead of two.. why?
 
@Mr_Green huh?
 
nvm
when I resize the letters are changing.. did you see that?
 
2:05 PM
3 mins ago, by Benjamin Gruenbaum
waits for people to figure out I used pop instead of shift
 
ohh that was for me
kk
 
Read the code and make sure you understand it :)
 
yeah sure
 
oh, we can un-closevote?
 
Why is Array.length non standard :O?
Wait nvm
Just badly defined
 
2:12 PM
It's from Function.prototype.length ?
 
doesn't have its own section/subsection
 
oh, that
 
@Darkyen any idea how to make the diamond square shit iterative instead of recursive?
 
I thought you literally meant `Array.length`
!!> Array.length
 
@Zirak 1
 
nice. just found my own answer on google looking how to do something
2
A: Get div position (top) in javascript?

rlemonI will give you the vanilla solution.. don't complain.. add a [0] to your element and it's fixed! :P hope this helps. function getOffset( el ) { var _x = 0; var _y = 0; while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) { _x += el.offsetLeft - el.scrollLeft; ...

 
:-)
 
ah yes, the stackerang.
 
Hah, awesome.
 
2:36 PM
@AlecHewitt 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.
@Péter 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.
 
Hi, does anyone have any experience of using google app engine's channel api to send images?
0
Q: Displaying images in html5 canvas from binary data

Alec HewittI am trying to send an image from a canvas through the google app engine channel api to another client who will then display the same image. The message is being received but it is not displaying the image. On the sending side: var image = context.getImageData(0, 0, imageCanvas.width, imageCan...

 
@Zirak I'm embarrassed how long it took me to get it. :(
 
@BenjaminGruenbaum awesome
@rlemon ^
sorry benji wrong ping
@rlemon very simple indeed
 
@AlecHewitt I think you need to pass an URL to Canvas
 
use steps :P
say ur canvas is 64 x 64 for for the first iteration in the 3d loop increment i in the first time by 63 ;D
then reduce the increment by 2 and re-do it until the increment is <= 1
soo
 
2:46 PM
huh
@Darkyen I think I found an example I can look at that does it how I want to
 
for( var incrementer = 63; incrementer >= 1; incrementer-- ){
   for(var y = 0; y < 64; y += incrementer){
       for(var x = 0; x < 64; x += incrementer){
            /* the x 1 = x , y1 = y, x2 = x + incrementer, y2= y + incrementor */
           /* Diamond them here */
       }
   }
}
 
0
Q: Is it possible to send images through app engine channel api

Alec HewittI have been trying to send and receive images utilizing google app engine channel api. However I have not been very successful. I posted this question on stackoverflow earlier today: http://stackoverflow.com/questions/17879641/displaying-images-in-html5-canvas-from-binary-data however I have had...

0
Q: phonegap : download and parse xml

user2589881i want to make a Phonegap app to connect to a website with headers and get the response as XML then parse it :D simple with XML HTTP Request ... but the problem is that when i'm using it ... the browser locks till the response is completely back. please let me know if there is a better and ...

 
@rlemon
 
0
A: Displaying images in html5 canvas from binary data

rlemonswap drawImage with putImageData createImageData() returns an ImageData object. http://tinker.io/e3ec8

 
see that ?
 
2:48 PM
@Darkyen yea, but see this: codepen.io/DanielWeiner/pen/obFDh
he pretty much does it how I need to do it
 
Anyone else participating in the BOINC project(s)?
 
@rlemon what exactly you want to do ?
 
pretty much what that demo is doing
I pissed around for a bit trying to fudge it with recursion. but it looks like it just won't fly
I could do a cool 3d model with it, but for a top down view it doesn't work
 
ah he doesnt use recursion? crazy
 
nope, iterative
which is how you have to implement DS so there isn't the blocky side effects
 
2:53 PM
Mines recursive
 
(according to the article)
 
!!/google boinc
 
 While the length of the side of the squares
 is greater than zero {
   Pass through the array and perform the diamond
   step for each square present.
   Pass through the array and perform the square
   step for each diamond present.
   Reduce the random number range.
 }
 
ah nice I liked his implementation
but mine is shorter
I assumed mine was way longer
I havent looked at the code for mine in forever
 
2:57 PM
^ you iterate dont u @Loktar
 
I iterate via each subsection I suppose
then call the displacement for each section
 
basically what i said ?
 
just pure and simple midpoint stuffs....
god I hate you for making this look so simple... :/
/me gets smoke and coffee
 

« first day (1014 days earlier)      last day (3937 days later) »