-
Notifications
You must be signed in to change notification settings - Fork 40
/
index.html
690 lines (674 loc) · 34.2 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
<!DOCTYPE html>
<html>
<head>
<title>Genea.app - Build your family tree</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Genea is a free tool to author your family tree without an account. Genea gives you complete control over where to store your GEDCOM ancestry heritage data." />
<meta name="keywords" content="genea,genealogy,software,free,open source,gedcom,family tree,family lineage,heritage,myheritage,web based,online,genealogist,historian,ancestors,archive,ancestry,legacy,birth,death,funeral,marriage,privacy by design" />
<link rel="icon" href="favicon.ico" type="image/x-icon">
<!-- Dependencies -->
<script src="resources/vuejs/vue.js"></script>
<script src="resources/wasm/index.min.js"></script>
<script>
var hpccWasm = window["@hpcc-js/wasm"];
</script>
<script src="https://unpkg.com/@isomorphic-git/lightning-fs"></script>
<script src="https://unpkg.com/isomorphic-git@beta"></script>
<script type="module">
import http from 'https://unpkg.com/isomorphic-git@beta/http/web/index.js'; window.http = http; window.fs = new LightningFS('fs'); window.pfs = window.fs.promises;
</script>
<link href="resources/googlefonts/materialicons.css" rel="stylesheet">
<link rel="stylesheet" href="resources/materialize/css/materialize.min.css">
<!-- Genea.app -->
<link rel="stylesheet" href="css/style.css" />
<script type="application/javascript" src="js/tags.js"></script>
<script type="application/javascript" src="js/gedcom.js"></script>
<script type="application/javascript" src="js/stamboom.js"></script>
<script type="application/javascript" src="components/tree.js"></script>
<script type="application/javascript" src="components/personaldetails.js"></script>
<script type="application/javascript" src="components/relations.js"></script>
<script type="application/javascript" src="components/debug.js"></script>
<script type="application/javascript" src="modals/new-person.js"></script>
</head>
<body>
<div id="genea">
<!-- Start -->
<div id="overlay" v-if="page=='start'" class="container" style="max-width: 600px;">
<h1 class="header">Genea.app</h1>
<div class="divider"></div>
<div class="section" v-if="!isNative()">
<h4 class="light">Build and edit your family tree; completely free!</h4>
<p style="text-align: justify;">
Genea is a <a href="https://en.wikipedia.org/wiki/Privacy_by_design" target="_blank">privacy by design</a> and <a href="https://github.com/genea-app/genea-app" target="_blank">open source</a> tool anyone can use to author or edit their
family tree. Your data is formatted following the <a href="https://www.gedcom.org/" target="_blank">GEDCOM</a> specifications so it can be exchanged with other genealogy services. All processing is done in the browser, leaving you
in control on where to save your data, avoiding any type of vendor lock-in.
</p>
<p>
<a href="screenshots/doe_family.mp4" target="_blank">
<img src="screenshots/doe_family.png" title="Family tree preview" class="responsive-img" />
</a>
</p>
<p style="text-align: justify;">
You can use Genea both on your mobile devices as well as on your desktop. The changes you make are persistently stored on your device. To work on your family tree from multiple devices, you can either save the GEDCOM file when you are done and exchange
it for example via e-mail or a cloud service like Dropbox, or you can use the built in Git integration which lets you store your work in any private or public repository.
</p>
</div>
<div class="section" v-if="isNative()">
<h4 class="light">Build and edit your family tree</h4>
<p style="text-align: justify;">
Create a new family tree from scratch, or start from a GEDCOM file previously exported from other services like MyHeritage, FamilySearch, or Ancestry.
</p>
</div>
<div class="section" v-if="isLocalStorage()" v-cloak>
<button class="btn-large waves-effect waves-light red lighten-2" v-on:click="page='tree'; loadLocalStorage()">
<i class="material-icons left">sync</i>
Continue with current family tree
</button>
</div>
<div class="section">
<button class="btn-large waves-effect waves-light teal darken-3" v-on:click="loadExample('new')">
<i class="material-icons left">create</i>
Start new family tree
</button>
<label class="btn-large waves-effect waves-light" v-on:click="openGitModal('load')">
<i class="material-icons left">cloud_download</i>
Open
</label>
<label class="btn-large waves-effect waves-light">
<i class="material-icons left">get_app</i>
Upload
<input type="file" style="display: none;" accept=".gedcom,.ged,.txt" v-on:change="loadFile">
</label>
</div>
<div class="section">
<h4 class="light">Examples</h4>
<p>
Explore Genea with these sample trees.
</p>
</div>
<div class="section">
<div class="collection left-align">
<a href="#" v-on:click="loadExample('royal92')" class="collection-item avatar">
<span class="title">Royal '92</span>
<img src="sample/royal92.png" alt="" class="circle">
<p>Features the Kings and Queens of Europe, including Great Britain. Published back in 1992 by Denis R. Reid it is perhaps a little out of date, but it is a classic.</p>
</a>
<a href="#" v-on:click="loadExample('pres2020')" class="collection-item avatar">
<span class="title">Presidents 2020</span>
<img src="sample/pres2020.png" alt="" class="circle">
<p>An excellent collection of the presidents of the US, with their ancestors and descendants updated to 2020 by Paul Stobbe.</p>
</a>
<a href="#" v-on:click="loadExample('harrypotter')" class="collection-item avatar">
<span class="title">Harry Potter</span>
<img src="sample/harrypotter.png" alt="" class="circle">
<p>Fictional family tree for the Harry Potter series, created by famousfamilytrees.blogspot.com.</p>
</a>
</div>
</div>
<div class="section" v-if="isDebug()">
<h4 class="light">Debug</h4>
</div>
<div class="section" v-if="isDebug()">
<button class="btn-large waves-effect waves-light" v-on:click="loadExample('gedcom1')">Debug Example 1</button>
</div>
<div class="divider" v-if="!isNative()"></div>
<div class="section" v-if="!isNative()">
<p>
<a href="mailto:contact@genea.app" target="_blank">contact</a> -
<a href="https://github.com/genea-app/genea-app/issues" target="_blank">issues</a> -
<a href="https://github.com/genea-app/genea-app" target="_blank">github</a> -
<a href="https://github.com/genea-app/genea-app/blob/main/LICENSE" target="_blank">license</a> -
<a href="https://github.com/genea-app/genea-app/blob/main/PRIVACY.md" target="_blank">privacy</a>
</p>
</div>
</div>
<!-- App -->
<header v-show="Object.keys(person).length > 0 && page!='start'" v-cloak>
<a data-target="nav-mobile" class="top-nav sidenav-trigger btn-floating btn-large teal lighten-3 waves-effect waves-light hide-on-large-only" style="margin: 15px;">
<i class="material-icons">menu</i>
</a>
<ul id="nav-mobile" class="sidenav sidenav-fixed">
<li>
<div class="user-view">
<div class="background teal lighten-3"></div>
<img src="img/unknown.png" style="max-width: 100px; max-height: 100px;" />
<span class="white-text name">
{{person.name}}
</span>
<span class="white-text email">
{{person.birth}}
-
{{person.death}}
</span>
</div>
</li>
<li>
<div class="row" style="margin-top: 0; margin-bottom: 0;">
<div class="input-field col s11 offset-s1" style="margin-top: 0; margin-bottom: 0;">
<i class="material-icons" style="position: absolute; display: inline-block; right: 24px; top: 15px;">search</i>
<input id="search" placeholder="Find Person" class="autocomplete" style="font-weight: 300; color: #777; border: 0;" />
</div>
</div>
</li>
<li>
<div class="divider"></div>
</li>
<li>
<a class="subheader">View</a>
</li>
<li class="bold sidenav-close" :class="{active: page=='tree'}">
<a :href="'#/tree/' + person.id" class="waves-effect waves-teal"><i class="material-icons">account_tree</i>Family Tree</a>
</li>
<li class="bold sidenav-close" :class="{active: page=='personaldetails'}">
<a :href="'#/personaldetails/' + person.id" class="waves-effect waves-teal"><i class="material-icons">person</i>Personal Details</a>
</li>
<li class="bold sidenav-close" :class="{active: page=='relations'}">
<a :href="'#/relations/' + person.id" class="waves-effect waves-teal"><i class="material-icons">people</i>Relations and Children</a>
</li>
<li>
<div class="divider"></div>
</li>
<li>
<a class="subheader">Actions</a>
</li>
<li class="bold sidenav-close">
<a @click.prevent="saveGit();" v-if="isGitConnected() && !git.outstandingChanges" class="waves-effect waves-teal grey-text"><i class="material-icons">published_with_changes</i>Up to date</a>
<a @click.prevent="saveGit();" v-if="isGitConnected() && git.outstandingChanges" class="waves-effect waves-teal"><i class="material-icons">cloud_upload</i>Unsaved changes</a>
<a @click.prevent="saveGit();" v-if="!isGitConnected()" class="waves-effect waves-teal"><i class="material-icons">cloud_upload</i>Save to Git</a>
</li>
<li class="bold sidenav-close" v-if="!isNative()">
<a @click.prevent="saveFile();" class="waves-effect waves-teal"><i class="material-icons">save_alt</i>Download</a>
</li>
<li class="bold sidenav-close" v-if="isNative()">
<a @click.prevent="shareFile();" class="waves-effect waves-teal"><i class="material-icons">share</i>Share</a>
</li>
<li class="bold sidenav-close">
<a @click="close();" class="waves-effect waves-teal"><i class="material-icons">logout</i>Close</a>
</li>
<li v-if="isDebug()">
<div class="divider"></div>
</li>
<li v-if="isDebug()">
<a class="subheader">Development</a>
</li>
<li class="bold sidenav-close" :class="{active: page=='debug'}" v-if="isDebug()">
<a :href="'#/debug'" class="waves-effect waves-teal"><i class="material-icons">adb</i>Debug</a>
</li>
</ul>
</header>
<main v-show="page=='tree'">
<tree :person="person" />
</main>
<main v-show="page=='personaldetails'" class="container">
<personaldetails :person="person" />
</main>
<main v-show="page=='relations'" class="container">
<relations :person="person" />
</main>
<main v-show="page=='debug'" class="container">
<debug :debug="debug" />
</main>
<!-- Modals -->
<new-person :person="person" ref="modalNewPerson" />
<div id="modalGit" class="modal">
<div class="modal-content">
<div class="row">
<h4>Git Repository</h4>
</div>
<div class="row">
<p>Connect to a Git Repository to load or save your GEDCOM family tree. You can use a hosted service like <a href="https://github.com/" target="_blank">GitHub</a> or <a href="https://gitlab.com/" target="_blank">GitLab</a>, or connect
to a self hosted repository like <a href="https://gitea.io/" target="_blank">Gitea</a>, <a href="https://gogs.io/" target="_blank">Gogs</a>, or <a href="https://github.com/gitbucket/gitbucket" target="_blank">GitBucket</a>.</p>
</div>
<div class="row">
<h4>Connection Details</h4>
</div>
<div class="row">
<div class="input-field">
<label for="gitRepository" class="active">Repository URL</label>
<input id="gitRepository" type="text" v-model="git.repository" />
</div>
<div class="input-field">
<label for="gitBranch" class="active">Branch</label>
<input id="gitBranch" type="text" v-model="git.branch" />
</div>
<div class="input-field">
<label for="gitPersonalAccessToken" class="active">Personal Access Token</label>
<input id="gitPersonalAccessToken" type="text" v-model="git.personalAccessToken" />
</div>
<div class="input-field">
<label for="gitCorsProxy" class="active">CORS Proxy (optional)</label>
<input id="gitCorsProxy" type="text" v-model="git.corsProxy" />
</div>
</div>
<a class="btn waves-effect waves-light modal-close" v-show="git.operation=='load'" v-on:click="loadGitData();"><i class="material-icons left">link</i>Load</a>
<a class="btn waves-effect waves-light modal-close" v-show="git.operation=='save'" v-on:click="saveGitData();"><i class="material-icons left">link</i>Save</a>
</div>
<div class="modal-footer">
<a class="modal-close waves-effect waves-green btn-flat">Close</a>
</div>
</div>
</div>
<script type="application/javascript">
// Bind stamboom
var stamboom = new Stamboom();
// DOM bindings
var genea = new Vue({
el: "#genea",
data: {
page: "",
debug: {
dot: "",
gedcom: ""
},
git: {
repository: null,
branch: "main",
personalAccessToken: null,
corsProxy: "https://cors.isomorphic-git.org",
operation: null,
outstandingChanges: false
},
person: {}
},
mounted: function() {
if (window.localStorage.getItem("git")) {
this.git = JSON.parse(window.localStorage.getItem("git"));
}
if (this.isLocalStorage()) {
this.page = "tree";
window.setTimeout(function() {
genea.loadLocalStorage();
}, 200);
} else {
this.page = "start";
}
if (this.isGitConnected()) {
this.page = "tree";
window.setTimeout(function() {
genea.loadGitData();
}, 200);
}
},
watch: {
person: {
handler: function(val, oldVal) {
//if (oldVal.id == val.id) {
const isEqual = (...objects) => objects.every(obj => JSON.stringify(obj) === JSON.stringify(objects[0]));
if (!isEqual(val, oldVal)) {
this.git.outstandingChanges = true;
this.autoSave();
}
//}
},
deep: true
},
git: {
handler: function(val, oldVal) {
window.localStorage.setItem("git", JSON.stringify(this.git));
},
deep: true
}
},
methods: {
autoSave: function() {
// Save changes into local storage
window.clearTimeout(window.autoSaveTimeout);
window.autoSaveTimeout = window.setTimeout(function() {
genea.saveLocalStorage();
}, 1000);
// If git is connected, save changes
if (genea.isGitConnected()) {
// Delay saving until no changes have been made for 10 seconds
clearTimeout(window.autoGitSaveTimeout);
window.autoGitSaveTimeout = setTimeout(function() {
// Let only one window auto save
if (!window.localStorage.getItem("isGitSaving")) {
window.localStorage.setItem("isGitSaving", true);
genea.saveGitData();
} else {
this.git.outstandingChanges = false;
}
}, 10 * 1000);
}
},
loadExample: function(example) {
if (!stamboom.isLoaded || window.confirm("This will clear the family tree you previously had open.")) {
genea.page = "tree";
if (example == "new") {
fetch("sample/empty.ged").then(function(response) {
return response.text();
}).then(function(data) {
stamboom.load(data);
stamboom.select();
});
}
if (example == "gedcom1") {
fetch("sample/gedcom1.ged").then(function(response) {
return response.text();
}).then(function(data) {
stamboom.load(data);
stamboom.select("@I3@");
});
}
if (example == "royal92") {
fetch("sample/royal92.ged").then(function(response) {
return response.text();
}).then(function(data) {
stamboom.load(data);
stamboom.select("@I52@");
});
}
if (example == "pres2020") {
fetch("sample/pres2020.ged").then(function(response) {
return response.text();
}).then(function(data) {
stamboom.load(data);
stamboom.select("@I2185@");
});
}
if (example == "harrypotter") {
fetch("sample/harrypotter.ged").then(function(response) {
return response.text();
}).then(function(data) {
stamboom.load(data);
stamboom.select("@ind00001@");
});
}
}
},
close: function() {
if ((this.isGitConnected() && !this.git.outstandingChanges) || window.confirm("This will clear the family tree. Changes made will not be saved.")) {
// Clear local storage
window.localStorage.clear();
// Go back to start
document.location = document.location.origin + document.location.pathname;
}
return false;
},
loadFile: function(event) {
if (!stamboom.isLoaded || window.confirm("This will clear the family tree you previously had open.")) {
let file = event.srcElement.files[0];
let reader = new FileReader();
reader.readAsText(file);
reader.onload = function() {
genea.page = "tree";
stamboom.load(reader.result);
stamboom.select();
};
reader.onerror = function() {
alert("Error reading selected file.");
};
}
},
saveFile: function() {
const a = document.createElement("a");
const file = new Blob([stamboom.save()], {
type: "text/plain"
});
a.href = URL.createObjectURL(file);
a.download = stamboom.getFilename();
a.click();
URL.revokeObjectURL(a.href);
},
shareFile: function() {
var file = new File([stamboom.save()], stamboom.getFilename(), {
type: "text/plain"
});
var share = {
title: "Family Tree",
text: "Authored using Genea.app; https://www.genea.app/",
files: [file]
}
try {
navigator.share(share);
} catch (e) {
console.log("Error sharing file:", e);
alert("Error sharing file");
}
},
openGitModal: function(operation) {
this.git.operation = operation;
var modal = M.Modal.init(document.querySelector("#modalGit"), {
"onCloseEnd": function() {
M.FloatingActionButton.init(document.querySelectorAll('.fixed-action-btn'));
}
});
modal.open();
},
isGitConnected: function() {
return this.git.repository && this.git.branch && this.git.personalAccessToken;
},
loadGit: function() {
if (!this.isGitConnected()) {
this.openGitModal("load");
} else {
this.loadGitData();
}
},
loadGitData: async function() {
// Load family tree from a git repository
if (!this.isGitConnected()) {
alert("Cannot connect to Git due to a missing Repository URL, Branch, or Personal Access Token.");
return;
}
try {
// Clean state
window.fs = new LightningFS('fs', {
wipe: true
});
window.pfs = window.fs.promises;
// Create local file system
window.dir = "/gedcom";
await pfs.mkdir(dir);
await git.clone({
fs,
http,
dir,
url: this.git.repository,
corsProxy: this.git.corsProxy,
ref: this.git.branch,
singleBranch: true,
depth: 10,
onAuth: () => ({
username: this.git.personalAccessToken
})
});
// Load file
var files = await pfs.readdir(dir);
if (files.includes("genea.ged")) {
var result = new TextDecoder().decode(await pfs.readFile(dir + '/genea.ged'));
genea.page = "tree";
stamboom.load(result);
router();
if (!genea.person.id) {
var selectedPerson = window.localStorage.getItem("selectedPerson");
stamboom.select(selectedPerson);
}
} else {
alert("Cannot load GEDCOM file. Ensure there is a file called 'genea.ged' in the root of the repository.");
}
} catch (e) {
alert(`Error connecting to Git repository or loading GEDCOM file.\n\nMessage: ${e.message}`);
}
},
saveGit: function() {
if (!this.isGitConnected()) {
this.openGitModal("save");
} else {
this.saveGitData();
}
},
saveGitData: async function() {
// Save family tree to a git repository
if (!this.isGitConnected()) {
alert("Cannot connect to Git due to a missing Repository URL, Branch, or Personal Access Token.");
return;
}
try {
// Clean state
window.fs = new LightningFS('fs', {
wipe: true
});
window.pfs = window.fs.promises;
// Create local file system
window.dir = "/gedcom";
await pfs.mkdir(dir);
await git.clone({
fs,
http,
dir,
url: this.git.repository,
corsProxy: this.git.corsProxy,
ref: this.git.branch,
singleBranch: true,
depth: 10,
onAuth: () => ({
username: this.git.personalAccessToken
})
});
// Save file
await pfs.writeFile(`${dir}/genea.ged`, stamboom.save(), "utf8");
// Stage file
await git.add({
fs,
dir,
filepath: "genea.ged"
});
// Commit file
let sha = await git.commit({
fs,
dir,
author: {
name: "Genea.app",
email: "git@genea.app",
},
message: `Updated "genea.ged" at ${new Date().toISOString().replace("T", " ").replace("Z", "")}`
})
console.log("Committed:", sha);
// Push change
let pushResult = await git.push({
fs,
http,
dir,
remote: "origin",
ref: this.git.branch,
onAuth: () => ({
username: this.git.personalAccessToken
}),
});
console.log("Pushed:", pushResult);
window.localStorage.removeItem("isGitSaving");
if (pushResult.ok) {
this.git.outstandingChanges = false;
} else {
alert("Cannot save GEDCOM file.");
}
} catch (e) {
alert(`Error connecting to Git repository or saving GEDCOM file.\n\nMessage: ${e.message}`);
}
},
isLocalStorage: function() {
return window.localStorage.getItem("selectedPerson");
},
isNative: function() {
return window.localStorage.getItem("isNative") == "true";
},
loadLocalStorage: function() {
var data = window.localStorage.getItem("stamboom");
stamboom.load(data);
router();
if (!genea.person.id) {
var selectedPerson = window.localStorage.getItem("selectedPerson");
stamboom.select(selectedPerson);
}
window.addEventListener('storage', function(e) {
if (e.key == "stamboom") {
stamboom.load(e.newValue);
stamboom.select(genea.person.id);
}
});
},
saveLocalStorage: function() {
var data = stamboom.save();
window.localStorage.setItem("stamboom", data);
window.localStorage.setItem("selectedPerson", genea.selectedPerson);
},
debugUpdate: function() {
this.debug.dot = stamboom.debug();
this.debug.gedcom = stamboom.save();
},
isDebug: function() {
if (window.sessionStorage.getItem("isDebug") != "on") {
// This function will detect whether Dev Tools are on, and if so, enable debug mode for the session
var t1 = new Date();
debugger;
if (new Date() - t1 > 200) {
window.sessionStorage.setItem("isDebug", "on");
} else {
window.sessionStorage.setItem("isDebug", "off");
}
}
return (window.sessionStorage.getItem("isDebug") == "on" ? true : false);
}
}
});
function router() {
var url = document.location.hash.split("/");
switch (url[1]) {
case "tree":
case "personaldetails":
case "relations":
genea.page = url[1];
stamboom.select(url[2]);
document.title = `Genea.app - ${genea.person.name}`;
break;
case "native":
window.localStorage.setItem("isNative", "true");
// Forward to start
genea.page = "start";
break;
case "debug":
genea.page = "debug";
genea.debugUpdate();
break;
default:
// Unknown link, do nothing
genea.page = "start";
document.title = `Genea.app`;
break;
}
}
window.addEventListener("hashchange", router);
router();
</script>
<!-- Dependencies -->
<script type="application/javascript" src="resources/materialize/js/materialize.min.js"></script>
<script type="application/javascript">
M.AutoInit();
M.Sidenav.init(document.querySelector('.sidenav'));
document.addEventListener("click", function(e) {
if (e.target && e.target.id == "search") {
// (Re)populate data in Search autocomplete any time the field is activated
M.Autocomplete.init(document.querySelector('#search'), {
data: (function() {
var persons = stamboom.getPersons();
persons = Object.fromEntries(persons.map(person => [person.caption]));
return persons;
})(),
onAutocomplete: function(selection) {
var person = stamboom.getPersons().find(person => person.caption == selection);
if (person && person.id) {
genea.page = 'tree';
stamboom.select(person.id);
} else {
alert("Person not found.");
}
this.el.value = "";
}
});
}
});
</script>
</body>
</html>