« first day (2032 days earlier)      last day (3138 days later) » 

08:01
now back to integrating this with a persons IP.... this could be fun lol! ....
anyone suggest a good reading about returning a value from an ajax call at all? I know someone sent me an article on here about it, and i cant find it :S
thanks Awal :)
glad to be the official Google Search Result Distributor Vice President for Stack Overflow JavaScript Chat Room.
@Neil but you don't know which of the choices are found... unless you immediately do something like txt.indexOf(["sky"], ["sun"], ["clouds"]) > -1 ? document.getElementById("demo").innerHTML= "<img src='" + txt + ".jpg' alt='' />" : console.log('no value found');
the Google-Fu is strong with Awal :D
@JimmPratt true, but I assume that if you're passing an array, you don't really care
@Neil point conceded
@AwalGarg have you not learned that google results depend on people?
But you're right, you'd be missing information
08:08
@FlorianMargaine not my problem that you get jQuery results everytime because of your love for jQuery
guys, i guess with promise not supported by IE (i have to support to IE8) i will be looking down the call back route for using ajax value?
short answer: yes
long answer: ie8 lol wtf lmao
assuming that the array contents are exact enough (i think the 'clear sky' might fudge things up with the space, but you could always do a replace-space-with-underscore), using a ternary let's Kristi handle all the options on one line (assuming again that graphic file names match the stuff in the array)
people still require IE8 support?
firefox is stupid... it doesn't do s/ /%20/g when you copy paste an url...
08:09
unfortunately i do in my role Shea :(
@FlorianMargaine it is a feature
@KirstyHarris that can get messy. You wouldn't prefer to include Q or something?
@KirstyHarris bluebird can work on ie8
@AwalGarg to be stupid? yeah, I know
ok, i will bare that in mind Florian,
Guys, in Intellij/Webstorm, do you know of a way to disable/suppress inspections for a single file?
08:11
@Neil basically im using an ip call to determine a persons location to construct a URL based on an Ajax call
@MadaraUchiha use emacs
I have a legacy JS project with hundreds of warnings, and it clutters my editor too much
@FlorianMargaine eff off.
I sort of want to correct your usage of bare but I am not sure myself.
yay jsFiddle supports Typescript! but... booooo now i have one less reason not to learn Typescript :(
is it bear or bare
08:12
@AwalGarg bear
bear*
as in to carry the weight of the decision
this is so very entertaining /s
So, does anyone know?
Without switching editors?
@KirstyHarris have you done a lot of Ajax callback code? It can get to be unreadable imho
08:13
@MadaraUchiha use vim
@MadaraUchiha wherever you work, the legacy is strong
from grammarist.com "Bear has no adjectival definition. When not referring to the large mammal, it is a verb with a variety of meanings, none of which relate to uncovering or exposing. A few of its meanings are to hold, to support, to exhibit, to carry oneself in a specified way, to endure, to give birth to, and to yield (especially fruit). Its past tense is bore (e.g., it bore fruit), and its past participle is borne (e.g., it has borne fruit).

So bear is the correct spelling in the phrasal verbs bear down, bear out, and bear up. It’s also the correct word in the phrases bear down on, bea
08:14
It sounds like you might need promises in your case since you're making multiple calls
And uh cccombobreaker
still time to edit
@MadaraUchiha emacs
@Neil no i havent, it was just a way i found of retrieving a persons IP and location. Is there better ways?
@KirstyHarris The browser can politely ask the user for their geolocation
^ IE8
08:17
@MadaraUchiha emacs
IE ... 8
function getUserIp() {
    // like the real one would be real
    return [0,0,0,0].map(el => Math.ceil(Math.random()*255)).join('.');
}
@AwalGarg 255*
08:19
ty, fixed
ok why are my code backticks not working >:(
@JimmPratt For multiline code, paste, CTRL+K, enter
Doh
oh
I went from 8 to 16GB RAM this morning
i listend to Awal >.<
08:20
@JimmPratt That works too
that should feel nice in a few hours.
@JimmPratt sorry i missed that code there.
I hate that kind of code though, the one that still kinda hopes that ActiveX will be there
It's 2016, stop writing code for IE6.
That was what i was using but using freegeoip
or something similar
08:21
heh... admittedly it was from 2011
@MadaraUchiha talk about people with legacy code :P
@AwalGarg Our code actually has a good reason for supporting IE6-7
Those 0.2% of traffic are worth the trouble.
1 message moved to Trash can
@KirstyHarris Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. For posting large code blocks, use a paste site like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
@CapricaSix rude
argh neither is mine Jim, i just did delete it lol!
08:22
@KirstyHarris paste, CTRL+K, enter
No other keystrokes in between.
(or CMD+K if you vape)
are you really actually laughing out loud while writing all these messages? I am sensing lies
@AwalGarg With 4 billion requests per day, 0.2% is a lot.
Worth the maintenance cost (from the company's perspective)
pastie.org/10830021 I pasted it here @JimmPratt, but basically when i tried to use that variable to construct a url it wasnt doing good so looking at that article as i need to form some form of if statement anyways for no returns :)
@MadaraUchiha Is it worth enough to cancel out serving extra code to the other 99.8% of the 4 billion requests per day?
@AwalGarg Yeah
(Again, from the company's perspective, I happen to think differently)
08:25
i was going to suggest talking a look at the long answer at stackoverflow.com/questions/391979/… by 10basetom where he goes through several options... but he uses jQuery for the API calls. could take that as a guide and do it in raw ajax i guess.
well, 80M requests per day is still something
@AwalGarg depends on how much you're willing to spend
We're a 3rd party in someone else's page, I feel like we should have 2 versions, one with all the polyfills and ugliness and one without
@JimmPratt thats awesome, thanks for the suggestion
And have the publisher decide based on their traffic diversity.
Some sites could be frequented more by IE6 users than others, and they might decide it's worth it.
Also, with 2 versions, you can A/B test to see which generates more revenue.
But alas, not yet.
08:26
Yahoo and Google, you had better believe that they go through the trouble of making their home pages compatible with IE
@Kristi be warned that the answer is old, so many of those services may not be active anymore.. but the concept is sound
@MadaraUchiha aside: do you guys submit browser stats to stat collectors? if not, you should!
ok Jimm, no problems, thanks for the heads up
@KirstyHarris i meant
@AwalGarg I honestly don't know
08:31
@MadaraUchiha 4B/day is enough to help with that, even if it is specific to an area :)
4B a day? Nice..
40,000 $10 digital droplets
in PHP, 13 mins ago, by Gordon
speaking of java and javascript mixed together: https://www.javapoly.com/
@AwalGarg ...
@littlepootis where's the "haha, this is all bullshit" disclaimer?
08:40
Looks like that javapoly is a JS-based java (de-)compiler.
Which is ridiculous.
I have no words
But props to them for getting it to work.
oh fuck you, reddit
Front page is full of GOT spoilers, bastards
> But could you pls make it more like Java? I mean, it's great that es6 and 7 are getting closer and closer to normal languages then why not be simply Java?
I know nothing.
Let's keep it that way.
08:43
> more like Java
wat
yeah, just don't visit reddit
> getting closer to normal languages
wut
> why not be simply Java
!!wat3
because Java is an abomination. that's why
/thread
08:44
i'll stick with my python and javascript, thank you! :P
Oh, by the way: GoT spoilers will get you kicked here. Regardless of if they're accurate or not.
16
jQuery or javascript ?
or both of them ?
@Cerbrus Will be enforced.
@gtzinos jQuery is a library in JavaScript
i know..
08:46
@gtzinos first JavaScript, then jQuery if you still really feel the need to
You can't and shouldn't try to learn it without JavaScript first.
i prefer using raw JS, but sometimes i'm addicted to $.each() :(
@JimmPratt To $.each() of all things?
i am addicted to jquery too
hehe
08:47
@MadaraUchiha Appreciated.
if JS had a native for...each() i'd kick jQuery to the curb... well ok except for the occasional animate() need
maybe
y'all toasting in a troll bread
@JimmPratt it... kinda has
@JimmPratt NodeLists have .forEach and friends natively now :)
@Shea mmmmm, smells like trolol
08:49
anybody has a lynda.com account?
lynda.com vs. teamtreehouse.com, which one is better
bootstrap or another library ?
@JimmPratt could i ask u a question? :)
@gtzinos whatever you feel like using
seeming u have been extremely helpful :)
oh you mean like... numbers.forEach(myFunction) ?
i know nothing!
08:51
lol
i just play a web developer on tv
what's the question... odds are good someone else types faster than I can
@ZhengquanBai I prefer teamtreehouse because treehouses are awesome
I'm building a client-side application with React and Flux and I need to implement some kind of routing. Should routing come under React's SOI or would munging the backbone router into there make more sense?
@JimmPratt yeah. JS offers a good variety of built-in methods now
im using the geobytes one from the article you sent me, it prints in console, great,... is there anything where i can use one of the piece of data as a variable for somewhere else?
as i want to do a URL construct based on the city data with a fallback if it doesnt return
08:52
@ZhengquanBai sorry, I don't know either, but I'd tend to try treehouse to be honest. Heard that it should be pretty good
I got a video2brain account
You'll be laughing, but why isn't this alerting the parameter jsfiddle.net/rejm3z14/1
@GNi33 yeah i know i am woefully behind in es5/es6 stuff... i got distracted by python a couple of years back... now trying to teach myself React stuff >.<
@Neil lynda.com seems to be more abundant
yep, me too
@JimmPratt you might find this as interesting as me: es6katas.org
abundant available resources
08:55
nvm, wrong quotes used in php while escaping
@ZhengquanBai maybe, but I really like trees
@KirstyHarris if the return value is an array of stuff (that's a technical term), then i would suspect you can just parse the array for the thing you want... i'd have to see what you are getting back from geobytes to be more specific.
well, lynda has tutorials for basically everything
/me clicks GN's link
gah wrong type of chatroom xD
!!s/array/json/g
08:57
i'll throw one back at you @GNi33 - youmightnotneedjquery.com
@Shea @KirstyHarris if the return value is an json of stuff (that's a technical term), then i would suspect you can just parse the json for the thing you want... i'd have to see what you are getting back from geobytes to be more specific. (source)
hi @JimmPratt is is an array by the look of it :)
Wat! Isis! I don't work for no Isis!
@Abhishrek oi!
08:59
sup?
@Abhishrek o/
\o
where do you guys, put server sent event / or other event sources
in redux?
Can't find a good example for that :-|
hello
is there a way to replace group of characters with one character in javascript?
actually it looks more like a list of values @JimmPratt
the process is like this.
09:00
!!tell macroscripts mdn String.replace
@macroscripts Something went on fire; status 403
I want to use indexOf and inside replace characters with one star ?
u got me wrong
here is what I do
I have a text on page and its on amazaon.com
Oh got it, state.dispatch
directly
09:02
so on amazon it's like this
Sold by Some copany and Fulfilled by Amazon
!!> var input = "whatever"; input.substr(0, 2) + "*" + input.substr(5);
@MadaraUchiha "wh*ver"
and this part Some copany is changable...
@JimmPratt
09:03
@KirstyHarris var arr = JSON.parse(response.responseText); console.log(arr);
argh think i wrote it wrong Shea lol
sorry got distracted by work
replace console.log(JSON.stringify(data, null, 2)); with the line I gave you
@Shea how do I pronounce your name?
@macroscripts looks like you want a template.
09:07
@Abhishrek Shea
lol
@FlorianMargaine tnx
its saying response is not defined ?
wait....
@Shea She ya?
@Abhishrek Shay
09:08
Okay (:
@KirstyHarris why are you doing JSON.stringify(data, null, 2)?
Hi
JSON Question incoming...
200 downloads on aflit and no issues so far. Man I am gonna be the BDFL
this is from an article here
Big Dog For Life ? o.O
09:09
289
Q: Get client IP using just JavaScript?

FlySwatI need to somehow pull the client's IP address using pure JavaScript; no server side code, not even SSI. Any ideas? I'm not against using a free 3rd party script, if someone can suggest one. This is an emergency stop gap until we can deploy new code.

data is probably already they object you need. just do console.log(data)
@FlorianMargaine you can be the CTO of project aflit :s
:agrees with Shea
gah
no /me type emote here eh+
@AwalGarg awesome
as long as you don't bring dpkg or any debian related thing in it
09:10
The Problem is that while i am getting the JSON Data correctly (checked via Firebug) it is not being displayed when i try to access it. It just shows undefinded.
function bdetails(){

		  $.ajax({
		  url: "getbd.php",
		  type: "post",
		  data: 'email='+localStorage.user+'&bcode='+localStorage.bcode,
		  success: function(data) {
			  var json = jQuery.parseJSON(data);
			  $("#details").text("Dear " +json.FirstName);
		  },

          error: function(data, errorThrown)
          {
              alert('request failed :'+errorThrown);
          }
	});

}
yea its passed it now as an object but obviously i want to get a value from that object so i can use as a variable
console.log(data.geobytescountry);
I quit.
but i cant declare that outside the function thou can i? sorry to sound thick, im still learning :S
as Shea points out the first field is the key variable name that holds the info you want... just access it by name (data.geowhatever)
@AwalGarg I thought I was the CTO?
09:12
hey folks
IE. If it returns country, van i state.... var X = console.log (data.geobytescountry); but because that line is in the function, i cant use the variable x outside it can i?
I'm the one taking technical-related decisions
sorry @JimmPratt / @Shea...... :(
@FlorianMargaine you are the CTO as long as you don't do that :P <3
see? I can do lawyer speech too :D
var json = jQuery.parseJSON(data);
$("#details").text("Dear " +json.FirstName);
where is my mistake?
it just shows undefined
Dear undefined
09:14
because you are using FirstName and i dont see FirstName defined?
it's in the json object
i checked via firebug. it is ther
var dataObj = jQuery.parseJSON(data);
console.log(dataObj);
$("#details").text("Dear " + dataObj.FirstName);
ok i'll try
isnt that similar to mine Shea?
json might be a reserved word, but I doubt it. still not a good idea to use.
09:16
doh..., there is no way to check the current state of a vanilla promise, is there?
ok, point taken
besides, why would you name it json? it's not json anymore, it's an object.
@jAndy not synchronously :)
good point
i will rename
@AwalGarg does bluebird support promise states?
09:17
yes. check the PromiseInspection interface
I'm wondering why there is no native approach to this, seems like an epic fail
I think Promises are just one (hacky) step towards fixing the asynchronicity problem. There is more to come, and that is not just async/await or generators.
> Okay, I know it is a scripting language so it can not be as verbose as Java...
...
nope still no success =(
09:19
> then just simply take stuff away from Java
wat
does your console should the results atleast?
@littlepootis oh you know. . stuff
yes, console displayed everything
and it was beautiful. a pity i can't use it
@Neil bad stuff..
well if dataObj is being parsed correctly, then FirstName isn't in it.
09:21
> You can actually make a difference and create a standard language that could be used everywhere
@AwalGarg True, but it's a huge fail anyways. Just for the reason that it saves so much overkill, like unnecessarily attaching handlers to a promise which already has fulfilled or rejected... you don't know if you pass the promise object around right
it is. i can see it in the console
how can you miss that when you write a spec for such things
We still have a lot to learn from FP :)
@Zombievirus no it's not
09:24
and we probably never will
and how to explain the FirstName visible in the console?
nope.jpg
nope.png
we might not learn from FP, but we can still simply copy things from FP without understanding everything, like we copied the array methods, promises, first class functions, rfp etc.
09:27
!!>JS > FP
@AwalGarg That didn't make much sense. Use the !!/help command to learn more.
@AwalGarg true
@KirstyHarris sorry again, getting busy at work... if you are getting the data back in a list (or array), that looks like the output you previously displayed (with the "geoblahblah" : "192.168.x.x" arrangement), then whatever variable name you used to retrieve that data is used in conjunction with the first field in the list... so if your callback store the result in 'arr', then your data can be accessed by: arr.geoblahblah -- which will contain "192.168.x.x" (in my poor example above.)
(correct me if i am wrong, Shea)
nope.bmp
nope.xml?
@CapricaSix \o/
09:29
!!/help
@JimmPratt Information on interacting with me can be found at this page
well that didn't help xD
!!> ['hello', 'world'].join(' ')
09:31
@JimmPratt "hello world"
well i'll be darned... the parser works
@GNi33 thanks for the es6katas.org link... neat stuff! ^^
blah headache and cold getting to me... tiem to head home for tea and sleep
later kids!
uploads himself back to the net
I have a MySQL DB and in PHP i run a Query. The Result is then saved in json using json_encode
the result looks like this
[{"FirstName":"Lucky","LastName":"Singh","Email":"[email protected]","BookingID":"504367","Arrival"
:"2016-05-25 20:00:00","Checkout":"2016-05-31 13:00:00","RoomType":"TR","maxPersons":"3","Breakfast"
:"0","Amount":"0","Nights":"6","Comment":"gh fgh ","BookTime":"2016-05-07 12:54:26"}]
now i cannot get certain values to display using jquery
I want Dear Lucky to display but it won't work
dataObj[0].FirstName
09:45
YES!!!!!
Now it is working!
Please enlighten me with the difference
@Zombievirus when you see [] , think arrays
dataObj.FirstName vs dataObj[0].FirstName
var thisIsAnArray = []; var thisIsAnObject = {};
littlepoot[0]
I bet you did dataObj.FirstName ,am I right?
09:47
var thisIsTheGame = 'lose';
oh so the result i get from php was an array not an objecT?
Correct.
@Zombievirus yep, an array of objects presumably
@Shea whatIsThis = { 1: "pootis", length: 1 }
but i did
 var res = $.parseJSON(data);
09:48
gr8
is there a library like i draw a line using canvas then convert line to unit measurement?
still just a primitive object
i thought i made an object out of the result by doing it
ok
@vzhen elaborate
09:49
and what is the 0 is dataObj[0]
@littlepootis i want draw a square then give it's side in inch
@Zombievirus Array !== Object
look at your JSON, it's wrapped with []
i understand, i was just wondering if i have to do dataobj[1] when i want to access other values
ah ok
so it will always be [0] whatever value i want to get out of the result
09:51
in PHP you just just do json_encode($results[0]);
The 0 is the first index in the array
What @Shea suggests is a better solution, actually.
Ah, is it from a curl
the problem is that your PHP array looks like this array(0=>array('key' => 'value', etc...));
Just debug your code and you'll find out what's wrong with
09:53
this is what my php looks like:
$res=json_encode($results);

echo $res;
json_encode will produce object/arrays respectively
2 mins ago, by Shea
in PHP you just just do json_encode($results[0]);
no, now everything works. i am just trying to understand why it works
90% of the questions i see here are: can you help m debug my code pls
easy to say such stuff if you have experience
@Zombievirus: $results is array with only one value in it.
user5563983
09:54
:D
if nothing I have said explains it, maybe this will?
@wp42 Welcome to the JavaScript chat! Please review the room 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.
@Shea I would say that's a good place for him to start
thank you for your help. Shea is my hero of the week
09:55
work beckons
@Zombievirus put this in your php echo '<pre>' . print_r($results, 1) . '</pre>';
maybe even that will help you understand
@Zombievirus I'm not really experienced. I am a high school kid who's also a hobbyist programmer. That's just how i fix most of my errors. Simple console.logs and var dumps.
@AwalGarg so... not a CTO
or maybe echo in your php using gettype php.net/gettype echo gettype($results); and on a newline echo gettype($results[0]);

« first day (2032 days earlier)      last day (3138 days later) »