forked from pieter/gitx
-
Notifications
You must be signed in to change notification settings - Fork 205
/
Copy pathinlinedifftest.html
132 lines (124 loc) · 4.78 KB
/
inlinedifftest.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<html>
<head>
<link rel="stylesheet" href="css/GitX.css" type="text/css" media="screen" title="no title" charset="utf-8">
<link rel="stylesheet" href="css/diff.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script src="lib/jquery-2.0.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="lib/GitX.js" type="text/javascript" charset="utf-8"></script>
<script src="lib/diffHighlighter.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div id="results"></div>
<textarea id="test-data">
-the red fox jumped into the leaf
+the brown fox dashed into the leaf
---------------------------------------
-Deploying from branch BRANCH to stage STAGE Awesome!
+Deploying to stage STAGE from branch BRANCH Awesome!
---------------------------------------
-foo bar baz barf
+foo baz bar barf
---------------------------------------
-foo bar moo baz barf
+foo bar baz barf
---------------------------------------
-foo bar baz barf
+foo bar moo baz barf
---------------------------------------
- return {bounds:[from,to],good:good};
+ var ret = {bounds:[from,to],good:good};
+ Controller.log_("computeSelection: from: "+from.outerHTML);
+ Controller.log_("computeSelection: {bounds:["+from+","+to+"],good: "+good+" }");
+ return ret;
---------------------------------------
-whitespace
+whitespace
---------------------------------------
- tab indent to spaces
+ tab indent to spaces
---------------------------------------
- a = "hello";
- b = "world";
- c = a + " " + b;
+ if (true) {
+ a = "hello";
+ b = "world";
+ c = a + " " + b;
+ }
---------------------------------------
- n = n.replace(/</g, "&lt;");
- n = n.replace(/>/g, "&gt;");
+ if (true) {
+ n = n.replace(/</g, "&lt;");
+ n = n.replace(/>/g, "&gt;");
+ }
---------------------------------------
- NSString* installationPath = @"/usr/local/bin/gitx";
+ NSString* installationPath = @"/usr/local/bin/";
+ NSString* installationName = @"gitx";
---------------------------------------
- char const* arguments[] = { "-f", "-s", [toolPath UTF8String], [installationPath UTF8String], NULL };
+ char const* mkdir_arg[] = { "-p", [installationPath UTF8String], NULL};
+ char const* mkdir = "/bin/mkdir";
+ AuthorizationExecuteWithPrivileges(auth, mkdir, kAuthorizationFlagDefaults, (char**)mkdir_arg, NULL);
+ char const* arguments[] = { "-f", "-s", [toolPath UTF8String], [[installationPath stringByAppendingString: installationName] UTF8String], NULL };
</textarea>
<script type="text/javascript" charset="utf-8">
jQuery(function($){
update();
return;
function getData() {
return $('#test-data').val();
}
function parseData(rawData) {
var blocks = rawData.split(/\n?-{10,}\n?/);
return $.map(blocks, function(block) {
var l = block.split(/\n/),
o = [], n = [];
for (var i = 0; i < l.length; i++) {
(l[i][0] == "-" ? o : n).push(l[i].substring(1));
}
return [[o.join("\n"), n.join("\n")]];
});
}
function update() {
var testData = parseData(getData());
$('#results').text('');
for (var i = 0; i < testData.length; i++) {
var o = testData[i][0], n = testData[i][1];
$('#results').append(resultForTestData(o, n));
};
}
function stripTags(h) {
return h.replace(/<\/?\w+\/?>/g,'');
}
function resultForTestData(o,n) {
var diff = inlinediff.diffString3(o,n);
var eo = inlinediff.escape(o);
var en = inlinediff.escape(n);
var oldOk = eo == stripTags(diff[1]);
var newOk = en == stripTags(diff[2]);
var ok = oldOk && newOk;
return $("<div/>")
.addClass("test")
.addClass(ok ? "ok" : "fail")
.append([oldOk, newOk].join(", "))
//.append($("<pre/>").addClass("comb").html(diff[0]))
.append($("<pre/>").addClass("old").html(diff[1]))
.append($("<pre/>").addClass("new").html(diff[2]));
}
});
</script>
<style type="text/css">
.test {
margin: 1em; border: 1px solid #eee; padding: 0.5em; border-radius: 0.5em;
}
.test.fail {border: 2px solid #a60004;}
.test pre { margin:0 }
.test .old { background: #feccce}
.test .new { background: #c4ffc1}
.test ins, .test del { background-color: rgba(0,0,0,0.15); text-decoration: none; border-radius: 0.25em;}
.test .comb del { background-color: rgba(255,0,0,0.15); text-decoration: line-through; }
.test .comb ins { background-color: rgba(0,255,0,0.15); }
</style>
</body>
</html>