-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddArticleAliases.html
85 lines (64 loc) · 1.95 KB
/
AddArticleAliases.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
<html>
<head>
<title>
</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-latest.js' />
<script type='text/javascript'>
</script>
<script type='text/javascript'>
window.onload = function() {
function compileWord(strFileLine)
{
var pattFunc = new RegExp("(jQuery)*\.[a-z]+[A-Z]*\(.*\)");
var pattSelector = new RegExp(":[a-z\-]+[A-Z]*\(.*\)");
var bln_pattFunc = pattFunc.test(strFileLine);
var bln_pattSelector = pattSelector.test(strFileLine);
var str_Result
if(bln_pattFunc)
{
str_Result = strFileLine.replace("\.", " ").replace("\(", "").replace("\)", "").replace("jQuery", " ");
}
if(bln_pattSelector)
{
str_Result = str_Result.replace("\:", " ").replace("\(", "").replace("\)", "");
}
return str_Result.replace(/([a-z])([A-Z])/g, '$1 $2')
}
function compileLines(strFile)
{
var strFileLines = strFile.split('\n');
var strOutput ="";
$.each(strFileLines, function( index, value ) {
strOutput += strFileLines[index] + " ==>" + " " + compileWord(strFileLines[index]) + '\n';
});
return strOutput;
}
///
var fileInput = document.getElementById('fileInput');
var fileDisplayArea = document.getElementById('fileDisplayArea');
fileInput.addEventListener('change', function(e) {
var file = fileInput.files[0];
//var textType = /text.* /;
var textType = new RegExp("text.*");
if (textType.test(file.type)) {
var reader = new FileReader();
reader.onload = function(e) {
fileDisplayArea.innerText = compileLines(reader.result);
}
reader.readAsText(file);
} else {
fileDisplayArea.innerText = "File not supported!"
}
});
}
</script>
</head>
<body>
<h1>Add Article Aliases</h1>
<div>
Select a text file:
<input type="file" id="fileInput">
</div>
<div id="fileDisplayArea">
</div>
</body>