-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff.htm
More file actions
106 lines (101 loc) · 2.21 KB
/
Copy pathdiff.htm
File metadata and controls
106 lines (101 loc) · 2.21 KB
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
<html>
<head>
<title>Latin Diff</title>
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
<style type="text/css">
h1,h3 { text-align:center; }
body{
background-color:#ffffff;
padding:2em;
}
#left {
width:50%;
height:10em;
}
#right {
float:right;
width:50%;
height:10em;
}
.rb {
background-color: red;
font-weight:bold;
}
</style>
</head>
<body>
<button onclick='convert("htmlbox")'>convert</button><br/><br/>
<div>
<textarea id='left'></textarea>
<textarea id='right'></textarea>
</div>
<br/><br/><hr/><br/>
<div class='html' id='diffout'>asdf</div>
<script type='text/javascript'>
var l = document.getElementById('left');
var r = document.getElementById('right');
var o = document.getElementById('diffout');
var repl = function(s) {
t = s.toLowerCase()
.replace(/æ/gi,'ae')
.replace(/ǽ/gi,'ae')
.replace(/œ́/gi,'oe')
.replace(/œ/gi,'oe')
.replace(/ë/gi,'e')
.replace(/á/gi,'a')
.replace(/é/gi,'e')
.replace(/í/gi,'i')
.replace(/ó/gi,'o')
.replace(/ú/gi,'u')
.replace(/ý/gi,'y');
t = t.replace(//g, '');
t = t.replace(/[0-9]/gi,'');
t = t.replace(/[^a-zA-Z0-9]+/gi,' ');
t = t.replace(/^[^a-zA-Z]+/gi,'');
return t;
};
var fnch = function() {
outi = [];
outj = [];
lt = repl(l.value);
rt = repl(r.value);
lta = lt.split(' ');
rta = rt.split(' ');
var j = 0;
for(var i=0;i<Math.max(lta.length, rta.length); i++) {
var it = "";
var jt = "";
if(lta.length>i) it = lta[i];
if(rta.length>i) jt = rta[i];
if(it==jt) {
outi.push(it);
outj.push(jt);
}
else {
outi.push("<span class='rb'>"+it+"</span>");
outj.push("<span class='rb'>"+jt+"</span>");
}
}
o.innerHTML = outi.join(' ') + "<hr>" + outj.join(' ');
};
l.onchange = fnch;
r.onchange = fnch;
/*
function convert(t) {
var input = 'textile';
if(typeof(t)=="string") input = t;
console.log('start ' + input);
var tt = document.getElementById(input);
var ttText = tt.innerHTML;
if(tt.tagName.toUpperCase()=="TEXTAREA") ttText = tt.value;
var outh = document.getElementById('htmlout');
var outb = document.getElementById('outbox');
outh.innerHTML = textileToHtml(ttText);
outb.value = textileToHtml(ttText);
console.log('done');
}
window.onload = convert;
*/
</script>
</body>
</html>