DOCTYPE html -- To change this license header choose License Headers i

 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
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>Hello gnomeSort</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<script>
function read(file)
{
if (window.File && window.FileReader && window.FileList && window.Blob)
{
var fr = new FileReader();
fr.readAsText(file.files[0]);
fr.onload = function (e)
{
document.getElementById('dates').innerHTML = getSortedList(e.target.result);
};
}
}
function getSortedList(data)
{
var dates = data.split('\r\n');
for (var i = 0; i < dates.length; i++)
{
dates[i] = new Date(Date.parse(dates[i]));
}
dates = sortDates(dates);
var text = '<ul>';
for (var i in dates)
{
text += '<li>' + dates[i].toString() + '</li>';
}
text += '</ul>'
return text;
}
</script>
</head>
<body>
<input type='file' onChange='read(this)' />
<div id='dates'>
</div>
</body>
</html>