Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #4 from tinyhippos/next

Code Pull for ripple 0.6.0
  • Loading branch information...
commit 1225bb0b2003885a93245587cad70e60a825d5d2 2 parents 7c78160 + b614829
@gtanner gtanner authored
Showing with 531 additions and 334 deletions.
  1. +2 −2 Jakefile
  2. +0 −1  build/btest/test.html
  3. +1 −2  build/test.js
  4. BIN  ext/assets/images/Torch.png
  5. BIN  ext/assets/images/Torch_landscape.png
  6. +4 −3 ext/chromium/controllers/Insertion.js
  7. +0 −1  lib/ripple.js
  8. +6 −6 lib/ripple/console.js
  9. +12 −10 lib/ripple/devices/Torch/skin.css
  10. +8 −3 lib/ripple/emulatorBridge.js
  11. +1 −1  lib/ripple/fileSystem.js
  12. +3 −8 lib/ripple/platform.js
  13. +5 −5 lib/ripple/platform/opera/4.0/widget.js
  14. +1 −2  lib/ripple/platform/phonegap/0.9/navigator.js
  15. +2 −3 lib/ripple/platform/phonegap/0.9/notification.js
  16. +1 −1  lib/ripple/platform/w3c/1.0/geolocation.js
  17. +4 −7 lib/ripple/platform/wac/1.0/AudioPlayer.js
  18. +3 −4 lib/ripple/platform/wac/1.0/Camera.js
  19. +1 −2  lib/ripple/platform/wac/1.0/DataNetworkInfo.js
  20. +2 −3 lib/ripple/platform/wac/1.0/Device.js
  21. +3 −3 lib/ripple/platform/wac/1.0/DeviceStateInfo.js
  22. +1 −2  lib/ripple/platform/wac/1.0/Messaging.js
  23. +4 −5 lib/ripple/platform/wac/1.0/PowerInfo.js
  24. +1 −2  lib/ripple/platform/wac/1.0/RadioInfo.js
  25. +2 −5 lib/ripple/platform/wac/1.0/VideoPlayer.js
  26. +3 −3 lib/ripple/platform/wac/1.0/Widget.js
  27. +17 −2 lib/ripple/platform/web/default/spec.js
  28. +5 −0 lib/ripple/platform/web/default/spec/ui.js
  29. +1 −1  lib/ripple/platform/webworks/2.0.0/XMLHttpRequest.js
  30. +1 −1  lib/ripple/platform/webworks/2.0.0/client/Appointment.js
  31. +9 −9 lib/ripple/platform/webworks/2.0.0/client/AudioPlayer.js
  32. +1 −1  lib/ripple/platform/webworks/2.0.0/client/Contact.js
  33. +1 −1  lib/ripple/platform/webworks/2.0.0/client/Memo.js
  34. +1 −1  lib/ripple/platform/webworks/2.0.0/client/Message.js
  35. +3 −3 lib/ripple/platform/webworks/2.0.0/client/Phone.js
  36. +5 −5 lib/ripple/platform/webworks/2.0.0/client/PhoneLogs.js
  37. +1 −1  lib/ripple/platform/webworks/2.0.0/client/Task.js
  38. +10 −10 lib/ripple/platform/webworks/2.0.0/client/app.js
  39. +1 −1  lib/ripple/platform/webworks/2.0.0/client/blackberry.js
  40. +36 −0 lib/ripple/platform/webworks/2.0.0/client/category.js
  41. +4 −4 lib/ripple/platform/webworks/2.0.0/client/dialog.js
  42. +6 −6 lib/ripple/platform/webworks/2.0.0/client/identity.js
  43. +4 −4 lib/ripple/platform/webworks/2.0.0/client/identity/phone.js
  44. +1 −1  lib/ripple/platform/webworks/2.0.0/client/menu.js
  45. +2 −22 lib/ripple/platform/webworks/2.0.0/client/pim.js
  46. +1 −1  lib/ripple/platform/webworks/2.0.0/client/push.js
  47. +1 −1  lib/ripple/platform/webworks/2.0.0/client/sms.js
  48. +7 −7 lib/ripple/platform/webworks/2.0.0/client/system.js
  49. +24 −15 lib/ripple/platform/webworks/2.0.0/client/transport.js
  50. +33 −14 lib/ripple/platform/webworks/2.0.0/server/contact.js
  51. +0 −1  lib/ripple/platform/webworks/2.0.0/server/dialog.js
  52. +0 −1  lib/ripple/platform/webworks/2.0.0/server/menu.js
  53. +1 −2  lib/ripple/platform/webworks/2.0.0/server/sms.js
  54. +5 −1 lib/ripple/platform/webworks/2.0.0/spec.js
  55. +3 −2 lib/ripple/ui/plugins/deviceSettings.js
  56. +1 −2  lib/ripple/ui/plugins/phone.js
  57. +1 −1  lib/ripple/ui/plugins/platformEvents.js
  58. +1 −2  lib/ripple/ui/plugins/telephony.js
  59. +1 −1  lib/ripple/widgetConfig.js
  60. +1 −1  lib/ripple/xhr/base.js
  61. +50 −10 test/console.js
  62. +6 −6 test/emulatorBridge.js
  63. +0 −2  test/phonegap/navigator.js
  64. +48 −27 test/platform.js
  65. +6 −8 test/w3c/geolocation.js
  66. +31 −0 test/web/geolocation.js
  67. +1 −1  test/webworks/Message.js
  68. +2 −2 test/webworks/Task.js
  69. +1 −1  test/webworks/app.js
  70. +4 −4 test/webworks/appointment.js
  71. +1 −1  test/webworks/audioPlayer.js
  72. +1 −1  test/webworks/blackberry.js
  73. +17 −17 test/webworks/category.js
  74. +3 −3 test/webworks/contact.js
  75. +4 −4 test/webworks/dialog.js
  76. +4 −6 test/webworks/identity/Transport.js
  77. +6 −6 test/webworks/identity/identity.js
  78. +4 −4 test/webworks/identity/phone.js
  79. +1 −1  test/webworks/memo.js
  80. +8 −9 test/webworks/phone.js
  81. +4 −4 test/webworks/system.js
  82. +70 −8 test/webworks/transport.js
View
4 Jakefile
@@ -23,8 +23,8 @@ desc("test and lint before building (with js compression)");
task('deploy', [], require('./build/deploy'));
desc("run all tests in node with an emulated dom - jake test [path,path2]");
-task('test', [], function (custom) {
- require('./build/test')(null, custom);
+task('test', [], function () {
+ require('./build/test')(null, process.argv.length >= 4 ? process.argv[3] : null);
});
desc("boot test server for running all tests in the browser");
View
1  build/btest/test.html
@@ -82,7 +82,6 @@
<script src="thirdparty/browser-require/require.js" type="text/javascript" charset="utf-8"></script>
<script src="thirdparty/Math.uuid.js" type="text/javascript" charset="utf-8"></script>
<script src="thirdparty/jquery.js" type="text/javascript" charset="utf-8"></script>
- <script src="thirdparty/aop.js" type="text/javascript" charset="utf-8"></script>
<script src="thirdparty/jquery.ui.js" type="text/javascript" charset="utf-8"></script>
<script src="thirdparty/jquery.dimensions.js" type="text/javascript" charset="utf-8"></script>
<script src="thirdparty/jquery.tooltip.js" type="text/javascript" charset="utf-8"></script>
View
3  build/test.js
@@ -46,8 +46,7 @@ function _setupEnv(ready) {
layout = fs.readFileSync(__dirname + "/../ext/assets/index.html", "utf-8"),
thirdparty = [
__dirname + "/../thirdparty/jquery.js",
- __dirname + "/../thirdparty/jquery.ui.js",
- __dirname + "/../thirdparty/aop.js"
+ __dirname + "/../thirdparty/jquery.ui.js"
];
jsdom.env(layout, thirdparty, function (error, window) {
View
BIN  ext/assets/images/Torch.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  ext/assets/images/Torch_landscape.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
7 ext/chromium/controllers/Insertion.js
@@ -16,12 +16,13 @@
(function () {
function _subscribeToEnableDisable() {
chrome.extension.onRequest.addListener(function (request, sender, sendResponse) {
- switch (request.action)
- {
+ var uri = location.href;
+ switch (request.action) {
case "enable":
break;
case "disable":
localStorage.removeItem("tinyhippos-enabled-uri");
+ uri = uri.toLowerCase().replace("?enableripple=true", "").replace("&enableripple=true", "");
break;
default:
@@ -29,7 +30,7 @@
}
sendResponse({});
- location.assign(location.href);
+ location.assign(uri);
});
}
View
1  lib/ripple.js
@@ -36,7 +36,6 @@ var omgwtf = require('ripple/omgwtf'),
.andThen(devices.initialize, devices)
.andThen(platform.initialize, platform)
.andThen(widgetConfig.initialize, widgetConfig)
- .andThen(platform.inject, platform)
.andThen(deviceSettings.initialize, deviceSettings)
.andThen(ui.initialize, ui)
.start(booted);
View
12 lib/ripple/console.js
@@ -13,15 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+var _self;
+
function _log(msg, method) {
try {
- console[method](msg);
+ console[method](_self.prefix ? _self.prefix + " :: " + msg : msg);
} catch (e) {
// silent
}
}
-module.exports = {
+_self = {
log: function (msg) {
_log(msg, "log");
},
@@ -32,9 +34,7 @@ module.exports = {
error: function (msg) {
_log(msg, "error");
- },
-
- clear: function () {
- console.clear();
}
};
+
+module.exports = _self;
View
22 lib/ripple/devices/Torch/skin.css
@@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
/* ------------------------------>
- Torch Skin (446x782) offset (41x144)*/
+ Torch Skin (444x779) offset (40x142)*/
.viewport-wrapper-Torch {
width:360px;
height:480px;
@@ -23,9 +24,9 @@
.device-wrapper-Torch {
position: relative;
- padding: 144px 0 0 41px;
- width:405px;
- height:638px;
+ padding: 142px 0 0 40px;
+ width:404px;
+ height:637px;
margin: 0 auto;
border: none;
-webkit-box-shadow: none;
@@ -35,7 +36,7 @@
.menu-button-wrapper-Torch {
position: relative;
display: inline-block;
- margin: 30px 0 0 75px;
+ margin: 32px 0 0 75px;
width: 55px;
height: 65px;
cursor: pointer;
@@ -44,14 +45,14 @@
.back-button-wrapper-Torch {
position: relative;
display: inline-block;
- margin: 0 0 0 95px;
+ margin: 0 0 0 92px;
width: 55px;
height: 65px;
cursor: pointer;
}
.viewport-wrapper-landscape-Torch {
- margin: -99px 0 0 104px;
+ margin: -99px 0 0 103px;
width:480px;
height:360px;
border: none;
@@ -60,9 +61,9 @@
.device-wrapper-landscape-Torch {
position: relative;
- padding: 144px 0 0 41px;
- width:740px;
- height:300px;
+ padding: 142px 0 0 40px;
+ width:739px;
+ height:302px;
margin: 0 auto;
border: none;
-webkit-box-shadow: none;
@@ -86,3 +87,4 @@
height: 65px;
cursor: pointer;
}
+
View
11 lib/ripple/emulatorBridge.js
@@ -15,6 +15,7 @@
*/
var _isMouseDown = false,
platform = require('ripple/platform'),
+ builder = require('ripple/platform/builder'),
constants = require('ripple/constants'),
utils = require('ripple/utils'),
exception = require('ripple/exception'),
@@ -72,12 +73,16 @@ module.exports = {
_frame = frame;
var marshal = function (obj, key) {
- window[key] = _frame.contentWindow[key] = obj;
- };
+ window[key] = _frame.contentWindow[key] = obj;
+ },
+ sandbox = {};
marshal(window.tinyHippos, "tinyHippos");
marshal(window.XMLHttpRequest, "XMLHttpRequest");
- utils.forEach(platform.sandbox, marshal);
+
+ builder.build(platform.current().objects).into(sandbox);
+
+ utils.forEach(sandbox, marshal);
_marshalScreen(_frame.contentWindow);
_marshalScreen(window);
View
2  lib/ripple/fileSystem.js
@@ -77,7 +77,7 @@ module.exports = {
}
catch (e) {
exception.handle(e);
- _console.log("Emulator :: failed to check if [" + path + "] exists");
+ _console.log("failed to check if [" + path + "] exists");
return false;
}
},
View
11 lib/ripple/platform.js
@@ -20,8 +20,7 @@ var _current,
constants = require('ripple/constants'),
app = require('ripple/app'),
event = require('ripple/event'),
- builder = require('ripple/platform/builder'),
- spec,
+ spec = require('ripple/platform/spec'),
_self;
function _checkForDeprecatedPlatforms(replacement) {
@@ -39,10 +38,7 @@ function _getPlatform() {
}
_self = {
- sandbox: {},
-
initialize: function () {
- spec = require('ripple/platform/spec');
var firstAvailablePlatform = utils.map(this.getList(), function (platform) {
return utils.map(platform, function (details, version) {
return {name: details.id, version: version};
@@ -56,10 +52,8 @@ _self = {
} else {
_current = firstAvailablePlatform;
}
- },
- inject: function () {
- builder.build(_getPlatform().objects).into(_self.sandbox);
+ _console.prefix = _getPlatform().name;
},
getList: function () {
@@ -101,6 +95,7 @@ _self = {
db.save(constants.ENCAPSULATOR.LAYOUT, null, null, baton.pass);
}).andThen(function () {
event.trigger("PlatformChangedEvent", true);
+ _console.prefix = null;
_console.log("Emulator :: loading platform " + platform.name);
});
View
10 lib/ripple/platform/opera/4.0/widget.js
@@ -25,7 +25,7 @@ var event = require('ripple/event'),
event.on("ScreenChangeDimensions", function (width, height) {
var eventToFire = document.createEvent("Event");
- _console.log(platform.current().name + " :: Firing resolution changed event for width: " + width + " and height: " + height);
+ _console.log("Firing resolution changed event for width: " + width + " and height: " + height);
eventToFire.height = height;
eventToFire.width = width;
eventToFire.initEvent("resolution", false, false);
@@ -61,7 +61,7 @@ _self = {
utils.validateNumberOfArguments(1, 2, arguments.length);
utils.validateArgumentType(key, "string");
- var msg = platform.current().name + " :: ",
+ var msg = "",
prefix = platform.getPersistencePrefix();
if (app.isPreferenceReadOnly(key)) {
@@ -90,7 +90,7 @@ _self = {
var prefix = platform.getPersistencePrefix(),
value = db.retrieve(key, prefix) || undefined;
- _console.log(platform.current().name + " :: retrieving preference " + key + " == " + value);
+ _console.log("retrieving preference " + key + " == " + value);
return value;
},
@@ -116,13 +116,13 @@ _self = {
},
addEventListener: function (type, expression, bubbling) {
- _console.log(platform.current().name + " :: Adding Widget Event Listener for type == " + type);
+ _console.log("Adding Widget Event Listener for type == " + type);
bubbling = bubbling || false;
window.addEventListener(type, expression, bubbling);
},
removeEventListener: function (type, listener, useCapture) {
- _console.log(platform.current().name + " :: Removing a Widget Event Listener for type == " + type);
+ _console.log("Removing a Widget Event Listener for type == " + type);
window.removeEventListener(type, listener, useCapture);
}
};
View
3  lib/ripple/platform/phonegap/0.9/navigator.js
@@ -18,7 +18,6 @@ var nav = require('ripple/platform/w3c/1.0/navigator'),
_console = require('ripple/console'),
utils = require('ripple/utils'),
emulatorBridge = require('ripple/emulatorBridge'),
- platform = require('ripple/platform'),
_self = {};
event.on("TinyHipposLoaded", function () {
@@ -26,7 +25,7 @@ event.on("TinyHipposLoaded", function () {
evt = doc.createEvent("Events");
evt.initEvent("deviceready", true, true);
doc.dispatchEvent(evt);
- _console.log(platform.current().name + " :: fired deviceready event!");
+ _console.log("fired deviceready event!");
});
utils.mixin(nav, _self);
View
5 lib/ripple/platform/phonegap/0.9/notification.js
@@ -17,8 +17,7 @@ var notifications = require('ripple/notifications'),
constants = require('ripple/constants'),
_console = require('ripple/console'),
ui = require('ripple/ui'),
- goodVibrations = require('ripple/ui/plugins/goodVibrations'),
- platform = require('ripple/platform');
+ goodVibrations = require('ripple/ui/plugins/goodVibrations');
module.exports = {
alert: function (message, title, buttonName) {
@@ -27,7 +26,7 @@ module.exports = {
beep: function (times) {
for (var i = times; i > 0; i--) {
- _console.log(platform.current().name + " :: beep!");
+ _console.log("beep!");
}
notifications.openNotification(constants.NOTIFICATIONS.TYPES.NORMAL, "BEEP x " + times);
},
View
2  lib/ripple/platform/w3c/1.0/geolocation.js
@@ -28,6 +28,7 @@ event.on("PositionInfoUpdatedEvent", function (positionInfo) {
_positionInfo.coords.longitude = positionInfo.longitude;
_positionInfo.coords.altitude = positionInfo.altitude;
_positionInfo.coords.altitudeAccuracy = positionInfo.altitudeAccuracy;
+ _positionInfo.coords.accuracy = positionInfo.accuracy;
_positionInfo.coords.heading = positionInfo.heading;
_positionInfo.coords.speed = positionInfo.speed;
_positionInfo.timestamp = positionInfo.timeStamp.getTime();
@@ -59,7 +60,6 @@ _self = {
var watchId = (new Date()).getTime().toString(),
watchObj = {};
-
if (geolocationOptions &&
geolocationOptions.frequency && typeof
geolocationOptions.frequency === "number" &&
View
11 lib/ripple/platform/wac/1.0/AudioPlayer.js
@@ -15,7 +15,6 @@
*/
var constants = require('ripple/constants'),
event = require('ripple/event'),
- platform = require('ripple/platform'),
exception = require('ripple/exception'),
utils = require('ripple/utils'),
fileSystem = require('ripple/fileSystem'),
@@ -40,9 +39,9 @@ _audio = utils.createElement("audio", {
});
_audio.addEventListener('error', function () {
- _console.warn(platform.current().name + " :: AudioPlayer encountered an error: " + _audio.error.code);
+ _console.warn("AudioPlayer encountered an error: " + _audio.error.code);
if (_audio.error.code === 4) {
- _console.warn(platform.current().name + " :: AudioPlayer error 4 could be caused by missing codecs");
+ _console.warn("AudioPlayer error 4 could be caused by missing codecs");
}
_state = null;
event.trigger("MultimediaAudioStateChanged", [null], true);
@@ -68,8 +67,7 @@ function _validateAndSet(state, validStates, callbackBeforeSuccess) {
}
if (!valid) {
- _console.warn(platform.current().name +
- " :: Attempted to initiate AudioPlayer." + state +
+ _console.warn("Attempted to initiate AudioPlayer." + state +
" in invalid state. current state: " + _state);
} else {
if (typeof(callbackBeforeSuccess) === "function") {
@@ -86,8 +84,7 @@ function _validateAudioType(fileUrl) {
type = matched ? matched[1] : "";
if (_audio && _audio.canPlayType("audio/" + type) === "") {
- _console.warn(platform.current().name +
- " :: Attempting to load an audio that might not work in the current browser [" + fileUrl + "]");
+ _console.warn("Attempting to load an audio that might not work in the current browser [" + fileUrl + "]");
}
}
View
7 lib/ripple/platform/wac/1.0/Camera.js
@@ -19,7 +19,6 @@ var exception = require('ripple/exception'),
constants = require('ripple/constants'),
_console = require('ripple/console'),
utils = require('ripple/utils'),
- platform = require('ripple/platform'),
notifications = require('ripple/notifications'),
_currentlySet,
_img,
@@ -78,7 +77,7 @@ _self = {
var msg = constants.CAMERA.WARNING_TEXT;
msg = msg.replace("{file}", fileName);
notifications.openNotification(constants.NOTIFICATIONS.TYPES.NORMAL, msg);
- _console.log(platform.current().name + " :: simulated saved image as: " + fileName);
+ _console.log("simulated saved image as: " + fileName);
if (_self.onCameraCaptured) {
_self.onCameraCaptured.apply(_self, [fileName]);
}
@@ -106,7 +105,7 @@ _self = {
['string', 'boolean', 'integer', 'boolean'],
ExceptionTypes.INVALID_PARAMETER,
"invalid parameter type", new Exception());
- _console.log(platform.current().name + " :: started recording video");
+ _console.log("started recording video");
var interval = window.setTimeout(function () {
_self.stopVideoCapture();
}, maxDurationSeconds * 1000);
@@ -133,7 +132,7 @@ _self = {
stopVideoCapture: function () {
utils.validateNumberOfArguments(0, 0, arguments.length, ExceptionTypes.INVALID_PARAMETER, "stopVideoCapture invalid number of parameters", new Exception());
if (_videoCapture) {
- _console.log(platform.current().name + " :: simulated saving a video as: " + _videoCapture.fileName);
+ _console.log("simulated saving a video as: " + _videoCapture.fileName);
if (_buttons) {
_buttons.setAttribute("style", "display: none");
}
View
3  lib/ripple/platform/wac/1.0/DataNetworkInfo.js
@@ -14,7 +14,6 @@
* limitations under the License.
*/
var event = require('ripple/event'),
- platform = require('ripple/platform'),
utils = require('ripple/utils'),
_console = require('ripple/console'),
deviceSettings = require('ripple/deviceSettings'),
@@ -37,7 +36,7 @@ _self = {
event.on("DataNetworkConnectionChanged", function (newConnectionName) {
var callback = _self.onNetworkConnectionChanged,
- msg = platform.current().name + " :: Fired onNetworkConnectionChanged with newConnectionName: " + newConnectionName;
+ msg = "Fired onNetworkConnectionChanged with newConnectionName: " + newConnectionName;
if (callback && typeof callback === "function") {
callback.apply(null, [newConnectionName]);
View
5 lib/ripple/platform/wac/1.0/Device.js
@@ -14,9 +14,8 @@
* limitations under the License.
*/
var constants = require('ripple/constants'),
- exception = require('ripple/platform'),
+ exception = require('ripple/exception'),
_console = require('ripple/console'),
- platform = require('ripple/platform'),
utils = require('ripple/utils'),
notifications = require('ripple/notifications'),
ApplicationTypes = require('ripple/platform/wac/1.0/ApplicationTypes'),
@@ -82,7 +81,7 @@ _self = {
}
notifications.openNotification(constants.NOTIFICATIONS.TYPES.NORMAL, message);
- _console.log(platform.current().name + " :: " + message);
+ _console.log(message);
},
copyFile: function () {
View
6 lib/ripple/platform/wac/1.0/DeviceStateInfo.js
@@ -13,8 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-var platform = require('ripple/platform'),
- utils = require('ripple/utils'),
+var utils = require('ripple/utils'),
exception = require('ripple/exception'),
_console = require('ripple/console'),
geo = require('ripple/geo'),
@@ -30,7 +29,7 @@ event.on("ScreenChangeDimensions", function (width, height) {
if (typeof _self.onScreenChangeDimensions === 'function') {
_self.onScreenChangeDimensions(width, height);
}
- _console.log(platform.current().name + " :: called DeviceStateInfo.onScreenChangeDimensions callback function with width = " + width + " and height = " + height);
+ _console.log("called DeviceStateInfo.onScreenChangeDimensions callback function with width = " + width + " and height = " + height);
} catch (e) {
exception.handle(e, false);
}
@@ -106,3 +105,4 @@ _self.__defineGetter__("processorUtilizationPercent", function () {
});
module.exports = _self;
+
View
3  lib/ripple/platform/wac/1.0/Messaging.js
@@ -18,7 +18,6 @@ var exception = require('ripple/exception'),
constants = require('ripple/constants'),
notifications = require('ripple/notifications'),
_console = require('ripple/console'),
- platform = require('ripple/platform'),
Message = require('ripple/platform/wac/1.0/Message'),
MessageTypes = require('ripple/platform/wac/1.0/MessageTypes'),
Exception = require('ripple/platform/wac/1.0/Exception'),
@@ -68,7 +67,7 @@ module.exports = {
// insert fail check here
notifications.openNotification(constants.NOTIFICATIONS.TYPES.NORMAL, message);
- _console.log(platform.current().name + " :: " + message);
+ _console.log(message);
},
moveMessageToFolder: function () {
_throwUnsupportedException("Messaging.moveMessageToFolder");
View
9 lib/ripple/platform/wac/1.0/PowerInfo.js
@@ -16,7 +16,6 @@
var _self,
event = require('ripple/event'),
_console = require('ripple/console'),
- platform = require('ripple/platform'),
deviceSettings = require('ripple/deviceSettings'),
_lastPercentRemaining;
@@ -45,13 +44,13 @@ function _getCurrentChargeState(percentRemaining, isCharging) {
event.on("DeviceBatteryStateChanged", function (isCharging) {
var callback = _self.onChargeStateChange,
- msg = platform.current().name,
+ msg = "",
batteryLevel = _self.percentRemaining,
batteryState;
batteryState = _getCurrentChargeState(batteryLevel, isCharging);
- msg += " :: Fired onChargeStateChange with batteryState: " + batteryState;
+ msg += "Fired onChargeStateChange with batteryState: " + batteryState;
if (callback && typeof callback === "function") {
callback.apply(null, [batteryState]);
@@ -67,7 +66,7 @@ event.on("DeviceBatteryLevelChanged", function (percentRemaining) {
var callback = _self.onChargeLevelChange,
lowBatteryCallback = _self.onLowBattery,
- msg = platform.current().name + " :: Fired onChargeLevelChange with percentRemaining: " + percentRemaining;
+ msg = "Fired onChargeLevelChange with percentRemaining: " + percentRemaining;
// blah, stupid Options returning strings
percentRemaining = parseInt(percentRemaining, 10);
@@ -83,7 +82,7 @@ event.on("DeviceBatteryLevelChanged", function (percentRemaining) {
if (percentRemaining <= 10) {
- msg = platform.current().name + " :: Fired onLowBattery with percentRemaining: " + percentRemaining;
+ msg = "Fired onLowBattery with percentRemaining: " + percentRemaining;
if (lowBatteryCallback && typeof lowBatteryCallback === "function") {
lowBatteryCallback.apply(null, [percentRemaining]);
View
3  lib/ripple/platform/wac/1.0/RadioInfo.js
@@ -16,7 +16,6 @@
var _self,
event = require('ripple/event'),
_console = require('ripple/console'),
- platform = require('ripple/platform'),
deviceSettings = require('ripple/deviceSettings');
_self = {
@@ -31,7 +30,7 @@ event.on("RadioSignalSourceChanged", function () {
var callback = _self.onSignalSourceChange,
isRoaming = _self.isRoaming,
signalSource = _self.radioSignalSource,
- msg = platform.current().name + " :: Fired onSignalSourceChange. signalSource: " + signalSource + ", isRoaming: " + isRoaming;
+ msg = "Fired onSignalSourceChange. signalSource: " + signalSource + ", isRoaming: " + isRoaming;
if (callback && typeof callback === "function") {
callback.apply(null, [signalSource, isRoaming]);
View
7 lib/ripple/platform/wac/1.0/VideoPlayer.js
@@ -15,7 +15,6 @@
*/
var _self,
_console = require('ripple/console'),
- platform = require('ripple/platform'),
event = require('ripple/event'),
utils = require('ripple/utils'),
fileSystem = require('ripple/fileSystem'),
@@ -43,8 +42,7 @@ function _validateVideoType(fileUrl) {
type = matched ? matched[1] : "";
if (_video && _video.canPlayType("video/" + (maps[type] || type)) === "") {
- _console.warn(platform.current().name +
- " :: Attempting to load a video that might not work in the current browser [" + fileUrl + "]");
+ _console.warn("Attempting to load a video that might not work in the current browser [" + fileUrl + "]");
}
}
@@ -58,8 +56,7 @@ function _validateAndSet(state, validStates, callbackBeforeSuccess) {
}
if (!valid) {
- _console.warn(platform.current().name +
- " :: Attempted to initiate VideoPlayer." + state +
+ _console.warn("Attempted to initiate VideoPlayer." + state +
" in invalid state. current state: " + _state);
} else {
if (typeof(callbackBeforeSuccess) === "function") {
View
6 lib/ripple/platform/wac/1.0/Widget.js
@@ -33,7 +33,7 @@ event.on("ScreenChangeDimensions", function (height, width) {
if (typeof app.onRestore === 'function') {
app.onRestore();
}
- _console.log(platform.current().name + " :: called Widget.onRestore and Widget.onMaximize callback function");
+ _console.log("called Widget.onRestore and Widget.onMaximize callback function");
}
catch (e) {
exception.handle(e, false);
@@ -80,7 +80,7 @@ _self = {
utils.validateArgumentType(key, "string", ExceptionTypes.INVALID_PARAMETER, "setPreferenceForKey invalid parameter! Key:" +
key + ", Value: " + value, new Exception());
- var msg = platform.current().name + " :: ",
+ var msg = "",
prefix;
if (app.isPreferenceReadOnly(key)) {
msg += "Cannot modify a read only preference. Preference key: " + key;
@@ -119,7 +119,7 @@ _self = {
value = undefined;
}
- _console.log(platform.current().name + " :: retrieving preference " + key + " == " + value);
+ _console.log("retrieving preference " + key + " == " + value);
return value;
View
19 lib/ripple/platform/web/default/spec.js
@@ -18,14 +18,29 @@ module.exports = {
id: "web",
version: "default",
name: "Mobile Web",
- ui: {},
+
+ ui: require('ripple/platform/web/default/spec/ui'),
device: {},
persistencePrefix: "tinyhippos-",
objects: {
+ Coordinates: {
+ path: "w3c/1.0/Coordinates"
+ },
+ Position: {
+ path: "w3c/1.0/Position"
+ },
+ PositionError: {
+ path: "w3c/1.0/PositionError"
+ },
navigator: {
- path: "w3c/1.0/navigator"
+ path: "w3c/1.0/navigator",
+ children: {
+ geolocation: {
+ path: "w3c/1.0/geolocation"
+ }
+ }
},
tinyHipposWeb: {
path: "web/default/tinyHipposWeb"
View
5 lib/ripple/platform/web/default/spec/ui.js
@@ -0,0 +1,5 @@
+module.exports = {
+ plugins: [
+ "geoView"
+ ]
+};
View
2  lib/ripple/platform/webworks/2.0.0/XMLHttpRequest.js
@@ -113,7 +113,7 @@ module.exports = function () {
var pair = param.split("="),
value;
try {
- value = JSON.parse(pair[1]);
+ value = JSON.parse(decodeURIComponent(pair[1]));
} catch (e) {
value = pair[1] === "undefined" ? undefined : pair[1];
}
View
2  lib/ripple/platform/webworks/2.0.0/client/Appointment.js
@@ -72,7 +72,7 @@ Appointment.find = function (filter, orderBy, maxReturn, service, isAscending) {
}
};
- return transport.call(_uri + "find", opts).data.map(function (obj) {
+ return transport.call(_uri + "find", opts).map(function (obj) {
var appt = new Appointment();
appt.allDay = obj.allDay;
appt.attendees = obj.attendees;
View
18 lib/ripple/platform/webworks/2.0.0/client/AudioPlayer.js
@@ -21,7 +21,7 @@ function Player(locator, type, async) {
var _id = transport.call(_uri + "create", {
get: {locator: locator, type: type},
async: false
- }).data,
+ }),
_listener,
_closed,
_self,
@@ -30,7 +30,7 @@ function Player(locator, type, async) {
get: {id: _id}
}, function (response) {
if (_listener) {
- _listener(_self, response.data.event, response.data.eventData);
+ _listener(_self, response.event, response.eventData);
}
return !!_listener;
@@ -61,24 +61,24 @@ function Player(locator, type, async) {
close: function () {
_listener = null;
_closed = true;
- return transport.call(_uri + "close", {get: {id: _id}}).data;
+ return transport.call(_uri + "close", {get: {id: _id}});
},
pause: function () {
- return transport.call(_uri + "pause", {get: {id: _id}}).data;
+ return transport.call(_uri + "pause", {get: {id: _id}});
},
play: function () {
- return transport.call(_uri + "play", {get: {id: _id}}).data;
+ return transport.call(_uri + "play", {get: {id: _id}});
}
};
_self.__defineGetter__("duration", function () {
- return transport.call(_uri + "getDuration", {get: {id: _id}}).data;
+ return transport.call(_uri + "getDuration", {get: {id: _id}});
});
_self.__defineGetter__("mediaTime", function () {
- return transport.call(_uri + "getMediaTime", {get: {id: _id}}).data;
+ return transport.call(_uri + "getMediaTime", {get: {id: _id}});
});
_self.__defineSetter__("mediaTime", function (val) {
@@ -86,11 +86,11 @@ function Player(locator, type, async) {
});
_self.__defineGetter__("state", function () {
- return transport.call(_uri + "getState", {get: {id: _id}}).data;
+ return transport.call(_uri + "getState", {get: {id: _id}});
});
_self.__defineGetter__("volumeLevel", function () {
- return transport.call(_uri + "getVolumeLevel", {get: {id: _id}}).data;
+ return transport.call(_uri + "getVolumeLevel", {get: {id: _id}});
});
_self.__defineSetter__("volumeLevel", function (val) {
View
2  lib/ripple/platform/webworks/2.0.0/client/Contact.js
@@ -88,7 +88,7 @@ Contact.find = function (fieldFilter, orderBy, maxReturn, service, isAscending)
service: service,
isAscending: isAscending
}
- }).data.map(function (properties) {
+ }).map(function (properties) {
var contact = new Contact(),
key;
for (key in properties) {
View
2  lib/ripple/platform/webworks/2.0.0/client/Memo.js
@@ -51,7 +51,7 @@ Memo.find = function (filter, orderBy, maxReturn, service, isAscending) {
}
};
- return transport.call(_uri + "find", opts).data.map(function (obj) {
+ return transport.call(_uri + "find", opts).map(function (obj) {
var memo = new Memo();
memo.uid = obj.uid;
memo.categories = obj.categories || [];
View
2  lib/ripple/platform/webworks/2.0.0/client/Message.js
@@ -90,7 +90,7 @@ Message.find = function (filter, maxReturn, service) {
}
};
- return transport.call(_uri + "find", opts).data.map(function (obj) {
+ return transport.call(_uri + "find", opts).map(function (obj) {
var msg = new Message();
msg.uid = obj.uid;
View
6 lib/ripple/platform/webworks/2.0.0/client/Phone.js
@@ -20,7 +20,7 @@ var transport = require('ripple/platform/webworks/2.0.0/client/transport'),
_self = {
activeCalls: function () {
- return transport.call(_uri + "activeCalls").data;
+ return transport.call(_uri + "activeCalls");
},
addPhoneListener: function (callback, eventType) {
@@ -38,7 +38,7 @@ _self = {
var func = _listeners[eventType];
if (func) {
- func(response.data.callId, response.data.error);
+ func(response.callId, response.error);
}
return !!func;
@@ -46,7 +46,7 @@ _self = {
},
inActiveCall: function () {
- return transport.call(_uri + "inActiveCall").data;
+ return transport.call(_uri + "inActiveCall");
}
};
View
10 lib/ripple/platform/webworks/2.0.0/client/PhoneLogs.js
@@ -48,7 +48,7 @@ function handle(evt) {
var func = _onCallLog[evt], args;
if (func) {
- args = utils.map(response.data, function (value) {
+ args = utils.map(response, function (value) {
return _toCallLog(value);
});
func.apply(null, args);
@@ -92,7 +92,7 @@ _self = {
index: index,
folderID: folderID
}
- }).data;
+ });
if (log && log.date) {
log.date = new Date(log.date);
@@ -107,7 +107,7 @@ _self = {
index: index,
folderID: folderID
}
- }).data;
+ });
},
find: function (filter, folderID, orderBy, maxReturn, isAscending) {
@@ -119,7 +119,7 @@ _self = {
maxReturn: maxReturn,
isAscending: isAscending
}
- }).data.map(_toCallLog);
+ }).map(_toCallLog);
},
numberOfCalls: function (folderID) {
@@ -127,7 +127,7 @@ _self = {
get: {
folderID: folderID
}
- }).data;
+ });
}
};
View
2  lib/ripple/platform/webworks/2.0.0/client/Task.js
@@ -77,7 +77,7 @@ Task.find = function (filter, orderBy, maxReturn, isAscending) {
maxReturn: maxReturn,
isAscending: isAscending
}
- }).data.map(function (properties) {
+ }).map(function (properties) {
var task = new Task(),
key;
for (key in properties) {
View
20 lib/ripple/platform/webworks/2.0.0/client/app.js
@@ -53,43 +53,43 @@ _self = {
};
_self.__defineGetter__("author", function () {
- return transport.call(_uri + "author").data;
+ return transport.call(_uri + "author");
});
_self.__defineGetter__("authorEmail", function () {
- return transport.call(_uri + "authorEmail").data;
+ return transport.call(_uri + "authorEmail");
});
_self.__defineGetter__("authorURL", function () {
- return transport.call(_uri + "authorURL").data;
+ return transport.call(_uri + "authorURL");
});
_self.__defineGetter__("copyright", function () {
- return transport.call(_uri + "copyright").data;
+ return transport.call(_uri + "copyright");
});
_self.__defineGetter__("description", function () {
- return transport.call(_uri + "description").data;
+ return transport.call(_uri + "description");
});
_self.__defineGetter__("id", function () {
- return transport.call(_uri + "id").data;
+ return transport.call(_uri + "id");
});
_self.__defineGetter__("license", function () {
- return transport.call(_uri + "license").data;
+ return transport.call(_uri + "license");
});
_self.__defineGetter__("licenseURL", function () {
- return transport.call(_uri + "licenseURL").data;
+ return transport.call(_uri + "licenseURL");
});
_self.__defineGetter__("name", function () {
- return transport.call(_uri + "name").data;
+ return transport.call(_uri + "name");
});
_self.__defineGetter__("version", function () {
- return transport.call(_uri + "version").data;
+ return transport.call(_uri + "version");
});
module.exports = _self;
View
2  lib/ripple/platform/webworks/2.0.0/client/blackberry.js
@@ -17,7 +17,7 @@ var blackberry = {},
transport = require('ripple/platform/webworks/2.0.0/client/transport');
blackberry.__defineGetter__("network", function () {
- return transport.call("blackberry/system/network").data;
+ return transport.call("blackberry/system/network");
});
module.exports = blackberry;
View
36 lib/ripple/platform/webworks/2.0.0/client/category.js
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2011 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+var transport = require('ripple/platform/webworks/2.0.0/client/transport'),
+ _uri = "blackberry/pim/category/",
+ _self;
+
+_self = {
+ addCategory: function (categoryName) {
+ transport.call(_uri + "addCategory", {
+ get: {categoryName: categoryName}
+ });
+ },
+ deleteCategory: function (categoryName) {
+ transport.call(_uri + "deleteCategory", {
+ get: {categoryName: categoryName}
+ });
+ },
+ getCategories: function () {
+ return transport.call(_uri + "getCategories");
+ }
+};
+
+module.exports = _self;
View
8 lib/ripple/platform/webworks/2.0.0/client/dialog.js
@@ -44,9 +44,9 @@ _self = {
}
}, function (response) {
if (callback) {
- callback(response.data);
+ callback(response);
}
- }).data;
+ });
},
standardAskAsync: function (message, type, callback, settings) {
@@ -59,9 +59,9 @@ _self = {
}
}, function (response) {
if (callback) {
- callback(response.data);
+ callback(response);
}
- }).data;
+ });
}
};
View
12 lib/ripple/platform/webworks/2.0.0/client/identity.js
@@ -19,26 +19,26 @@ var transport = require('ripple/platform/webworks/2.0.0/client/transport'),
_self = {
getDefaultService: function () {
- return transport.call(_uri + "getDefaultService").data;
+ return transport.call(_uri + "getDefaultService");
},
getServiceList: function () {
- return transport.call(_uri + "getServiceList").data;
+ return transport.call(_uri + "getServiceList");
},
getTransportList: function () {
- return transport.call(_uri + "getTransportList").data;
+ return transport.call(_uri + "getTransportList");
}
};
_self.__defineGetter__("IMEI", function () {
- return transport.call(_uri + "IMEI").data;
+ return transport.call(_uri + "IMEI");
});
_self.__defineGetter__("IMSI", function () {
- return transport.call(_uri + "IMSI").data;
+ return transport.call(_uri + "IMSI");
});
_self.__defineGetter__("PIN", function () {
- return transport.call(_uri + "PIN").data;
+ return transport.call(_uri + "PIN");
});
module.exports = _self;
View
8 lib/ripple/platform/webworks/2.0.0/client/identity/phone.js
@@ -19,16 +19,16 @@ var transport = require('ripple/platform/webworks/2.0.0/client/transport'),
_self = {
getLineIds: function () {
- return transport.call(_uri + "getLineIds").data;
+ return transport.call(_uri + "getLineIds");
},
getLineLabel: function (id) {
- return transport.call(_uri + "getLineLabel", {get: {id: id}}).data;
+ return transport.call(_uri + "getLineLabel", {get: {id: id}});
},
getLineNumber: function (id) {
- return transport.call(_uri + "getLineNumber", {get: {id: id}}).data;
+ return transport.call(_uri + "getLineNumber", {get: {id: id}});
},
getLineType: function (id) {
- return transport.call(_uri + "getLineType", {get: {id: id}}).data;
+ return transport.call(_uri + "getLineType", {get: {id: id}});
}
};
View
2  lib/ripple/platform/webworks/2.0.0/client/menu.js
@@ -30,7 +30,7 @@ _self = {
if (utils.count(_items) === 1) {
transport.poll(_uri + "onSelect", {}, function (response) {
- var item = _items[response.data];
+ var item = _items[response];
if (item && item.callback) {
item.callback();
View
24 lib/ripple/platform/webworks/2.0.0/client/pim.js
@@ -1,6 +1,6 @@
/*
* Copyright 2011 Research In Motion Limited.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -13,24 +13,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-var transport = require('ripple/platform/webworks/2.0.0/client/transport'),
- _uri = "blackberry/pim/category/",
- _self;
-
-_self = {
- addCategory: function (categoryName) {
- transport.call(_uri + "addCategory", {
- get: {categoryName: categoryName}
- });
- },
- deleteCategory: function (categoryName) {
- transport.call(_uri + "deleteCategory", {
- get: {categoryName: categoryName}
- });
- },
- getCategories: function () {
- return transport.call(_uri + "getCategories").data;
- }
-};
-
-module.exports = _self;
+module.exports = {};
View
2  lib/ripple/platform/webworks/2.0.0/client/push.js
@@ -33,7 +33,7 @@ _self = {
var func = callbacks["onPush" + port];
if (func) {
- func(new PushData(response.data, port));
+ func(new PushData(response, port));
}
return !!func;
View
2  lib/ripple/platform/webworks/2.0.0/client/sms.js
@@ -23,7 +23,7 @@ _self = {
onReceive = callback;
transport.poll(_uri + "onReceive", {}, function (response) {
if (onReceive) {
- onReceive(response.data.body, response.data.from, response.data.time);
+ onReceive(response.body, response.from, response.time);
}
return !!onReceive;
});
View
14 lib/ripple/platform/webworks/2.0.0/client/system.js
@@ -21,21 +21,21 @@ _self = {
hasCapability: function (capability) {
return transport.call(_uri + "hasCapability", {
get: {capability: capability}
- }).data;
+ });
},
hasDataCoverage: function () {
- return transport.call(_uri + "hasDataCoverage").data;
+ return transport.call(_uri + "hasDataCoverage");
},
hasPermission: function (desiredModule) {
return transport.call(_uri + "hasPermission", {
get: {desiredModule: desiredModule}
- }).data;
+ });
},
isMassStorageActive: function () {
- return transport.call(_uri + "isMassStorageActive").data;
+ return transport.call(_uri + "isMassStorageActive");
},
setHomeScreenBackground: function (filePath) {
@@ -47,13 +47,13 @@ _self = {
};
_self.__defineGetter__("model", function () {
- return transport.call(_uri + "model").data;
+ return transport.call(_uri + "model");
});
_self.__defineGetter__("scriptApiVersion", function () {
- return transport.call(_uri + "scriptApiVersion").data;
+ return transport.call(_uri + "scriptApiVersion");
});
_self.__defineGetter__("softwareVersion", function () {
- return transport.call(_uri + "softwareVersion").data;
+ return transport.call(_uri + "softwareVersion");
});
_self.__defineGetter__("ALLOW", function () {
View
39 lib/ripple/platform/webworks/2.0.0/client/transport.js
@@ -69,33 +69,42 @@ function RemoteFunctionCall(functionUri) {
};
this.addPostParam = function (name, value) {
- postParams[name] = JSON.stringify(value);
+ postParams[name] = encodeURIComponent(JSON.stringify(value));
};
- this.makeSyncCall = function (callback) {
+ this.makeSyncCall = function (success, error) {
var requestUri = composeUri(),
request = createXhrRequest(requestUri, false),
- res;
+ response, errored, cb, data;
request.send(postString);
- res = JSON.parse(request.responseText || "null");
+ response = JSON.parse(request.responseText || "null");
+ errored = response.code < 0;
+ cb = errored ? error : success;
+ data = errored ? response.msg : response.data;
- if (callback) {
- callback(res);
+ if (cb) {
+ cb(data, response);
}
-
- return res;
+ else if (errored) {
+ throw data;
+ }
+
+ return data;
};
- this.makeAsyncCall = function (responseCallback) {
+ this.makeAsyncCall = function (success, error) {
var requestUri = composeUri(),
request = createXhrRequest(requestUri, true);
request.onreadystatechange = function () {
if (request.readyState === 4 && request.status === 200) {
- var response = JSON.parse(request.responseText || "null");
- return responseCallback && responseCallback(response);
+ var response = JSON.parse(request.responseText || "null"),
+ cb = response.code < 0 ? error : success,
+ data = response.code < 0 ? response.msg : response.data;
+
+ return cb && cb(data, response);
}
};
@@ -104,7 +113,7 @@ function RemoteFunctionCall(functionUri) {
}
_self = {
- call: function (url, opts, callback) {
+ call: function (url, opts, success, error) {
var request = new RemoteFunctionCall(url),
name;
@@ -126,15 +135,15 @@ _self = {
}
}
- return opts.async ? request.makeAsyncCall(callback) : request.makeSyncCall(callback);
+ return opts.async ? request.makeAsyncCall(success, error) : request.makeSyncCall(success, error);
},
poll: function (url, opts, callback) {
opts = opts || {};
opts.async = true;
- _self.call(url, opts, function (response) {
- if (callback(response)) {
+ _self.call(url, opts, function (data, response) {
+ if (callback(data, response)) {
_self.poll(url, opts, callback);
}
});
View
47 lib/ripple/platform/webworks/2.0.0/server/contact.js
@@ -20,27 +20,38 @@ var select = require('ripple/platform/webworks/2.0.0/select'),
_self;
function _defaultContacts() {
- return [{
- uuid: Math.uuid(null, 16),
+ var id1 = Math.uuid(null, 16),
+ id2 = Math.uuid(null, 16),
+ id3 = Math.uuid(null, 16),
+ id4 = Math.uuid(null, 16),
+ contacts = {};
+
+ contacts[id1] = {
+ uuid: id1,
firstName: "Leonardo",
homePhone: "4567892345",
email1: "leo@underground.com"
- }, {
- uuid: Math.uuid(null, 16),
+ };
+ contacts[id2] = {
+ uuid: id2,
firstName: "Raphael",
homePhone: "4563457890",
email1: "raph@underground.com"
- }, {
- uuid: Math.uuid(null, 16),
+ };
+ contacts[id3] = {
+ uuid: id3,
firstName: "Michelangelo",
homePhone: "4563453425",
email1: "mike@underground.com"
- }, {
- uuid: Math.uuid(null, 16),
+ };
+ contacts[id4] = {
+ uuid: id4,
firstName: "Donatello",
homePhone: "4563453425",
email1: "don@undergound.com"
- }];
+ };
+
+ return contacts;
}
function _get() {
@@ -51,13 +62,21 @@ function _save(contacts) {
db.saveObject(_KEY, contacts);
}
+//---------------------------------------------------
+//HACK: gotta fix the shiznit
+//TODO: if still here at 0.7.0 please remove
+var fix = _get();
+if (fix instanceof Array) {
+ _save(_defaultContacts());
+}
+//END OF HACK (may god have mercy on our souls)
+//---------------------------------------------------
+
_self = {
save: function (get, post) {
- var contacts = _get(),
- properties = post.contact,
- id = properties.uid;
+ var contacts = _get();
- contacts[id] = properties;
+ contacts[post.contact.uid] = post.contact;
_save(contacts);
return {code: 1};
},
@@ -81,7 +100,7 @@ _self = {
match.max(post.maxReturn);
}
- return {code: 1, data: match.where(post.filterField)};
+ return {code: 1, data: match.where(post.fieldFilter)};
}
};
View
1  lib/ripple/platform/webworks/2.0.0/server/dialog.js
@@ -16,7 +16,6 @@
var constants = require('ripple/constants'),
event = require('ripple/event'),
devices = require('ripple/devices'),
- _console = require('ripple/console'),
ui = require('ripple/ui'),
utils = require('ripple/utils'),
isDialogVisible = false,
View
1  lib/ripple/platform/webworks/2.0.0/server/menu.js
@@ -17,7 +17,6 @@ var _menuItems = {},
constants = require('ripple/constants'),
event = require('ripple/event'),
events = require('ripple/platform/webworks/2.0.0/client/events'),
- _console = require('ripple/console'),
ui = require('ripple/ui'),
devices = require('ripple/devices'),
utils = require('ripple/utils'),
View
3  lib/ripple/platform/webworks/2.0.0/server/sms.js
@@ -17,7 +17,6 @@ var _listener,
_isListeningForMessage,
notifications = require('ripple/notifications'),
constants = require('ripple/constants'),
- platform = require('ripple/platform'),
event = require('ripple/event'),
_console = require('ripple/console'),
_onReceive,
@@ -42,7 +41,7 @@ _self = {
send: function (args) {
var msg = "To " + args.address + ": " + args.message;
notifications.openNotification(constants.NOTIFICATIONS.TYPES.NORMAL, msg);
- _console.log(platform.current().name + " :: " + msg);
+ _console.log(msg);
return {code: 1};
}
};
View
6 lib/ripple/platform/webworks/2.0.0/spec.js
@@ -52,8 +52,12 @@ module.exports = {
children: {
pim: {
path: "webworks/2.0.0/client/pim",
- feature: "blackberry.pim.Task|blackberry.pim.Recurrence|blackberry.pim.Reminder|blackberry.pim.Appointment|blackberry.pim.Address|blackberry.pim.Attendee|blackberry.pim.Memo|blackberry.pim.Contact",
+ feature: "blackberry.pim.category|blackberry.pim.Task|blackberry.pim.Recurrence|blackberry.pim.Reminder|blackberry.pim.Appointment|blackberry.pim.Address|blackberry.pim.Attendee|blackberry.pim.Memo|blackberry.pim.Contact",
children: {
+ category: {
+ path: "webworks/2.0.0/client/category",
+ feature: "blackberry.pim.category"
+ },
Task: {
path: "webworks/2.0.0/client/Task",
feature: "blackberry.pim.Task"
View
5 lib/ripple/ui/plugins/deviceSettings.js
@@ -88,9 +88,10 @@ function _buildDOMNode(setting, settingType, key) {
switch (setting.control.type) {
case "checkbox":
jNode.bind("click", function () {
- deviceSettings.persist(fullKey, jQuery(this).attr("checked"));
+ var checked = this.checked ? true : false;
+ deviceSettings.persist(fullKey, checked);
if (typeof setting.callback === "function") {
- setting.callback(jQuery(this).attr("checked"));
+ setting.callback(checked);
}
});
View
3  lib/ripple/ui/plugins/phone.js
@@ -17,7 +17,6 @@ var utils = require('ripple/utils'),
Phone = require('ripple/platform/webworks/2.0.0/client/Phone'),
CallLog = require('ripple/platform/webworks/2.0.0/client/CallLog'),
event = require('ripple/event'),
- platform = require('ripple/platform'),
_console = require('ripple/console'),
eventSelect = document.getElementById("phone-event-types"),
eventErrorContainer = document.getElementById("phone-event-error-container"),
@@ -110,7 +109,7 @@ module.exports = {
event.trigger("PhoneEvent", [type, callId, error]);
- _console.log(platform.current().name + " :: Fired PhoneEvent (type " + type + ") CallID: " +
+ _console.log("Fired PhoneEvent (type " + type + ") CallID: " +
callId + (error ? (" (error type " + error + ")") : ""));
}, false);
}
View
2  lib/ripple/ui/plugins/platformEvents.js
@@ -83,7 +83,7 @@ module.exports = {
if (events[select.value].args) {
args.push(eventArgs.value);
}
- _console.log(platform.current().name + " :: fired event => " + eventContext.context + "." + select.children[select.selectedIndex].innerText);
+ _console.log("fired event => " + eventContext.context + "." + select.children[select.selectedIndex].innerText);
try {
event.trigger(select.value, args);
}
View
3  lib/ripple/ui/plugins/telephony.js
@@ -17,7 +17,6 @@ var constants = require('ripple/constants'),
db = require('ripple/db'),
utils = require('ripple/utils'),
_console = require('ripple/console'),
- platform = require('ripple/platform'),
_optionTemplate = "<option value='[key]' [selected]>[value]</option>",
_textTemplate = "<td><input class='call-[key] ui-state-default ui-corner-all' type='text' value='[value]'></td>";
@@ -62,7 +61,7 @@ function _addRow(calltype, number, name) {
var calltype = jQuery(this).next().val(),
number = jQuery(this).parent().parent().prev().find(".call-number").val();
- _console.log(platform.current().name + " :: called Widget.Telephony.onCallEvent function [" + calltype + "," + number + "]");
+ _console.log("called Widget.Telephony.onCallEvent function [" + calltype + "," + number + "]");
if (Widget.Telephony.onCallEvent) {
Widget.Telephony.onCallEvent(calltype, number);
View
2  lib/ripple/widgetConfig.js
@@ -362,7 +362,7 @@ function _process(results) {
var validVersion = app.validateVersion(results);
if (!validVersion) {
- _console.warn(platform.current().name + " :: Your application does not appear to match" +
+ _console.warn("Your application does not appear to match" +
" the platform you have selected. The version number in your configuration might not " +
"match the selected platform version or your configuration file has errors in it.");
}
View
2  lib/ripple/xhr/base.js
@@ -37,7 +37,7 @@ function _writeable(obj) {
var newObj = {},
key;
- // need protoypes
+ // need prototypes
for (key in obj) {
if (typeof obj[key] === "function") {
newObj[key] = _handle(obj, key);
View
60 test/console.js
@@ -16,23 +16,63 @@
describe("console", function () {
var _console = require('ripple/console');
- it("is an object", function () {
- expect(typeof _console).toBe("object");
+ beforeEach(function () {
+ _console.prefix = null;
});
- it("log is a function", function () {
- expect(typeof _console.log).toBe("function");
+ describe("when logging", function () {
+ it("calls the log method", function () {
+ spyOn(console, "log");
+ _console.log("beavers!!!");
+ expect(console.log).toHaveBeenCalledWith("beavers!!!");
+ });
});
- it("warn is a function", function () {
- expect(typeof _console.warn).toBe("function");
+ describe("when erroring", function () {
+ it("calls the error method", function () {
+ spyOn(console, "error");
+ _console.error("this is teh broken");
+ expect(console.error).toHaveBeenCalledWith("this is teh broken");
+ });
});
- it("error is a function", function () {
- expect(typeof _console.error).toBe("function");
+ describe("when warning", function () {
+ it("calls the warn method", function () {
+ spyOn(console, "warn");
+ _console.warn("Thundercats Hoooo");
+ expect(console.warn).toHaveBeenCalledWith("Thundercats Hoooo");
+ });
});
- it("clear is a function", function () {
- expect(typeof _console.clear).toBe("function");
+ describe("when setting the prefix", function () {
+ beforeEach(function () {
+ _console.prefix = "PLATFORM";
+ });
+
+ it("uses the prefix when logging", function () {
+ spyOn(console, "log");
+ _console.log("Thundercats Hoooo");
+ expect(console.log).toHaveBeenCalledWith("PLATFORM :: Thundercats Hoooo");
+ });
+
+ it("uses the prefix when erroring", function () {
+ spyOn(console, "error");
+ _console.error("Carebears Stare");
+ expect(console.error).toHaveBeenCalledWith("PLATFORM :: Carebears Stare");
+ });
+
+ it("uses the prefix when warning", function () {
+ spyOn(console, "warn");
+ _console.warn("Danger Will Robinson");
+ expect(console.warn).toHaveBeenCalledWith("PLATFORM :: Danger Will Robinson");
+ });
+
+ it("will not use a falsy prefix", function () {
+ _console.prefix = false;
+ spyOn(console, "log");
+ _console.log("EX-TERM-IN-ATE");
+ expect(console.log).toHaveBeenCalledWith("EX-TERM-IN-ATE");
+ });
});
+
});
View
12 test/emulatorBridge.js
@@ -60,6 +60,12 @@ describeBrowser("emulator_bridge", function () {
_emulatedDocument.appendChild(_emulatedHtml);
_emulatedViewport.appendChild(_emulatedDocument);
+ spyOn(platform, "current").andReturn({objects: {
+ foo: {a: 1},
+ bar: {b: 1},
+ woot: [1, 2, 3, 4, 5]
+ }});
+
emulatorBridge.link(_emulatedFrame);
});
@@ -116,12 +122,6 @@ describeBrowser("emulator_bridge", function () {
});
it("it marshals over everything in the sandbox", function () {
- platform.sandbox.foo = {a: 1};
- platform.sandbox.bar = {b: 1};
- platform.sandbox.woot = [1, 2, 3, 4, 5];
-
- emulatorBridge.link(_emulatedFrame);
-
expect(window.foo).toBeDefined();
expect(window.bar).toBeDefined();
expect(window.woot).toBeDefined();
View
2  test/phonegap/navigator.js
@@ -31,7 +31,6 @@ describe("phonegap_navigator", function () {
spyOn(emulatorBridge, "getWidgetDocument").andReturn(document);
spyOn(document, "dispatchEvent");
spyOn(_console, "log");
- spyOn(platform, "current").andReturn({name: "whatup"});
event.trigger("TinyHipposLoaded");
@@ -39,7 +38,6 @@ describe("phonegap_navigator", function () {
runs(function () {
expect(document.dispatchEvent.callCount).toEqual(1);
expect(_console.log.callCount).toEqual(1);
- expect(platform.current.callCount).toEqual(1);
});
});
View
75 test/platform.js
@@ -17,6 +17,7 @@ describe("platform", function () {
var platform = require('ripple/platform'),
db = require('ripple/db'),
+ app = require('ripple/app'),
builder = require('ripple/platform/builder'),
event = require('ripple/event'),
_console = require('ripple/console'),
@@ -34,7 +35,7 @@ describe("platform", function () {
platform.initialize();
});
- it("getPlatformNameValues should return correct value", function () {
+ it("getList should return correct value", function () {
var returnedPlatforms = platform.getList();
expect(typeof returnedPlatforms["wac"]["1.0"].id).toEqual("string");
@@ -42,45 +43,65 @@ describe("platform", function () {
expect(typeof returnedPlatforms["wac"]["1.0"].type).toEqual("string");
});
- it("changeEnvironment should persist successfully", function () {
- spyOn(platform, "initialize");
- spyOn(db, "saveObject").andCallFake(function (a, b, c, baton) {
- baton();
- });
- spyOn(db, "save").andCallFake(function (a, b, c, baton) {
- return baton && baton();
- });
- spyOn(event, "trigger");
- spyOn(resizer, "resize");
-
+ describe("when changing the environment", function () {
var platformSpec = {
name: "someplatform",
version: "1.0"
},
deviceId = "some_id";
- platform.changeEnvironment(platformSpec, deviceId);
+ beforeEach(function () {
+ spyOn(db, "saveObject").andCallFake(function (a, b, c, baton) {
+ baton();
+ });
- expect(db.saveObject.argsForCall[0][0]).toEqual("api-key");
- expect(db.save.argsForCall[0][0]).toEqual("device-key");
+ spyOn(db, "save").andCallFake(function (a, b, c, baton) {
+ return baton && baton();
+ });
- //Expected layout to be set to null in persistence
- expect(db.save.argsForCall[1][0]).toEqual(constants.ENCAPSULATOR.LAYOUT);
- expect(db.save.argsForCall[1][1]).toEqual(null);
+ spyOn(event, "trigger");
+ });
- expect(event.trigger.argsForCall[0][0]).toEqual("PlatformChangedEvent");
- });
+ it("saves the platform", function () {
+ platform.changeEnvironment(platformSpec, deviceId, function () {
+ expect(db.saveObject.argsForCall[0][0]).toEqual("api-key");
+ expect(db.saveObject.argsForCall[0][1]).toEqual(platformSpec);
+ });
+ });
- it("getID should return a string", function () {
- expect(typeof platform.current().id).toEqual("string");
- });
+ it("saves the device", function () {