« first day (1717 days earlier)      last day (3234 days later) » 

@Abhishrek Where am I putting data: at? right now when I update company.logo with the base64 string it's trying to tack on my localhost:xxxx to it
 
ah, then you will need a ternary
ng-src="{{company.Logo ? 'data:' + company.Logo : 'http://someDefaultImage.png'}}"
 
ES6 cleans up a language we use. that's exciting. It doesn't have to invent some new paradigm to be interesting and useful.
 
@SomeKittens no
i wonder what his data-url is
its been a while since i have seen one without data: in front
 
@Abhishrek a data url without data: in front? When have you ever seen one of those?
 
6:07 PM
@ssube Phonegap
that too in a case
where the friken developer had a reference to a file
and its path
but chose to convert it to a dataurl in memory
 
Does anyone know how to deploy a Node.js app as .EXE?
 
@EckV 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.
 
that too without the mime or anything -_-
@EckV lol
 
@Abhishrek too funny?
 
@EckV just include a shell script to launch node
 
6:08 PM
well you can use node-webkit or nw
 
imgur.com/gallery/XqZV7Nt son of a bitch these people are clever
 
but thats for a webkit :P browser
better is to just do what ssube said
 
@EckV back up some. Why does it need to be .exe?
 
cmd for windows, sh for nix, bundle the script and the node redist
 
Isn't node-webkit a GUI?
 
6:09 PM
@EckV yes, ignore @Abhishrek
 
@ssube i assumed gui cause he said .exe
 
I want to use this EXE for myself
 
oh that
you can just make a shortcut on your desktop
 
write a one line shell script that launches node with the appropriate script
 
to node and change it to run the actual script on runtime.
 
6:09 PM
I'd be very surprised if you can't just grab one off the web already
 
@ssube why not change the properties of shortcut.
 
that'll work, but if it's a shell script you can keep the startup arguments (if any) in you project's code or in soure control
 
I want to use this EXE when I don't have Node.js installed on the PC I'm using
 
no can do. you need node
 
I know I need Node
 
6:11 PM
but you can bundle a node.exe with your app prtty easily, i think
 
I just want to know how to bundle Node with my script into one exe
 
it's pretty easy
you can't bundle it into one single exe
that's not gonna happen (in real life)
 
Why?
 
too complicated
 
Hmm
 
6:11 PM
it's theoretically possible, but only with some clever changes to existing files
 
you include node.exe and them a small script that jsut calls it:
// some cmd file
node.exe my.js
 
just make a ZIP that contains launch.cmd, your-script.js, node.exe
 
DUDES WHY THE HECK ARE U NOT DOING THIS ?
 
@SomeKittens GET unsafe:data:data:image/jpeg;base64,/9j/4AA... do I need to use the $sce stuff here?
 
6:12 PM
@Abhishrek shh
 
launch.cmd should just call node.exe your-script.js
 
its windows !
 
Using your code snippet you posted
 
@Abhishrek stop confusing them
 
6:12 PM
shortcuts are a pain in the ass compared to a shell script
 
@ssube its the fool proof way to doing it in windows o_O
 
@Abhishrek no, it's not
it will cause a bunch of problems later
a batch file is much simpler and safer
 
okay if you say so
 
We do.
 
@Austin ah, yeah.
 
6:13 PM
well here is what your launch.cmd will look like
 
How can I execute that ZIP?
 
cd /path/to/your/directory
node start.js
 
@Abhishrek not exactly. You have to make sure the paths are right.
@EckV You can't. Your user downloads it, extracts it, then runs the batch file.
 
imgur.com/gallery/VM8Y3MM last one because im impressed
 
@ssube node adds path to "PATH" in windows out of the box.
 
6:14 PM
@Abhishrek if you've installed it, sure, which is exactly not what we're doing here
reading comprehension is a wonderful thing
 
@ssube That's very bothersome....
 
didn't he said he wants it for himself.
 
Well I actually want it for everyone
 
@EckV bundling multiple binaries is technically possible, but really academic and does weird stuff (like setting off virus scanners, usually)
it's used by viruses all the time, which ruined it for everyone
 
I have a Node.js module published on NPM
 
6:15 PM
eh @EckV erm node.js not installed on your pc
 
@Abhishrek that's the entire point
 
@EckV you do realize NPM requires node installed.
 
It is installed, where did you get the idea?
 
there was a tool i used a long while back, lemme find it, it'd create a package
extract and start it somewhere
 
@Abhishrek take time to read, man, you are just spewing randomness
 
6:16 PM
btw iirc nw.js can do the same if you dont create a window :D
 
@Abhishrek those are called "installers"
 
@copy I love that guy
 
@SomeKittens would it be setup like this? ng-src="{{company.Logo ? 'data:' + $sce.trustAsResourceUrl(company.Logo) : 'http://example.png'}}"
 
@ssube oh no not installer, it was just a zip, extracted it in /temp/ and opened it.
 
@Abhishrek a self-extracting archive? like, maybe, an installer?
 
6:17 PM
a smarter one that read if /temp/ already has /temp/foo
 
WinZIP has self-extracting executables
 
@Austin You could, but you're getting to the point where you're doing a bit much in the view.
 
@EckV forget that. ps you cant have npm without node.
 
@SomeKittens I tried that and it still errors on me :/
 
@EckV You can set up a self-extracting archive or a real installer, if you want. Otherwise, a ZIP file (since Windows has builtin extraction). Include your script, node, and a batch file to run it.
To any windows user, the batch file will look like an executable and work the same.
But it saves you any complicated executable bundling step, you won't get flagged as a virus, etc. It's a pretty common way to launch apps that use some runtime like Java or Node.
 
6:18 PM
> Well I actually want it for everyone
 
@EckV check out this question, sounds similar to your use case
 
Anyway guys, it's okay, my module can be installed with NPM so I guess I will stick to NPM...
 
I think that's best, but you still always have the option of distrubuting your code + nod_modules + node.exe and one small .cmd file
 
Pst, @KendallFrey. Entry so smooth yo mama digged it
 
6:22 PM
@EckV Those essentially create a self-partially extracting executable that has the other programs in the .data segment, which is what antivirus hates.
 
The sheer grace
 
Good morning. Has anyone used the Snap.svg library before?
 
I have a problem
 
@SterlingArcher he just keeps running
 
What is the proper way of creating elements from "templates" using jQuery? I find myself in two ways of solving the problem. 1) Loading template from outside file using AJAX; 2) Build a nasty string.
    Note.template = [
        '<div>',
        '   <div class="tools">',
        '       <span class="delete"></span>',
        '   </div>',
        '   <div class="content-wrapper">',
        '       <textarea spellcheck="false" class="content"></textarea>',
        '   </div>',
        '</div>'
    ].join('');
    var el = $(Note.template);
    el.addClass('red');
    // other shit
Any suggestions?
 
6:23 PM
@afonsomatos webpack + handlebars
 
agree. or webpack + react
 
I just need to create elements from 1 template using this. I find it would be overkill to use a library for this.
 
webpack and any templating library
 
If intellij crashes on me one more time imma lose my shit
 
do you have any bundling tools in use? require.js, webpack, browserify, wtc?
you can require('sometemplate') in all of them in one form or another
 
6:26 PM
It's in the browser.
I want to make it light.
 
Yup.
 
@afonsomatos that's not an answer
How are you bundling your code?
 
all of those tools will let you require('my-postit-template') and keep it in a separate file, so no ugly strings.
 
I'm scared to click
 
6:26 PM
@ssube Basically, the user has an "Add button" and each time he clicks, a new element is created and pops out.
 
oh god dammit i was expecting a funny
 
@SterlingArcher I took the most sfw result I found
 
@afonsomatos And that code is bundled how?
 
The problem is finding something lightweight to create that element, having in mind a pre-written template.
@ssube I don't understand, what do you mean bundled ?
It's a common website with a common script?
 
those bundling tools take a pile of separate .js files and make one (or a few) .js files for the browser
it lets you keep code orgnized while still doing things in a browser-friendly way.
 
6:29 PM
Oh right, I am just using gulp, to minify stuff.
Nothing more.
 
well then, you won't be able to do anything
you could use webpack or browserify, then bundle your templates in with your scripts
 
except, maybe, include it inline:
<script id="postit-template" type="text/html> ... my template ... </script>
then use jquery (or plain DOM) to get the template innerHtml
 
Maybe I could do that, although it seems nasty.
 
It is kind of nasty, although relatively safe. Using a bundler and real templates will work better.
 
lots of other template libaries use that method
 
6:31 PM
It's not even that hard to set up, especially if you already have gulp.
 
I have never used bundling tools.
I need to check them out asap.
 
webpack is the awesomest of them all.
 
browserify might be simpler to start with, though..
 
it combines most of the tools you'll need and hopefully is a decent example of how they're supposed to work
 
6:34 PM
So If I get this straight, these bundling tools compile all your production code into a single file ready to distribute to the browser?
Or, that is the main goal.
 
roughly
 
Wouldn't that only be used for large-scale projects?
 
More or less, yes. You want to keep the number of requests and the total payload down so having a build-step is a good idea
 
@afonsomatos no
 
@afonsomatos I think it should be used for every project where you have users. There are places in the world where data traffic costs a lot, and you don't want to burden those people with downloading more bytes than they strictly need to
 
6:37 PM
The work you'll put into convincing requirejs to load a template in its own file will be ~5000000x what you'd use setting up webpack
and requirejs will break, guaranteed
 
besides, a smaller payload will make the site faster
 
it never works right
 
@afonsomatos You can use regex and load the template string from the dom. I made a quick example here
 
@BenjaminGruenbaum Yes, I don't think it was too called for.
 
6:43 PM
@Zirak Ok, thanks, not going to back off now but will keep it in mind for the future.
 
@Enijar oh, man, that's, uh, a little interesting. Regex is probably not the right choice for that.
 
@ssube What would you use for replacing variables in template strings, if you're not allowed to use a library? Just curious...
 
@SterlingArcher ohhhhhhh
 
@Enijar I would use a library
 
"if you're not allowed to use a library" :P
 
6:50 PM
I would probably find a new job
although I have written a variable parser, that didn't use regex, so that would be a fallback
 
@Enijar Not do that and implement something which doesn't rely on templating
 
@Enijar What is this, CS101? Use a library, that's what they're there for.
 
@ssube I wouldn't use this, just an answer to @afonsomatos' question. What would you use to parse a template string though?
 
I think he answered. A library. :)
 
@SomeKittens :)
 
6:53 PM
@Enijar a real parser
not a regex
 
@ssu
@ssube Like what?
 
You can't throw rock without hitting a decent template library/engine.
 
@ssube @Luggage "if you're not allowed to use a library" :P
 
I am allowed.
 
It says in the rules that you can't :P
 
6:54 PM
@KendallFrey it's tastefully sexist? lol
is that even a thing?
 
@Enijar get a new job because the one you have is run by morons
 
Let me put it another way... How do you replace variables inside a template string without using regex or a library?
 
@Enijar What rules?
If this is for a class/contest, say so
 
This wasn't my question. I have a fantastic team :)
@SomeKittens My rules!
 
@Enijar Although RegExp would be alright for little examples, consider more complex cases, where there are }{ that are not specifying any variable, or nested }{, or even not balanced }{.
 
6:56 PM
@Enijar Welp, I give up. Got a nail? Use a hammer. If you're too stubborn to learn about hammers I can't help you.
 
RegExp has its limits.
 
@SomeKittens I think I'd prefer to use a jackhammer :P
 
@Enijar for purely academic purposes, you pick a pair of delimiters (Start and end), search for the first end, look backwards to the first start, replace and repeat
 
@Enijar You'd prefer to use a jackhammer on a nail?
 
Just to be clear I'd use angular or handlebars (as @Luggage) pointed out, put as @afonsomatos' question stated "without a library"
@SomeKittens Yeah, why not?
Sarcasm intended
 
6:59 PM
And our suggestion to him, too, is to use a library. You can whip something up with either regex or replacing. No os is arguiung that.
 
var sndwch = Object.defineProperties(new String("Sandwich"), {
    banana: {
        get: function(){
            return Object.defineProperties(new Boolean(true), {
                toString: {
                    value: function(){ return "banana"; }
                }
            });
        }
    },
    peanutButter: {
        get: function(){
            return Object.defineProperties(new Boolean(true), {
                toString: {
                    value: function(){ return "peanut butter"; }
 
but to do it right will take a lot of work, so.. it's a task for a library. and there are soo many nice ones, too.
 
@Luggage it's actually not that bad. I use it as an interview question.
 
@ssube Like this? /\{(.+)(?=\})\}/gmi
 
@Enijar no. You should almost never have to use regex.
 
7:01 PM
@ssube Sorry for being stupid, but how do you do that without regex?
 
@Enijar gimme a sec
 
@ssube Okay :)
 
Any clue how I can unmatch the third invalid link from the bottom in the text section? regexr.com/3b9ta
 
@ssube Is this better?
 
7:09 PM
@NickDugger which one? Why is it invalid?
 
something.com./ is valid?
 
Without using RegExp
 
I can't see your test cases
 
"http://www.foo.bar./"
Nah, I just grabbed a random list of links from a site, and I wanna match most of their rules
This is the alst one that I'm trying to fit
Some of their "should not match" rules are just stupid
but this one seems like a good idea
 
Can I ask Node.js questions here
 
7:10 PM
let me look in debuggex
 
@BenBeri Yup.
 
@Enijar you want something like this that doesn't loop infinitely
 
@NickDugger I guess tweaking the lookahead should do
along the lines of (?=\.\w)
 
@Enijar that's the right principle
 
How can I use modules's functions, such as feed parser module, how can I use that code inside .jade file? Like in a php file you can do <?php ?> and have the code inbetween? I need to loop through some data and print elements
 
7:13 PM
@BenBeri call your functions and prep your data, then pass it to the template all at once
don't mix logic and templates
 
So basically build the html outside the template and then pass it to the template?
 
@ssube Yeah I see now. Thanks for sharing. I've honestly never used my own rollout of a variable parser before in JavaScript, just thought I'd try a stab at it for @afonsomatos' question.
 
@BenBeri parse data outside the template. Turning it into HTML can be done in templates.
 
@JanDvorak Oh yeah I can do for each in jade and then turn it to html
 
Hello
 
7:16 PM
@arnauddel. 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.
 
what is the sublime text package that color/hilit javascript depending on the method depth ?
 
@BenBeri yeah, just feed it an array of prepared data
 
@BenBeri be sure to show us your code for review when you have something to show
 
Sure ill show it when It's done
 
you should never need more than if and each in your templates
if you do, then the data hasn't been prepped well enough
 
7:18 PM
how about a switch?
 
switch outside of the template
or use the value in the template (like if its a css class)
tbh, I rarely use switch in normal code
 
Hi guys, I am in need of help for a project I'm working on. Is this the right place to ask?
 
@Tahmid 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.
 
@uselesschien I have a new tee for ya bewakoof.com/men-full-sleeve-round-neck-t-shirt/…
 
I am working on a unit converter (much like Google's one). My unit converter consists of two input boxes and two select boxes (to select the unit of conversion). I am very new to Javascript and I need some help on how this would be created. Can anyone point me in the right direction?
 
7:24 PM
Hi, how can I read data from a window with https location from another with http location?
 
@Jovito that's a different origin. So, no.
 
So how can I get facebook user data from a popup into the main window?
 
@Jovito do they expose a CORS-enabled API?
@Tahmid I'd suggest starting with a tutorial. Look at what's available on MDN, or if you want real basics of programming, Eloquent Javascript is decent.
 
@JanDvorak I don't know.
 
Okay thank you.
 
7:33 PM
@JanDvorak I'm opening a popup with the login url, that redirects to facebook login page. If, the user is already logged in, the server bypasses the facebook login page and renders the static html page with the user data set through a template.
But if the user is not logged in, I get a Uncaught SecurityError: Blocked a frame with origin.
Because, as you said, its a different origin.
 
focusOutListener: function () {
	validationOptions.textInputs.addEventListener('focusout', function () {
           //how do I select the specific element, the this keyworkd here?
        });
}
 
Can I get the window to return the data and close itself when that's defined or would that still cause a Security Error?
 
@StevensHaen Are you sure you want to create NEW event listeners each time focusout occurs?
 
Add the event just once
I have to use Vanilla though to validate fields.
 
if focusOutListener is an event handler, then it look sliek you attach new events each time
 
7:41 PM
no, just once, onload
 
ok, then. events atke and argument that has a 'target' property.
that is the element that the event is on
or Event.currentTarget, if bubbling.
 
I'm shaky on the subject
 
good thing it's well documented, then.
 
savePhotos: function(photos) {
    return Promise.all(photos.map(function(photo) {
       return new Promise(function (resolve, reject) {
            $.ajax('/api/photos', {
                contentType: 'application/json',
                type: 'POST',
                data: JSON.stringify({})
        }));
    }
}
dem promises
 
7:50 PM
too much indentation
 
fixed
I probably fucked it up
whatever
 
@JABFreeware pastebin.com/qG2bwuP1 It doesnt work, I used response.render('index', {data: data}); A bit new to Jade
 
Yup. My desktop has died. Ugh
 
seems legit now
JSON.stringify({}) ???
 
@JanDvorak any other ideas?
 
7:55 PM
@JanDvorak The editing textarea on chat is too small
so i fucked up editing the code
 
*messed up
 
wat
Are you offended by adult words now?
 
I don't like them
 
@NickDugger He always was
 
7:56 PM
That's why I didn't mention there's a vagina in his code
 
passing empty objects to functions is sometimes useful.
 
@monners I should have known!
 

« first day (1717 days earlier)      last day (3234 days later) »