|
edit: ignore
|
# ¿ Jan 11, 2012 09:10 |
|
|
# ¿ Apr 29, 2024 14:47 |
|
DreadCthulhu posted:Can someone in the know kindly summarize what's going on with all of the JS MVC frameworks that have sprouted in the past couple of years? Angular, Ember, Knockout, Backbone etc.. why does the world need so many and which ones should I be following? Say you want to do MVC. You have your model classes (where your data is.) You have your view - the thing that presents your data. Your problem is that without a framework, you need to figure out yourself how to get your view to reflect the content of your model. You can do this yourself but it's boring and sucks rear end. With a framework like knockout JS, you get stuff like * Declarative Bindings - easily associate DOM elements with model data. * Automatic UI refresh - when the data in your model changes, the UI will automatically update itself to reflect the state of the model for free. So you get the ability to just annotate an HTML file with a tag indicating that the html element (like an item dropdown) is part of your model, and the framework will update the content of the dropdown accordingly, and change the values in the model when the value changes in the UI. Regarding which framework is best, I have no idea because I am a C++ developer and know very little about front end development. Just pick the one that's least annoying - I liked knockout for what it's worth, but I bet people hate it because microsoft likes it.
|
# ¿ Feb 11, 2013 23:17 |
|
ManiacClown posted:I'm trying to build a page that's going to dynamically look up systems from a database based on OEM, then power supplies compatible with those systems depending on OEM and type of system. I'm trying to do this with AJAX, but this is my first time using AJAX and I'm having trouble wrapping my head around it. Should I be using jQuery, or can I do it easily enough with vanilla AJAX? You don't have to use jQuery, but jQuery has done the work of making it so XMLHTTPRequest is called the correct way on the different platforms so you don't need to do the cross-browser support yourself. I think there may be other frameworks may do that plumbing for you as well.
|
# ¿ Jul 2, 2013 02:53 |
|
Tres Burritos posted:Ugghh, I'm having a hell of a time wrapping my head around JQuery UI. It's like all of the components that I need are there, I can see them, I'm just not sure how to properly hook them together yet. Take a look at this reference: http://jqueryui.com/sortable/#connect-lists-through-tabs
|
# ¿ Oct 13, 2013 13:30 |
|
Tres Burritos posted:Yeah, I was looking at that but my problem is that I can't parse what the hell is going on. http://jqueryui.com/tabs/ That line makes the html element with id 'tabs' start being tab-able (probably some stylesheet fuckery) 1. Use the F12 developer tools! Press F12, put a break point on any line you don't understand! 2. Use Google!
|
# ¿ Oct 15, 2013 02:58 |
|
Plorkyeran posted:I have come to dread doing anything involving Google APIs or Google libraries. They're frequently shockingly bad, and when they aren't, the documentation is. *cough google closure cough*
|
# ¿ Oct 16, 2013 04:22 |
|
pliable posted:I'm going to preface this by saying that I am a complete JS newbie...my forte are languages like Java, C, and Python.
|
# ¿ Nov 22, 2013 02:39 |
|
pliable posted:Can you call it directly? Or do you have to surround it with <script> tags? I would recommend putting it in an onload handler of your body element, just to simplify things.
|
# ¿ Nov 22, 2013 02:43 |
|
pliable posted:What's the proper syntax for that? Here's a hint http://jsfiddle.net/BC8Yx/ (That url is to an image that changes every single time you access it.)
|
# ¿ Nov 22, 2013 03:06 |
|
pliable posted:Welp I'm confused all over again: Yep, that's the fun of javascript Passing parameters doesn't work like that. In browsers that aren't IE, your parameter can be your third/fourth argument, etc. I'd recommend just declaring a variable outside the scope of the settimeout and incrementing it. The way settimeout works in javascript is totally weird. Wait until you get to the part where you realize the parameter for milliseconds is only the minimum time it'll take a timeout to execute, not a guarantee.
|
# ¿ Nov 22, 2013 06:03 |
|
bobua posted:Yeah, knew about the security issue, was just really hoping having complete control of the browser would mitigate that. Guess not. The term 'web app' is a marketing thing - web applications are not first class citizens. It's very easy for desktop applications to do stuff like drag and drop between applications, print, save files to the hard drive, have keyboard shortcuts and accelerators and menu bars and floating toolbars, and a whole host of other poo poo that people take for granted in the desktop world that doesn't translate to the web/mobile experience. The worst thing your marketing team can do is look at an existing desktop application and go "Take this and make it be a webapp." That's why all that activex/client side java poo poo got super popular back in they day - people would just write lovely activex controls and voila, "webapp." There has been some progress in providing richer web/mobile platforms, but the progress has been made primarily in understanding the target platforms better, keeping it simple, and not trying to recreate the desktop experience.
|
# ¿ Dec 15, 2013 03:14 |
|
OddObserver posted:How exactly would self change on that recursive call? Experience has shown that people like to use "var self = this;" when using closures, and sometimes they slip and do "self = this;"
|
# ¿ Jan 21, 2014 14:23 |
|
Misogynist posted:So this is dumb, but I'm working on an application with my team that seems to have randomly stopped logging runtime error messages -- I can [].butt('fart') and the task will abort but not log an error. It's like something is globally catching exceptions. window.onerror is not set. The application is loaded and run through RequireJS. Look to see if someone did: code:
You can also just intentionally throw a loggable exception, put a breakpoint on it, and step through to see where it goes.
|
# ¿ Jan 26, 2014 13:54 |
|
Dominoes posted:Looking for thoughts on 'for in' loops in javascript, and this Stack Overlow question on the topic. The accepted answer is that the order of a for...in loop is also undefined in the standard. it's implementation specific what order the loop executes.
|
# ¿ May 25, 2014 15:38 |
|
return overamt+recursion(etc) is returning a string that says "9898[object]".
|
# ¿ Aug 5, 2014 00:40 |
|
Raskolnikov2089 posted:I'm working with different types of money with different strings attached, so when I started graphing out the nested for loops and if then statements that would be required, I thought recursion might be easier to unravel. I tend to avoid recursion when I write javascript. In javascript, every time you make a recursive call, you make a new stack, and it's very easy to run into "max call stack size exceeded." Other languages avoid this using compiler optimizations, but in javascript you have to manually optimize to make fewer recursive calls.
|
# ¿ Aug 5, 2014 14:28 |
|
Peanut and the Gang posted:It's trying to convert it to a bool (null/undefined/0/"" would become false), but actually it's superfluous because if-statements already convert the condition to bools anyway. Yeah that's bad js developer smell seeing the !!.
|
# ¿ Aug 22, 2014 00:19 |
|
Wheany posted:From what I can tell, once an image has been queued for downloading, it cannot be unqueued, so changing the src attributes is useless if the intention is never to download the images, or only download a certain subset of them. You can stop an image (or anything else) download by doing something like: code:
|
# ¿ Sep 17, 2014 04:43 |
|
Xenoveritas posted:Well, or writing a local proxy running on the same domain. The great traditional solution to a problem that by all rights shouldn't exist in the first place. gently caress you, SOLR. Er, what were we talking about again? You could always just roll with --disable-web-security in Chrome or enabling access to datasource across domains in IE security settings if this is just a personal thing.
|
# ¿ Nov 4, 2014 14:20 |
|
Tomed2000 posted:I'm working on a JS app that basically sits in other peoples' websites where we're compiling/minifying a local jQuery and various plugins into one file. This has been working fine but we've been trying to reduce the footprint of our app. The idea is to load jQuery only if the website we're in doesn't already have it. So basically I ended up with something like this when jQuery doesn't exist: You should start looking into a script loader - something like require.js (although there are many others.) A lot of work has been done on automating script loading and making it so pages load faster already, you probably shouldn't roll your own.
|
# ¿ Dec 22, 2014 23:49 |
|
Wheany posted:So, I learned about Douglas Crockford's DEC64 and was thinking: Does Javascript actually require float (or double) specifically, or is it an implementation detail? The ECMAScript standard says that number type is "primitive value corresponding to a double-precision 64-bit binary format IEEE 754 value." A javascript implementation using DEC64 would violate the ECMAScript standard.
|
# ¿ Apr 18, 2015 12:14 |
|
huhu posted:Could you elaborate in a full sentence? Node runs javascript. If you have node installed and(set up on your path) and type "node file.js" it will run the file provided on the command line in a node server. Window.console output will be logged to the command line. If you're not big on node, phantomjs does the same thing.
|
# ¿ May 10, 2015 00:13 |
|
huhu posted:Thanks. It looks like you're trying to write an HTML parser in javascript. That... seems unnecessary.
|
# ¿ May 11, 2015 04:20 |
|
huhu posted:Just looked up what a parser was... don't think that's what I'm doing. Just to be explicit, read this (http://stackoverflow.com/questions/8227612/how-to-create-document-objects-with-javascript), look at the response than mentions var doc = (new DOMParser).parseFromString(markup, mime_type), and then use vince/wheany's JQuery stuff to populate the array, rather than looking at the HTML input as a string yourself. Make the browser do the work. Bruegels Fuckbooks fucked around with this message at 13:20 on May 11, 2015 |
# ¿ May 11, 2015 13:13 |
|
v1nce posted:The main difference is the regex method ignores HTML comments and picks up everything that even looks remotely like an element.
|
# ¿ May 11, 2015 13:53 |
|
Knifegrab posted:I just looked up es6 style imports and its not yet supported by firefox so I think I had better hold off on using that for now. One thing you can do with typescript is compile multiple ts files into one big js file, and just serve that as a single script.
|
# ¿ Sep 16, 2015 04:36 |
|
It's important to remembert that the problems with javascript are primarily human problems. Like, you can do anything you want in client side javascript. The problem is that since literally any rear end in a top hat can write javascript, all third party libraries and all tools are poo poo. The node.js people are eventually going to win - like, Typescript and other compile-to-js stuff is a win, and eventually, someone is going to make non-retarded versions of Node.JS and angular - hell, even Microsoft has gotten tired of loving dealing with IIS and is starting to embrace Node. But until actual non-retards start getting interested in front end development, we're going to have to deal with stuff like gulp and bower and grunt and require.js.
|
# ¿ Sep 24, 2015 03:44 |
|
my effigy burns posted:What's a good response in a technical interview for a javascript position when they tell you to do a specific kind of search and modify operation with an unsorted array and then to "convert it into a hash map." I was under the impression that since javascript arrays are objects and their indices are actually keys, a hash map is not a meaningful concept. If I asked this in a javascript interview, this is how I'd expect it to go: code:
|
# ¿ Oct 21, 2015 13:16 |
|
German Joey posted:Speaking of, and I'm kinda laughing at myself for even thinking about this, but is there any way to sandbox Javascript in the browser? Like, lets say I have some widget that has a bunch of methods attached to it, and I want to allow user-written scripts that can interact with this widget. As in, User A writes a script on the site, and User B loads the script and runs it.... WITHOUT needing to worry about his computer blowing up or known terrorists now knowing his credit card number and his mother's maiden name. Just from the top of my head, I'd want to ban DOM manipulations except via the widget's method calls, or modifying the widget itself, or the use the eval function, or access to cookies, or to load any external objects, or who knows what else. Is this possible natively? The requirement for making it so the script interacts with the widget means you should probably look into having the widget render on the server with the user script executing on the server as well (like using node / Rhino) - some of the codepad utilities will run the javascript in an iframe, but since the script needs to interact with the widget, it'll be nearly impossible to lock everything down client side.
|
# ¿ Nov 5, 2015 14:06 |
|
Suspicious Dish posted:And does anybody use client-side certs yet? OK, OK, outside of that one weird corporate site you encountered once that also required a custom ActiveX plugin. Then they decided Gmail was too open. Solution: 1. Instead of logging into gmail, you log into some external provider. 2. User needs client side certificate and activex control to log in, and can no longer go directly to gmail, but has to go through some weird website, which requires typing in the concatenation of your company id and employee id plus your password to log in. 3. You need to install a bunch of weird bullshit to get gmail on a phone to work but that's OK because you need authorization from someone director level or higher to get it on your phone. It loving sucks. I can't figure out how to have Fiddler open and check my email at the same time, or get Gmail to work with loving google chrome.
|
# ¿ Nov 8, 2015 15:41 |
|
peepsalot posted:Is it possible to do very RAM intensive computations in google chrome? I have a script that I fully expect to use multiple GB of ram, but it can only allocate up to about 1.5GB before chrome gives up with an "Aw Snap", even though I still have 8-10GB free and on 64bit system. The aw snap page is supremely unhelpful and only suggests that i close other tabs to free up RAM. Are you on windows? 32-bit processes will crash when they hit the virtual size limit on windows. You should try using 64-bit chrome.
|
# ¿ Nov 15, 2015 15:49 |
|
Kuule hain nussivan posted:Nope, still can't get it to work IE or Chrome? If .checked = true doesn't work in Chrome, then you might be running into this: http://stackoverflow.com/questions/16950751/checked-checked-not-working-in-chrome.
|
# ¿ Nov 22, 2015 18:32 |
|
Lord Windy posted:I've never been good at Web development. I don't understand it at all. I went to live in the world of low level C instead. For shits and giggles I went with a group of friends to a Hackathon and we've walked away with something that both might win and we think might be a good startup idea to pursue over the summer break. As a general rule, the "let's pull random javascript libraries that do cool things and smash them together" style of JS development is just a pain to work with. I would say: a) Minimize the library use in your project. If you don't really need the whole library, or can do it yourself, just cut it. Vanilla JS is almost always easier to deal with than library slop. b) Consider converting to a compile-to-JS language like typescript. Raw JS is more difficult to maintain than compile to JS languages. c) Minimize the amount of stuff done in the browser - web apis are easier to test and maintain, and it'll be easier to refactor when someone decides to get rid of your flavor of the month UI library.
|
# ¿ Nov 30, 2015 14:32 |
|
Skandranon posted:For...of works differently. It is an iterator of each object in a container, where for...in is iterating over the objects properties. I like to use forEach for iterating over an array. It's like for...in but actually does the correct thing - only downside is you can't break forEach, but it wouldn't be javascript without having five ways of doing the same thing that are broken in subtly different ways.
|
# ¿ Jul 11, 2016 04:48 |
|
geeves posted:yeah. Just don't. when I had to do money-like numbers, I just sent it to the server instead. Much safer and not much longer. I was thinking about replying like this but then I remembered that node.js is a thing, so it's conceivable that node.js could be used by like banking sites or some poo poo.
|
# ¿ Jan 2, 2017 06:16 |
|
Professor of Cats posted:I think what people are trying to say is it isn't that JS is bad at math, it is that doing any sort of math poo poo on the front end is dumb, unsafe and untrustworthy. In JS, there is no integer type - all numbers are IEEE 754 doubles, and it is impossible to represent .1 accurately using such a number- for instance, .1 + .2 !== .3 in javascript. This can cause issues with interest rate calculations and the display of numbers, especially over time (e.g. all the problems http://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency are valid.) If you're just using dollars, you can avoid this by storing in cents (e.g. instead of $5.24, use 524.) The two problems with this approach are a) You need to decide whether you care about fractions of a cent b) This doesn't work for all kinds of currency. Bitcoin in particular has lots of weird fractions. The separate problem is that doing the math on the front end is a bad idea because it's client side, but I was sarcastically pointing out that a) node.js exists so you can't necessarily make the assumption that JS is client side b) there are actually problems with doing this regardless of whether the JS is running client/server side for the above reason c) man, since node.js is so popular, i bet people really have this problem
|
# ¿ Jan 2, 2017 15:01 |
|
Jabor posted:for all 2.7 people in the world who care about using bitcoins, javascript is just fine because bitcoin is built on doubles anyway I googled around to try to figure out why that came to mind and I found this: https://en.bitcoin.it/wiki/Proper_Money_Handling_%28JSON-RPC%29.
|
# ¿ Jan 3, 2017 04:45 |
|
fankey posted:In my code I'm not storing any references to either the ws or socket - they appear to go out of scope when add() returns. At this point are they eligible for gc and could be yanked out from under me? If so, should I just store them in a collection manually? If they somehow aren't eligible for gc then I have the opposite quesiton - what do I need to do once I'm done with both connections to ensure the gc will clean up memory for me? Or do things just magically work and I don't need to worry about such things - which is hard for someone with years of C++ and C# development to come to terms with. The javascript GC actually garbage collecting something that you don't want it to garbage collect is polar opposite of the problem I usually have with it (it not loving garbage collecting something that ought to be garbage collected). Note that there are like, tools for figuring this poo poo out - like, if you follow along with this guide using node inspector https://www.toptal.com/nodejs/debugging-memory-leaks-node-js-applications and using the heap snapshot tool in Chrome, you should be able to test whether or not you actually have a problem.
|
# ¿ Jan 29, 2017 15:22 |
|
Thermopyle posted:Thanks for the replies. Why the gently caress is node so popular on the backend if there aren't any good full-feature frameworks for it yet? It's actually a total mystery what the core value of node.js is - like all the alleged benefits it lists on its website are either completely transparent lies (scalability/concurrency yet still has to be put behind nginix in production !) or prima facie idiotic (run javascript on both the server and the client, so you can just take your front end js wizards and make them back end devs with no training!). but I think a lot of web devs who are sick of Ruby on Rails are switching to it, and Microsoft is encouraging its use for whatever reason.
|
# ¿ Feb 10, 2017 20:37 |
|
|
# ¿ Apr 29, 2024 14:47 |
|
ROFLburger posted:Just curious, why is this? I'm just going to post this without comment: https://thefullsnack.com/don-t-serve-static-files-with-nodejs-31666462f79c#.ynw7kcwer
|
# ¿ Feb 10, 2017 23:28 |