-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
56 lines (47 loc) · 1.84 KB
/
script.js
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
var app = angular.module('surfacearea', []);
app.controller('myCtrl', function($scope) {
$scope.list = ['a-propos/', 'services/'];
$scope.d2lAddress = "https://maxime-guinard.fr/"
$scope.lastMod = "2023-05-31";
$scope.xml = {
header: '<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
footer: "</urlset>",
beginLine: "<url><loc>",
endLinea: "</loc><lastmod>",
endLineb: "</lastmod><changefreq>weekly</changefreq><priority>0.1</priority></url>"
};
$scope.appTitle = "XML Sitemap Generator";
});
function selectText(xmlOutput) {
if (document.selection) {
var range = document.body.createTextRange();
range.moveToElementText(document.getElementById(xmlOutput));
range.select();
} else if (window.getSelection) {
var range = document.createRange();
range.selectNode(document.getElementById(xmlOutput));
window.getSelection().addRange(range);
}
}
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
// Start file download.
document.getElementById("dwn-btn-txt").addEventListener("click", function() {
// Generate download of hello.txt file with some content
var text = document.getElementById("xmlOutput").textContent;
var filename = "sitemap.txt";
download(filename, text);
}, false);
document.getElementById("dwn-btn-xml").addEventListener("click", function() {
// Generate download of hello.txt file with some content
var text = document.getElementById("xmlOutput").textContent;
var filename = "sitemap.xml";
download(filename, text);
}, false);