Skip to content

Instantly share code, notes, and snippets.

@jrburke
Created October 4, 2013 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrburke/6821302 to your computer and use it in GitHub Desktop.
Save jrburke/6821302 to your computer and use it in GitHub Desktop.
Clock patch
diff --git a/apps/clock/Makefile b/apps/clock/Makefile
index e17f42e..78e8465 100644
--- a/apps/clock/Makefile
+++ b/apps/clock/Makefile
@@ -1,9 +1,16 @@
-# We can't figure out XULRUNNERSDK on our own; it's complex and some builders
-# may want to override our find logic (ex: TBPL), so let's just leave it up to
-# the root Makefile. If you know what you're doing, you can manually define
-# XULRUNNERSDK and XPCSHELLSDK on the command line.
-ifndef XPCSHELLSDK
-$(error This Makefile needs to be run by the root gaia makefile. Use `make APP=clock` from the root gaia directory.)
+SYS=$(shell uname -s)
+
+ifeq ($(SYS),Darwin)
+XULRUNNERSDK=../../xulrunner-sdk/bin/XUL.framework/Versions/Current/run-mozilla.sh
+XPCSHELLSDK=../../xulrunner-sdk/bin/XUL.framework/Versions/Current/xpcshell
+else ifeq ($(findstring MINGW32,$(SYS)), MINGW32)
+# For windows we only have one binary
+XULRUNNERSDK=
+XPCSHELLSDK=../../xulrunner-sdk/bin/xpcshell
+else
+# Otherwise, assume linux
+XULRUNNERSDK=../../xulrunner-sdk/bin/run-mozilla.sh
+XPCSHELLSDK=../../xulrunner-sdk/bin/xpcshell
endif
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
diff --git a/apps/clock/js/alameda.js b/apps/clock/js/alameda.js
index e2e48ac..020e02f 100644
--- a/apps/clock/js/alameda.js
+++ b/apps/clock/js/alameda.js
@@ -1,5 +1,5 @@
/**
- * alameda 0.0.6 Copyright (c) 2011-2012, The Dojo Foundation All Rights Reserved.
+ * alameda 0.0.9 Copyright (c) 2011-2012, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/requirejs/alameda for details
*/
@@ -10,7 +10,7 @@
var requirejs, require, define;
(function (global, undef) {
- var prim, topReq, dataMain,
+ var prim, topReq, dataMain, src, subPath,
bootstrapConfig = requirejs || require,
hasOwn = Object.prototype.hasOwnProperty,
contexts = {},
@@ -93,7 +93,7 @@ var requirejs, require, define;
* - removed UMD registration
*/
/**
- * prim 0.0.3 Copyright (c) 2012-2013, The Dojo Foundation All Rights Reserved.
+ * prim 0.0.4 Copyright (c) 2012-2013, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/requirejs/prim for details
*/
@@ -261,7 +261,7 @@ var requirejs, require, define;
return result;
};
- prim.nextTick = typeof setImmediate === 'function' ? setImmediate :
+ prim.nextTick = typeof setImmediate === 'function' ? setImmediate.bind() :
(typeof process !== 'undefined' && process.nextTick ?
process.nextTick : (typeof setTimeout !== 'undefined' ?
asyncTick : syncTick));
@@ -1001,8 +1001,7 @@ var requirejs, require, define;
traced[id] = true;
if (!d.finished() && d.deps) {
d.deps.forEach(function (depMap) {
- var depIndex,
- depId = depMap.id,
+ var depId = depMap.id,
dep = !hasProp(handlers, depId) && getDefer(depId);
//Only force things that have not completed
@@ -1011,13 +1010,11 @@ var requirejs, require, define;
//in the module already.
if (dep && !dep.finished() && !processed[depId]) {
if (hasProp(traced, depId)) {
- d.deps.some(function (depMap, i) {
+ d.deps.forEach(function (depMap, i) {
if (depMap.id === depId) {
- depIndex = i;
- return true;
+ d.depFinished(defined[depId], i);
}
});
- d.depFinished(defined[depId], depIndex);
} else {
breakCycle(dep, traced, processed);
}
@@ -1341,6 +1338,17 @@ var requirejs, require, define;
//Strip off any trailing .js since dataMain is now
//like a module name.
dataMain = dataMain.replace(jsSuffixRegExp, '');
+
+ if (!bootstrapConfig || !bootstrapConfig.baseUrl) {
+ //Pull off the directory of data-main for use as the
+ //baseUrl.
+ src = dataMain.split('/');
+ dataMain = src.pop();
+ subPath = src.length ? src.join('/') + '/' : './';
+
+ topReq.config({baseUrl: subPath});
+ }
+
topReq([dataMain]);
}
}
diff --git a/apps/clock/js/alarm.js b/apps/clock/js/alarm.js
index c525c21..cc40107 100644
--- a/apps/clock/js/alarm.js
+++ b/apps/clock/js/alarm.js
@@ -1,7 +1,8 @@
-define(function(require, exports, module) {
+define(function(require) {
'use strict';
+ var AlarmsDB = require('alarmsdb');
var Utils = require('utils');
var constants = require('constants');
var mozL10n = require('l10n');
@@ -249,13 +250,10 @@ define(function(require, exports, module) {
delete: function alarm_delete(callback) {
this.cancel();
- // TODO: Address this circular dependency
- require(['alarmsdb'], function(AlarmsDB) {
AlarmsDB.deleteAlarm(this.id,
function alarm_innerDelete(err, alarm) {
callback(err, this);
}.bind(this));
- }.bind(this));
},
// ---------------------------------------------------------
@@ -274,13 +272,10 @@ define(function(require, exports, module) {
},
save: function alarm_save(callback) {
- // TODO: Address this circular dependency
- require(['alarmsdb'], function(AlarmsDB) {
AlarmsDB.putAlarm(this, function(err, alarm) {
idMap.set(this, alarm.id);
callback && callback(err, this);
}.bind(this));
- }.bind(this));
},
// ---------------------------------------------------------
@@ -371,6 +366,6 @@ define(function(require, exports, module) {
// ---------------------------------------------------------
// Export
- module.exports = Alarm;
+ return Alarm;
});
diff --git a/apps/clock/js/alarmsdb.js b/apps/clock/js/alarmsdb.js
index b43045d..99efb1b 100644
--- a/apps/clock/js/alarmsdb.js
+++ b/apps/clock/js/alarmsdb.js
@@ -1,8 +1,7 @@
-define(function(require) {
+define(function(require, exports) {
'use strict';
var Utils = require('utils');
-var Alarm = require('alarm');
var BaseIndexDB = function(objectStoreOptions) {
this.query = function ad_query(dbName, storeName, func, callback, data) {
@@ -111,38 +110,35 @@ var BaseIndexDB = function(objectStoreOptions) {
};
};
-var AlarmsDB = {
- DBNAME: 'alarms',
- STORENAME: 'alarms',
-
- // Database methods
- getAlarmList: function ad_getAlarmList(callback) {
- function getAlarmList_mapper(err, list) {
- callback(err, (list || []).map(function(x) {
- return new Alarm(x);
- }));
- }
- this.query(this.DBNAME, this.STORENAME, this.load, getAlarmList_mapper);
- },
-
- putAlarm: function ad_putAlarm(alarm, callback) {
- this.query(this.DBNAME, this.STORENAME, this.put, callback,
- alarm.toSerializable());
- },
-
- getAlarm: function ad_getAlarm(key, callback) {
- this.query(this.DBNAME, this.STORENAME, this.get,
- function(err, result) {
- callback(err, new Alarm(result));
- }, key);
- },
-
- deleteAlarm: function ad_deleteAlarm(key, callback) {
- this.query(this.DBNAME, this.STORENAME, this.delete, callback, key);
+exports.DBNAME = 'alarms';
+exports.STORENAME = 'alarms';
+
+// Database methods
+exports.getAlarmList = function ad_getAlarmList(callback) {
+ function getAlarmList_mapper(err, list) {
+ callback(err, (list || []).map(function(x) {
+ return new (require('alarm'))(x);
+ }));
}
+ this.query(this.DBNAME, this.STORENAME, this.load, getAlarmList_mapper);
+};
+
+exports.putAlarm = function ad_putAlarm(alarm, callback) {
+ this.query(this.DBNAME, this.STORENAME, this.put, callback,
+ alarm.toSerializable());
+};
+
+exports.getAlarm = function ad_getAlarm(key, callback) {
+ this.query(this.DBNAME, this.STORENAME, this.get,
+ function(err, result) {
+ callback(err, new (require('alarm'))(result));
+ }, key);
+};
+
+exports.deleteAlarm = function ad_deleteAlarm(key, callback) {
+ this.query(this.DBNAME, this.STORENAME, this.delete, callback, key);
};
-Utils.extend(AlarmsDB, new BaseIndexDB({keyPath: 'id', autoIncrement: true}));
+Utils.extend(exports, new BaseIndexDB({keyPath: 'id', autoIncrement: true}));
-return AlarmsDB;
});
diff --git a/apps/clock/js/startup.js b/apps/clock/js/startup.js
index 3c4aef0..58aa98d 100644
--- a/apps/clock/js/startup.js
+++ b/apps/clock/js/startup.js
@@ -1,5 +1,5 @@
require.config({ baseUrl: 'js' });
-define('startup', function(require) {
+define('startup_init', function(require) {
'use strict';
var App = require('app');
@@ -37,5 +37,5 @@ if (needsMocks) {
});
require(['require_config'], function() {
- requirejs(['startup']);
+ requirejs(['startup_init']);
});
diff --git a/apps/clock/style/clock.css b/apps/clock/style/clock.css
index 6cb8635..3dace46 100644
--- a/apps/clock/style/clock.css
+++ b/apps/clock/style/clock.css
@@ -1,7 +1,7 @@
-@import url('/shared/style/switches.css');
-@import url('/shared/style/input_areas.css');
-@import url('/shared/style/buttons.css');
-@import url('/shared/style/edit_mode.css');
+@import url('../shared/style/switches.css');
+@import url('../shared/style/input_areas.css');
+@import url('../shared/style/buttons.css');
+@import url('../shared/style/edit_mode.css');
html, body {
width: 100%;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment