Skip to content

Instantly share code, notes, and snippets.

@potch
Created January 10, 2012 23:52
Show Gist options
  • Select an option

  • Save potch/1591990 to your computer and use it in GitHub Desktop.

Select an option

Save potch/1591990 to your computer and use it in GitHub Desktop.

Revisions

  1. potch revised this gist Jan 11, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.rst
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    Bugzilla Color Friend!
    ======================

    A `dotjs <https://addons.mozilla.org/en-US/firefox/addon/dotjs/>` script to add some color to Bugzilla.
    A `dotjs <https://addons.mozilla.org/en-US/firefox/addon/dotjs/>`_ script to add some color to Bugzilla.

    It's The Worst!™
  2. potch revised this gist Jan 11, 2012. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions README.rst
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    Bugzilla Color Friend!
    ======================

    A `dotjs <https://addons.mozilla.org/en-US/firefox/addon/dotjs/>` script to add some color to Bugzilla.

    It's The Worst!™
  3. potch revised this gist Jan 11, 2012. 1 changed file with 8 additions and 3 deletions.
    11 changes: 8 additions & 3 deletions bugzilla.mozilla.org.js
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,11 @@ function textColor(bg) {
    return yiq >= 128 ? "black" : "white";
    }

    function bgColor(el, i) {
    var bn = $("a", el).eq(i).text().match(/\d+/)[0];
    return ("000000" + bn).substr(-6);
    }

    var tds = $('.bz_id_column'),
    head = $('.bz_alias_short_desc_container'),
    start = 0,
    @@ -15,7 +20,7 @@ function doChunk() {
    for (i=start; i<start+20; i++) {
    el = tds[i];
    if (!el) break;
    var c = ("000000" + $.trim($("a", el).text())).substr(-6);
    var c = bgColor(el, 0);
    $(el).css('background-color', "#" + c);
    $("a", $(el)).css('color', textColor(c));
    }
    @@ -28,6 +33,6 @@ if (tds.length) {
    }

    if (head.length) {
    var c = ("000000" + $.trim($("a", head).eq(1).text())).substr(-6);
    var c = bgColor(head, 1);
    $("body").css('background-color', "#" + c);
    }
    }
  4. potch revised this gist Jan 11, 2012. 1 changed file with 14 additions and 2 deletions.
    16 changes: 14 additions & 2 deletions bugzilla.mozilla.org.js
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,12 @@ function textColor(bg) {
    var yiq = (r * 299 + g * 587 + b * 114) / 1000;
    return yiq >= 128 ? "black" : "white";
    }
    var tds = $('.bz_id_column'), start=0, i;

    var tds = $('.bz_id_column'),
    head = $('.bz_alias_short_desc_container'),
    start = 0,
    i;

    function doChunk() {
    for (i=start; i<start+20; i++) {
    el = tds[i];
    @@ -18,4 +23,11 @@ function doChunk() {
    if (i<tds.length)
    setTimeout(doChunk, 0);
    }
    doChunk();
    if (tds.length) {
    doChunk();
    }

    if (head.length) {
    var c = ("000000" + $.trim($("a", head).eq(1).text())).substr(-6);
    $("body").css('background-color', "#" + c);
    }
  5. potch revised this gist Jan 11, 2012. 1 changed file with 14 additions and 5 deletions.
    19 changes: 14 additions & 5 deletions bugzilla.mozilla.org.js
    Original file line number Diff line number Diff line change
    @@ -5,8 +5,17 @@ function textColor(bg) {
    var yiq = (r * 299 + g * 587 + b * 114) / 1000;
    return yiq >= 128 ? "black" : "white";
    }
    $('.bz_id_column').each(function() {
    var c = ("000000" + $.trim($("a", this).text())).substr(-6);
    $(this).css('background-color', "#" + c);
    $("a", $(this)).css('color', textColor(c));
    });
    var tds = $('.bz_id_column'), start=0, i;
    function doChunk() {
    for (i=start; i<start+20; i++) {
    el = tds[i];
    if (!el) break;
    var c = ("000000" + $.trim($("a", el).text())).substr(-6);
    $(el).css('background-color', "#" + c);
    $("a", $(el)).css('color', textColor(c));
    }
    start = i;
    if (i<tds.length)
    setTimeout(doChunk, 0);
    }
    doChunk();
  6. potch revised this gist Jan 10, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion bugzilla.mozilla.org.js
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ function textColor(bg) {
    return yiq >= 128 ? "black" : "white";
    }
    $('.bz_id_column').each(function() {
    var c = $.trim($(this).text());
    var c = ("000000" + $.trim($("a", this).text())).substr(-6);
    $(this).css('background-color', "#" + c);
    $("a", $(this)).css('color', textColor(c));
    });
  7. potch created this gist Jan 10, 2012.
    12 changes: 12 additions & 0 deletions bugzilla.mozilla.org.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    function textColor(bg) {
    var r = parseInt(bg.substr(0,2),16),
    g = parseInt(bg.substr(2,2),16),
    b = parseInt(bg.substr(4,2),16);
    var yiq = (r * 299 + g * 587 + b * 114) / 1000;
    return yiq >= 128 ? "black" : "white";
    }
    $('.bz_id_column').each(function() {
    var c = $.trim($(this).text());
    $(this).css('background-color', "#" + c);
    $("a", $(this)).css('color', textColor(c));
    });