« first day (444 days earlier)      last day (4729 days later) » 
00:00 - 17:0017:00 - 00:00

00:40
@Darknight the internet police willl get you
0
Q: Good JavaScript book/tutorial for PHP/C++ programmer

TiddoI am programming for several years mainly in PHP, but also regularly in languages like C++/C# or Java. For websites I create I also sometimes have to program in JavaScript. I know the (very?) basics of JavaScript, but I program in a C++ like OO style. From what I've heard good programming in Java...

01:44
Is this the right room for questions about Firefox's Add-on Builder?
(Since it is about referencing JavaScript files.)
 
4 hours later…
05:21
Anyone know why I can't access getContext() of a canvas created with:
document.createElement('canvas');
@GeorgeEdison Works fine for me in Chrome/Firefox from the console, what happens for you instead?
@GeorgeEdison jsfiddle.net/522mj
>>> typeof canvas.getContext
  'undefined'
If it helps, this JS code is running within the context of a Firefox extension.
Aha!
0
A: Manipulating <canvas> image data in Firefox extension

MatrixFrogI suspect the problem with the first snippet is that document is a XUL document, so its createElement function will create a XUL element and there is no such thing as a XUL:canvas. It is possible to create HTML elements in a XUL document, but then you'll want to use createElementNS(). Why src_dat...

Ah, yes.
btw, for anyone interested, the bot is running now
05:42
Oh yeah... you guys wrote some bots here, right?
05:56
why'd you write a bot for?
06:18
0
Q: Generate JavaScript linked to db from a form?

user1043838(I am writing my own like button system) How would I go about generating JavaScript linked to a UID on my server, for people to embed on there website? Examples of sites which do this: Facebook like button DISQUS embeddable discussion

06:28
hello
anybody there?
GGG
GGG
sort of
I have question about javascript.
06:30
Can I create class like C# in javascript.?
GGG
GGG
sorta
yes.....
you can create an object and assign to it method as object.prototype.method_name
so all object of that type
GGG
GGG
right
GGG
GGG
you create a function which acts as a constructor
06:31
I know C# very well. in C# we can implement structure with OOB.. but How can we create in javascript.
GGG
GGG
since functions are first-class objects in js, they can have properties
can we explain sample code?
GGG
GGG
so for example
function MyThing (x, y) { this.x = x; this.y = y;}
there's your constructor
now you want to add "methods"
in js they are function properties of the constructor's prototype
MyThing.prototype.getPosition = function(){ return 'i am at position ' + x + ', ' + y; }
+ is string concat in js
var thing = new MyThing(12, 34);
console.log(thing.getPosition());
make sense?
ok
by using prototype. huhhh and if it is in jquery then?
what is prototype in above code?
Is it compulsory to wrote ?
GGG
GGG
jquery doesn't really deal with this stuf afaik
all functions are objects
all functions have a prototype property that is an object
when you invoke a function with new, the resulting object has a reference to all properties in the prototype chain
next you are going to want to know about inheritance right ;)
06:42
thanks for good explanation , yes
GGG
GGG
ok inheritance in javascript is messy and controversial
but here's how it works
explain about inheritance and polymorphism in JS
GGG
GGG
i will but hang on a sec lemme find my pipe
 
1 hour later…
08:01
RT @kangax: Fabric now has (almost complete) SVG export, which means you can SVG --> canvas (+any modifications) --> SVG http://t. ...
RT @Cubiq: replicating complex objects with CSS is just an exercise in style. the way to go is SVG, just make browsers good at it
 
1 hour later…
09:15
hi allll
how to access parent node with jquery? for example tried this $(this).parent().siblings(".class_name").remove(); but it doesnt work
i have an iframe loaded in the same page so i want to remove element on the page from within the iframe
10:01
anyone
GGG
GGG
10:34
element.parentElement.removeChild(element)
11:22
ugh
element.parentNode.removeChild(element)
Mainly because parentNode has larger browser penetration and because it minifies better
@AbhishekBhalani raynos.org/blog/17
12:01
hey..i have 10 drop downs...so i want to change the value of one drop down n all other drop downs should have same value
any suggesstion
I have 10 cars, and when I change the color of one car I want to change the colors of all the rest to the same color. Any suggestion?
Or is my question somehow faulty, because there's no obvious reason a suggestion is necessary?
@Zirak ???
That's exactly my query as well
???
@Zirak this is what i did
<script type="text/javascript">
function setIndex(o, id) {
document.getElementById(id).selectedIndex = o.selectedIndex;
}
</script>

<select id="country" onchange="setIndex(this, 'prefix')">
<option>Denmark</option>
<option>Sweden</option>
</select>
<select id="prefix" >
<option>45</option>
<option>46</option>
</select>
I already see two mistakes, but do go on.
12:07
but there are 10 drop downs..when i select denmark all the 9 drop downs should change
Do they all have a common parent?
yes
here only 1 drop down values changes
Then parent.getElementsByTagName( 'select' ), iterate over the elements, set all their values to whatever you wish.
@Zirak pls give an example
Do you know how to iterate over an array?
12:13
@Zirak what id to assign to each select option
You don't need to. You're not selecting by id, you're selecting by tag name. Hence get Elements By TAG Name
~meme 'y-u-no' 'Y U NO' 'DO IT YOURSELF'
@Esailija glares
12:29
0
Q: What version of ruby use with cygwin?

Ivan PericicI'm using cygwin and install on them ruby, so cause I don't have much experiences with ruby I always get much error that those version is buggy to use fix, and many more... So my question is what version of ruby use with cygwin, that bypass all those problems?

@Raynos the delimiters are double quotes =)
12:57
o hai guise! did everyone have a nice xmas?
@AndyE hate
13:11
@Zirak did you get a lump of coal in your stocking?
posted on January 03, 2012

It’s a new year, and we’re supposed to make some predictions. So I’ll try to order my thoughts about the post-Android market, although I should warn you I won’t make a true prediction but will be a bit wishy-washy and vague. Back in September or October I was a lot more certain. Back then I predicted Android was going to be in trouble because of Google’s acquisit

13:24
Hey is anybody else getting JavaScript errors on SO? It's just not working for me in either Firefox or Chrome.
@Pointy nope, what type of page in so gives you errors?
Yes I've reloaded my cache etc. I get JavaScript errors about the "StackExchange" object not working. (Meta does work, for whatever that's worth.)
Also there's some weird problem with a <script> it's trying to import; hold on a sec and I'll duplicate the prob and report back ...
The error specifically is "StackExchange is not defined"
<script type="text/javascript" src="http://cdn.sstatic.net/js/stub.js?v=db457559e6b0"></script>
defines StackExchange
then the code after that is inlined like so
    <script type="text/javascript">



        StackExchange.ready(function () {

                $('#answer-8712750').animate({ backgroundColor:'#FFF' }, 2000, 'linear', function() { $(this).css('background-color', ''); });



            StackExchange.question.init({votesCast:[],canViewVoteCounts:true,totalCommentCount:0,shownCommentCount:0,highlightColor:'#F4A83D',backgroundColor:'#FFF',questionId:8709575});



            styleCode();

        });

    </script>
Well when I try to look at that source, I get an error about it having a MIME type that the browser doesn't like.
that will cause not defined error if the stub.js failed
13:29
Hold on I need to install tamper data on this machine ... maybe the CDN is messed up.
happens to me in Chrome too if I didn't say that already
what happens if you just directly go to cdn.sstatic.net/js/stub.js
that works ... hmm
it occurs to me that I might be a victim of some really stupid firewall (I'm behind an unfamiliar network).
yep it's definitely something on your end
thanks everybody - weird thing is that it worked yesterday I think
@Pointy What's the drawing that's your avatar? It seems very familiar
13:36
Wuddup JavaScriptPeeps
13:47
That's Mr. Arnolfini from Jan van Eyck's "Arnolfini Wedding Portrait", in the National Gallery in London
(I minored in Art History :-)
aahhh, long time since I've seen a Jan van Eyck, thanks
Don
Don
14:00
hi, I have a question about DOM events
when my page loads there are some listeners attached to the window resize event
I don't know what these handler functions are because they're attached by Ext JS
but is there some way that I can cause these handlers to fire when the page is displayed?
@Don yes I commented the instructions into your question.........
Don
Don
hi Esailija and thanks for your comments
I'm not asking how I can tell if there are handlers attached
I'm asking how I can programatically fire the handlers that are attached
@Don the breakpoints show what functions are fired and walks you through them
you can then see what the functions do with the page to make it work
and do the same
Don
Don
in my case they are minified functions that are attached by ExtJS, so it's not very easy to see anything
oh, well ExtJS sucks and people here hate it with passion :P
sorry I can't help with ExtJs
Don
Don
14:07
my question is just a general JS/DOM question
"how can I programatically fire the handlers that are bound to a particular event"
in this case the object is window and the event is resize
Re: my weird JS issue - oddly, if I issue the HTTP request with that "v" nonce parameter (or is it really a nonce?) given any other value than db457559e6b0 then the script loads just fine. Bizarre.
window.dispatchEvent(new Event('resize'));
Although I don't know whether 'resize' is the correct event name
Don
Don
thanks @Raynos I'll try that
@Don requires DOM4 :D
Don
Don
do you know of a good JS/DOM API reference page
14:10
I think new Event only works in chrome 17
if you want a more cross browser thing use
if (document.createEvent) { // W3C
    var ev = document.createEvent('Event');
    ev.initEvent('resize', true, true);
    window.dispatchEvent(ev);
} else { // IE
    document.fireEvent('onresize');
}
Don
Don
OK so the complete code is

var ev = document.createEvent('Event');
ev.initEvent('resize', true, true);
window.dispatchEvent(ev);
is that right?
You need the if check to check whether the browser implements DOM events
or you use a dom abstraction
or you use a dom shim
@Don w3.org/TR/domcore is the reference
You may also want to read w3.org/TR/DOM-Level-3-Events
@Raynos I still haven't gotten event dispatch to fire an event based on an event object for all types of events (ie, repeat keypress at a later time), only clicks and on form inputs.
Don
Don
@Raynos OK, I'll try your if-else statement above, thanks a lot
@Raynos I was looking for an API reference, with some simple examples, something similar to w3schools.com/jsref/jsref_obj_date.asp
@Don w3schools is the devil and I doubt it exists
Don
Don
14:15
but the w3schools reference only covers the JS libraries, not the DOM
just read the spec
Don
Don
well I guess I'm looking for an online equivalent of the reference in the "JavaScript the Definitive Guide" book
@Incognito window.addEventListener('resize', function () { console.log('wat u talking bout'); });window.dispatchEvent(new Event('resize'));
Works in chrome 16
@Don I dont know of a good DOM reference, I was thinking of writing one. Just read the DOM4 spec
Don
Don
I'm afraid of it :(
@Esailija ragequit
22
Q: How do I learn about browser host objects

Raynos4 months later: I'm reading the WHATWG and W3C specifications. If you want to know host objects read them. Don't trust other resources. TL:DR; I listed some host objects learning resources, but these resources don't go out of the way to teach me. Are there any proper learning resources for lea...

@Don answer is read the damn spec
@Incognito maybe your problem is your dispatching the same event object multiple times, that doesnt work
create a new event object for every dispatch
14:21
@Raynos Is there a node equivalent to encodeURIComponent?
oh nvm, querystring module
Don
Don
@Raynos that page is flagged as "porno" by my internet police
@Raynos stackoverflow.com/questions/8084970/… I may have been thinking a browser bug is a spec feature.
> This method allows the dispatch of events into the implementations event model. Events dispatched in this manner will have the same capturing and bubbling behavior as events dispatched directly by the implementation. The target of the event is the EventTarget on which dispatchEvent is called.
jsfiddle.net/u27xb/3 should unclick all the clicked boxes when you hit replay (because it dispatches the click event on them a second time), and it indeed did work a few browsers back.
@Don your internet police is trolls
@Incognito dont send the same event twice
@Raynos Re-create the object with values? Is is this a pass-by-ref issue?
Yes re create the object
new Event() or document.createEvent()
@Incognito I agree it is probably a bug, but easy to work around
14:30
=/ now I want to know why it worked a few browsers back.
Okay.
Note that if you stop propagation on an event object you cant re-use it
because the internal flag is still set and you cant reset it
You might be able to call .initEvent again
Try calling ev.initEvent again before re-sending it
I don't see a way I can just pass the object into a constructor and have it work, the constructor is all wonky.
what constructor?
new Event('click', { cancelable: true, bubbles: true })
Note Event as a constructor only works in chrome 16 and DOM-shim
Well, I've recorded a full event object:
event: MouseEvent
altKey: false
bubbles: true
button: 0
cancelBubble: false
cancelable: true
charCode: 0
clientX: 58
clientY: 71
clipboardData: undefined
ctrlKey: false
currentTarget: null
dataTransfer: null
defaultPrevented: false
detail: 1
eventPhase: 0
fromElement: null
keyCode: 0
layerX: 58
layerY: 71
metaKey: false
offsetX: 11
offsetY: 1
pageX: 58
pageY: 71
relatedTarget: null
returnValue: true
screenX: 1057
screenY: 507
shiftKey: false
srcElement: HTMLInputElement
target: HTMLInputElement
The document.createEvent(type), takes a string.
My issue is I can't just go document.createEvent(allThatObectData) and magic happens.
The event dispatch takes an event, but I can't take an event that fired and make it into an event.
As far as I can see. In a direct way.
Well yes
you have to clone the details
14:39
Raynos you going to speak at jsconf?
@Loktar o_o
Why do people say this to me as if I can give a good speech at jsconf
@Raynos That's so ugly!
Ive been gone for a week just noticed you pinned the link
@Raynos Because you're knowledgeable.
yeah, id try and make it for that
id be like "I know that guy! On the internet!"
14:40
@Incognito yes it is. Your not meant to re-use event objects
@Loktar o/
If people vote for me and I get asked to talk Ill talk
@Raynos Sure, but why shouldn't I be able to create an event by providing an object literal or something like that? Is that really ugly?
@Incognito The DOM doesnt work like that currently, go complain to www mailing list
This is the DOM were talking about
extend(new Event(oldEv.type, { cancelable: true, bubbles: true }), oldEv);
That's the best you can do
It's simply weird to me. Events are fired as objects, events are dispatched as objects, events are created from strings and provided attributes.
events arent fired :p
there only dispatched
throws hands in the air abstraction layer time.
@Raynos I fire them with my event cannon.
14:44
I was just thinking the other day
we need DOM utility functions
to be able to minimize code
so rather then have el.parentNode.removeChild(el) everywhere
we want remove(el) (function remove(el) { el.parentNode.removeChild(el); })
So that we can minify shit properly
That's why you have libraries.
I've been thinking about how to minify shit properly, i think our best chance is a library designed specifically for google closure compiler.
4
Q: How to take advantage of closure compiler when using a library?

IncognitoI've recently been playing with the awesome tool from google that does some code-optimization and partial execution, for instance it would take something like: //Just an alias for an elementByID selector function $(bar){ return document.getElementById(bar); } //Call the selector alert($("fo...

It's a mostly unexplored area, a few people have done some work but not a whole lot.
Thats what im thinking too
I dont like dom abstractions though :(
Abstract the dom when you have a specific task in mind.
@Raynos What topic would you discuss at jsconf?
15:03
not sure
when even is it
April.
Well the shit I know about is DOM and node
So I can talk about EDA wrt JavaScript
that might be an interesting talk
or I can talk about DOM shimming
@Raynos EDA wrt?
event driven architecture?
Event driven architecture with respect to javascript
I was planning to do some EDA today
But Im getting side tracked by buying flights and trains
then groveling and apologizing that the costs are higher then expected and asking for the money back
Exciting!
Anyway, the deed is done. I've suggested JSConf pick you.
15:08
but anyway the idea of EDA i was going to work on was rearchitecture the express 3.0 boilerplate to be EDA using nCore
and then blog about how you do EDA
or how I do EDA
or more specifically how I attempt to architecture applications in an EDA fashion using nCore as the base library
but thats only if I get that far
so jsfiddle is still crazy slow eh..
of course
they refuse to get better serves
probably because there running the backend on something that doesnt scale <trollface />
gah so annoying
regardless I even had to scale zg.net its not hard if your limited by the technology you developed in
run a clustered apache environ
nah
do it with a node cluster
@Raynos Would devs pay for a jsfiddle clone?
15:14
scales out of the box
@Raynos yeah if they did it in node definitly
@Incognito I had an idea to build a jsfiddle clone that utilized a 4th box for node
Im just saying even if you used IIS you can still increase performance
w/o a total rewrite
@Incognito shelfed it because there wasnt a solid sandbox thign out there at the time but there might be now
@Raynos The boxes don't scale well at all, sometimes you want to see more code or less code or.. bleh.
15:15
I think its defiantly worth while
well I see value in a environment like jsfiddle
Basically a light weight cloud9ide
Yeah it's great, just the UI isn't quite there.
I couldn't stand cloud9 when I used it.
html/css/js and express or something
does it have a business model? Don't know
I'd like more like gists on github to be honest.
gists are good
JSFiddle's business model is: use our stuff, we're not taking your money even if you want to donate it.
15:17
lol yeah exactly
Personally I think permanent persistence and chosen urls along with no-lag priority for a monthly fee can work
which serverfault forum covers server related stuff?
So can you run gists?
I was just thinking like jsfiddle but add a 4th box for server side node code and shit just works
You could host an entire game on it
or whatever you want
like a really small site
you could host those annoying 'YES' sites on it
then buy a domain and forward it to 'ourservice.com/yoururl/'
Note to self: Must not give away great business ideas in the public domain
@Raynos People knowing about your idea won't stop you from making it.
15:43
Just used valign='top' on a TD element... I feel so dirty.
0
Q: Parse/evaluate/generate CrontabExpressions outside of linux?

IncognitoI'm building some software that needs a scheduling input, and I'd really like to re-use the design of crontab because it simply works. CrontabExpressions can be really simple */5 * * * * "run every five minutes" or more complex 2-59/3 1,9,22 11-26 1-6 ? 2003 "In 2003 on the 11th to 26th of each ...

How can i stop the recursive function when i press stop button:

<script language="javascript">
function rec_fun(a){
$.ajax({url:"centerdata.php?id="+a, success:function(result){
$("#centerdata").html(result);
rec_fun(a);
}});
}

</script>
<input name='start' type="button" onclick="javascript: rec_fun('1')" >
<input name='stop' type="button" >
What is the function
@user994144 Stop using onclick="javascript: ...." .
is it running?
can you do a check before going into it?
15:47
@Incognito why and what do i use then?
var stopped = false;
function StopButtonClick() {
   stopped = true;
}

if( !stopped ) {
 //.. run function
}
Don
Don
if anyone has any advice about this I would love to hear it stackoverflow.com/questions/8712036/…
@user994144 Because you shouldn't put javascript inside your HTML tags. Use Event listeners.
@user994144 code separation.. you want all of your js in a specific place for maintainability.
15:50
                                                    do {
                                                    Ext.Function.defer(function(){
                                                                Store.loadData(Ext.decode(objHandler.DiscoveryToJson(action.result) ) )
                                                                console.log('count: '+DiscoveryStore.count()+' action: '+action.result);//

                                                            }, 30000);

                                                    } while(Store.count()==0)
im trying to make this work
defer() is equivalent to setTimeout()
this is what you get , when people, who have not spent a single day in learning javascript , become "jquery programmers"
7
@astrocybernaute click 'edit' and 'fixed font'
but it seems that it only delay onece
@rlemon And Javascript: is a non-standard psudo-protocol that doesn't make sense. Use of it is an antipattern for maintainability, code reuse, readability, etc...
well. onclick doesn't need 'javascript pseudo element'
15:52
@tereško Perhaps I should start saying RoR instead of LoL.
@astrocybernaute it seems like a very specific ExtJS question , you might get better results in IRC channels specifically for that framework ... it kinda depends on implementation of Ext.Function.defer()
i already tried it with setTimeout() ad it gives the same result
@Incognito .. well .. LoL is a taken acronym , there is a quite popular game , called League of Legends , which stands for LoL
only delays the first time
@astrocybernaute , you might be looking for setInterval , or some combination of it and setTimeout()
as i said before , this all depends on ExtJS implementation , and you will get better answers if you try freenode IRC server
16:05
@tereško I'll make my own framework and call it LoL. It will stand for LOnLols, in the unix recursive fashion.
Don
Don
0
Q: DOM event fired by window resize

DonI have a page that has a fairly complicated layout. When the page is initially opened there's a problem with the aligment of some of the elements. However, this problem can be resolved (permanently) by changing the size of the brower window. Obviously I don't want the user to have to resize the ...

16:24
How do i stop following ajax request that is waiting for a response?

$.ajax({url:"centerdata.php?id="+a, success:function(result){
$("#centerdata").html(result);
}});
@user994144 you add a check
@rlemon like how?
if( condition ) {
   // true results
}
seriously. do you want to stop the request on the server from ever being processed. or just cancel the 'success' function from being executed.
I haven't apt-get mooed in a long time, that was refreshing.
@rlemon I would prefer both but even if i can let success function not execute that should be enough for now
16:28
var stopSuccess = false,
    stopBtn = $("#stopSuccessButton");
stopBtn.on('click', function() {
    stopSuccess = true;
});
$.ajax({
    url: "centerdata.php?id=" + a,
    success: function(result) {
        if (!stopSuccess) {
            $("#centerdata").html(result);
        }
    }
});

<button id="stopSuccessButton">Stop</button>
@rlemon can only*
stopping it on the SS would likely require quite a bit more work.
@rlemon thanks but that would create more problems as i want to execute another function with similar request. I think if i can stop the previous request (on server) that would be much better
what is the request doing?>
waiting for an update... similar to facebook wall...
16:33
lazy polling?
@rlemon yes... to save some load on the server
and php?
I have like 2 walls, when user goes to 2nd wall from first wall, I want to cancel request that was generated on the first wall
what about php?
is you server side language PHP
@rlemon yes
16:41
-1
Q: ajax response vs normal http response

cipherBy checking the x-requested-with header we can check whether a request is an ajax or not, but how does the browser knows it's an ajax response and it need not be rendered, rather it needs to be handled by JS?

Oh my
@rlemon I think this should be a solution but long way: i request another ajax and store some value in session variable that would tell the server to stop previous requests...
then do that.
user1385191
a predominantly server-side question belongs in a server-side room
basically you are asking for the 'best way to do something' but when it is presented you realize 'shit this is going to be a lot of work to re-factor my code to allow this' and now you are looking for a hacky solution...
it was there... they gave him a solution he didn't like so came here.
user1385191
the PHP room is probably the most helpful on this entire site
Don
Don
16:51
you would need to have spent time in every room to make that statement with any degree of confidence ;)
@rlemon I am still looking for a best solution. If you know any better solution, please do tell...
user1385191
considering the only other competition—aside from this room—is the C++ room, I rest my case
@MattMcDonald the question is related to Js
Don
Don
why knows what kind of wonderful things could be going on in the Dart or Erlang rooms?
user1385191
you should research the android room :)
16:55
Seeing as one is a piece of shit and the other mainly purists use...
00:00 - 17:0017:00 - 00:00

« first day (444 days earlier)      last day (4729 days later) »