Line 3: | Line 3: | ||
<head> | <head> | ||
− | < | + | <div class="container logbook neat" id="log-container"> |
+ | <h2>Log book</h2> | ||
+ | <p>Log book is recorded weekly, you may find the significant breakthroughs in chronological order.</p> | ||
− | < | + | <span>Categories:</span> |
+ | <select id="CategoriesSelect" onchange="changeCat(this)"> | ||
+ | <option value="all" selected="selected">(please select [ALL]:)</option> | ||
+ | <option value="ibp">Ice binding protein</option> | ||
+ | <option value="cloning">Cloning</option> | ||
+ | <option value="biobrick">Biobrick</option> | ||
+ | <option value="organiclab">Organic lab</option> | ||
+ | </select> | ||
+ | <!-- automation below --> | ||
+ | <p></p> | ||
+ | </div> | ||
− | < | + | <script> |
− | + | // Catelogue | |
+ | var bGenerateCat = false; | ||
− | + | var xhr = new XMLHttpRequest(); | |
− | + | xhr.overrideMimeType("application/json"); | |
+ | xhr.open("GET", "https://2018.igem.org/Team:TU-Eindhoven/logbook?action=raw&ctype=text/json", true); | ||
+ | console.log("start generating logbook..."); | ||
+ | xhr.onreadystatechange = function(){ | ||
+ | if (xhr.readyState == 4 && xhr.status == "200") { | ||
+ | var logJSON = JSON.parse(xhr.responseText); | ||
+ | var log = document.getElementById("log-container"); | ||
+ | // var dates = Object.keys(logtext).length; | ||
+ | var trans = {'ibp':'Ice Binding Protein', | ||
+ | 'cloning':'Cloning', | ||
+ | 'biobrick':'Biobrick', | ||
+ | 'organiclab':'Organic Lab' | ||
+ | }; | ||
+ | for(var key in logJSON) { | ||
+ | let btn = document.createElement("BUTTON"); | ||
+ | btn.classList.add("accordion"); | ||
+ | btn.innerHTML = key; | ||
+ | log.appendChild(btn); | ||
+ | let panel = document.createElement("DIV"); | ||
+ | panel.classList.add("panel"); | ||
+ | for(var part in logJSON[key]) { | ||
+ | let h = document.createElement('H2'); | ||
+ | h.innerHTML = trans[part]; | ||
+ | let d = document.createElement("DIV"); | ||
+ | d.classList.add(part, "all"); | ||
+ | d.innerHTML = logJSON[key][part]["html"]; | ||
+ | d.insertBefore(h, d.firstChild); | ||
+ | panel.appendChild(d); | ||
+ | } | ||
+ | log.appendChild(panel); | ||
+ | } | ||
+ | var acc = document.getElementsByClassName("accordion"); | ||
+ | var i; | ||
− | + | for (i = 0; i < acc.length; i++) { | |
− | + | acc[i].addEventListener("click", function() { | |
− | + | this.classList.toggle("active"); | |
− | + | var panel = this.nextElementSibling; | |
− | + | if (panel.style.maxHeight){ | |
− | + | panel.style.maxHeight = null; | |
− | + | } else { | |
− | + | panel.style.maxHeight = panel.scrollHeight + "px"; | |
+ | } | ||
+ | }); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | xhr.send(null); | ||
− | + | // change categories | |
+ | function changeCat(e) { | ||
+ | var catClass = e.value; | ||
+ | var target = document.getElementsByClassName(catClass); | ||
+ | var all = document.getElementsByClassName("all"); | ||
+ | |||
+ | console.log(catClass); | ||
− | < | + | for (var i=0; i<all.length;i++) { |
− | + | all[i].style.display="none"; | |
− | + | } | |
− | + | ||
− | + | for (var i=0; i<target.length; i++) { | |
− | + | target[i].style.display="block"; | |
− | + | } | |
− | + | } | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | </ | + | // |
+ | |||
+ | </script> | ||
</html> | </html> | ||
{{:Team:TU-Eindhoven/footer}} | {{:Team:TU-Eindhoven/footer}} |
Revision as of 08:03, 9 October 2018
Log book
Log book is recorded weekly, you may find the significant breakthroughs in chronological order.
Categories: