Repository navigation
Expand file tree
/
Copy pathpermalink.html
More file actions
69 lines (56 loc) · 2.23 KB
/
Copy pathpermalink.html
File metadata and controls
69 lines (56 loc) · 2.23 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
62
63
64
65
66
67
68
69
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>sphinx-needs permalink</title>
<script>
function loadJSON(filename, callback) {
var xobj = new XMLHttpRequest();
xobj.overrideMimeType('application/json');
xobj.open('GET', filename, true);
xobj.onreadystatechange = function () {
if (xobj.readyState == 4 && xobj.status == '200') {
callback(xobj.responseText);
}
};
xobj.send(null);
}
function main() {
loadJSON('needs.json', function (response) {
const needs = JSON.parse(response);
const current_version = needs['current_version'];
const versions = needs['versions'];
const version = versions[current_version];
const needs_obj = version['needs'];
const id = getParameterByName('id');
var pathname = new URL(window.location.href).pathname;
pathname = pathname.substring(0, pathname.lastIndexOf('permalink.html'));
const keys = Object.keys(needs_obj);
var docname = 'index';
keys.forEach((key, index) => {
if (key === id) {
const need = needs_obj[key];
docname = need['docname'];
return;
}
});
window.location.replace(pathname + docname + '.html#' + id);
});
}
function getParameterByName(name, url = window.location.href) {
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
window.addEventListener('DOMContentLoaded', main);
</script>
</head>
<body>
<h1>Searching, Please Wait...</h1>
</body>
</html>