Preliminary main mbed library for nexpaq development
tools/ci_templates/scripts.js@1:d96dbedaebdb, 2016-11-04 (annotated)
- Committer:
- nexpaq
- Date:
- Fri Nov 04 20:54:50 2016 +0000
- Revision:
- 1:d96dbedaebdb
- Parent:
- 0:6c56fb4bc5f0
Removed extra directories for other platforms
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nexpaq | 0:6c56fb4bc5f0 | 1 | <script> |
nexpaq | 0:6c56fb4bc5f0 | 2 | var elements = document.querySelectorAll(".toggleshow"), |
nexpaq | 0:6c56fb4bc5f0 | 3 | hideClass = 'toggleshow-hide'; |
nexpaq | 0:6c56fb4bc5f0 | 4 | |
nexpaq | 0:6c56fb4bc5f0 | 5 | for (var i = 0; i < elements.length; i++) { |
nexpaq | 0:6c56fb4bc5f0 | 6 | var arrow = elements[i].querySelector(".toggleshow-arrow"); |
nexpaq | 0:6c56fb4bc5f0 | 7 | // Initial hide/show based on class |
nexpaq | 0:6c56fb4bc5f0 | 8 | // Update arrow as well |
nexpaq | 0:6c56fb4bc5f0 | 9 | if (containsClass(elements[i], 'toggleshow-hide')) { |
nexpaq | 0:6c56fb4bc5f0 | 10 | toggleDisplay(elements[i]); |
nexpaq | 0:6c56fb4bc5f0 | 11 | changeArrow(arrow, false); |
nexpaq | 0:6c56fb4bc5f0 | 12 | } else { |
nexpaq | 0:6c56fb4bc5f0 | 13 | changeArrow(arrow, true); |
nexpaq | 0:6c56fb4bc5f0 | 14 | } |
nexpaq | 0:6c56fb4bc5f0 | 15 | |
nexpaq | 0:6c56fb4bc5f0 | 16 | // Add click handler |
nexpaq | 0:6c56fb4bc5f0 | 17 | addClick(elements[i], toggleDisplay); |
nexpaq | 0:6c56fb4bc5f0 | 18 | } |
nexpaq | 0:6c56fb4bc5f0 | 19 | |
nexpaq | 0:6c56fb4bc5f0 | 20 | function containsClass(element, className) { |
nexpaq | 0:6c56fb4bc5f0 | 21 | var eleClassName = ' ' + elements[i].className + ' '; |
nexpaq | 0:6c56fb4bc5f0 | 22 | return eleClassName.indexOf(' ' + className + ' ') > -1; |
nexpaq | 0:6c56fb4bc5f0 | 23 | } |
nexpaq | 0:6c56fb4bc5f0 | 24 | |
nexpaq | 0:6c56fb4bc5f0 | 25 | function toggleDisplay(parentElement) { |
nexpaq | 0:6c56fb4bc5f0 | 26 | var body = parentElement.querySelector(".toggleshow-body"), |
nexpaq | 0:6c56fb4bc5f0 | 27 | arrow = parentElement.querySelector(".toggleshow-arrow"); |
nexpaq | 0:6c56fb4bc5f0 | 28 | |
nexpaq | 0:6c56fb4bc5f0 | 29 | if (body.style.display == 'block' || body.style.display == '') { |
nexpaq | 0:6c56fb4bc5f0 | 30 | body.style.display = 'none'; |
nexpaq | 0:6c56fb4bc5f0 | 31 | changeArrow(arrow, false); |
nexpaq | 0:6c56fb4bc5f0 | 32 | } else { |
nexpaq | 0:6c56fb4bc5f0 | 33 | body.style.display = 'block'; |
nexpaq | 0:6c56fb4bc5f0 | 34 | changeArrow(arrow, true); |
nexpaq | 0:6c56fb4bc5f0 | 35 | } |
nexpaq | 0:6c56fb4bc5f0 | 36 | } |
nexpaq | 0:6c56fb4bc5f0 | 37 | |
nexpaq | 0:6c56fb4bc5f0 | 38 | function changeArrow(element, visible) { |
nexpaq | 0:6c56fb4bc5f0 | 39 | if (visible) { |
nexpaq | 0:6c56fb4bc5f0 | 40 | element.innerHTML = '▲'; |
nexpaq | 0:6c56fb4bc5f0 | 41 | } else { |
nexpaq | 0:6c56fb4bc5f0 | 42 | element.innerHTML = '▼'; |
nexpaq | 0:6c56fb4bc5f0 | 43 | } |
nexpaq | 0:6c56fb4bc5f0 | 44 | } |
nexpaq | 0:6c56fb4bc5f0 | 45 | |
nexpaq | 0:6c56fb4bc5f0 | 46 | function addClick(parentElement, func) { |
nexpaq | 0:6c56fb4bc5f0 | 47 | parentElement.querySelector(".toggleshow-title").addEventListener("click", function(e) { |
nexpaq | 0:6c56fb4bc5f0 | 48 | func(parentElement); |
nexpaq | 0:6c56fb4bc5f0 | 49 | e.preventDefault(); |
nexpaq | 0:6c56fb4bc5f0 | 50 | return false; |
nexpaq | 0:6c56fb4bc5f0 | 51 | }); |
nexpaq | 0:6c56fb4bc5f0 | 52 | } |
nexpaq | 0:6c56fb4bc5f0 | 53 | </script> |