Skip to content

Commit 6b88771

Browse files
committed
Closes #28 - Restored commenting functionality
1 parent 9c64250 commit 6b88771

File tree

3 files changed

+17
-29
lines changed

3 files changed

+17
-29
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,19 @@ https://chrome.google.com/webstore/detail/lgoghlndihpmbbgmbpjohilcphbfhddd
2323
* Social sharing for Twitter, Facebook, Google+, Buffer
2424

2525

26+
## Development
27+
28+
This code is old, it's not good, there are jQuery selectors all over the place and
29+
It's probably best rebuilt from scratch. You've been warned :)
30+
31+
2632
## License
2733

2834
HackerNew is released under the MIT license. It is simple and easy to understand and places almost no restrictions on what you can do with it.
2935
[More Information](http://en.wikipedia.org/wiki/MIT_License)
3036

3137

32-
## Credits
38+
## Credits
3339

3440
* Uses jQuery hover intent plugin by [Brian Cherne](http://cherne.net/brian/resources/jquery.hoverIntent.html)
3541
* Entypo pictograms by [Daniel Bruce](http://www.entypo.com)

js/hn.js

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ var hn = {
88
endless_preload: 300,
99

1010
init: function(){
11-
1211
hn.setPage();
1312
hn.styleElements();
1413
hn.replaceImages();
@@ -36,13 +35,12 @@ var hn = {
3635
hn.createQuickReply();
3736
break;
3837
default:
39-
hn.createFilterMenu();
38+
hn.createFilterMenu();
4039
$('html').addClass('news');
4140
}
4241
},
4342

4443
styleElements: function(){
45-
4644
$('input[type=submit]').addClass('btn');
4745
},
4846

@@ -54,12 +52,10 @@ var hn = {
5452
},
5553

5654
createProfileBubble: function(){
57-
5855
$('body').append('<div id="profile-bubble"><em></em><div class="profile"></div></div>');
5956
},
6057

6158
createQuickReply: function(){
62-
6359
$('body').append('<div id="quick-reply"><em></em><div class="reply"><form><textarea></textarea><input type="submit" value="reply" class="btn" /></form></div></div>');
6460
},
6561

@@ -79,7 +75,6 @@ var hn = {
7975
},
8076

8177
refreshFilters: function(){
82-
8378
var filters = hn.getStorage('filters');
8479
var $filters = '';
8580

@@ -178,7 +173,6 @@ var hn = {
178173
},
179174

180175
checkPageEnd: function(){
181-
182176
// dont do anything if we're already loading the next page
183177
if (hn.endless_loading) return;
184178

@@ -205,7 +199,6 @@ var hn = {
205199

206200
// load next page
207201
$temp.load(url, function(){
208-
209202
// find the first news title and jump up two levels to get news table body
210203
$temp = $temp.find('td.title:first-child').parent().parent().html();
211204

@@ -250,15 +243,15 @@ var hn = {
250243

251244
// load real reply form from server, modify and submit
252245
$temp.load(url, function(){
253-
254246
$temp.find('textarea').val($textarea.val());
255-
$temp.find('form').submit();
247+
var $form = $temp.find('form');
248+
document.body.appendChild($form[0]);
249+
$form.submit();
256250
});
257251
});
258252
},
259253

260254
toggleReplies: function(ev){
261-
262255
var $button = $(this);
263256

264257
if ($button.hasClass('collapsed')) {
@@ -290,15 +283,14 @@ var hn = {
290283
return false;
291284
}
292285
});
293-
$button.parents("td.default").children("span.comment, p").hide();
294286

287+
$button.parents("td.default").children("span.comment, p").hide();
295288
$button.text("[+]")
296-
.addClass('collapsed')
297-
.data('uniq', uniq);
289+
.addClass('collapsed')
290+
.data('uniq', uniq);
298291
},
299292

300293
loadUserDetails: function(ev){
301-
302294
var $temp = $('<div/>');
303295
var url = $(this).attr('href') + ' table';
304296
var username = $(this).text();
@@ -316,8 +308,7 @@ var hn = {
316308
var urlsWithIndices = twttr.txt.extractUrlsWithIndices($temp.html());
317309
var filtered = [];
318310

319-
for (var i = 0; i < urlsWithIndices.length; i++) {
320-
311+
for (var i = 0; i < urlsWithIndices.length; i++) {
321312
// ensure urls are properly formed
322313
if(!urlsWithIndices[i].url.match(/^https?:\/\//gi)){
323314
urlsWithIndices[i].url = 'http://' + urlsWithIndices[i].url;
@@ -327,7 +318,7 @@ var hn = {
327318
if(!urlsWithIndices[i].url.match(/ycombinator/gi)){
328319
filtered.push(urlsWithIndices[i].url);
329320
}
330-
};
321+
};
331322

332323
if (filtered.length) {
333324
hn.renderProfileBubble([], filtered, username, karma);
@@ -344,7 +335,6 @@ var hn = {
344335
},
345336

346337
loadUserProfiles: function(urls, callback){
347-
348338
var name = 'ident' + (new Date).getTime();
349339
var port = chrome.extension.connect({name: name});
350340
port.postMessage({urls: urls});
@@ -353,9 +343,7 @@ var hn = {
353343
},
354344

355345
renderProfileBubble: function(identities, urls, username, karma){
356-
357346
if (identities || urls || karma) {
358-
359347
identities = identities || [];
360348
urls = urls || [];
361349

@@ -420,14 +408,12 @@ var hn = {
420408
},
421409

422410
closeQuickReply: function(ev){
423-
424411
if (!$(ev.target).parents('#profile-bubble').length && ev.target != $('#profile-bubble')[0]) {
425412
$('#profile-bubble').fadeOut(200);
426413
}
427414
},
428415

429416
augmentStories: function(){
430-
431417
var follows = hn.getStorage("follows");
432418

433419
$('td.title').not('.hn-processed').each(function(){
@@ -468,7 +454,6 @@ var hn = {
468454
},
469455

470456
augmentComments: function(){
471-
472457
$('span.comment').each(function(){
473458
var $wrapper = $(this).parent();
474459
var $meta = $wrapper.find('span.comhead');
@@ -481,7 +466,6 @@ var hn = {
481466
},
482467

483468
updateHighlights: function() {
484-
485469
var follows = hn.getStorage("follows");
486470

487471
$('span.comment').each(function(){
@@ -500,7 +484,6 @@ var hn = {
500484
},
501485

502486
filterStories: function(){
503-
504487
var count = 0;
505488

506489
$('td.title a').each(function(){
@@ -538,7 +521,6 @@ var hn = {
538521
},
539522

540523
checkFiltered: function(title, domain, username){
541-
542524
var filters = hn.getStorage('filters');
543525
var filter;
544526

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "HackerNew",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "The best Hacker News extension, making HN quicker and more useful since 2012.",
55
"background": {
66
"page": "background.html"

0 commit comments

Comments
 (0)