Repository navigation
Expand file tree
/
Copy pathcss_wiki_test.html
More file actions
48 lines (32 loc) · 2.09 KB
/
Copy pathcss_wiki_test.html
File metadata and controls
48 lines (32 loc) · 2.09 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
<!DOCTYPE html>
<!-- testing purpose file, used for trying to print a correctly formatted wikipedia page -->
<html>
<head> <!-- Tout ce qui est pas dans le contenu -->
<title> game setup </title> <!-- Titre de l'onglet -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"> </script>
<link rel="stylesheet" href="//en.wikipedia.org/w/load.php?modules=mediawiki.legacy.commonPrint,shared|mediawiki.skinning.elements|mediawiki.skinning.content|mediawiki.skinning.interface|skins.vector.styles|site|mediawiki.skinning.content.parsoid|ext.cite.style&only=styles&skin=vector"/>
//en.wikipedia.org/w/load.php?debug=false&lang=en&modules=mediawiki.legacy.commonPrint,shared|skins.vector.styles&only=styles&skin=vector&*"
</head>
<body style="background-color:white;">
<h1 id="wiki-title">MiniWiki</h1>
<div id="content"></div>
<script>
var contentElem = document.getElementById('content');
var stylesheetElem = document.getElementById('style');
var titleElem = document.getElementById('wiki-title');
var url = 'https://en.wikipedia.org:443/api/rest_v1/page/html/Ancient_Egypt';
$.ajax(url).then(function (data) {
var $content = $(contentElem).empty();
// $(stylesheetElem).remove();
var doc = (new DOMParser()).parseFromString(data, 'text/html');
// stylesheetElem = doc.querySelector('head link[rel="stylesheet"]');
$('head').append(stylesheetElem);
$(titleElem).text(doc.title.replace(/^User:Cscott\//, '').replace(/_/g, ' '));
Array.from(doc.body.attributes).forEach(function (attr) {
$content.attr(attr.name, attr.value);
});
$content.append(Array.from(doc.body.children));
});
</script>
</body>
</html>