-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoordsToCTABulkInput.html
More file actions
61 lines (56 loc) · 1.67 KB
/
CoordsToCTABulkInput.html
File metadata and controls
61 lines (56 loc) · 1.67 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
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width" />
<title>coords to cachetur bulk input format</title>
</head>
<body>
<h1>coords to cachetur bulk input format</h1>
Given a list of coordinates 1/line with optional comment after, generate cachetur bulk input format lines. Format: coords;comment<br/>
<button onclick="compute()" style="font-size:24px;width:200px;height=200px;border-width:4px">Generate</button> <br><br>
Coordinate Name Prefix: <input id="prefix" type="text"/></br>
<textarea id="in" rows="20" cols="80"></textarea><br>
<b>Bulk format data</b><br>
<textarea id="res" rows="20" cols="80"></textarea>
<script>
var result = document.getElementById('res');
function compute() {
var prefix = document.getElementById('prefix').value;
var lines = document.getElementById('in').value.split('\n');
// strip blank lines
for( var i = 0; i < lines.length; i++){
if ( lines[i].length === 0) {
lines.splice(i, 1);
i--;
}
}
var list = "";
for(var i = 0;i < lines.length;i++){
var ll = toBulk(i+1,prefix,lines[i]);
if (ll.length > 0) {
list = list + ll;
if (i+1 !== lines.length) {
list+= "\n";
}
}
}
result.value = list;
// Make copy to clipboard easy
result.setSelectionRange(0, 9999);
}
function toBulk(i,prefix,coords) {
var coord = coords.split(";");
var line = "";
var prfx = prefix?prefix:"C";
line=prfx+i+";lab;" + coord[0] + ";";
if (coord[1]) {
line += '"' +coord[1]+'"';
} else {
line += '"' +prfx+i+'"';
}
return line;
}
</script>
</body>
</html>