forked from seajs/seajs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare.js
51 lines (36 loc) · 1.08 KB
/
prepare.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* Prepare for bootstrapping
*/
;(function(seajs, util, global) {
// The safe and convenient version of console.log
seajs.log = util.log
// Sets a alias to `sea.js` directory for loading plugins.
seajs.config({
alias: { seajs: util.loaderDir }
})
// Uses `seajs-xxx` flag to load plugin-xxx.
util.forEach(getStartupPlugins(), function(name) {
seajs.use('seajs/plugin-' + name)
// Delays `seajs.use` calls to the onload of `mapfile` in debug mode.
if (name === 'debug') {
seajs._use = seajs.use
seajs._useArgs = []
seajs.use = function() { seajs._useArgs.push(arguments); return seajs }
}
})
// Helpers
// -------
function getStartupPlugins() {
var ret = []
var str = global.location.search
// Converts `seajs-xxx` to `seajs-xxx=1`
str = str.replace(/(seajs-\w+)(&|$)/g, '$1=1$2')
// Add cookie string
str += ' ' + document.cookie
// Excludes seajs-xxx=0
str.replace(/seajs-(\w+)=[1-9]/g, function(m, name) {
ret.push(name)
})
return util.unique(ret)
}
})(seajs, seajs._util, this)