mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-03 12:40:00 +00:00
Require.js example expanded.
Helpers.js\moment.js included. Alogos are still BROKEN. I'm deploying them here for testing.
This commit is contained in:
parent
ff8721b4a3
commit
ffdf279ee1
6 changed files with 29 additions and 3 deletions
|
|
@ -16,5 +16,6 @@ requirejs.config({
|
|||
//Load array of modules (in this case 'app/module') into the variables (in this case module). "cs!" - means this file has to be parsed by cs plugin first.
|
||||
requirejs(['cs!app/module'], function (module) {
|
||||
//foo() is defined within module.coffee. We can use it within this callback.
|
||||
//Note that we are passing lowercase here. But will get UPPERCASE because we use parentModule within module.
|
||||
module.foo('Hello!')
|
||||
});
|
||||
|
|
@ -6,10 +6,15 @@
|
|||
(F)->
|
||||
F(require, exports, module)
|
||||
)}).define (require, exports, module)->
|
||||
|
||||
#Write your code here as usual
|
||||
|
||||
#I.e. require parent module
|
||||
#NOTE: I did not figure out how to require coffee-script here. As this has to be both Node.js and require.js compatible syntax. And they disagree on how to do that. Anyway we can stick with .js parent modules for a while.
|
||||
parent = require('./parentModule');
|
||||
|
||||
module.exports =
|
||||
{
|
||||
foo: (message)->
|
||||
alert message
|
||||
#use parent module
|
||||
alert parent.parentFoo message
|
||||
}
|
||||
12
require.js-example/app/parentModule.js
Normal file
12
require.js-example/app/parentModule.js
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
//this module is required to run module.
|
||||
({
|
||||
define: (typeof define === "function" ? define : function (F) {
|
||||
return F(require, exports, module);
|
||||
})
|
||||
}).define(function (require, exports, module) {
|
||||
return module.exports = {
|
||||
parentFoo: function (message) {
|
||||
return message.toUpperCase();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
@ -5,6 +5,8 @@
|
|||
(F)->
|
||||
F(require, exports, module)
|
||||
)}).define (require, exports, module)->
|
||||
helpers = require('./helpers')
|
||||
moment = require('./moment')
|
||||
XP = 15
|
||||
HP = 2
|
||||
obj = module.exports =
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
var dayMapping, moment;
|
||||
|
||||
moment = require('moment');
|
||||
moment = require('./moment');
|
||||
|
||||
exports.daysBetween = function(yesterday, now, dayStart) {
|
||||
if (!((dayStart != null) && (dayStart = parseInt(dayStart)) && dayStart >= 0 && dayStart <= 24)) {
|
||||
|
|
|
|||
6
script/moment.js
Normal file
6
script/moment.js
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue