| Total Complexity | 6 |
| Complexity/F | 2 |
| Lines of Code | 42 |
| Function Count | 3 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | const slide_speed = 0.4; |
||
|
|
|||
| 2 | |||
| 3 | function toggle_twisty(id) { |
||
| 4 | var element = document.getElementById(id); |
||
| 5 | |||
| 6 | if (!element) { |
||
| 7 | return; |
||
| 8 | } |
||
| 9 | let twisty = element.previousSibling.previousSibling.firstChild.nextSibling; |
||
| 10 | twisty.classList.toggle('fa-caret-up'); |
||
| 11 | twisty.classList.toggle('fa-caret-down'); |
||
| 12 | |||
| 13 | if (element.parentNode.classList.contains('open')) { |
||
| 14 | remove_anchor(id); |
||
| 15 | } else { |
||
| 16 | add_anchor(id); |
||
| 17 | } |
||
| 18 | element.parentNode.classList.toggle('open') |
||
| 19 | element.parentNode.classList.toggle('closed') |
||
| 20 | } |
||
| 21 | |||
| 22 | function remove_anchor(id) { |
||
| 23 | if (!window.location.hash) { |
||
| 24 | return; |
||
| 25 | } |
||
| 26 | |||
| 27 | id = id.replace(/_contents[,]*/, ''); |
||
| 28 | |||
| 29 | var string = window.location.hash, |
||
| 30 | regexp = new RegExp(id, 'g'); |
||
| 31 | string = string.replace(regexp, ''); |
||
| 32 | |||
| 33 | string = string.replace(/#[,]*/, '#'); |
||
| 34 | string = string.replace(/[,]*$/, ''); |
||
| 35 | string = string.replace(/,,/g, ','); |
||
| 36 | |||
| 37 | window.location.hash = string; |
||
| 38 | } |
||
| 39 | |||
| 40 | function add_anchor(id) { |
||
| 41 | window.location.hash = '#' + id.replace(/_contents$/, ''); |
||
| 42 | } |
||
| 43 |