-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxml_generator.htm
142 lines (94 loc) · 4.16 KB
/
xml_generator.htm
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
<html>
<head>
<title>XML Generator</title>
<script async src="https://cse.google.com/cse.js?cx=003736524176309227229:whsyk9ptpff"></script>
<script src="./alh_common/alh_sprintf.js?v=278"></script>
<script src="./alh_common/alh_common.js?v=278"></script>
<script src="hart-ged.js?v=278"></script>
<script src="ged_read.js?v=278"></script>
<script src="bk_data.js?v=278"></script>
<script>
var iptr;
var fptr;
var cptr;
var pptr;
var notes;
var show_pages = true;
//var show_all = true;
//var single_record = "@I6@";
var ged_objects;
//show_all = true;
read_ged_file();
</script>
<body>
<h3>Click Below to save JSON</h3>
<br><button onclick="do_save();">Save JSON</button>
<script>
iout = 0;
date = new Date().toISOString().substr(0, 10);
base_pages = ["families.htm", "resources.htm"];
person_pages = ["ged_person.htm" , "ancestors.htm", "descendants.htm"];
sxml = `<?xml version="1.0" encoding="UTF-8"?>\n`;
sxml += `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n`;
sxml += sprintf(` <url><loc>https://ourfolkgen.com/</loc><lastmod>%s</lastmod></url>\n`, date);
sxml += sprintf(` <url><loc>https://ourfolkgen.com/index.html</loc><lastmod>%s</lastmod></url>\n`, date);
spages = "";
for (ip = 0; ip < base_pages.length; ip++)
{
sxml += sprintf(` <url><loc>https://ourfolkgen.com/ourfolk/%s</loc><lastmod>%s</lastmod></url>\n`, base_pages[ip], date);
}
spages = "<table><tr><th>ID</th><th>Name</th>\n";
for (ip = 0; ip < person_pages.length; ip++)
{
spages += sprintf("<th>%s</th>", person_pages[ip]);
}
spages += "</tr>\n";
var keys = Object.keys(ged_objects);
for (var ik = 0; ik < keys.length; ik++)
{
key = keys[ik];
//console.log("ik: %s %s", ik, key);
if (key.substr(0,2) == "@F")
break;
if (key.substr(0,2) != "@I")
continue;
iptr = get_person(key);
spages += sprintf("<tr><td>%s</td><td>%s</td>\n", iptr.id, iptr.full_name);
for (ip = 0; ip < person_pages.length; ip++)
{
sxml += sprintf(` <url><loc>https://ourfolkgen.com/ourfolk/%s?id=%s</loc><lastmod>%s</lastmod></url>\n`,
person_pages[ip], iptr.id, date);
spages += sprintf("<td><a href='%s?id=%s'>%s</a></td>",
person_pages[ip], iptr.id, person_pages[ip]);
}
spages += "</tr>\n";
}
spages += "</table>\n";
sxml += `</urlset>\n`;
document.writeln(sprintf("<h3>SXML Created: %s bytes</h3>", sxml.length));
document.writeln("<br><br>" + spages);
function do_save()
{
save_xml_data(sxml, "sitemap.xml")
}
function save_xml_data(sxml, file_name)
{
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
console.log("sxml.length: %s", sxml.length);
//bytes = new TextEncoder().encode(sxml);
blob = new Blob([sxml], {
type: "application/txt;charset=utf-8"});
//var blob = new Blob([sxml], {type: "text/plain;charset=utf-8"});
var url = window.URL.createObjectURL(blob);
a.href = url;
a.download = file_name;
a.click();
window.URL.revokeObjectURL(url);
document.writeln(sprintf("<h3>%s Saved: %s bytes</h3>", file_name, sxml.length));
}
</script>
</body>
</head>
</html>