Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/delibero.git

Injecting JavaScript file; refactored JS code to eliminate minor duplication.

Author Dave Jarvis <email>
Date 2014-12-05 19:24:15 GMT-0800
Commit 3b73e737d2cefc9e5703df68f145e62f2eae522d
Parent 5a1f820
xml/.gitignore
-hColumns/
-wysiwyg
+editor
xml/account.xml
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="common.xsl"?>
-<account>
- <implications>
- <header>
- <implication>Implication</implication>
- <policy-title>Proposal</policy-title>
- <timestamp>Date</timestamp>
- <state>State</state>
- </header>
- <entry>
- <implication>
- Surveillance data is susceptible to theft.
- </implication>
- <policy><xref id="3">Digital Freedom Act</xref></policy>
- <timestamp><date>Jun 15, 2014</date><time>14:32:05</time></timestamp>
- <state>Accepted</state>
- </entry>
- <entry>
- <implication>
- Data retention can overturn the presumption of innocence.
- </implication>
- <policy><xref id="3">Digital Freedom Act</xref></policy>
- <timestamp><date>Jun 15, 2014</date><time>16:12:50</time></timestamp>
- <state>Accepted</state>
- </entry>
- <entry>
- <implication>
- Ensure anonymity when seeking or communicating sensitive
- health-related information.
- </implication>
- <policy><xref id="3">Digital Freedom Act</xref></policy>
- <timestamp><date>Jun 15, 2014</date><time>18:21:22</time></timestamp>
- <state>Pending</state>
- </entry>
- <entry>
- <implication>
- Improve the mental and physical health of citizens.
- </implication>
- <policy><xref id="3">Digital Freedom Act</xref></policy>
- <timestamp><date>Jun 16, 2014</date><time>09:15:38</time></timestamp>
- <state>Conjecture</state>
- </entry>
- </implications>
+<policy>
+ <account>
+ <implications>
+ <header>
+ <implication>Implication</implication>
+ <policy-title>Proposal</policy-title>
+ <timestamp>Date</timestamp>
+ <state>State</state>
+ </header>
+ <entry>
+ <implication>
+ Surveillance data is susceptible to theft.
+ </implication>
+ <policy><xref id="3">Digital Freedom Act</xref></policy>
+ <timestamp><date>Jun 15, 2014</date><time>14:32:05</time></timestamp>
+ <state>Accepted</state>
+ </entry>
+ <entry>
+ <implication>
+ Data retention can overturn the presumption of innocence.
+ </implication>
+ <policy><xref id="3">Digital Freedom Act</xref></policy>
+ <timestamp><date>Jun 15, 2014</date><time>16:12:50</time></timestamp>
+ <state>Accepted</state>
+ </entry>
+ <entry>
+ <implication>
+ Ensure anonymity when seeking or communicating sensitive
+ health-related information.
+ </implication>
+ <policy><xref id="3">Digital Freedom Act</xref></policy>
+ <timestamp><date>Jun 15, 2014</date><time>18:21:22</time></timestamp>
+ <state>Pending</state>
+ </entry>
+ <entry>
+ <implication>
+ Improve the mental and physical health of citizens.
+ </implication>
+ <policy><xref id="3">Digital Freedom Act</xref></policy>
+ <timestamp><date>Jun 16, 2014</date><time>09:15:38</time></timestamp>
+ <state>Conjecture</state>
+ </entry>
+ </implications>
+ </account>
<related>
<flags id="1" />
</related>
-</account>
+</policy>
xml/common.xsl
<xsl:include href="xsl/chart.xsl"/>
<xsl:include href="xsl/tags.xsl"/>
-<xsl:include href="xsl/support.xsl"/>
<xsl:output
<script type="text/javascript">
-var file = location.pathname.split( "/" ).pop();
-var link = document.createElement( "link" );
+function inject( type ) {
+ var file = location.pathname.split( "/" ).pop();
+ var src = type + "/" + file.substr( 0, file.lastIndexOf( "." ) ) + "." + type;
+ var tag, link;
-link.href = "css/" + file.substr( 0, file.lastIndexOf( "." ) ) + ".css";
-link.type = "text/css";
-link.rel = "stylesheet";
-link.media = "all";
+ if( type === "css" ) {
+ var link = document.createElement( "link" );
-document.getElementsByTagName( "head" )[0].appendChild( link );
+ link.href = src;
+ link.type = "text/" + type;
+ link.rel = "stylesheet";
+ link.media = "all";
+
+ tag = "head";
+ }
+ else if( type === "js" ) {
+ var link = document.createElement( "script" );
+
+ link.src = src;
+ link.type = "text/javascript";
+
+ tag = "body";
+ }
+
+ document.getElementsByTagName( tag )[0].appendChild( link );
+}
+
+inject( "css" );
</script>
</head>
<body>
<xsl:apply-templates/>
+ <script type="text/javascript">
+ inject( "js" );
+ </script>
</body>
</html>
xml/css/discuss.css
font-family: 'Montserrat', Helvetica, sans-serif;
font-weight: bold;
- text-align: middle;
content: "Implications";
xml/css/summary.css
font-size: 1.5em;
font-weight: bold;
- text-align: middle;
}
xml/css/tags.css
div.breadcrumb, div.toolbar {
background: linear-gradient(#f0f0f0, #d8d8d8);
- background: -webkit-linear-gradient(#f0f0f0, #d8d8d8);
- background: -o-linear-gradient(#f0f0f0, #d8d8d8);
- background: -moz-linear-gradient(#f0f0f0, #d8d8d8);
}
xml/js/account.js
xml/js/discuss.js
xml/js/hypothesis.js
xml/js/index.js
xml/js/proposal.js
xml/js/resources.js
xml/js/summary.js
xml/js/support.js
xml/js/tags.js
Delta 75 lines added, 58 lines removed, 17-line increase