Skip to content

Commit

Permalink
add original poster css once in bulk instead of once per root post.
Browse files Browse the repository at this point in the history
  • Loading branch information
arhughes committed Mar 22, 2010
1 parent 0a677ea commit 700455b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions chromeshack_posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ ChromeShack =
{
ChromeShack.processPost(item, item.id.substr(5));
}
fullPostsCompletedEvent.raise();
},

processPost: function(item, root_id)
Expand Down
1 change: 1 addition & 0 deletions init_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ Event.prototype.raise = function(arg1, arg2, arg3)
}

var processPostEvent = new Event();
var fullPostsCompletedEvent = new Event();
var processPostBoxEvent = new Event();
var settingsLoadedEvent = new Event();
21 changes: 17 additions & 4 deletions scripts/highlight_original_poster.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ settingsLoadedEvent.addHandler(function()

css: getSetting("original_poster_css"),

highlight: function(item, id, is_root_post)
selectors: [],

gatherCss: function(item, id, is_root_post)
{
if (is_root_post)
{
Expand All @@ -17,13 +19,24 @@ settingsLoadedEvent.addHandler(function()
if (fpauthor)
{
var authorId = fpauthor[1];
var style = "div#root_" + id + " div.olauthor_" + authorId + " a.oneline_user { " + HighlightOriginalPoster.css + " }";
insertStyle(style);
HighlightOriginalPoster.selectors.push("div#root_" + id + " div.olauthor_" + authorId + " a.oneline_user ");
}
}
},

installCss: function()
{
if (HighlightOriginalPoster.selectors.length > 0)
{
var css = HighlightOriginalPoster.selectors.join(", ");
css += " { " + HighlightOriginalPoster.css + " }";
insertStyle(css);
}
}

}

processPostEvent.addHandler(HighlightOriginalPoster.highlight);
processPostEvent.addHandler(HighlightOriginalPoster.gatherCss);
fullPostsCompletedEvent.addHandler(HighlightOriginalPoster.installCss);
}
});

0 comments on commit 700455b

Please sign in to comment.