« first day (1013 days earlier)      last day (3927 days later) » 

6:00 AM
It's early...the code sucks
 
m59
hahaha, you're epic.
Funny you should say so. That code looks better than about 99.9% of code I ever see, ever.
Ohh, I see what you mean, now, lol.
 
@Anshad.Musafir 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.
 
m59
It's just so nice to see code all nicely nested an object-erified.
 
It's pretty clean, but dirs is a mess
I should just use a vector
 
m59
I'm nowhere NEAR good enough to say anything about what your code ought to do, but if it were my code I would feel the need to kind of...automate some of it
I mean, a lot of the objects look so similar that they could probably be generated more dynamically?
['up', 'diagonalUpLeft'][Math.round(Math.random())];
 
6:06 AM
Exactly right.
 
m59
Scorezzzzz
and...
it needs more jQuery, right??
 
jquery is for noobs, it needs angularjs
 
m59
did I make you facepalm?
hahaha
oh yeah, you got it =D
Hey, what is your job? @Zirak
 
I drive around in a van, delivering candy
 
m59
lolll
aka full-time js dev?
 
6:09 AM
I haven't done js for a job in several years now
 
m59
sad news.
 
But interesting how "scary paedophile" means "full time js dev" in your book.
 
m59
hahahaa
I'm writing code 12 hours a day (err...most of those hours, when I'm not screwing around on SO) and hoping I make something of it at some point.
I have a nice freelance job coming up when I get this content manager done, then, who knows.
 
Neat. Anything interesting?
 
m59
Nah, kind of typical.
The CMS, very interesting =D
 
6:13 AM
Goodmorning!
I have a question the following code wont redirect after saving
alert(opt.successAddEventMessage);
document.location.reload();
 
m59
They have Joomla now, and hate it (that's called wisdom) and they are thinking of going to Wordpress. I've convinced them pretty solidly to do neither, and just use mine, haha.
 
Is it something I am doing wrong?
 
hehehe
 
m59
@Tredged reloading is probably doing it wrong.
 
@m59 Is there a other or maybe even better solution?
 
m59
6:15 AM
I think it has something to do with caching, btw.
Is it not reloading at all? or just not doing whatever update you need?
 
Well
after that message
its suppose to reload and go to a different page
it only reloads
 
m59
@Tredged considering all of the capabilities we have now, reloads are meaningless.
Yeah, that sounds like cache.
When you say, different page, you mean different url??
 
How can I fix that since I am not that experienced with javascript
 
m59
or just the same url looks different?
 
Nah just re-direct like from test.php to home.php
 
m59
6:17 AM
reload(true);
like that
will probably fix it.
still, it would be very good for you and your clients to learn js well, and take advantage of all it offers you.
 
I agree with you for sure I am learning and trying so :P
 
m59
For example, my sites have NO .php, EVER.
 
@Tredged Well yes, you told it to reload
Hence location.reload
 
m59
This room has ruined most websites for me, haha.
You got to a site to SEE things. That's html =D
index.html
 
If you want to move elsewhere, set location.href to your desired url, or location.assign(theUrl)
 
6:19 AM
Hahaha
 
m59
@Zirak I think he's saying that the page looks different on the reload? Maybe I misunderstood
Like, restore it to its original state?
 
3 mins ago, by Tredged
Nah just re-direct like from test.php to home.php
 
m59
That can mean two different things, lol.
 
No, for some reason I can't make it redirect
Thats the issue xd
 
m59
when you say "redirect"...
can you explain what all is happening?
 
6:21 AM
@Zirak location.assign(theUrl) wont work either.
 
m59
what do the url and page look like when you start?
he means location.href = 'my/new/url';
or either, my bad.
Gosh, I'm tired.
 
@Zirak How is it you're still up ?
 
@dievardump I slept, as I assume you did too.
 
I did not. I do not need to sleep. I am a robot.
 
@Zirak I have this: window.location = opt.savedRedirect;
it wont redirect ..
 
m59
6:23 AM
location.href
 
also wont work lol
it says undefined then
 
m59
you got prollems.
 
@dievardump Well, hello there Robot. Why are you sexually harassing random humanoids?
@Tredged What's in opt.savedRedirect ?
 
m59
would it be difficult to show me all of your js?
 
savedRedirect: 'planning.php',
@Zirak
 
m59
6:25 AM
what did it say is undefined?
 
If you're getting undefined when assigning to something, that's usually a sign that something is...undefined. So log opt.savedRedirect just before the assignment.
 
m59
It it said location is undefined, then you overwrote it with a var.
 
now its undefined
also location.href = opt. or location href with a url wont work lol
 
m59
you definitely have scoping issues.
 
It just doesnt redirect to the page I want
 
m59
6:27 AM
paste me the code =D
 
calendar.save = function()
				{
					$(opt.formAddEventSelector).on('submit', function(e)
					{
						$.post(opt.ajaxEventSave, $(this).serialize(), function(response)
						{
							if(response == 1)
							{
								alert(opt.successAddEventMessage);
								location.href = opt.savedRedirect;
							} else {
								alert(opt.failureAddEventMessage);
							}

						});
						e.preventDefault();
					});
				};
 
Try doing it manually, location.href = yourDesiredUrl, see that the problem isn't with the assignment, but with your variable.
!!tell Tredged format
 
@Tredged Format your code - hit Ctrl+K before sending and see the faq
 
(you can press up to edit messages)
 
Done :)
 
m59
6:32 AM
is opt a global??
if not, how could that function know about it?
 
@Zirak please add a variant of /format to the welcome message
 
it is @m59
Why would it otherwise show the message xd
 
@JanDvorak If you can think of a good way to incorporate it, I'm all ears
 
m59
I'm pretty sure I'd need a lot more of the code in order to figure it out. This looks ok.
 
@Zirak I guess you dont know :(
 
6:36 AM
8 mins ago, by Zirak
Try doing it manually, location.href = yourDesiredUrl, see that the problem isn't with the assignment, but with your variable.
 
ok
 
m59
you need to see why that property of opt is getting lost.
That isn't in the code you included.
By the way, I find this much easier on the eyes and brain, but that might just be me :)
calendar.save = (function() {
  var save = function() {
    $(opt.formAddEventSelector).on('submit', save.submit);
  }
  save.submit = function(e) {
    $.post(opt.ajaxEventSave, $(this).serialize(), function(response) {
      if(response == 1) {
        alert(opt.successAddEventMessage);
        location.href = opt.savedRedirect;
      }
      else {
        alert(opt.failureAddEventMessage);
      }
    });
    e.preventDefault();
  };
  return save;
}());
 
@Zirak 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. Don't forget to format your code using CTRL+K or use a copy-pasting service like ... if it's more than just a few lines
 
m59
Hope that wasn't too many, lol.
I heard 15 was about right =D
and that's more, lol. oops.
 
m59
6:46 AM
ahahhaaha that made me cry
ohh man that was a good one
@Zirak I think it would be better not to minify it though.
In case you ever want to add any functions like, angular.someFunction
You could...
add your entire js code into angular's library...
YES.
OH MYYY
You could add jQuery to angular!!!!
 
I'll make a pull request
 
m59
angular.jQuery.zirakFunction
SCORE.
That's nothing but Web 4.0, right there.
@Zirak since I resent using .php files and did my CMS's output (the site itself) as 1 index.html that retrieves everything via ajax, should I just stick with that for the admin panel too?
I keep debating it.
That would mean that a clever person could hide the login screen via the dev tools and click around in the admin panel, but they'd never get any info that isn't available on the site anyway and couldn't save, etc.
 
Problem solved?
 
m59
I dunno...doesn't that make it a little scarier?
Admin panel running from a php file would let me check if they are logged in before they see anything but a login screen.
 
If you're worried about the file extensions, you can always make these optional or change them via htaccess (or web.config or whatever)
 
m59
6:55 AM
But if my api requires auth for any kind of post/put...there's absolutely no way anything could ever go wrong anyway
I just mean the separation. You guys taught it to me and I'm obsessive.
 
Make showing the admin page require the same auth?
 
m59
I'm convinced that the only php file doing anything is api/index.php that deals with other php files.
@Zirak if it's all js/html they could do whatever they want. But yeah...if you're smart enough for all of that, I guess you should be smart enough to stop wasting your time with it, lol.
 
@MajidMobini 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.
 
m59
maybe they'll hack into the admin panel and be like "man, that's a nice admin panel. I wanna hire this guy".
I see this:
  $dAdb->close();
}
?>
<!DOCTYPE html>
<html lang="en" ng-app="admin" ng-controller="adminCtrl">
and I am sad.
Anything I need to know about storing the authentication tokens in a cookie with js?
 
m59
7:03 AM
obviously, a person could fake them and all and get into the panel (I see no reason to check first) but then when they try to get something secure or save anything, they will be in mad troubles.
 
@TapanAnand 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.
 
m59
night dudes!
 
7:21 AM
Am not really tempted to work :/
 
I can relate
 
@DylanCole 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.
 
Hello earthlings
I want to manipulate the DOM by getting users Data and that DOM tree should be updated on the JSON file which is on the Server side. What steps should be taken here?
 
7:37 AM
Lots of cool Game Dev stuff (and well explained math for programmers in generell, splines, rotation, etc.) essentialmath.com/tutorial.htm
 
Anyone?
 
0
Q: How to replace colon and remove extra spaces?

WonderWolfieSure, I can make it work, with 2 replace() entries, but is there a way for me to aggregate the two replaces? I need every colon and every extra space (but not the one space between words, just the white space) to be removed from the text string. $(this).text().replace(':', '').replace(/\s+/g, "...

 
Compass sprite generator is really bad
@IvoWetzel o/. It was starred two days ago I think. I don't know why nobody pinned it.
 
7:54 AM
@Mr_Green nice.
 
@IvoWetzel PDF ? :(
 
you mean the post? @BenjaminGruenbaum
ok thanks
 
@dievardump indeed
 
@preetam 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.
 
I never had to use Object.isPrototypeOf before
4
Q: Default behaviour for Object.create()

gabenoI am trying to understand how object creation works and the corresponding prototype for an object created with Object.create(). I have the following code: var obj = Object.create({name: "someValue"}); console.log(Object.getPrototypeOf(obj)); // => Object{name: "someValue"} console.log(obj.cons...

Has anyone actually used it in production before?
 
8:04 AM
@Darkyen That's a shame for something that used.
 
@dievardump :(
 
Well... I will manage with that
 
@BenjaminGruenbaum I haven't
 
I don't like this answer. While it's true that OP's code is clearer, you might not know how regex work : they were designed from the start to be fast and they're fast (at least the versions without back reference). Here, luk2302 solution is faster : jsperf.com/regorreplacdystroy 1 min ago
 
@dystroy I upvoted that answer. I think OP's solution is better than the one suggested.
 
8:08 AM
@BenjaminGruenbaum It's only better because it's clearer. Saying it's faster shows a lack of understanding of regexes (I didn't downvote by the way).
 
I don't think that was the point he was trying to make, but I agree that it's wrong.
 
to his defense, he did say "probably"
 
Also, didn't know .text accepts a function, nice.
 
Hey, has anyone else come accross this problem? I am using the google Charts API and the geomap loads fine in chrome, IE, safari but it doesnt display in FireFox... theres no console errors, not sure how to work it out...
 
fiddle ? tinker ? jsbin ?
 
8:12 AM
@Vade if you post a fiddle, we can take a look
but no, I've never encountered this
 
er sure, ill set one up
 
@Mr_Green Your comment is incorrect, your regexp is between quotes.
 
You forgot a call to text(). — Jan Dvorak 1 min ago
should I edit the parens in or wait for the OP?
 
@JanDvorak too late
 
er not too sure what to put in the fiddle, basically i have a ASP.net site which i am using the google analytics api and charts api to display data, this fiddle has the function which handles the result from the Analytics and then displays the GeoMap, like i say it works fine on everything cept FF
 
8:16 AM
@dystroy you didn't make the fix I suggested :-/
 
@Vade I meant something we could play with and see it not working
 
ah k 2 mins
 
@Vade code review: L17 is a bit too long. More linebreaks wouldn't hurt.
L32: the same in spades: make the d.gebi call on a separate line and store the element in a variable.
(or at least flank with newlines)
nice code, otherwisee
 
I can't believe nobody did this yet...
!!mustache Vade
That was...rather disappointing.
!!undo
 
8:23 AM
Caprica Six:whose pic was thaT
 
Vade's. Btw...
!!undo
 
@JanDvorak User -1 was not found (if the user is not in room 17, pass a user-id instead of a username).
@JanDvorak I've yet to say a word.
 
!!mustache dileephell
 
@JanDvorak User -1 was not found (if the user is not in room 17, pass a user-id instead of a username).
 
You're really bad at names.
 
8:24 AM
 
jsfiddle.net/7smXC/1 but this actually works in FF... i cant post my code from the site as it is fed from my analytics accout.
 
@Zirak doesn't explain why I couldn't undo
 
That is odd
 
@Zirak it seems that she tried to undo the post she didn't make
after I edited
and her response was the same as the previous one
Could it be due to the chat debouncing identical messages?
 
!!mustache Elusio
!!undo
Maybe. If it wasn't too late, we could've tried providing a message-id.
 
8:28 AM
@Poojan 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.
 
user1125394
hmm you can't do itinaries in the new gmap interface..
 
8:44 AM
@Zirak oops yes
I will remove it
^ read it in a old post of SO
 
@Mr_Green What's that wizardry ?
 
I don't know much about it
but the user had commented that it will not required in upcoming modern browsers
 
I suspect it mainly changes where in memory the compiled regex is stored.
 
I mean in future
ya maybe
 
For a deprecated feature it's still strangely effective...
 
8:56 AM
yeah
9
Q: What is replaceAll performance secret? [HTML escape]

SaramI spent some time looking best way to escape html string and found some discussions on that: discussion 1 discussion 2. It leads me to replaceAll function. Then I did performance tests and tried to find solution achieving similar speed with no success :( Here is my final test case set. I found i...

 
This almost looks like a V8 bug. A regex literal should be compiled from the start, or at least before being used
 
0
Q: NodeJS, Async - What is the more effective way to pass variables

Rayjaxasync.waterfall([ function (next) { var x = 52; next(null); }, function(next){ console.log(x) //prints 52 } ], function (err) { }) It can log "x" even if i didn't pass it to next as an argument. So, do we really have to pass each variable ...

Hum, weird
 

« first day (1013 days earlier)      last day (3927 days later) »