This repository has been archived by the owner on Dec 31, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
111 lines (101 loc) · 2.64 KB
/
demo.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
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
<script src="../src/prettify.js"></script>
<script src="../src/lang-css.js"></script>
<style type="text/css">
body { margin: 0; padding: 0; }
pre { margin: 0; }
#container { width: 40em; display: inline-block; }
</style>
<script type="text/javascript">
/**
* Call out to the parent so that it can resize the iframe once this
* document's body is loaded.
* @param {string} theme
*/
function adjustHeightInParent(theme) {
if (parent !== window) {
try {
var div = document.getElementById('container');
parent.adjustChildIframeSize(theme, div.offsetWidth, div.offsetHeight);
} catch (ex) {
// Can happen when this page is opened in its own tab.
}
} else {
// redirect to main page if this page is loaded directly
window.location = "./index.html";
}
}
/**
* Theme name is specified by iframe in which the page is loaded
* @return {string}
*/
function getThemeName() {
// theme is named in the query part of the URL
//var theme = decodeURIComponent(document.location.search.substring(1));
// theme is named in the "name" property of the embedded iframe
var theme = window.frameElement && window.frameElement.getAttribute("name");
return theme ? theme : 'default';
}
/**
* Load the necessary CSS
* @param {string} theme
*/
function loadTheme(theme) {
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = theme === 'default' ? '../src/prettify.css' : theme + '.css';
document.getElementsByTagName('head')[0].appendChild(link);
}
/**
* Called on page load.
* This page displays some code styled using theme specified.
*/
function onLoadFcn() {
// syntax highlight
PR.prettyPrint();
// call to parent we're embedded into
var theme = getThemeName();
adjustHeightInParent(theme);
}
(function () {
// Load the stylesheet that we're demoing.
var themeName = getThemeName();
document.title = 'Theme ' + themeName;
loadTheme(themeName);
})();
</script>
</head>
<body onload="onLoadFcn();">
<div id="container">
<pre class="prettyprint lang-html linenums">
<!doctype html>
<html>
<head>
<title>HTML Test</title>
<script type="text/javascript">
// Say hello world until the user starts questioning
// the meaningfulness of their existence.
function helloWorld(world) {
for (var i = 42; --i >= 0;) {
alert('Hello ' + String(world));
}
}
</script>
<style type="text/css">
p { color: pink }
b { color: blue }
u { color: "umber" }
</style>
</head>
<body>
<h1>Hello world!</h1>
</body>
</html>
</pre>
</div>
</body>
</html>