| OLD | NEW |
| (Empty) |
| 1 JAVASCRIPT = ''' | |
| 2 // <;![Cdata[ | |
| 3 // | |
| 4 // Cookie functions | |
| 5 // | |
| 6 | |
| 7 // Creates a new cookie. | |
| 8 function createCookie(name, value, day) { | |
| 9 var date = new Date(); | |
| 10 date.setTime(date.getTime() + (day * 24 * 60 * 60 * 1000)); | |
| 11 var expires = "; expires=" + date.toGMTString(); | |
| 12 document.cookie = name + "=" + value+expires + "; path=/"; | |
| 13 } | |
| 14 | |
| 15 // Returns the vaue of a cookie, or null if it does not exist. | |
| 16 function readCookie(name) { | |
| 17 var begin = name + "="; | |
| 18 var data = document.cookie.split(';'); | |
| 19 for(var i = 0; i < data.length; i++) { | |
| 20 var cookie = data[i]; | |
| 21 while (cookie.charAt(0) == ' ') | |
| 22 cookie = cookie.substring(1, cookie.length); | |
| 23 if (cookie.indexOf(begin) == 0) | |
| 24 return cookie.substring(begin.length, cookie.length); | |
| 25 } | |
| 26 | |
| 27 return null; | |
| 28 } | |
| 29 | |
| 30 // Deletes a cookie. | |
| 31 function eraseCookie(name) { | |
| 32 createCookie(name, "", -1); | |
| 33 } | |
| 34 | |
| 35 // | |
| 36 // Functions to change the layout of the page. | |
| 37 // | |
| 38 | |
| 39 // Hides all "details" and "comments" section. | |
| 40 function collapse() { | |
| 41 // Hide all Comments sections. | |
| 42 var comments = document.querySelectorAll('.DevComment'); | |
| 43 for(var i = 0; i < comments.length; i++) { | |
| 44 comments[i].style.display = "none"; | |
| 45 } | |
| 46 | |
| 47 // Hide all details sections. | |
| 48 var details = document.querySelectorAll('.DevDetails'); | |
| 49 for(var i = 0; i < details.length; i++) { | |
| 50 details[i].style.display = "none"; | |
| 51 } | |
| 52 | |
| 53 // Fix the rounding on the Revision box. (Lower right corner must be round) | |
| 54 var revisions = document.querySelectorAll('.DevRev'); | |
| 55 for(var i = 0; i < revisions.length; i++) { | |
| 56 revisions[i].className = revisions[i].className + ' DevRevCollapse'; | |
| 57 } | |
| 58 | |
| 59 // Fix the rounding on the last category box. (Lower left corner must be rou
nd) | |
| 60 var status = document.querySelectorAll('.last'); | |
| 61 for(var i = 0; i < status.length; i++) { | |
| 62 status[i].className = status[i].className + ' DevStatusCollapse'; | |
| 63 } | |
| 64 | |
| 65 // Create a cookie to remember that we want the view to be collapsed. | |
| 66 createCookie('collapsed', 'true', 30) | |
| 67 | |
| 68 // Hide the collapse and the unmerge buttons. | |
| 69 document.querySelectorAll('.collapse')[0].style.display = 'none' | |
| 70 document.querySelectorAll('.unmerge')[0].style.display = 'none' | |
| 71 | |
| 72 // Activate the merge and expand buttons. | |
| 73 document.querySelectorAll('.expand')[0].style.display = 'inline' | |
| 74 document.querySelectorAll('.merge')[0].style.display = 'inline' | |
| 75 } | |
| 76 | |
| 77 // Expands the view. This is the opposite of "Collapse" | |
| 78 function expand() { | |
| 79 // Make the comments visible. | |
| 80 var comments = document.querySelectorAll('.DevComment'); | |
| 81 for(var i = 0; i < comments.length; i++) { | |
| 82 comments[i].style.display = ""; | |
| 83 } | |
| 84 | |
| 85 // Make the details visible. | |
| 86 var details = document.querySelectorAll('.DevDetails'); | |
| 87 for(var i = 0; i < details.length; i++) { | |
| 88 details[i].style.display = ""; | |
| 89 } | |
| 90 | |
| 91 // Remove the round corner (lower right) for the Revision box. | |
| 92 var revisions = document.querySelectorAll('.DevRev'); | |
| 93 for(var i = 0; i < revisions.length; i++) { | |
| 94 revisions[i].className = revisions[i].className.replace('DevRevCollapse'
, ''); | |
| 95 } | |
| 96 | |
| 97 // Remoe the round corner (lower left) for the last category box. | |
| 98 var status = document.querySelectorAll('.DevStatus'); | |
| 99 for(var i = 0; i < status.length; i++) { | |
| 100 status[i].className = status[i].className.replace('DevStatusCollapse', '
'); | |
| 101 } | |
| 102 | |
| 103 // Delete the cookies that say that we want to be collapsed or merged. | |
| 104 eraseCookie('collapsed') | |
| 105 eraseCookie('merged') | |
| 106 | |
| 107 // Display the "collapse" and "merge" buttons. | |
| 108 document.querySelectorAll('.collapse')[0].style.display = 'inline' | |
| 109 document.querySelectorAll('.merge')[0].style.display = 'inline' | |
| 110 | |
| 111 // Remove the "expand" and "unmerge" buttons. | |
| 112 document.querySelectorAll('.expand')[0].style.display = 'none' | |
| 113 document.querySelectorAll('.unmerge')[0].style.display = 'none' | |
| 114 } | |
| 115 | |
| 116 // | |
| 117 // Merge all the status boxes together. | |
| 118 function merge() { | |
| 119 // First step is to collapse the view. | |
| 120 collapse(); | |
| 121 | |
| 122 // Hide all the spacing. | |
| 123 var spacing = document.querySelectorAll('.DevStatusSpacing'); | |
| 124 for(var i = 0; i < spacing.length; i++) { | |
| 125 spacing[i].style.display = "none"; | |
| 126 } | |
| 127 | |
| 128 // Each boxes have, in the className, a tag that uniquely represents the | |
| 129 // build where this data comes from. | |
| 130 // Since we want to merge all the boxes coming from the same build, we | |
| 131 // parse the document to find all the builds, and then, for each build, we | |
| 132 // concatenate the boxes. | |
| 133 | |
| 134 var allTags = []; | |
| 135 all = document.getElementsByTagName('*') | |
| 136 for(var i = 0; i < all.length; i++) { | |
| 137 var element = all[i]; | |
| 138 start = element.className.indexOf('Tag') | |
| 139 if (start != -1) { | |
| 140 var className = "" | |
| 141 end = element.className.indexOf(' ', start) | |
| 142 if (end != -1) { | |
| 143 className = element.className.substring(start, end); | |
| 144 } else { | |
| 145 className = element.className.substring(start); | |
| 146 } | |
| 147 allTags[className] = 1; | |
| 148 } | |
| 149 } | |
| 150 | |
| 151 // Mergeall tags that we found | |
| 152 for (i in allTags) { | |
| 153 var current = document.querySelectorAll('.' + i); | |
| 154 | |
| 155 // We do the work only if there is more than 1 box with the same | |
| 156 // build. | |
| 157 if (current.length > 1) { | |
| 158 // Add the noround class to all the boxes. | |
| 159 for(var i = 0; i < current.length; i++) { | |
| 160 current[i].className = current[i].className + ' noround'; | |
| 161 } | |
| 162 | |
| 163 // Add the begin class to the first box. | |
| 164 current[0].className = current[0].className + ' begin'; | |
| 165 | |
| 166 // Add the end class to the last box. | |
| 167 last = current.length - 1; | |
| 168 current[last].className = current[last].className + ' end'; | |
| 169 } | |
| 170 } | |
| 171 | |
| 172 // Display the "unmerge" and "expand" button. | |
| 173 // TODO(nsylvain): expand does not work well here. we should remove it. | |
| 174 document.querySelectorAll('.unmerge')[0].style.display = 'inline' | |
| 175 document.querySelectorAll('.expand')[0].style.display = 'inline' | |
| 176 | |
| 177 // Remove the "collapse" and "merge" button. | |
| 178 document.querySelectorAll('.collapse')[0].style.display = 'none' | |
| 179 document.querySelectorAll('.merge')[0].style.display = 'none' | |
| 180 | |
| 181 // Create a cookie to remember that we want to be merged. | |
| 182 createCookie('merged', 'true', 30) | |
| 183 } | |
| 184 | |
| 185 // Un-merge the view. This is the opposite of "merge". | |
| 186 function unmerge() { | |
| 187 // We start by expanding the view. | |
| 188 expand(); | |
| 189 | |
| 190 // We put back all the spacing. | |
| 191 var spacing = document.querySelectorAll('.DevStatusSpacing'); | |
| 192 for(var i = 0; i < spacing.length; i++) { | |
| 193 spacing[i].style.display = ""; | |
| 194 } | |
| 195 | |
| 196 // We remove the class added to all the boxes we modified. | |
| 197 var noround = document.querySelectorAll('.noround'); | |
| 198 for(var i = 0; i < noround.length; i++) { | |
| 199 noround[i].className = noround[i].className.replace("begin", ''); | |
| 200 noround[i].className = noround[i].className.replace("end", ''); | |
| 201 noround[i].className = noround[i].className.replace("noround", ''); | |
| 202 } | |
| 203 | |
| 204 // Delete the cookie, we don't want to be merged anymore. | |
| 205 eraseCookie('merged') | |
| 206 | |
| 207 // Display the "merge" and "collapse" button. | |
| 208 document.querySelectorAll('.collapse')[0].style.display = 'inline' | |
| 209 document.querySelectorAll('.merge')[0].style.display = 'inline' | |
| 210 | |
| 211 // Hide and "expand" and "unmerge" button. | |
| 212 document.querySelectorAll('.expand')[0].style.display = 'none' | |
| 213 document.querySelectorAll('.unmerge')[0].style.display = 'none' | |
| 214 } | |
| 215 | |
| 216 function SetupView() { | |
| 217 if (readCookie('merged')) { | |
| 218 merge(); | |
| 219 } else if (readCookie('collapsed')) { | |
| 220 collapse(); | |
| 221 } else { | |
| 222 unmerge(); | |
| 223 expand(); | |
| 224 } | |
| 225 } | |
| 226 | |
| 227 // | |
| 228 // Functions used to display the build status bubble on box click. | |
| 229 // | |
| 230 | |
| 231 // show the build status box. This is called when the user clicks on a block. | |
| 232 function showBuildBox(url, event) { | |
| 233 // Find the current curson position. | |
| 234 var cursorPosTop = (window.event ? window.event.clientY : event.pageY) | |
| 235 var cursorPosLeft = (window.event ? window.event.clientX : event.pageX) | |
| 236 | |
| 237 // Offset the position by 5, to make the window appears under the cursor. | |
| 238 cursorPosTop = cursorPosTop + document.body.scrollTop -5 ; | |
| 239 cursorPosLeft = cursorPosLeft + document.body.scrollLeft - 5; | |
| 240 | |
| 241 // Move the div (hidden) under the cursor. | |
| 242 var divBox = document.getElementById('divBox'); | |
| 243 divBox.style.top = parseInt(cursorPosTop) + 'px'; | |
| 244 divBox.style.left = parseInt(cursorPosLeft) + 'px'; | |
| 245 | |
| 246 // Reload the hidden frame with the build page we want to show. | |
| 247 // The onload even on this frame will update the div and make it visible. | |
| 248 document.getElementById("frameBox").src = url | |
| 249 | |
| 250 // We don't want to reload the page. | |
| 251 return false; | |
| 252 } | |
| 253 | |
| 254 // OnLoad handler for the iframe containing the build to show. | |
| 255 function updateDiv(event) { | |
| 256 // Get the frame innerHTML. | |
| 257 var iframeContent = document.getElementById("frameBox").contentWindow.docume
nt.body.innerHTML; | |
| 258 | |
| 259 // If there is any content, update the div, and make it visible. | |
| 260 if (iframeContent) { | |
| 261 var divBox = document.getElementById('divBox'); | |
| 262 divBox.innerHTML = iframeContent ; | |
| 263 divBox.style.display = "block"; | |
| 264 } | |
| 265 } | |
| 266 | |
| 267 // Util functions to know if an element is contained inside another element. | |
| 268 // We use this to know when we mouse out our build status div. | |
| 269 function containsDOM (container, containee) { | |
| 270 var isParent = false; | |
| 271 do { | |
| 272 if ((isParent = container == containee)) | |
| 273 break; | |
| 274 containee = containee.parentNode; | |
| 275 } while (containee != null); | |
| 276 | |
| 277 return isParent; | |
| 278 } | |
| 279 | |
| 280 // OnMouseOut handler. Returns true if the mouse moved out of the element. | |
| 281 // It is false if the mouse is still in the element, but in a blank part of it, | |
| 282 // like in an empty table cell. | |
| 283 function checkMouseLeave(element, event) { | |
| 284 if (element.contains && event.toElement) { | |
| 285 return !element.contains(event.toElement); | |
| 286 } | |
| 287 else if (event.relatedTarget) { | |
| 288 return !containsDOM(element, event.relatedTarget); | |
| 289 } | |
| 290 } | |
| 291 | |
| 292 function addBox(url, title, color, tag) { | |
| 293 document.write('<td class="DevStatusBox">') | |
| 294 document.write('<a href="#" onClick="showBuildBox(\\\'') | |
| 295 document.write(url); | |
| 296 document.write('\\\', event); return false;\" title="'); | |
| 297 document.write(title); | |
| 298 document.write('" class="DevStatusBox '); | |
| 299 document.write(color + ' ' + tag); | |
| 300 document.write('" target=_blank></a></td>'); | |
| 301 } | |
| 302 | |
| 303 document.addEventListener("DOMContentLoaded", SetupView, false); | |
| 304 | |
| 305 // ]]> | |
| 306 ''' | |
| OLD | NEW |