-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
68 lines (52 loc) · 1.6 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
<!doctype html>
<html>
<head>
<meta name="asq-elements" content="width=device-width, initial-scale=1, user-scalable=no">
<title>ASQ-JS-FUNCTION-BODY | Demo</title>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link href="asq-js-function-body.html" rel="import">
<link href="../asq-stem/asq-stem.html" rel="import">
<style shim-shadowdom>
body {
font-family: RobotoDraft, 'Helvetica Neue', Helvetica, Arial;
font-size: 14px;
margin: 0;
padding: 24px;
-webkit-tap-highlight-color: rgba(0,0,0,0);
-webkit-touch-callout: none;
}
section {
padding: 20px 0;
}
section > div {
padding: 14px;
font-size: 16px;
}
</style>
</head>
<body>
<section>
<asq-js-function-body functionName="wrap(str, tagName)" question="wrap('hello World', 'div');">
<asq-stem><h4>Implement a function that wraps a given string with an HTML tag:</h4></asq-stem>
</asq-js-function-body>
<script>
var x = document.querySelector('asq-js-function-body');
window.onmessage = function(e){
if (typeof e.data.role == "string" && e.data.role.length > 0) {
var allAsqElements = document.querySelectorAll('html /deep/ *');
allAsqElements = Array.prototype.slice.call(allAsqElements).filter(function(el) {
return isASQEl(el);
});
//set role for every asq-element in this page
allAsqElements.forEach(function(elem, index) {
elem.role = e.data.role;
});
}
function isASQEl(el) {
return el.localName.indexOf('asq-') != -1;
}
};
</script>
</template>
</body>
</html>