Changes To Cookbook
Not logged in

Changes to "Cookbook" between 2011-01-20 20:59:45 and 2011-01-20 21:19:14

992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007









1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022














1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034

1035
1036

1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050












1051
1052
1053
1054


1055
1056
1057
1058


1059
1060
1061
1062
1063
1064
992
993
994
995
996
997
998









999
1000
1001
1002
1003
1004
1005
1006
1007















1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032

1033


1034
1035
1036












1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050


1051
1052
1053
1054


1055
1056
1057
1058
1059
1060
1061
1062







-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+











-
+
-
-
+


-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+


-
-
+
+


-
-
+
+







================================

<script>
/*  Simple diff highlighting */
var DiffHighlighter = {

  isDiff : function(s){
    return (s.match(/^@@.*@@/m) && s.match(/^[+-]/m));
  },
  
  highlightElement : function(el){
    var s = el.innerHTML;
    if (!this.isDiff(s)){
      return;
    }
 isDiff : function(s){
   return (s.match(/^@@.*@@/m) && s.match(/^[+-]/m));
 },

 highlightElement : function(el){
   var s = el.innerHTML;
   if (!this.isDiff(s)){
     return;
   }
    el.className += 'diff';
    s = s.replace("<", "&lt;");
    s = s.replace(/^\+.*$/mg, '<span class="diff-mark added">$&</span>');
    s = s.replace(/^\-.*$/mg, '<span class="diff-mark removed">$&</span>');
    s = s.replace(/^@@.*$/mg, '<span class="diff-mark position">$&</span>');
    s = "<pre>" + s + "</pre>"; // workaround for IE
    el.innerHTML = s;
  },
  
  highlightElementsWithTagName : function(tagName){
    var els = document.getElementsByTagName(tagName);
    for (var i=0; i < els.length; i++){
      this.highlightElement(els[i]);
    }
  }
   s = s.replace("<", "&lt;");
   s = s.replace(/^\+.*$/mg, '<span class="diff-added">$&</span>');
   s = s.replace(/^\-.*$/mg, '<span class="diff-removed">$&</span>');
   s = s.replace(/^@@.*$/mg, '<span class="diff-position">$&</span>');
   s = "<pre class='diff'>" + s + "</pre>"; // workaround for IE
   el.innerHTML = s;
 },

 highlightElementsWithTagName : function(tagName){
   var els = document.getElementsByTagName(tagName);
   for (var i=0; i < els.length; i++){
     this.highlightElement(els[i]);
   }
 }
};

DiffHighlighter.highlightElementsWithTagName('pre');
</script>

================================

And add this (or something to your taste) to your CSS:

================================

.diff-mark {
pre.diff {
  display: inline;
  color: #000;
 color: #000;
}

.diff-mark.position {
  display:-moz-inline-stack;
  display:inline-block;
  zoom:1;
  *display:block;
  width: 100%;
  font-style: italic;
  padding: 0.5em 0;
  margin: 0.5em 0;
  border-top: 1px dotted #A2B5CD;
  border-bottom: 1px dotted #A2B5CD;
  color: #A2B5CD;
pre .diff-position {
 display:-moz-inline-stack;
 display:inline-block;
 zoom:1;
 *display:block;
 width: 100%;
 font-style: italic;
 padding: 0.5em 0;
 margin: 0.5em 0;
 border-top: 1px dotted #A2B5CD;
 border-bottom: 1px dotted #A2B5CD;
 color: #A2B5CD;
}

.diff-mark.added {
  background-color: #CEFBC3;
pre .diff-added {
 background-color: #CEFBC3 !important;
}

.diff-mark.removed {
  background-color: #F5C2C1;
pre .diff-removed {
 background-color: #F5C2C1 !important;
}

================================

That's it: the script will automatically detect diffs and color them.
</verbatim>