Fossil with Commonmark

Artifact [2a217daa99]
Login

Artifact 2a217daa993d333e6d96ff43b5693f96b0d4ea41:

Attachment "additional_header_stuff.txt" to ticket [fd5f24a5ca] added by anonymous 2010-12-01 21:29:41.

<style type="text/css">
.diff {padding: .5em; border: 1px solid #ccc;}
.added {padding-left: .5em; border-left: .5em solid #00f;}
.deleted {padding-left: .5em; border-left: .5em solid #f00;}
.modified {padding-left: .5em; border-left: .5em solid #f80;}
.changed {padding-left: .5em; border-left: .5em solid #0f0;}
</style>
<script type="text/javascript">
//<![CDATA[

function annotate() {
/* quick, dirty & ugly color coding of annotations
   !only per day(s), not by event! */
if (!document.title.match(/Annotation/))
  return false; /* go out here */

/* color definitions: initial, current, next to last ..., all others (between) */
var colors = new Array('#eee','#f60','#0f6','#60f','#48b','#8bb', '#ffa');
var pres = document.getElementsByTagName('pre')[0].getElementsByTagName('a');
var days = new Array();
for (var i = 0; i < pres.length; i++) { /* collecting dates */
  var day = pres[i].nextSibling.data;
  var get = day.match(/\s+(\d{4})-(\d{2})-(\d{2})\s.+/i);
  trash = get.shift();
  days = days.concat( get.join('') ); }

var initial = days.shift();
days = days.sort(); i = 0;
var last = '';
var five = new Array('1','2','3','4','5'); /* dummy dates */
do { /* getting the most recent five days */
  var hold = days.pop();
  if (hold != last) {
    five[i] = hold;
    i++;
    last = hold; }
} while ((days.length > 0) && (i < 5));
//alert(i +' '+ five+' # '+ first);
/* apply color definition */
var pres = document.getElementsByTagName('pre')[0].getElementsByTagName('a');
//alert(pres[0].nextSibling.data);
for (var i = 0; i < pres.length; i++) {
  var day = pres[i].nextSibling.data;
  var get = day.match(/\s(\d{4})-(\d{2})-(\d{2})\s.+/i);
  var wert = get[1]+get[2]+get[3];
  pres[i].style.paddingRight = '.5em';
  pres[i].style.borderRight = ".5em solid ";
  switch (wert) {
    case (initial): /* first ci */
      pres[i].style.backgroundColor = colors[0];
      pres[i].style.borderRightColor = colors[0];
      break;	
    case (five[0]): /* current */
      pres[i].style.backgroundColor = colors[1];
      pres[i].style.borderRightColor = colors[1];
      break;	
    case (five[1]): /* next to last */
      pres[i].style.backgroundColor = colors[2];
      pres[i].style.borderRightColor = colors[2];
      break;	
    case (five[2]):
      pres[i].style.borderRightColor = colors[3];
      break;	
    case (five[3]):
      pres[i].style.borderRightColor = colors[4];
      break;	
    case (five[4]):
      pres[i].style.borderRightColor = colors[5];
      break;	
    default: /* others */
      pres[i].style.borderRightColor = colors[6];
      break;
}}
  return true;
} /* annotate() */

function colordiff() {
var pres = document.getElementsByTagName('pre');
for (var i = 0; i < pres.length; i++) {
  if (pres[i].hasChildNodes() && (pres[i].getAttribute('class') == 'diff')) {
    pres[i].innerHTML = pres[i].innerHTML.replace(/^(.+)$/mg, "<span>$1</span>");
    //pres[i].style.border = '1px dashed #f60';
    var spans = pres[i].getElementsByTagName('span');
    //alert(spans.length);
    for (var j = 0; j < spans.length; j++)
      if (spans[j].hasChildNodes()) {
        var has = spans[j].innerHTML[0];
        if (has) {
          switch (has) {
            case '+': /* line added */
              spans[j].style.backgroundColor = "#9f9";
              break;
            case '-': /* line removed */
              spans[j].style.backgroundColor = "#f99";
              break;
            case '@': /* sync */
              spans[j].style.backgroundColor = "#ff9";
              break;
            default: /* unchanded lines */
              // spans[j].style.color = "#999";
              // spans[j].style.backgroundColor = "#ffe";
              break;
}}}}}} /* colordiff() */

function main() {
  if (!annotate())
    colordiff();
  document.getElementsByTagName("body")[0].setAttribute('onload', '');
} /* main() */

//]]>
</script>
</head>
<body onload='main()'>