| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 function toggleHelpBox() { | 5 function toggleHelpBox() { |
| 6 var helpBoxOuter = document.getElementById('help-box-outer'); | 6 var helpBoxOuter = document.getElementById('help-box-outer'); |
| 7 helpBoxOuter.classList.toggle('hidden'); | 7 helpBoxOuter.classList.toggle('hidden'); |
| 8 var moreLessButton = document.getElementById('more-less-button'); | 8 var detailsButton = document.getElementById('details-button'); |
| 9 if (helpBoxOuter.classList.contains('hidden')) { | 9 if (helpBoxOuter.classList.contains('hidden')) |
| 10 moreLessButton.innerText = moreLessButton.moreText; | 10 detailsButton.innerText = detailsButton.detailsText; |
| 11 } else { | 11 else |
| 12 moreLessButton.innerText = moreLessButton.lessText; | 12 detailsButton.innerText = detailsButton.hideDetailsText; |
| 13 } | |
| 14 } | 13 } |
| 15 | 14 |
| 16 function diagnoseErrors() { | 15 function diagnoseErrors() { |
| 17 var extension_id = "idddmepepmjcgiedknnmlbadcokidhoa"; | 16 var extensionId = 'idddmepepmjcgiedknnmlbadcokidhoa'; |
| 18 var diagnose_frame = document.getElementById('diagnose-frame'); | 17 var diagnoseFrame = document.getElementById('diagnose-frame'); |
| 19 diagnose_frame.innerHTML = | 18 diagnoseFrame.innerHTML = |
| 20 '<iframe src="chrome-extension://' + extension_id + | 19 '<iframe src="chrome-extension://' + extensionId + |
| 21 '/index.html"></iframe>'; | 20 '/index.html"></iframe>'; |
| 22 } | 21 } |
| 23 | 22 |
| 24 // Subframes use a different layout but the same html file. This is to make it | 23 // Subframes use a different layout but the same html file. This is to make it |
| 25 // easier to support platforms that load the error page via different | 24 // easier to support platforms that load the error page via different |
| 26 // mechanisms (Currently just iOS). | 25 // mechanisms (Currently just iOS). |
| 27 if (window.top.location != window.location) | 26 if (window.top.location != window.location) |
| 28 document.documentElement.setAttribute('subframe', ''); | 27 document.documentElement.setAttribute('subframe', ''); |
| 29 | 28 |
| 30 // Re-renders the error page using |strings| as the dictionary of values. | 29 // Re-renders the error page using |strings| as the dictionary of values. |
| 31 // Used by NetErrorTabHelper to update DNS error pages with probe results. | 30 // Used by NetErrorTabHelper to update DNS error pages with probe results. |
| 32 function updateForDnsProbe(strings) { | 31 function updateForDnsProbe(strings) { |
| 33 i18nTemplate.process(document, strings); | 32 i18nTemplate.process(document, strings); |
| 34 var context = new JsEvalContext(strings); | 33 var context = new JsEvalContext(strings); |
| 35 jstProcess(context, document.getElementById('t')); | 34 jstProcess(context, document.getElementById('t')); |
| 36 } | 35 } |
| 37 | 36 |
| 38 // Given the classList property of an element, adds an icon class to the list | 37 // Given the classList property of an element, adds an icon class to the list |
| 39 // and removes the previously- | 38 // and removes the previously- |
| 40 function updateIconClass(classList, newClass) { | 39 function updateIconClass(classList, newClass) { |
| 41 var oldClass; | 40 var oldClass; |
| 42 | 41 |
| 43 if (classList.hasOwnProperty('last_icon_class')) { | 42 if (classList.hasOwnProperty('last_icon_class')) { |
| 44 oldClass = classList['last_icon_class'] | 43 oldClass = classList['last_icon_class']; |
| 45 if (oldClass == newClass) | 44 if (oldClass == newClass) |
| 46 return; | 45 return; |
| 47 } | 46 } |
| 48 | 47 |
| 49 classList.add(newClass); | 48 classList.add(newClass); |
| 50 if (oldClass !== undefined) | 49 if (oldClass !== undefined) |
| 51 classList.remove(oldClass); | 50 classList.remove(oldClass); |
| 52 | 51 |
| 53 classList['last_icon_class'] = newClass; | 52 classList['last_icon_class'] = newClass; |
| 54 } | 53 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 location = url; | 86 location = url; |
| 88 } | 87 } |
| 89 } | 88 } |
| 90 | 89 |
| 91 function loadStaleButtonClick() { | 90 function loadStaleButtonClick() { |
| 92 if (window.errorPageController) { | 91 if (window.errorPageController) { |
| 93 errorPageController.loadStaleButtonClick(); | 92 errorPageController.loadStaleButtonClick(); |
| 94 } | 93 } |
| 95 } | 94 } |
| 96 | 95 |
| 97 function moreButtonClick() { | 96 function detailsButtonClick() { |
| 98 if (window.errorPageController) { | 97 if (window.errorPageController) |
| 99 errorPageController.moreButtonClick(); | 98 errorPageController.detailsButtonClick(); |
| 99 } |
| 100 |
| 101 var primaryControlOnLeft = true; |
| 102 <if expr="is_macosx or is_ios or is_linux or is_android"> |
| 103 primaryControlOnLeft = false; |
| 104 </if> |
| 105 |
| 106 // Sets up the proper button layout for the current platform. |
| 107 function setButtonLayout() { |
| 108 var buttonsDiv = document.getElementById('buttons'); |
| 109 var controlButtonDiv = document.getElementById('control-buttons'); |
| 110 var reloadButton = document.getElementById('reload-button'); |
| 111 var detailsButton = document.getElementById('details-button'); |
| 112 var staleLoadButton = document.getElementById('stale-load-button'); |
| 113 |
| 114 var primaryButton = reloadButton; |
| 115 var secondaryButton = staleLoadButton; |
| 116 |
| 117 if (primaryControlOnLeft) { |
| 118 buttons.classList.add('suggested-left'); |
| 119 controlButtonDiv.insertBefore(primaryButton, secondaryButton); |
| 120 } else { |
| 121 buttons.classList.add('suggested-right'); |
| 122 controlButtonDiv.insertBefore(secondaryButton, primaryButton); |
| 123 } |
| 124 |
| 125 if (reloadButton.style.display == 'none' && |
| 126 staleLoadButton.style.display == 'none') { |
| 127 detailsButton.classList.add('singular'); |
| 100 } | 128 } |
| 101 } | 129 } |
| 102 | 130 document.addEventListener('DOMContentLoaded', setButtonLayout); |
| 103 <if expr="is_macosx or is_ios or is_linux or is_android"> | |
| 104 // Re-orders buttons. Used on Mac, Linux, and Android, where reload should go | |
| 105 // on the right. | |
| 106 function swapButtonOrder() { | |
| 107 var reloadButton = document.getElementById('reload-button'); | |
| 108 var moreLessButton = document.getElementById('more-less-button'); | |
| 109 var staleLoadButton = document.getElementById('stale-load-button'); | |
| 110 reloadButton.parentNode.insertBefore(moreLessButton, reloadButton); | |
| 111 reloadButton.parentNode.insertBefore(staleLoadButton, reloadButton) | |
| 112 } | |
| 113 document.addEventListener("DOMContentLoaded", swapButtonOrder); | |
| 114 </if> | |
| OLD | NEW |