Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _includes/feed.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ section: smartContract
render = (data) => {
let html = '';
for(let network of data["{{stub}}"].networks) {
html += `<h2 id="${network.name}">${network.name}</h2>`;
html += `<h2 id="${network.name}">${network.name} <a class="anchor" href="#${network.name}"><img src="/images/link.svg" alt="Link to this section"></a></h2>`;

let proxyList = '';
for(let proxy of network.proxies) {
Expand Down
87 changes: 50 additions & 37 deletions _includes/main.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -54,35 +54,7 @@
gtag("config", "UA-128878871-16");
</script>

<script>
// Detect highlighting
let lastEvent = 0;
const checkForHighlight = (event) => {
try {
const selection = window.getSelection().toString();
// Rate limit to 30s
if(selection && Date.now() > (lastEvent + 1000 * 30)) {
gtag('event','select_content',{'event_category': 'docs-engagement', label: selection.substring(0,30)});
lastEvent = Date.now();
}
} catch (e) {}
}
document.addEventListener('mouseup',checkForHighlight);

// Track remix deployments
document.addEventListener('DOMContentLoaded', () => {
[...document.getElementsByTagName('a')]
.filter(x => x.href.startsWith('https://remix.ethereum.org/') && x.href.length > 27 )
.map(x => {x.addEventListener('click',(event) => {
console.log('sending to gtag!');
gtag('event','deploy-to-remix',{event_category:'docs-engagement'});
});});
[...document.getElementsByClassName('copy-to-clipboard-button')]
.map(x => {x.addEventListener('click',(event) => {
gtag('event','copy-code',{event_category:'docs-engagement'});
});});
})
</script>



</head>
Expand Down Expand Up @@ -275,17 +247,58 @@
</div>
</footer>


<script>
var links = document.links;
for (var i = 0, linksLength = links.length; i < linksLength; i++) {
if(!links[i].href.startsWith("javascript:")) {
if (links[i].hostname != window.location.hostname) {
links[i].target = '_blank';
}

document.addEventListener('DOMContentLoaded', () => {
// Detect highlighting
let lastEvent = 0;
const checkForHighlight = (event) => {
try {
const selection = window.getSelection().toString();
// Rate limit to 30s
if(selection && Date.now() > (lastEvent + 1000 * 30)) {
gtag('event','select_content',{'event_category': 'docs-engagement', label: selection.substring(0,30)});
lastEvent = Date.now();
}
} catch (e) {}
}
}
</script>
document.addEventListener('mouseup',checkForHighlight);

// Track remix deployments
[...document.getElementsByTagName('a')]
.filter(x => x.href.startsWith('https://remix.ethereum.org/') && x.href.length > 27 )
.map(x => {x.addEventListener('click',(event) => {
gtag('event','deploy-to-remix',{event_category:'docs-engagement'});
});});
[...document.getElementsByClassName('copy-to-clipboard-button')]
.map(x => {x.addEventListener('click',(event) => {
gtag('event','copy-code',{event_category:'docs-engagement'});
});});

// Open all external links in a blank context
const links = document.links;
for (var i = 0, linksLength = links.length; i < linksLength; i++) {
if(!links[i].href.startsWith("javascript:")) {
if (links[i].hostname != window.location.hostname) {
links[i].target = '_blank';
}
}
}

// Add header anchor tags
const headers = document.querySelectorAll('.article > h1:not(.page-title),.article > h2,.article > h3');
[...headers].map(header => {
const link = document.createElement('a');
link.href = `#${header.id}`;
link.classList.add('anchor');
link.innerHTML = '<img src="/images/link.svg" alt="Link to this section">';
header.appendChild(link);
})
})


</script>
</body>


Expand Down
2 changes: 1 addition & 1 deletion _includes/nodes.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ layout: ./main.liquid
{% endfor %}

</navigation>
<div>
<div class="article">
<!--{% include banner %}-->
{% if title %}
<h1 class="page-title">{{title}}</h1>
Expand Down
11 changes: 11 additions & 0 deletions _src/docs.css
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ a:hover,
#nav-container .tab a:hover {
color: #375bd2;
}
a.anchor {
display: none;
}
h1:hover .anchor,
h2:hover .anchor,
h3:hover .anchor {
display: inline;
}
a.anchor img {
margin: 0 0 0 8px;
}

/** Side navigation */
.nav-content {
Expand Down
1 change: 1 addition & 0 deletions _src/images/link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.