« first day (1264 days earlier)      last day (3909 days later) » 

11:09
what is the best way to dynamically create new (complex) html fragment through jquery? I always do something like:
var element = "<div class='example'><div class='...'> ... </div></div>" and append then through append(element).
@saum22 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.
how complex is it ?
( give an example of your structure )
@KarelG
http://pokit.org/get/?cc0eea906881283adc940ea06bf6c61f.jpg
so basically when user click on some button, i need to create that part(colored with red) and append that in "append-authors" div
@VladislavStanic 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.
user2509223
just putted some fruit juice on my leggings
user2509223
11:21
at least it didnt land on my SNS9
@Srle : use functions and createElement
fe for div
var createDiv = function(elClassName, childElements) {
   var div = document.createElement('div');
   div.className = elClassName;
   // check childs
   if ((childElements != null) && (Object.prototype.toString.call(childElements) === '[object Array]')) {
     var childrensToAdd = childElements.length;
     for(var i = 0; i < childrensToAdd; ++i) {
         div.appendChild(childElements[i]);
     }
}
// feel free to expand it with id, and such
// do same for label / input
it's better maintainable and intuitive
user2509223
11:37
@KarelG enterprise code? :D
user2509223
lunch is over, wp site still not running on localhost, not even in VM
@derylius : if ppl writes a good code, it should not only provide performance, but also good maintainability and being intuitive
the above is better then .innerHtml += '<div class="bla"><div class="foo"><p>hey</p></div></div>'
that one can lead to mistakes too
user2509223
@KarelG thats for sure :)
user2509223
but in my opinion, making a frame and then filling it is a better aproach
user2509223
simply for reusability
user2509223
11:46
unless you wanna write your own framework of course in which case i completely agree with you
user2509223
but in that case i would not make divs, but would use more semantic tags based on content type
well, if you use iframe, then it's much harder to manipulate data within it
i rarely use it, unless for audio/video/animation stuff if it needs to be wrapped
user2509223
@KarelG i said frame in its common meaning, not as iframe
user2509223
lets call it structure then
ah, misunderstanding from my end
11:58
@hendrikswan 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.
user2509223
@KarelG and thats why im working on the laid stack
user2509223
its a rather sytactic full stack than semantic
@Ivancho 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.
12:14
]o=|=o[
user2509223
@AbhishekHingnikar he?
what do you see init ?
user2509223
syntax error
a questionn
        $returnValue = array(
            'DATA_FOUND' => false,
            'DATA_NOT_FOUND' => true,
            'DATA_ERROR' => false,
            'data' => null
        );
is that a good structure for reply to AJAX call
user2509223
@KarelG redundant
12:16
or should i use 'status' => 'DATA_FOUND'
user2509223
if data null its obvious that theres no data
there are 3 status
@KarelG I'd go for the latter
if error, error message
if data => data check
if no data => skip
user2509223
12:17
then use status = statuscode
@karelG .. single key goes well in this case i suppose
user2509223
or stastus = {code: '', message: ''}
user2509223
@KarelG i solved this puzzle once a while
user2509223
the best is to have status, and data if succeeded or error if failed
is it not strange to see
HTTP_STATUS = 200 // success
HTTP_STATUS = 400 // bad request (incorrect params)
HTTP_STATUS = 404 // not found
user2509223
12:21
$returnValue = array(
            'status' => 'success|error',
            'data' => data|null,
            'error' => error|null
        );
SE API uses error_id and error_message
user2509223
or just send the error message in the data field, since the client will first check the status
@derylius ew
user2509223
$returnValue = array(
    'status' => 'success'|'error',
    'data' => data|error
);
Google Search Results for Inspirational ( That are actually kickass )
       iOS app designs : Many Millions of results
       Android App Designs : Millions of Results
       Windows / Windows 8 : Barely 25 !
user2509223
12:24
if success do stuff with data if error show error
@user3240361 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.
user2509223
its exactly what HTTP use, status header and then body
btw, using status codes can be confusing, i am going to skip it
( it's already sending one to the service itself )
@KarelG it's great for robots
user2509223
@KarelG and for devs
12:33
Microsoft Employee #1: "Sir, we're getting a lot of complaints that Visual Studio has too many compilation parameters.."
Microsoft Employee #2: "Hmm.. well lets see.. users like configurations.. Lets just let them have as many configurations as they want! That won't be confusing!"
it's probably hard to search for best practices for ajax reply structure :(
@Neil Well, nothing is forcing you to use more than 1 config
@Schone 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.
@KarelG What does "ajax reply structure" even mean?
the json structure of the response to ajax call. scroll a bit above
12:36
@Loktar ping
derylis came with
returnValue = array(
    'status' => 'success'|'error',
    'data' => data|error
);
@Kippie Still don't see how that is supposed to fix the problem with being too complicated
user2509223
@KarelG thats what i use, and its working great
.
.
/clears
@ncabral 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.
12:49
I'm reading a book on some js/web service stuff, and it has me send an object to my endpoint. In the example it doesn't use $.toJSON, but i see examples online that do.... is this required and my book made a mistake, or is this done w/ jquery behind the scenes or something

$.ajax({
type: "GET",
url: "/Home/GetMessage",
data: myData, // vs data: $.toJSON(myData)
contentType: "application/json",
success: myApp.processResult
});
@Steve the value passed as "data" should be a string which represents valid json
Typically you take a javascript object and you convert it to a valid json string before sending
$.getJson(..) = function -> using $.ajax(...) with predefined params to get json data
okay, yeah the book def. didn't do that, it defines "myData" as
var myData = {
UserName: nm,
RequstedDate: dt
};
However, if myData is already a json string, you don't need to perform any conversion
just an extra (obsolete) step to make people easier
toJson works the same way
12:54
Maybe jQuery calls toJson, not sure
hm
Long story short, you can't mess up by sending $.toJSON(myData)
However maybe jQuery thinks of that for you
okay cool
heh
cannot find toJSON in the documentation
@SomeKittens <3 Daft Punk vs. Strongbad
12:58
oh
it's from a jQuery extension
skip it :pp
node http-proxy with express and socket.io
F U
haha
I can feel your pain
so how do I proxy websockets?
Nexus 5 with Nexus Headphones... Now i have a headache
while still using express :/
13:01
proxy from where to where ?
Note to self : "Never lend the apple headphones to anyone till you have something better or equal"
client 'device' holds webpage - node/express/socket.io

server serves that page via proxy
@user2139038 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.
@SystematixInfotech 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.
@n8udd 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.
user2509223
@rlemon i have two question for you about the bot
13:19
@BenjaminGruenbaum is there any api in winjs that lets me have the user logged in using his microsoft account which hes already logged into ?
yes, ther eis. Not sure which.
@BenjaminGruenbaum I have been trying to search for it for past 1 hour
would U like to guide me ?
No idea, sorry.
System.User.UserInformation is useless it only gives me the name and domain :-(
What else do you need?
13:21
the username + domain
yay websockets are proxied as well
Congrats!
but they error first, then lag for a good 15 seconds
THEN work
and dob
@rlemon socket.io ?
or low level websockets ?
yup
> WebSocket connection to 'ws://never-gonna-give-you-up:4000' failed: Connection closed before receiving a handshake response
on page load.
but then 10-15 seconds later they kick in
13:23
@EricTung 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.
user2509223
cool
@rlemon try connecting them with a 100 milliseconds delay and also try them on firefox
@ADOConnection 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.
@nat 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.
put a delay in. same thing, but after the delay
:/
@AndyOHart 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.
13:32
if im trying to get something from a database, how can I returna date object? the dates are in the format of (Oct 3, 2011) so M, D, Y
if i check the response timer, it's not steady in the begin
but if you start to check it after a time, it's smooth. Like gasoil car
@AndyOHart return a timestamp
or use a library to parse it
^ easiest answers
@rlemon you seem to have major troubles with the URL you're calling there
fails, works, fails, works ->
I don't get it
13:34
@rlemon so i return a timestamp from MYSQL? becasue im scraping a website and its giving me the date as thagt
@AndyOHart read developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… then if that seems too hard look at this momentjs.com
thank you
@BenjaminGruenbaum \o/
13:48
var script = document.createElement('script');
script.src = 'http://jackrugile.com/jrumble/js/jquery.jrumble.1.3.min.js';
script.onload = function() {
  $('.message').jrumble({ x: 2, y: 2, rotation: 1 }).trigger('startRumble');
};
document.head.appendChild(script);
@BenjaminGruenbaum run this ^^
see if it helps
in HTML / CSS / WebDesign, 1 min ago, by rlemon
var script = document.createElement('script');
script.src = 'http://jackrugile.com/jrumble/js/jquery.jrumble.1.3.min.js';
script.onload = function() {
  $('.message,.avatar').jrumble({ x: 1, y: 1, rotation: 0.5 }).trigger('startRumble');
};
document.head.appendChild(script);
better version for the drunk
hey javascript!
has anyone used mongodb's aggregation?
@rlemon : tried it on the top of my current webpage which i'm working on aaaaaaannndddd nothing happens
user1596138
@AndyOHart You don't need a library for that. Just use strtodate()
user1596138
@rlemon come on dude
@KarelG only for the chat
@Jhawins I'm sorry I don't make the assumption he is using php
in fact, vague questions get vague answers
user1596138
13:58
I thought you guys were asking a php question specifically?
25 mins ago, by AndyOHart
if im trying to get something from a database, how can I returna date object? the dates are in the format of (Oct 3, 2011) so M, D, Y
user1596138
I swear I saw someone bitching about php here
all he said.
It's made with bits of real panther, so you know it's good.
user1596138
Ok, well the answer is not use PHP. So ignore me.
13:59
if the server can return the date in a format that JS understands. +1 (it can, but can he change that)
user1596138
I literally just woke up
if it can't. then moment.js is the easy path for parsing
user1596138
Or...
user1596138
!!> Date.parse('Oct 3, 2011')
@Jhawins 1317614400000
user1596138
14:00
Divide by 1000 for seconds.
@Jhawins That's far more precise, thank you. I was beginning to wonder if by Oct 3, 2011, you meant take the octal value for 3 and interpret that number as 3.2011 since in other cultures they use "," to mean the decimal point
user1596138
Haha. No
aw, the Unicorns are gone this morning.
user2509223
@RalphWiggum i was just as sad about it
user2509223
except for me it was 7 hours ago
14:06
in other cultures, they use '.' to mean the decimal point
<.<
user1596138
@AndyOHart !!> theD = new Date(Date.parse('Oct 3, 2011')); console.log(theD.toDateString())
@Jhawins "undefined" Logged: "Mon Oct 03 2011"
user1596138
No need for libraries for parsing that
user1596138
Return it however needed?
user2509223
all my muscles are burning
Sam
Sam
14:19
return c instanceof Array;
better way for verify if is an array?
@derylius : just stood up ?
@Sam :
var isArray = function(obj)
{
    return (Object.prototype.toString.call(obj) === '[object Array]');
};
user2509223
@KarelG no, yesterday GYM
@Sam this one is good but it breaks down if you mix arrays from different frames
@derylius : did you have defeated the leader ?
user2509223
in agility maybe
14:23
@zazk 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.
@rlemon Diing
/workday done -> beaming away -> hi sunshine and GF -> ** fill in yourself **
whats up?
@Loktar the sun
so, someone asks you in an interview what the most important part of being a coder is. what do you answer?
14:28
so... they want to convert this app we worked on to Angular now
and are wondering how long it will take..
@Loktar \o/
like 10k lines of crazy ass jquery/js
guess what I need help with????
THE GAME
@jAndy
lol
14:29
:P
no, but I did get a bit further last night
oh nice
@Loktar good enough. i'll take it
added bonuses
14:29
yeah thats cool
dem green apples
now real question.
1 hour ago, by rlemon
user image
websockets are being proxied... but they error first. :/
no clue :(
I havent done websockets with http proxy
I just know it supports them
his docs .. or lack of.. suck
0
Q: Convert an Angularjs Protractor promise from a string to float?

BrendanI'm using Angular.js Protractor to get check the values of cells in a grid. I'm able to get the values, but they are strings, and I'd like to do calculations with them. When I try this: ptor.findElements(protractor.By.className('ngCellText')).then(function(cells) { expect(parseFloat(cells[1...

yea
14:31
man, I really need someone who has done this :P
I wish there was something out there a bit more robust
the more and more I use node the more and more I hate automagic
Why does this work?
Why doesn't this work?
^ I ask myself this every few minutes with node
haha
keep in mind i'm using packages like socket.io, passport, and express, which are providing all of that automagic
if you don't like it, write it yourself ?
14:36
@jAndy The Game
but that.. would require a lot of time and effort :p
require('time');
user1596138
@rlemon I'm sure you've tried to connect the same way without the proxy to verify right?
require('effort');
is this what it says it is , or it posts something to backend server so i can generate js from lua? moonshinejs.org/editor
@Phoenix Is this a trick question?
14:37
@Jhawins yea it works fine without the proxy
I've been developing it "locally" for a few weeks now
user1596138
@rlemon Watch for the upgrade headers?
is this what it says it is , or it posts something to backend server so i can generate js from lua? moonshinejs.org/editor
@Jhawins well, in express that is never hit on app.on('upgrade'
user1596138
Well that wouldn't be 404 would it... I don't have any useful information for you :P
and no docs telling me how to do this with express (that I can find)
user1596138
14:39
@rlemon You can see the headers so you can check for it manually
user1596138
That's fine. It's still an html5 websocket right?
@rlemon poke a hole in the proxy?
Parser.prototype._readNumber = function () {... }
Parser.prototype._readInteger = function () {... }
...
@Jhawins express + socket.io on the one end. express + http-proxy on the other
Looks like it is compiling lua client-side
14:40
@Neil i don't know
user1596138
It has to follow the standard. So it has to upgrade the connection the same way by sending an upgrade header and then receiving it. A buddy was complaining once because his proxy server for some reason was never dropping the headers later, but that doesn't sound like your issue.
you see the image I posted right?
fail, work, fail, fail, work work work ->
user1596138
Oh that's literally what was happening?
Looks like a full blown token parser
Could be that they secretly shuffle the code off to the server to parse, but that would be a lot of trouble for nothing
user1596138
14:41
Hahaha that's borked dude. Compare requests? No difference == proxy problem. Difference == express problem?
@Jhawins yup. connect to the page. it errors, then hangs for a few seconds, then starts chugginging along
user1596138
Maybe it's the unikarma from mining all those unicoins yesterday
the ajax request when clicking run confused me
@Phoenix Could be that it informs the server that another person has visited the site and compiled code
@Phoenix Or no, perhaps it does both..
I see a compileOnline and a compileOffline..
@RicardoRivaldo 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.
15:07
!!doge payday,dog damn it, can't hide it
 wow
              very payday
                       so dog damn it
such  can't hide it
user1596138
> wow very payday so dog damn it such can't hide it
!!doge wow
     wow
such wow
@chrisvdp 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.
@jgreenberg 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.
15:33
0
Q: File APIs Javascript FileReader onload

user3387889 I am using File APIs with Javascript. I need to wait for the completation of onload method, how can I do it? reader.onload = function (e) { contents = reader.result; var addAttchCallBack = loadRequestExecutor(); addAttchCallBack.done(function (data) { alert("ok"); })...

how can i change a readonly textarea to an editable one
JS or jquery is fine
I gotta get some HTML out of a web page I get in some server side language
problem is, any html parser chokes on the html...
i've tried $('#myTextarea').attr('readonly','');
it has like 2 doctypes
sooo... regex to get the html inside a div with a specific id?
15:35
@nedt 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.
@Bubbas try prop(): $('textarea').prop('readonly', '');
@nedt thnx. i ended up using .removeAttr('readonly');
@FlorianMargaine does it need to support nested elements?
no
the textarea is at the bottom of the totem pole :)
but... why do you ask? im curious
posted on April 02, 2014

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); try { var pageTracker = _gat._getTracker("UA-3727700-1"); pageTracker._trackPageview(); } catch(err) {} ALLEGEDLY 1+1=2. ALLEGEDLY.

15:45
@KendallFrey what do you mean?
@FlorianMargaine specifically, can the html contain </div>?
the html you want to retrieve that is
you're screwed
unless you want to use .NET
15:46
well thanks anyway
no, php
I have a .NET regex for HTML :)
@Bewusstsein 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'm having a debate here with a friend. does object considers ( in js ) as a primitive type ? es5.github.io/#x4.2 says : an object is a member of the remaining built-in type Object where es5.github.io/#x4.3.2 says : member of one of the types Undefined, Null, Boolean, Number, or String as defined in Clause 8..... so does object is a primitive type ?
@Loktar who is Cat? Your wife?
yea
15:58
got an answer. tnx
who was phone?

« first day (1264 days earlier)      last day (3909 days later) »