-
Notifications
You must be signed in to change notification settings - Fork 0
/
ts-debugger.xsl
155 lines (149 loc) · 4.42 KB
/
ts-debugger.xsl
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ts="http://tokenscript.org/2020/06/tokenscript"
xmlns:ethereum="urn:ethereum:constantinople"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:html="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="xsl ts ethereum xsi">
<xsl:output method="html" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/|@*|node()">
<xsl:apply-templates select="@*|node()"/>
</xsl:template>
<xsl:template match="/ts:token">
<html>
<head>
<title>TokenScript Debugger</title>
<h3>Debug your TokenScript XML by refreshing the page</h3>
<!--script src="ts-debugger.js" type="text/javascript" charset="utf-8">/* */</script-->
<script type="text/javascript" charset="utf-8">
<![CDATA[
function loadIframe(){
var iframes = document.getElementsByTagName("iframe");
var div = document.getElementsByClassName("iframeContent");
for(var i=0; i<iframes.length; i++){
var iframe = iframes[i];
/*var textContent = iframe.textContent;
var wrapper = document.createElement('div');
wrapper.innerHTML = textContent;
iframeContentDocument = iframe.contentWindow.document;
iframeContentDocument.write(wrapper.innerHTML);
iframe.textContent = "";
*/
var doc = iframe.contentWindow.document;
doc.open();
doc.write(div[i].innerHTML);
doc.close();
}
}
function init(){
var coll = document.getElementsByClassName("collapsible");
for (var i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() {
this.classList.toggle("active");
var content = this.nextElementSibling;
if (content.style.display === "block") {
content.style.display = "none";
} else {
content.style.display = "block";
}
});
}
}
]]>
</script>
<style>
.collapsible {
background-color: #777;
color: white;
cursor: pointer;
padding: 10px;
width: 90%;
border: none;
text-align: left;
outline: none;
font-size: 15px;
}
.cardContiner {
border: solid #777;
width: 90%;
margin-bottom: 1em;
}
.noContent {
text-align: center;
margin-top: 50;
}
.iframe {
/* border: 1px solid #777; */
}
table.view, th {
width: 98%;
border: 1px solid #777;
}
table.view th {
text-align: left;
font: caption;
padding-left: 5px;
}
</style>
</head>
<body onload="init();loadIframe();">
<xsl:apply-templates select="@*|node()"/>
</body>
</html>
</xsl:template>
<xsl:template match="ts:card[ts:item-view or ts:view]">
<!--h5>TS input details: <xsl:value-of select="concat(local-name(.), ' for ', local-name(..), ' having type as ', ../@type )"/></h5-->
<button type="button" class="collapsible">
Card Details:
<xsl:for-each select="@*">
<xsl:text>@</xsl:text><xsl:value-of select="local-name(.)"/>: <xsl:value-of select="."/>
<xsl:text> </xsl:text>
</xsl:for-each>
</button>
<div class="cardContiner">
<xsl:for-each select="ts:item-view | ts:view">
<div class="iframeContent" style="display: none;">
<xsl:for-each select="html:style">
<style type="text/css">
<xsl:value-of select="."/>
</style>
</xsl:for-each>
<xsl:for-each select="html:script">
<script type="text/javascript">
<xsl:value-of select="."/>
</script>
</xsl:for-each>
<xsl:choose>
<xsl:when test="html:body">
<xsl:for-each select="html:body">
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<h3 style="text-align: center;margin-top: 50;">No HTML Content</h3>
</xsl:otherwise>
</xsl:choose>
</div>
<table class="view">
<tbody>
<tr><th><xsl:value-of select="local-name(.)"/></th></tr>
<tr>
<td>
<iframe src="about:blank" height="150" width="100%" title="Iframe" class="iframe">
<xsl:attribute name="height">
<xsl:choose>
<xsl:when test="self::ts:item-view">150</xsl:when>
<xsl:otherwise>300</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</iframe>
</td>
</tr>
</tbody>
</table>
</xsl:for-each>
</div>
</xsl:template>
</xsl:transform>