[extensions-web] js: Introduce a "dummy" version
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] js: Introduce a "dummy" version
- Date: Tue, 14 Feb 2012 18:14:23 +0000 (UTC)
commit 65e13dcc431d570b6ce267dca141db64ac88edc2
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Tue Feb 14 12:52:28 2012 -0500
js: Introduce a "dummy" version
This should simplify the code path of having to test for a dbusProxy
before using it.
sweettooth/static/js/dbus.js | 23 +++++++++--------------
sweettooth/static/js/extensions.js | 3 +--
sweettooth/static/js/versions/1/main.js | 2 ++
sweettooth/static/js/versions/2/main.js | 2 ++
sweettooth/static/js/versions/3/main.js | 2 ++
sweettooth/static/js/versions/dummy/main.js | 10 ++++++++++
6 files changed, 26 insertions(+), 16 deletions(-)
---
diff --git a/sweettooth/static/js/dbus.js b/sweettooth/static/js/dbus.js
index b786b2e..8d1756e 100644
--- a/sweettooth/static/js/dbus.js
+++ b/sweettooth/static/js/dbus.js
@@ -45,24 +45,19 @@ define({
return;
}
- var apiVersion;
+ var apiVersion = "dummy";
try {
- if (window.SweetTooth)
+ if (window.SweetTooth) {
apiVersion = window.SweetTooth.apiVersion;
- } catch (e) {
- apiVersion = null;
- }
+ }
+ } catch (e) { }
- if (apiVersion) {
- var scriptname = './versions/' + apiVersion + '/main';
- // requirejs caches response.
- req([scriptname], function(module) {
- onLoad(module);
- });
- } else {
- onLoad();
- }
+ var scriptname = './versions/' + apiVersion + '/main';
+ // requirejs caches response.
+ req([scriptname], function(module) {
+ onLoad(module);
+ });
});
}
});
diff --git a/sweettooth/static/js/extensions.js b/sweettooth/static/js/extensions.js
index dcf1623..62e853d 100644
--- a/sweettooth/static/js/extensions.js
+++ b/sweettooth/static/js/extensions.js
@@ -33,8 +33,7 @@ function($, messages, dbusProxy, extensionUtils) {
// While technically we shouldn't have mismatched API versions,
// the plugin doesn't check whether the Shell matches, so if someone
// is running with an old Shell version but a newer plugin, error out.
- if (dbusProxy === undefined ||
- dbusProxy.ShellVersion === undefined) {
+ if (dbusProxy.IsDummy) {
// We don't have a proper DBus proxy -- it's probably an old
// version of GNOME3 or the Shell.
messages.addError("You do not appear to have an up to date version " +
diff --git a/sweettooth/static/js/versions/1/main.js b/sweettooth/static/js/versions/1/main.js
index 23cb2ea..5da7a5d 100644
--- a/sweettooth/static/js/versions/1/main.js
+++ b/sweettooth/static/js/versions/1/main.js
@@ -2,6 +2,8 @@
define(['jquery', 'dbus!API', 'versions/common/common'], function($, API, common) {
var proxy = {
+ IsDummy: false,
+
ListExtensions: common.ListExtensions,
GetExtensionInfo: common.GetExtensionInfo,
GetErrors: common.GetErrors,
diff --git a/sweettooth/static/js/versions/2/main.js b/sweettooth/static/js/versions/2/main.js
index e90cae3..7518cfa 100644
--- a/sweettooth/static/js/versions/2/main.js
+++ b/sweettooth/static/js/versions/2/main.js
@@ -2,6 +2,8 @@
define(['jquery', 'dbus!API', 'versions/common/common'], function($, API, common) {
var proxy = {
+ IsDummy: false,
+
ListExtensions: common.ListExtensions,
GetExtensionInfo: common.GetExtensionInfo,
GetErrors: common.GetErrors,
diff --git a/sweettooth/static/js/versions/3/main.js b/sweettooth/static/js/versions/3/main.js
index c64ca36..7b99a26 100644
--- a/sweettooth/static/js/versions/3/main.js
+++ b/sweettooth/static/js/versions/3/main.js
@@ -2,6 +2,8 @@
define(['jquery', 'dbus!API', 'versions/common/common'], function($, API, common) {
var proxy = {
+ IsDummy: false,
+
ListExtensions: common.ListExtensions,
GetExtensionInfo: common.GetExtensionInfo,
GetErrors: common.GetErrors,
diff --git a/sweettooth/static/js/versions/dummy/main.js b/sweettooth/static/js/versions/dummy/main.js
new file mode 100644
index 0000000..1125895
--- /dev/null
+++ b/sweettooth/static/js/versions/dummy/main.js
@@ -0,0 +1,10 @@
+"use strict";
+
+define(['jquery'], function($) {
+ var proxy = {
+ IsDummy: true,
+ ShellVersion: undefined,
+ };
+
+ return proxy;
+});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]