-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.xsl
138 lines (126 loc) · 4.38 KB
/
index.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
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<!--
Varibables that are used in this stylesheet
-->
<!-- File where BTCR elements that will replace those in the input file -->
<xsl:variable name="home" select="document('btcr.html',/html)" />
<!-- The location of the coinbin repository -->
<xsl:variable name="coinbin" select="'external/coinbin/'" />
<!--
Preparing the document
-->
<!-- Set the output type to html -->
<xsl:output method="html"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd"
indent="yes"/>
<!--
Copy all the lines from input which should be the file
external/coinbin/index.html
-->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<!--
Modify the attributes so that they point to the resources in
the git submodule, located in the external/coinbin directory
-->
<!-- Modify the link href attributes -->
<xsl:template match="link/@href">
<xsl:attribute name="href">
<xsl:value-of select="concat($coinbin,.)"/>
</xsl:attribute>
</xsl:template>
<!-- Modify the script src attributes -->
<xsl:template match="script/@src">
<xsl:attribute name="src">
<xsl:value-of select="concat($coinbin,.)"/>
</xsl:attribute>
</xsl:template>
<!-- Modify the image href attributes -->
<xsl:template match="img/@src">
<xsl:attribute name="src">
<xsl:value-of select="concat($coinbin,.)"/>
</xsl:attribute>
</xsl:template>
<!--
in valid HTML you don't need to specify the type if it is javascript so
here we remove the 'type' attribute from script tag
-->
<xsl:template match="script/@type" />
<!--
This replaces the existing home div from the input with that
from the btcr.html file
-->
<!-- Replace the title -->
<xsl:template match="//head/title">
<xsl:copy-of select="$home//head/title"/>
</xsl:template>
<!-- Insert the script tags -->
<xsl:template match="//head">
<xsl:apply-templates />
<xsl:copy-of select="$home//head/script" />
</xsl:template>
<!-- replace the Home tab -->
<xsl:template match="//div[@id='home']">
<xsl:copy-of select="$home//body/div[@id='home']" />
</xsl:template>
<!-- replace the home button -->
<xsl:template match="//a[@id='homeBtn']">
<xsl:copy-of select="$home//body/a[@id='homeBtn']" />
</xsl:template>
<!-- replace the About tab -->
<xsl:template match="//div[@id='about']">
<xsl:copy-of select="$home//body/div[@id='about']" />
</xsl:template>
<!-- Replace links on footer -->
<xsl:template match="//a[@href='https://github.com/OutCast3k/coinbin/']/@href">
<xsl:attribute name="href">
<xsl:value-of select="'https://github.com/WebOfTrustInfo/btcr-tx-playground.github.io'"/>
</xsl:attribute>
</xsl:template>
<!--
Change default settings
-->
<!-- Change deafault wallet type -->
<xsl:template match="//input[@id=walletSegwit]/@checked" />
<xsl:template match="//input[@id='walletSegwitp2sh' or @id='walletSegwitBech32']">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:attribute name="disabled">disabled</xsl:attribute>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<!-- Change default address type -->
<xsl:template match="//button[@id='walletToBtn']/text()">Legacy</xsl:template>
<!-- Sort the network options in settings tab so that Bitcoin (Testnet) is first -->
<xsl:template match="//select[@id='coinjs_coin']">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:apply-templates select="option">
<xsl:sort select="substring(@value,1,1)" data-type="text" order="ascending" />
<xsl:sort select="substring(@value,9,1)" data-type="text" order="descending" />
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<!-- Insert new DID tab and link -->
<xsl:template match="//ul[@class='nav navbar-nav']/li[@class='dropdown']/ul">
<xsl:copy select="ul">
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()"/>
<li>
<xsl:copy-of select="$home//body/a[@id='btnNewDid']"/>
</li>
</xsl:copy>
</xsl:template>
<xsl:template match="//div[@id='content']/div[@class='tab-content']">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()"/>
<xsl:copy-of select="$home//body/div[@id='newDid']" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>