6 ms·
National (JavaScript) Security Agency
- maze-le 10y ago> assets/js/main.js I smell rails
- robin_reala 10y agoDefault Rails would be assets/javascripts/application.js
- _asummers 10y agoJavascriptS? Plural? Interesting.
- clentaminator 10y agoDon't forget CSSes.
- paulojreis 10y agoI also got intrigued when a fellow colleague used that nomenclature (folder called "javascripts", as well as "stylesheets", inside an "assets" folder).
- tcfunk 10y agoIs smelling rails a bad thing? (Genuine question)
- maze-le 10y agoNope, I don't think so. I am a rails developer myself. It might have sounded a bit condescending...
- DCRichards 10y agoThis isn't as secret as you might think... http://imgur.com/VYZbZKF http://imgur.com/VYZbZKF
- mpeg 10y ago// start comment block That's some properly documented code ! // end comment block
- cookiemonsta 10y agoWhat would be the reason for this: // analytics disable if url contains underscore try { if(window.location.href.indexOf('_') > 0) {window['ga-disable-UA-20753548-1'] = true;} } catch(e) {} });
- robotnoises 10y agoMy guess is that there is a test scenario in which they don't want google analytics to load?
- mpeg 10y agoIt seems like they store files (presumably both internal and public) under https://www.nsa.gov/ia/_files/ https://www.nsa.gov/ia/_files/ so I guess it's the way they represent their non-indexable urls.
- gizmo 10y agoThe if condition is wrong. This is why functions like indexOf should return a tuple of a boolean and an offset instead of encoding "not found" by returning -1.
- ChristianBundy 10y agoThe if condition should use >= rather than >, but it otherwise makes sense.
- dahart 10y agoI'm not arguing in favor of writing it that way, but I might argue it's not incorrect as written. location.href can never start with an underscore. A regex on location.pathname would sure be a lot clearer to read, though.
- crisisactor 10y agoStop advertising the NSA please
- BasDirks 10y agoThis surely isn't advertisement. The code is terrible. Try-catch jungle, ad-hoc URL manipulation, lack of caching, writing/constructing HTML in strange places, weak comparison operators in dangerous places (string vs lunch), etc.
- crisisactor 10y agoYeah but when visiting in Lynx, it displays fine. Lynx is the yardstick I use to judge a website. There are countless .GOV sites like this made on old Windows 2000 machines with Frontpage installed, but my point is the information is still communicated. It probably doesn't matter about some spagetti JS lumped in. I assume any sensible person will have JS turned off when visiting a URL like that anyway...
- BasDirks 10y agoI see. I think it's important to make websites work well for as many clients as possible, including lynx. Ideally, JavaScript should only be used for enhancement of necessary interactivity. But when a choice is made in favor of some technology, I like to see it used properly. In this case maintainability, performance and robustness could benefit from improving this code.
- kiya0 10y ago:) man have you even met today's web developers? Turning off js is like asking them to work in assembly. Now that Google has gone and built everything the OS does, into the browser the mordern day web dev is programmed to think that they exist to rebuild desktop apps in the browser. Communicating information simply in plain text is the last thing on their minds.
- BinaryIdiot 10y ago
- zuck9 10y agoLooks like it was written by a VB programmer, who's missing "on error resume next" in JS.
- rbirkby 10y agoShould have used RxJS https://xgrommx.github.io/rx-book/content/getting_started_with_rxjs/creating_and_querying_observable_sequences/error_handling.html#ignoring-errors-with-onerrorresumenext https://xgrommx.github.io/rx-book/content/getting_started_wi...
- PaulRobinson 10y agoI feel sorry for the people who wrote this. Which one of us would want a code review by people who did not understand the requirements given by "the client" done on the front page of HN?
- zobby 10y agoI found all those rants amusing considering how many times nodeJs news reached top places on hackerNews.
- lewisjoe 10y agoAnd then I visited their homepage and found the UI to be uglier than the code.
- skrowl 10y agoWhile this code is pretty bad, I'm going to guess that the NSA reserves their best IT folks for... you know... the assignments other than their public facing website.
- pba 10y agoAgreed, this code was probably written by a contractor rather than one of their mathematicians I'd imagine
- delinka 10y agoHave you seen mathematicians write code? For a website? We hired a few (we're in the crypto business) and we don't let them near production code. Ever.
- sremani 10y agoGeneral observation, mathematicians excel at functional v. imperative, partially because so many functional concepts are grounded in mathematics/logic.
- vertex-four 10y agoHonestly, it's... not terrible? It's hackish, sure, but the NSA website's frontend isn't a huge app where good software engineering needs to be practiced - the code does what it needs to do, was likely written quite quickly, and doesn't need the likes of webpack to build. In my core projects I'll use Ember or React+Redux, but where I just need a couple hundred lines of one-off code for e.g. a marketing site... why not some hackish jQuery?
- Grue3 10y agoA lot of popular websites have pretty crappily written JS code. The reason it's not noticed is that usually it's served compressed. The reason why it's crappy is that the bulk of functionality is implemented server-side, and the person who ends up writing that code is primarily a server-side programmer who half-asses a JS snippet to finish the feature, and then since it works, it is never refactored. It's not "real programming" anyway ;)
- FLUX-YOU 10y agoI would like to see a website with very good javascript code. I feel like it's basically impossible to write JS and have 10 or more people with 3-5+ years go "Yeah, I can't improve this at all and it's extremely clean".
- Pr0ducer 10y agoAbout a year a ago, started from scratch writing a front-end client SPA for web-based software -- it's a custom framework built around Backbone.js and jQuery, written in CoffeeScript. The .coffee files are beautiful, and on save a shell script automatically compiles all the .coffee files down to a single JavaScript file that I would describe as good JavaScript code. Not open source, so no demo, but it's definitely possible to create good JS.
- elcapitan 10y agoThey should add a comment ad in there at the bottom saying /* Smarter than that stuff? Come work for us. */
- borplk 10y ago/* Smart enough to not want to work for you sick bastards */