GitHub PullRequestReviewCommentEvent at 2014-03-04 13:10:11
Repository: gaia
Actor: crdlc
Payload: {"comment":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/10253421","id":10253421,"diff_hunk":"@@ -252,34 +146,180 @@\n   }\n \n   function addConnectionHandlers() {\n-    var error = getErrorFromURI();\n-    if (error.e === 'netOffline') {\n-      document.addEventListener('visibilitychange', checkConnection);\n-      window.addEventListener('online', checkConnection);\n-    }\n+    document.addEventListener('visibilitychange', checkConnection);\n+    window.addEventListener('online', checkConnection);\n   }\n \n+  function showSettingsView() {\n+    var activity = new window.MozActivity({\n+      name: 'configure',\n+      data: {\n+        target: 'device',\n+        section: 'root',\n+        filterBy: 'connectivity'\n+      }\n+    });\n+\n+    activity.onerror = function() {\n+      console.warn('Configure activity error:', activity.error.name);\n+    };\n+  }\n+\n+  function isInApp() {\n+    return window.history.length > 1;\n+  }\n+\n+  function cancel() {\n+    isInApp() ? goBack() : closeWindow();\n+  }\n+\n+  function goBack() {\n+    window.history.back();\n+  }\n+\n+  function closeWindow() {\n+    window.close();\n+  }\n+\n+  var ErrorView = function(error) {\n+    this.error = error;\n+    document.body.classList.add(error.e);\n+    this.node = document.getElementById('net-error-confirm-dialog');\n+  };\n+\n+  ErrorView.prototype = {\n+    init: function ew_init() {\n+      window.LazyLoader.load(this.node, (function loaded() {\n+        navigator.mozL10n.translate(this.node);\n+        this.title = document.getElementById('error-title');\n+        this.message = document.getElementById('error-message');\n+        this.populateMessages();\n+        this.addHandlers();\n+      }).bind(this));\n+    }\n+  };\n+\n+  // View by default\n+  var FramedErrorView = function(error) {\n+    ErrorView.call(this, error);\n+    applyFrameStyle();\n+  };\n+\n+  FramedErrorView.prototype = {\n+    __proto__: ErrorView.prototype,\n+\n+    addHandlers: function few_addHandlers() {\n+      document.body.onclick = function bodyClick() {\n+        document.getElementById('retry-icon').classList.remove('still');\n+        NetError.reload(true);\n+      };\n+    },\n+\n+    populateMessages: function few_populateMessages() {\n+      localizeElement(this.title, 'unable-to-connect');\n+      this.message.textContent = this.error.d;\n+    }\n+  };\n+\n+  var AppErrorView = function(error) {\n+    ErrorView.call(this, error);\n+    applyAppStyle();\n+  };\n+\n+  AppErrorView.prototype = {\n+    __proto__: FramedErrorView.prototype,\n+\n+    addHandlers: function aew_addHandlers() {\n+      document.getElementById('retry-btn').onclick = function retryClick() {\n+        NetError.reload(true);\n+      };\n+      document.getElementById('close-btn').onclick = closeWindow;\n+    }\n+  };\n+\n+  // Server not found view\n+  var DnsNotFoundFramedErrorView = function(error) {\n+    FramedErrorView.call(this, error);\n+  };\n+\n+  DnsNotFoundFramedErrorView.prototype = {\n+    __proto__: FramedErrorView.prototype,\n+\n+    populateMessages: function dnffew_populateMessages() {\n+      localizeElement(this.title, 'server-not-found');\n+      localizeElement(this.message, 'server-not-found-error', {\n+        name: location.host\n+      });\n+    }\n+  };\n+\n+  var DnsNotFoundAppErrorView = function(error) {\n+    AppErrorView.call(this, error);\n+  };\n+\n+  DnsNotFoundAppErrorView.prototype = {\n+    __proto__: DnsNotFoundFramedErrorView.prototype,\n+\n+    addHandlers: AppErrorView.prototype.addHandlers\n+  };\n+\n+  // Offline view\n+  var NetOfflineErrorView = function(error) {\n+    ErrorView.call(this, error);\n+    applyAppStyle();\n+    this.node = document.getElementById('net-error-action-menu');\n+  };\n+\n+  NetOfflineErrorView.prototype = {\n+    __proto__: ErrorView.prototype,\n+\n+    populateMessages: function noew_populateMessages() {\n+      if (isInApp()) {\n+        localizeElement(this.title, 'network-error-in-app');\n+      } else {\n+        getAppName((function localizeTitle(appName) {\n+          localizeElement(this.title, 'network-error-launching', {\n+            name: appName\n+          });\n+        }).bind(this));\n+      }\n+    },\n+\n+    addHandlers: function noew_addHandlers() {\n+      addConnectionHandlers();","path":"apps/system/js/net_error.js","position":358,"original_position":296,"commit_id":"59ff1100a2eef53af08c30bc75e2081b3c4557d5","original_commit_id":"a7d6309048803d7e4ff60c90414b5ab161ae90b2","user":{"login":"crdlc","id":1722741,"avatar_url":"https://avatars.githubusercontent.com/u/1722741","gravatar_id":"543212083e575559480c086cc3bc436d","url":"https://api.github.com/users/crdlc","html_url":"https://github.com/crdlc","followers_url":"https://api.github.com/users/crdlc/followers","following_url":"https://api.github.com/users/crdlc/following{/other_user}","gists_url":"https://api.github.com/users/crdlc/gists{/gist_id}","starred_url":"https://api.github.com/users/crdlc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crdlc/subscriptions","organizations_url":"https://api.github.com/users/crdlc/orgs","repos_url":"https://api.github.com/users/crdlc/repos","events_url":"https://api.github.com/users/crdlc/events{/privacy}","received_events_url":"https://api.github.com/users/crdlc/received_events","type":"User","site_admin":false},"body":"Finally we have two netoffline UIs for framed and un-framed ","created_at":"2014-03-04T13:10:11Z","updated_at":"2014-03-04T13:10:11Z","html_url":"https://github.com/mozilla-b2g/gaia/pull/16366#discussion_r10253421","pull_request_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/16366","_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/10253421"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/16366#discussion_r10253421"},"pull_request":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/16366"}}}}