Skip to content

Commit 731e464

Browse files
authored
Merge pull request #187 from Code-dot-mil/support-back
Support back
2 parents e29eda1 + 32b3e23 commit 731e464

2 files changed

Lines changed: 61 additions & 30 deletions

File tree

_pages/getting-started.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ tree-nodes:
5555
- text: "No"
5656
link: contract
5757

58-
- title: ""
58+
- title: Contract Complete
5959
id: contract-complete
6060
content: |
6161
Since the project has been completed, you should have received final delivery. What's key now is how that delivery was made: did you receive all of the source code, including any testing resources, build artifacts, documentation, etc? Or did you only receive a final built product?
@@ -68,7 +68,7 @@ tree-nodes:
6868
6969
<a href='/how-to-open-source.html' class='usa-button'>How to Open Source</a>
7070
71-
- title: Two Options
71+
- title: Contract In-progress
7272
id: contract
7373
content: |
7474
You should **review your contract** to see how delivery of the final product is expected. What we'd like to see is that delivery will be of all source code, development operations and testing code and artifacts, build code and artifacts, etc. If the contractor is only expected to deliver a working product then you might not get access to the code at all.
@@ -79,7 +79,7 @@ tree-nodes:
7979
8080
There are a lot of possibilities within those options, however. We encourage you to read our [frequently asked questions](/frequently-asked-questions.html) and then reach out to us by email at [{{site.email}}](mailto:{{site.email}}) to continue the conversation.
8181
82-
- title: ""
82+
- title: Gov Only
8383
id: gov-only
8484
content: |
8585
Awesome! We're really happy to hear about all the great things that the DoD is doing on a regular basis. You may not be aware, but most code produced by a U.S. federal employee within the scope of their employment does not have copyright protections in the U.S. and certain foreign jurisdictions. In the U.S., creative works (like code) without copyright protections are sometimes referred to as "public domain." Not all countries recognize the concept of public domain, and many countries actually recognize copyright protections for code written by U.S. federal employees.
@@ -92,7 +92,7 @@ tree-nodes:
9292
9393
<a href='/how-to-open-source.html' class='usa-button'>How to Open Source</a>
9494
95-
- title: ""
95+
- title: Gov and Contractor
9696
id: mixed-code
9797
content: |
9898
Great! We understand that partnering with the private sector is how most project development happens in the DoD. You may still be able to open source the resulting code for the project depending on the U.S. federal government's data rights in the contract! The key is to **identify any pieces of the code that are proprietary to the contractor or otherwise restricted from public disclosure**. If there are such pieces then you may need to segment those so that you don't violate the license terms in the contract. That said, if you have Unlimited Rights in segregable portions of the code, you should be able to follow the Code.mil guideline for open sourcing that code!
@@ -105,7 +105,7 @@ tree-nodes:
105105
106106
<a href='/how-to-open-source.html' class='usa-button'>How to Open Source</a>
107107
108-
- title: ""
108+
- title: Not yet
109109
id: info-only
110110
content: |
111111
That's great! We're glad you are interested in open source. You may want to start by reading our [Why Open Source](/why-open-source.html) page and some of the [Frequently Asked Questions](/frequently-asked-questions.html). You can also explore information on the OMB policy itself over on the [Code.gov](https://code.gov) website.

assets/js/main.js

Lines changed: 56 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -82,46 +82,77 @@
8282
}
8383

8484
var nodes = find('.tree-node', tree);
85-
nodes[0].classList.add('active');
85+
var hashHistory = [];
8686

87+
// Pull tree history from hash
88+
function updateHashHistory() {
89+
hashHistory = window.location.hash.replace('#','').split('!');
90+
if (hashHistory.length == 1) {
91+
hashHistory = ["tree-node-start"];
92+
}
93+
}
94+
95+
// Update tree to reflect hash state
96+
function renderTree() {
97+
updateHashHistory();
98+
var treeNodes = nodes.filter(function(n) {
99+
return n.classList && n.classList.contains('tree-node');
100+
});
101+
for (var i = 0; i < treeNodes.length; i++) {
102+
var node = treeNodes[i];
103+
if (hashHistory.includes(node.getAttribute('id'))) {
104+
node.classList.add('active');
105+
} else {
106+
node.classList.remove('active');
107+
}
108+
var childNodes = Array.prototype.concat.apply([], node.childNodes);
109+
var childNode = childNodes.filter(function(n) {
110+
return n.classList && n.classList.contains('tree-node-options');
111+
})[0];
112+
if (!childNode) {
113+
continue;
114+
}
115+
if (hashHistory[hashHistory.length - 1] == node.getAttribute('id')) {
116+
childNode.classList.remove('hidden');
117+
} else {
118+
childNode.classList.add('hidden');
119+
}
120+
}
121+
if (hashHistory.length > 1) {
122+
var node = document.getElementById(hashHistory[hashHistory.length - 1]);
123+
node.scrollIntoView({
124+
behavior: "smooth"
125+
});
126+
}
127+
}
128+
129+
// Render tree as it is now
130+
renderTree();
131+
132+
// Re-render tree each time the hash changes
133+
window.addEventListener("hashchange", function() {
134+
renderTree();
135+
});
136+
137+
// Update hash each time the tree is clicked
87138
tree.addEventListener('click', function treeNodeButtonClick(e) {
88139
if (!e.target.classList.contains('tree-link')) {
89140
return;
90141
}
91-
92142
e.preventDefault();
93-
94143
var node = nodes.filter(function(n) {
95144
return n.getAttribute('id') === e.target.getAttribute('href').substr(1);
96145
})[0];
97146
if (node) {
98-
node.classList.add('active');
99-
node.scrollIntoView({
100-
behavior: "smooth"
101-
});
102-
var answer = document.createElement('p');
103-
answer.classList.add('tree-node-answer');
104-
answer.innerText = e.target.innerText;
105-
e.target.parentNode.parentNode.appendChild(answer);
106-
e.target.parentNode.classList.add('hidden');
147+
hashHistory.push(node.getAttribute('id'));
148+
window.location.hash = hashHistory.join("!");
107149
}
108150
});
109151

152+
// support reset
110153
tree.querySelector('a.tree-reset').addEventListener('click', function treeNodeButtonClick(e) {
111154
e.preventDefault();
112-
nodes.forEach(function(n, i) {
113-
if (i === 0) {
114-
return;
115-
}
116-
n.classList.remove('active');
117-
});
118-
find('.tree-node-options', tree).forEach(function(n) {
119-
n.classList.remove('hidden');
120-
});
121-
find('.tree-node-answer', tree).forEach(function(n) {
122-
n.parentNode.removeChild(n);
123-
});
155+
window.location.hash = "";
124156
});
125157
})();
126-
127158
})();

0 commit comments

Comments
 (0)