Skip to content

Commit

Permalink
merge from cdzombak
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksonh committed Oct 22, 2011
2 parents a985460 + 16c56ad commit bd7aebb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
13 changes: 5 additions & 8 deletions chrome/dashboardscript.js
@@ -1,3 +1,4 @@

$("#watched_repos").ready( function() {

chrome.extension.sendRequest({greeting: "get_gitmarks"}, function(response) {
Expand All @@ -6,11 +7,10 @@ $("#watched_repos").ready( function() {
+ " <div class='top-bar'>"
+ " <h2>Gitmarked Repositories <em>("
+ response.gitmarks.length
+ ")</em></h2>"
+ " )</em></h2>"
+ "</div>"
+ "<ul class='repo_list' id='gitmarked_repo_listing'>";

var hidden = false;
for (var i=0; i<response.gitmarks.length; ++i) {
var gitmark = response.gitmarks[i];

Expand All @@ -20,10 +20,9 @@ $("#watched_repos").ready( function() {

dashboard += "<li class='public source"

if (i >= 10) {
if (i >= 10)
dashboard += " gitmark-hidden' style=\"display: none;\"";
hidden = true;
} else
else
dashboard += "'";

dashboard += ">"
Expand All @@ -32,11 +31,9 @@ $("#watched_repos").ready( function() {
+ "</a></li>";
}

if (hidden) {
dashboard += "<div class='bottom-bar'><a href=\"#\" class='show-more' id='inline-gitmarked-repos'>Show "
dashboard += "<div class='bottom-bar'><a href=\"#\" class='show-more' id='inline-gitmarked-repos'>Show "
+ (response.gitmarks.length - 10)
+ " more repositories...</a></div>";
}

$('#watched_repos').after(dashboard);

Expand Down
2 changes: 1 addition & 1 deletion chrome/manifest.json
Expand Up @@ -5,7 +5,7 @@
"background_page": "background.html",
"content_scripts": [
{
"matches": ["https://github.com/*"],
"matches": ["https://github.com/*/*"],
"js": ["jquery.js", "projectscript.js"]
},
{
Expand Down
25 changes: 18 additions & 7 deletions chrome/projectscript.js
@@ -1,3 +1,8 @@
if(typeof(String.prototype.trim) === "undefined") {
String.prototype.trim = function() {
return String(this).replace(/^\s+|\s+$/g, '');
};
}

function update_gitmarked_button () {
chrome.extension.sendRequest({greeting: "is_page_gitmarked"}, function(response) {
Expand All @@ -8,14 +13,20 @@ function update_gitmarked_button () {
});
}

$('.actions').ready (function () {
var actions = $('.actions');
$('.pagehead-actions').ready (function () {
var actions = $('.pagehead-actions');
if (!actions || !actions.children)
return;
if ($(actions.children ("li") [0]).hasClass ('for-owner'))
return;
$(actions.children ("li") [2]).before ("<li class='for-owner'><a href='#' class='minibutton' id='gitmark'><span class='icon' id='gitmarked_text'>Gitmark</span></a></li>");
update_gitmarked_button ();
return;

var currentUserName = $("div.userbox a.name").text();
var pieces = window.location.href.split('/');
var repoOwner = pieces[3];
if (repoOwner.trim() == currentUserName.trim())
return;

var actionsChildren = actions.children("li");
$(actionsChildren[actionsChildren.length-1]).before ("<li class='for-owner'><a href='#' class='minibutton' id='gitmark'><span class='icon' id='gitmarked_text'>Gitmark</span></a></li>");
update_gitmarked_button();
});

$('#gitmark').ready( function() {
Expand Down

0 comments on commit bd7aebb

Please sign in to comment.