function hide(id) {
var el = document.getElementById(id);
if (el) { el.style.visibility = 'hidden'; }
}
function vote(node) {
var v = node.id.split(/_/);
var item = v[1];
hide('up_' + item);
hide('down_' + item);
var ping = new Image();
ping.src = node.href;
return false;
}
I see a lot of comments here about how not having js on the page is a great thing and lets get back to the old days.
Lets be frank here, HN's UI is not good. At the very least it needs collapsible comments and responsiveness to mobile.
The fact that HN is a success is despite its bad UI, or maybe because of the many HN readers out there that fix all the broken stuff on the page.
While js on sites have surely overgrown, and there is a place for minimalism, I really don't want to go back to the old days where every click reloaded the page and interactivity was really only done in flash.
> At the very least it needs collapsible comments and responsiveness to mobile.
I don't even want that. On root comments, simply add a link (let's call the text "next") that jumps to the next root level comment. That would solve my only complaint about the HN UI.
HN's UI is clear, accessible, and uncluttered. If you want something different, they expose an API which everyone and their mother has written a client with, including native apps for mobile. The only JS on the site is in place to reduce the page reloads you were worried about.
The only think I'd like for mobile is better up and down arrows. That's literally the only thing. Otherwise, don't change the UI in any way. To do otherwise would make this site so much less great!
HN's design is fantastic - it is totally perfect for its function. Collapsible comments are a pig to use. HN looks and works great on mobile now (it didn't used to but they did a redesign in the last few months).
Downvoters do you care to explain why you disagree?
HN is a success despite its UI because it was written in a Lisp and because it has the cachet of Y-Combinator behind it. If this exact site were written in PHP, and posted as a Show HN in an alternate universe, no one would consider it anything but a toy, and no one would be defending the layout with the same cargo cult mentality that HN seems to inspire.
Is it just me, or it sounds... cult-ish / overly dramatic?
>> it wasn’t obvious to me that Hacker News had any JavaScript at all.
I guess he never votes.
>> I thought it would be weird and complicated, but it turned out to be quite the opposite. You’ll have to watch the video to see what I mean.
Well, it sends a HTTP request and hides an element. How on earth can it be complicated? I mean, ok, you can use The Framework Of The Week to do that and just that. Not everything that is related to HN/YC is some magical rocket science.
A few weeks ago I turned off javascript in my browser out of principle and to see if progressive enhancement was still a thing web developers cared about (hint: it's not). I was pleased that HN worked fine, and the only annoying thing was that voting caused a page reload. It's nice to see this get the attention it deserves!
Developers! You probably don't need javascript to achieve 90% of your goals. It will just slow your page load speeds.
The HTTP request for voting should be a POST request, not a GET request, since it changes state. So both the JS hack involving an image and the non-JS fallback are broken. The JS function should use XHR, and I guess the non-JS fallback should be a form with an image button, not a link.
The funny thing is, it's actually those things (along with Typescript, Flux, etc) that allows us to write readable and maintainable JS that doesn't devolve into spaghetti after a year.
The funny thing is that it's always been possible to write a bit of plain javascript but you don't seem to get much respect for that compared with the buzzword stuff.
Using this approach, a badly written prefetch add-on might automatically vote on everything. Any request that modifies server-side state really should use POST or PUT (or, at the very least, append a CSRF token in JavaScript).
I eventually find this bug on just about every project. One time a user complained that all comments would disappear from her posts. Found that an add-on was prefetching all "delete" links, visible only to her.
Yes, this is an old problem. It came up with early versions of Rails scaffolding, which only used GET at the time. There's no excuse for deleting with GET.
If we ever make it around to a second piece of javascript on here, can I request that it be a collapse comment function? I promise i won't ask for anything else.
It also highlights new comments and collapses threads without new comments on repeat visits. HN now feels unusable without it in scenarios where I can't use a userscript :-/
If you want the state of your collapsed comments to be remembered between session you're adding a lot of data to the backend of HN. I can see not implementing it, because threads are short lived and rarely get more comments that can be reasonably browser or searched.
I don't see that collapsing comments would really add much value, especially if the state is to kept per user per comment in the backend.
If you don't care about state, I feel reasonably sure that you could Greasemonkey your way out of not having that feature.
Alternatively, I'd appreciate if comments had a link to their siblings and not just their parents. It wouldn't require any JavaScript, but would (for me) have the same utility.
I wrote this a while ago, which seems to work. I reused the vote arrow with 1/4-turn rotation, placed on the other side of the comment header line to avoid confusion.
Seeing the "auth" query. There is a chance that HN was "too clever" about it, and it might be possible to use other users id to upvote, or upvote many times, if you can figure out the hash algorithm.
What I find interesting is that even this little piece could be done in plain HTML using an iframe for each vote button. The obvious disadvantage is http requests for each vote button, but even a middle ground could be chosen where the vote buttons submit to a hidden iframe and just don't disappear without Javascript. Perhaps even, but I'm not certain, they could be made to disappear using css' a:visited, loosing zero functionality and having no disadvantages.
> Want to take your AngularJS skills to the next level? If so, check out our flagship product, Angular Course. Through 115 HD videos, you'll learn Angular and the latest best practices as you build a fictional startup.
I don't think this is ironic at all. When I mentioned "framework of the week hype" in my initial comment (https://news.ycombinator.com/item?id=11308043), I was thinking specifically about how people are handling the transition from Angular 1 to 2. I am in no way advocating using plain JavaScript to build your app. I even mentioned in the video that I rarely work with plain JavaScript.
There's a lot of distraction around Angular 2 for both existing and new developers, when it's pretty clear to me that Angular 1.9.x will pretty much look like Angular 2. If you read the release notes, this is very clear. They said the the primary theme for the 1.5 release was improving the upgrade path to Angular 2.
What this means is that keeping up with the Angular 1 release cycle will gradually transition you to Angular 2. But everyone in the community seems to think this is boring and wants to blow up their apps and go to Angular 2 right away.
This is the kind of thinking that I wish we'd see less of. Rushing to 2 when it's still in beta makes no sense from a business perspective. It only makes sense from a "I like to tinker with the new thing and try new stuff because it's fun" perspective. Some people will say it's a performance issue (since Angular 2 is better in that respect), but for the vast majority of apps that want to upgrade to 2 now, the improvements won't be noticeable.
[+] [-] cypherpunks01|10 years ago|reply
[+] [-] Illniyar|10 years ago|reply
Lets be frank here, HN's UI is not good. At the very least it needs collapsible comments and responsiveness to mobile.
The fact that HN is a success is despite its bad UI, or maybe because of the many HN readers out there that fix all the broken stuff on the page.
While js on sites have surely overgrown, and there is a place for minimalism, I really don't want to go back to the old days where every click reloaded the page and interactivity was really only done in flash.
[+] [-] JeremyNT|10 years ago|reply
> At the very least it needs collapsible comments and responsiveness to mobile.
I don't even want that. On root comments, simply add a link (let's call the text "next") that jumps to the next root level comment. That would solve my only complaint about the HN UI.
[+] [-] jmiserez|10 years ago|reply
Please no. I like being able to zoom in or out, and too often "responsive" means no zoom and either huge or miniscule text.
[+] [-] ant6n|10 years ago|reply
[+] [-] fabulist|10 years ago|reply
What is the problem here?
[+] [-] chris_wot|10 years ago|reply
[+] [-] JupiterMoon|10 years ago|reply
Downvoters do you care to explain why you disagree?
[+] [-] pmlnr|10 years ago|reply
[+] [-] krapp|10 years ago|reply
[+] [-] gedrap|10 years ago|reply
>> it wasn’t obvious to me that Hacker News had any JavaScript at all.
I guess he never votes.
>> I thought it would be weird and complicated, but it turned out to be quite the opposite. You’ll have to watch the video to see what I mean.
Well, it sends a HTTP request and hides an element. How on earth can it be complicated? I mean, ok, you can use The Framework Of The Week to do that and just that. Not everything that is related to HN/YC is some magical rocket science.
[+] [-] smadge|10 years ago|reply
Developers! You probably don't need javascript to achieve 90% of your goals. It will just slow your page load speeds.
[+] [-] mwcampbell|10 years ago|reply
[+] [-] iamleppert|10 years ago|reply
God I hate what has happened to the web these days.
[+] [-] nathancahill|10 years ago|reply
[+] [-] tim333|10 years ago|reply
[+] [-] awqrre|10 years ago|reply
[+] [-] mdavidn|10 years ago|reply
I eventually find this bug on just about every project. One time a user complained that all comments would disappear from her posts. Found that an add-on was prefetching all "delete" links, visible only to her.
[+] [-] Semiapies|10 years ago|reply
[+] [-] seanalltogether|10 years ago|reply
[+] [-] dikaiosune|10 years ago|reply
I don't know about other browsers, but this works OK on Chrome.
[+] [-] Hansi|10 years ago|reply
[+] [-] insin|10 years ago|reply
It also highlights new comments and collapses threads without new comments on repeat visits. HN now feels unusable without it in scenarios where I can't use a userscript :-/
[+] [-] heyheyhey|10 years ago|reply
[+] [-] jrcii|10 years ago|reply
[+] [-] lurker2015|10 years ago|reply
[+] [-] mrweasel|10 years ago|reply
I don't see that collapsing comments would really add much value, especially if the state is to kept per user per comment in the backend.
If you don't care about state, I feel reasonably sure that you could Greasemonkey your way out of not having that feature.
[+] [-] fabulist|10 years ago|reply
[+] [-] pdkl95|10 years ago|reply
I wrote this a while ago, which seems to work. I reused the vote arrow with 1/4-turn rotation, placed on the other side of the comment header line to avoid confusion.
[+] [-] unknown|10 years ago|reply
[deleted]
[+] [-] TazeTSchnitzel|10 years ago|reply
[+] [-] mring33621|10 years ago|reply
[+] [-] BowBun|10 years ago|reply
What I'm curious is if someone can reiimplement this without and javascript.
[+] [-] mchahn|10 years ago|reply
[+] [-] z3t4|10 years ago|reply
[+] [-] z3t4|10 years ago|reply
[+] [-] amelius|10 years ago|reply
[+] [-] pmlnr|10 years ago|reply
A lot of those are either without javascript or with minimal, vanilla js.
[+] [-] teddyh|10 years ago|reply
https://www.gnu.org/philosophy/javascript-trap.html#Appendix...
[+] [-] sillysaurus3|10 years ago|reply
[+] [-] krapp|10 years ago|reply
[+] [-] lucb1e|10 years ago|reply
[+] [-] zbruhnke|10 years ago|reply
[+] [-] andrelaszlo|10 years ago|reply
[+] [-] cpg|10 years ago|reply
> Want to take your AngularJS skills to the next level? If so, check out our flagship product, Angular Course. Through 115 HD videos, you'll learn Angular and the latest best practices as you build a fictional startup.
[+] [-] gordonzhu|10 years ago|reply
I don't think this is ironic at all. When I mentioned "framework of the week hype" in my initial comment (https://news.ycombinator.com/item?id=11308043), I was thinking specifically about how people are handling the transition from Angular 1 to 2. I am in no way advocating using plain JavaScript to build your app. I even mentioned in the video that I rarely work with plain JavaScript.
There's a lot of distraction around Angular 2 for both existing and new developers, when it's pretty clear to me that Angular 1.9.x will pretty much look like Angular 2. If you read the release notes, this is very clear. They said the the primary theme for the 1.5 release was improving the upgrade path to Angular 2.
http://angularjs.blogspot.com/2016/02/angular-150-ennoblemen...
What this means is that keeping up with the Angular 1 release cycle will gradually transition you to Angular 2. But everyone in the community seems to think this is boring and wants to blow up their apps and go to Angular 2 right away.
This is the kind of thinking that I wish we'd see less of. Rushing to 2 when it's still in beta makes no sense from a business perspective. It only makes sense from a "I like to tinker with the new thing and try new stuff because it's fun" perspective. Some people will say it's a performance issue (since Angular 2 is better in that respect), but for the vast majority of apps that want to upgrade to 2 now, the improvements won't be noticeable.
[+] [-] pmlnr|10 years ago|reply
Everyone should learn the basics before frameworks.
( Also: http://vanilla-js.com/ )
[+] [-] wrigby|10 years ago|reply
[+] [-] gordonzhu|10 years ago|reply
[+] [-] rawTruthHurts|10 years ago|reply