Refresh CrOS offline interstitial design
[chromium-blink-merge.git] / chrome / browser / resources / chromeos / neterror.js
blob5dd4d3f8640af6649143fd1b066847742c5653f8
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
3 // found in the LICENSE file.
5 function toggleHelpBox() {
6   var helpBoxOuter = $('help-box-outer');
7   helpBoxOuter.classList.toggle('hidden');
8   var moreLessButton = $('details-button');
9   if (helpBoxOuter.classList.contains('hidden')) {
10     moreLessButton.innerText = moreLessButton.moreText;
11   } else {
12     moreLessButton.innerText = moreLessButton.lessText;
13   }
16 function diagnoseErrors() {
17   window.domAutomationController.setAutomationId(1);
18   window.domAutomationController.send('open_connectivity_diagnostics');
21 // Subframes use a different layout but the same html file.  This is to make it
22 // easier to support platforms that load the error page via different
23 // mechanisms (Currently just iOS).
24 if (window.top.location != window.location)
25   document.documentElement.setAttribute('subframe', '');
27 // Re-renders the error page using |strings| as the dictionary of values.
28 // Used by NetErrorTabHelper to update DNS error pages with probe results.
29 function updateForDnsProbe(strings) {
30   var context = new JsEvalContext(strings);
31   jstProcess(context, $('t'));
34 // Given the classList property of an element, adds an icon class to the list
35 // and removes the previously-
36 function updateIconClass(classList, newClass) {
37   var oldClass;
39   if (classList.hasOwnProperty('last_icon_class')) {
40     oldClass = classList['last_icon_class'];
41     if (oldClass == newClass)
42       return;
43   }
45   classList.add(newClass);
46   if (oldClass !== undefined)
47     classList.remove(oldClass);
49   classList['last_icon_class'] = newClass;
51   if (newClass == 'icon-offline') {
52     document.body.classList.add('offline');
53     new Runner('.interstitial-wrapper');
54   }