ripple-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brent Lintner <brent.lint...@gmail.com>
Subject Re: git commit: Add device selection to enableRipple qsparam
Date Thu, 14 Mar 2013 19:49:17 GMT
Nice!

On Thu, Mar 14, 2013 at 3:43 PM, <gtanner@apache.org> wrote:

> Updated Branches:
>   refs/heads/next 7c214f362 -> b36213d42
>
>
> Add device selection to enableRipple qsparam
>
> - updated the ui platform reload to regenerate the query string
>   parameter when it exists before refreshing. There was a bug where when
>   switching platforms using hosted it didn't switch due to the qs param
>   overriding the persisted values.
> - added device to the qsparam and made the search for devices with the
>   id case insensitive.
>
>
> Project: http://git-wip-us.apache.org/repos/asf/incubator-ripple/repo
> Commit:
> http://git-wip-us.apache.org/repos/asf/incubator-ripple/commit/b36213d4
> Tree:
> http://git-wip-us.apache.org/repos/asf/incubator-ripple/tree/b36213d4
> Diff:
> http://git-wip-us.apache.org/repos/asf/incubator-ripple/diff/b36213d4
>
> Branch: refs/heads/next
> Commit: b36213d426700a3cc62b4701bc75806ff8539528
> Parents: 7c214f3
> Author: Gord Tanner <gtanner@gmail.com>
> Authored: Thu Mar 14 15:16:10 2013 -0400
> Committer: Gord Tanner <gtanner@gmail.com>
> Committed: Thu Mar 14 15:42:03 2013 -0400
>
> ----------------------------------------------------------------------
>  lib/client/devices.js             |   11 ++++++++---
>  lib/client/platform.js            |    1 +
>  lib/client/ui/plugins/platform.js |    6 +++++-
>  test/unit/client/devices.js       |    3 ++-
>  4 files changed, 16 insertions(+), 5 deletions(-)
> ----------------------------------------------------------------------
>
>
>
> http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/b36213d4/lib/client/devices.js
> ----------------------------------------------------------------------
> diff --git a/lib/client/devices.js b/lib/client/devices.js
> index 4206ee4..68e68c9 100644
> --- a/lib/client/devices.js
> +++ b/lib/client/devices.js
> @@ -31,6 +31,11 @@ event.on("HardwareKeyDefault", function (key) {
>      }
>  });
>
> +function _getRequestedDevice() {
> +    //format is platform-version-device
> +    return (utils.queryString().enableripple || "").split('-')[2];
> +}
> +
>  _self = module.exports = {
>      initialize: function () {
>          _devices = [
> @@ -73,7 +78,7 @@ _self = module.exports = {
>              "WQVGA",
>              "WVGA"
>          ].reduce(function (hash, deviceID) {
> -            hash[deviceID] = ripple('devices/' + deviceID);
> +            hash[deviceID.toLowerCase()] = ripple('devices/' + deviceID);
>              return hash;
>          }, {});
>
> @@ -82,7 +87,7 @@ _self = module.exports = {
>      },
>
>      getCurrentDevice: function () {
> -        var deviceId = db.retrieve("device-key"),
> +        var deviceId = _getRequestedDevice() || db.retrieve("device-key"),
>              device = this.getDevice(deviceId),
>              platformId = platform.current().id,
>              does = function (device) {
> @@ -107,7 +112,7 @@ _self = module.exports = {
>      },
>
>      getDevice: function (deviceId) {
> -        return _devices[deviceId] ? utils.copy(_devices[deviceId]) : null;
> +        return utils.copy(_devices[(deviceId || "").toLowerCase()]);
>      },
>
>      getDevicesForPlatform: function (platformId) {
>
>
> http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/b36213d4/lib/client/platform.js
> ----------------------------------------------------------------------
> diff --git a/lib/client/platform.js b/lib/client/platform.js
> index cba9ab2..7a9eb37 100644
> --- a/lib/client/platform.js
> +++ b/lib/client/platform.js
> @@ -34,6 +34,7 @@ function _getRequestedPlatform() {
>
>      if (enableRippleArg) {
>          enableRippleArg = enableRippleArg.split('-');
> +        //format is platform-version-device
>          platform = spec.get(enableRippleArg[0], enableRippleArg[1]);
>          if (platform) {
>              requestedPlatform = { name: platform.id, version:
> platform.version };
>
>
> http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/b36213d4/lib/client/ui/plugins/platform.js
> ----------------------------------------------------------------------
> diff --git a/lib/client/ui/plugins/platform.js
> b/lib/client/ui/plugins/platform.js
> index 0a80b54..e1062bf 100644
> --- a/lib/client/ui/plugins/platform.js
> +++ b/lib/client/ui/plugins/platform.js
> @@ -66,7 +66,11 @@ function changePlatformOrDevice() {
>          "name": platformId,
>          "version": version
>      }, device, function () {
> -        location.reload();
> +        var original = utils.queryString().enableripple,
> +            updated = platformId + "-" + version + "-" + device;
> +
> +        if (original) { location.href = location.href.replace(original,
> updated); }
> +        else { location.reload(); }
>      });
>  }
>
>
>
> http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/b36213d4/test/unit/client/devices.js
> ----------------------------------------------------------------------
> diff --git a/test/unit/client/devices.js b/test/unit/client/devices.js
> index 98165c0..1fcebb6 100644
> --- a/test/unit/client/devices.js
> +++ b/test/unit/client/devices.js
> @@ -23,6 +23,7 @@ describe("devices", function () {
>          event = ripple('event'),
>          platform = ripple('platform'),
>          emulatorBridge = ripple('emulatorBridge'),
> +        utils = ripple('utils'),
>          bus = ripple('bus'),
>          db = ripple('db');
>
> @@ -33,8 +34,8 @@ describe("devices", function () {
>          spyOn(platform, "current").andReturn({
>              id: "web"
>          });
> +        spyOn(utils, "queryString").andReturn({});
>          devices.initialize();
> -
>      });
>
>      it("getDevice returns a copied device object", function () {
>
>


-- 
Brent

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message