* Check if the content has changed. * @param {Module} module The module to check. * @param {string} newHeader The new header that is generated. * @param {HTMLElement} newContent The new content that is generated. * @returns {boolean} True if the module need an update, false otherwise
(module, newHeader, newContent)
| 187 | * @returns {boolean} True if the module need an update, false otherwise |
| 188 | */ |
| 189 | function moduleNeedsUpdate (module, newHeader, newContent) { |
| 190 | const moduleWrapper = document.getElementById(module.identifier); |
| 191 | if (moduleWrapper === null) { |
| 192 | return false; |
| 193 | } |
| 194 | |
| 195 | const contentWrapper = moduleWrapper.getElementsByClassName("module-content"); |
| 196 | const headerWrapper = moduleWrapper.getElementsByClassName("module-header"); |
| 197 | |
| 198 | let headerNeedsUpdate = false; |
| 199 | let contentNeedsUpdate; |
| 200 | |
| 201 | if (headerWrapper.length > 0) { |
| 202 | headerNeedsUpdate = newHeader !== headerWrapper[0].innerHTML; |
| 203 | } |
| 204 | |
| 205 | const tempContentWrapper = document.createElement("div"); |
| 206 | tempContentWrapper.appendChild(newContent); |
| 207 | contentNeedsUpdate = tempContentWrapper.innerHTML !== contentWrapper[0].innerHTML; |
| 208 | |
| 209 | return headerNeedsUpdate || contentNeedsUpdate; |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * Update the content of a module on screen. |
no outgoing calls
no test coverage detected