File: aboutSocialError.xhtml

package info (click to toggle)
iceweasel 31.6.0esr-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 1,368,576 kB
  • sloc: cpp: 3,692,968; ansic: 1,797,194; python: 193,401; java: 180,622; asm: 133,557; xml: 89,288; sh: 71,748; perl: 22,087; makefile: 21,687; objc: 4,014; yacc: 1,995; pascal: 1,292; lex: 950; exp: 449; lisp: 228; awk: 211; php: 113; sed: 43; csh: 31; ada: 16; ruby: 3
file content (131 lines) | stat: -rw-r--r-- 4,783 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?xml version="1.0" encoding="UTF-8"?>

<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->

<!DOCTYPE html [
  <!ENTITY % htmlDTD
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "DTD/xhtml1-strict.dtd">
  %htmlDTD;
  <!ENTITY % netErrorDTD SYSTEM "chrome://global/locale/netError.dtd">
  %netErrorDTD;
]>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>&loadError.label;</title>
    <link rel="stylesheet" type="text/css" media="all"
          href="chrome://browser/skin/aboutSocialError.css"/>
  </head>

  <body>
    <div id="error-box">
      <p id="main-error-msg"></p>
      <p id="helper-error-msg"></p>
    </div>
    <div id="button-box">
      <button id="btnTryAgain" onclick="tryAgainButton()"/>
      <button id="btnCloseSidebar" onclick="closeSidebarButton()"/>
    </div>
  </body>

  <script type="text/javascript;version=1.8"><![CDATA[
    const Cu = Components.utils;

    Cu.import("resource://gre/modules/Services.jsm");
    Cu.import("resource:///modules/Social.jsm");

    let config = {
      tryAgainCallback: reloadProvider
    }

    function parseQueryString() {
      let url = document.documentURI;
      let queryString = url.replace(/^about:socialerror\??/, "");

      let modeMatch = queryString.match(/mode=([^&]+)/);
      let mode = modeMatch && modeMatch[1] ? modeMatch[1] : "";
      let originMatch = queryString.match(/origin=([^&]+)/);
      config.origin = originMatch && originMatch[1] ? decodeURIComponent(originMatch[1]) : "";

      switch (mode) {
        case "compactInfo":
          document.getElementById("btnTryAgain").style.display = 'none';
          document.getElementById("btnCloseSidebar").style.display = 'none';
          break;
        case "tryAgainOnly":
          document.getElementById("btnCloseSidebar").style.display = 'none';
          //intentional fall-through
        case "tryAgain":
          let urlMatch = queryString.match(/url=([^&]+)/);
          let encodedURL = urlMatch && urlMatch[1] ? urlMatch[1] : "";
          let url = decodeURIComponent(encodedURL);

          config.tryAgainCallback = loadQueryURL;
          config.queryURL = url;
          break;
        case "workerFailure":
          config.tryAgainCallback = reloadProvider;
          break;
        default:
          break;
      }
    }

    function setUpStrings() {
      let brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
      let browserBundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");

      let productName = brandBundle.GetStringFromName("brandShortName");
      let provider = Social._getProviderFromOrigin(config.origin);
      let providerName = provider && provider.name;

      // Sets up the error message
      let msg = browserBundle.formatStringFromName("social.error.message", [productName, providerName], 2);
      document.getElementById("main-error-msg").textContent = msg;

      // Sets up the buttons' labels and accesskeys
      let btnTryAgain = document.getElementById("btnTryAgain");
      btnTryAgain.textContent = browserBundle.GetStringFromName("social.error.tryAgain.label");
      btnTryAgain.accessKey = browserBundle.GetStringFromName("social.error.tryAgain.accesskey");

      let btnCloseSidebar = document.getElementById("btnCloseSidebar");
      btnCloseSidebar.textContent = browserBundle.GetStringFromName("social.error.closeSidebar.label");
      btnCloseSidebar.accessKey = browserBundle.GetStringFromName("social.error.closeSidebar.accesskey");
    }

    function closeSidebarButton() {
      SocialSidebar.toggleSidebar();
    }

    function tryAgainButton() {
      config.tryAgainCallback();
    }

    function loadQueryURL() {
      window.location.href = config.queryURL;
    }

    function reloadProvider() {
      // Just incase the current provider *isn't* in a frameworker-error
      // state, reload the current one.
      let provider = Social._getProviderFromOrigin(config.origin);
      provider.reload();
      // If the problem is a frameworker-error, it may be that the child
      // process crashed - and if that happened, then *all* providers in that
      // process will have crashed.  However, only the current provider is
      // likely to have the error surfaced in the UI - so we reload *all*
      // providers that are in a frameworker-error state.
      for (let provider of Social.providers) {
        if (provider.enabled && provider.errorState == "frameworker-error") {
          provider.reload();
        }
      }
    }

    parseQueryString();
    setUpStrings();
  ]]></script>
</html>