Commit 4fd76e81a25db67c6c0c110d0b24073fe66287fd
1 parent
87b6f1b0d7
Exists in
master
Prise en compte du fait qu'il n'y a pas forcément de nextSibling
Showing 1 changed file with 36 additions and 10 deletions Side-by-side Diff
templates/html/common/wizefunc.js
| ... | ... | @@ -42,11 +42,10 @@ |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - /* Convert the two first tags into info */ | |
| 46 | - /* use tags for image/table/object attributes */ | |
| 47 | - function tagToInfo() { | |
| 48 | - /* All H5 tags */ | |
| 49 | - var atags = document.getElementsByTagName('H5'); | |
| 45 | + | |
| 46 | + function tagToInfo(s5=false) { | |
| 47 | + /* All H4 tags */ | |
| 48 | + var atags = document.getElementsByTagName('H4'); | |
| 50 | 49 | /* extract configuration tags */ |
| 51 | 50 | tags=[]; |
| 52 | 51 | for (var i=0; i<atags.length;i++) { |
| 53 | 52 | |
| 54 | 53 | |
| 55 | 54 | |
| ... | ... | @@ -61,14 +60,41 @@ |
| 61 | 60 | for (var i=1; i <= n; i++) { |
| 62 | 61 | /* first make the tag not displayed */ |
| 63 | 62 | tags[i-1].setAttribute("style","display:none;"); |
| 64 | - var s = tags[i-1].innerHTML; | |
| 65 | - document.getElementById("footinfo"+i).innerHTML = s; | |
| 63 | + /* If next sibling is a <br> make it display:none too */ | |
| 64 | + if (tags[i-1].nextElementSibling && tags[i-1].nextElementSibling.tagName == 'BR') { | |
| 65 | + tags[i-1].nextElementSibling.setAttribute("style","display:none;"); | |
| 66 | + } | |
| 67 | + if (s5) { | |
| 68 | + var s = tags[i-1].innerHTML; | |
| 69 | + document.getElementById("footinfo"+i).innerHTML = s; | |
| 70 | + } | |
| 66 | 71 | } |
| 67 | - if (tags.length > 2) { | |
| 72 | + } | |
| 73 | + | |
| 74 | + /* Convert the two first tags into info */ | |
| 75 | + /* use tags for image/table/object attributes */ | |
| 76 | + function tagToStyle() { | |
| 77 | + /* All H5 tags */ | |
| 78 | + var atags = document.getElementsByTagName('H5'); | |
| 79 | + /* extract configuration tags */ | |
| 80 | + tags=[]; | |
| 81 | + for (var i=0; i<atags.length;i++) { | |
| 82 | + var s = atags[i].innerHTML; | |
| 83 | + if (s.match(/^#/)) { | |
| 84 | + atags[i].innerHTML = s.replace('#',''); | |
| 85 | + tags.push(atags[i]); | |
| 86 | + } | |
| 87 | + } | |
| 88 | + | |
| 89 | + if (tags.length > 0) { | |
| 68 | 90 | /* Image tags */ |
| 69 | - for (var i=1; i <= tags.length - 2; i++) { | |
| 70 | - var ctag = tags[i+1]; | |
| 91 | + for (var i=0; i < tags.length; i++) { | |
| 92 | + var ctag = tags[i]; | |
| 71 | 93 | ctag.setAttribute("style","display:none;"); |
| 94 | + /* If next sibling is a <br> make it display:none too */ | |
| 95 | + if (ctag.nextElementSibling && ctag.nextElementSibling.tagName == 'BR') { | |
| 96 | + ctag.nextElementSibling.setAttribute("style","display:none;"); | |
| 97 | + } | |
| 72 | 98 | var s = ctag.innerHTML; |
| 73 | 99 | /* find next img/table/zim-object */ |
| 74 | 100 | ctag = findNextObject(ctag); |