-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
98 lines (91 loc) · 3.75 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>fs-traversal-relationship-display sandbox</title>
<script src="fs-traversal-relationship-display.js"></script>
<script src="https://rawgit.com/victorquinn/chancejs/master/chance.js"></script>
<link rel="stylesheet" href="fs-traversal-relationship-display.css">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<script>
document.addEventListener('DOMContentLoaded', function(){
generate();
});
/**
* Generate and display new path
*/
function generate(){
var length = parseInt(document.getElementById('path-length').value);
var path = generatePath(length);
var lang = document.getElementById('lang').value;
var display = FSTraversalRelationshipDisplay(path, lang);
document.getElementById('display').innerHTML = display;
};
/**
* Generate a random path.
* length is number of people in path.
*/
function generatePath(length){
var path = [{rel:'start', person:generatePerson()}];
length--;
for(var i = 0; i < length; i++){
path.push({
rel: chance.pick(['child','father','mother','spouse']),
person: generatePerson()
});
}
return path;
};
/**
* Generate a random person
*/
function generatePerson(){
return {
id: chance.string({length: 7, pool: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'}),
gender: {
type: 'http://gedcomx.org/' + chance.gender()
},
display: {
name: chance.name({middle: true})
}
};
};
</script>
<style>
.panel {
margin-top: 15px;
overflow: auto;
max-height: 700px;
}
</style>
</head>
<body>
<div class="container">
<h1><a href="https://github.com/genealogysystems/fs-traversal-relationship-display">fs-traversal-relationship-display</a> sandbox</h1>
<div class="alert alert-warning"><p>The names and relationships are randomly generated using <a href="http://chancejs.com/" target="_blank">Chance.js.</a> The gender of the names may not match the gender of the relationships.</p></div>
<div class="row">
<div class="col-md-2 col-sm-4">
<label>Path Length</label>
<input type="text" class="form-control" id="path-length" placeholder="path length" value="10">
</div>
<div class="col-md-2 col-sm-4">
<label>Language</label>
<select id="lang" class="form-control">
<option value="en">English</option>
<option value="es">Spanish</option>
</select>
</div>
<div class="col-md-2 col-sm-4">
<label> </label><br>
<button class="btn btn-primary" onclick="generate();">Generate New Path</button>
</div>
</div>
<div class="panel panel-default">
<div id="display" class="panel-body"><p>Loading...</p></div>
</div>
</div>
<a href="https://github.com/genealogysystems/fs-traversal-relationship-display"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
</body>
</html>