-
Notifications
You must be signed in to change notification settings - Fork 27
/
cache.js
32 lines (29 loc) · 1.02 KB
/
cache.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
/**
* This plugin dumps modules content to localStorage
*
* Flag "cache"
*/
/**
* @name sandbox
*/
(function (sb) {
// If possible to dump and version passed (fallback mode)
// then dump application source
if (sb.global.localStorage && sb.options.version/*if ($P.OPERA_MOBILE) {*/ && /_/.test(function(){_()}) /*}*/) {
(function () {
var scriptElement = sb.document.getElementById('lmd-initializer'),
storageKey = scriptElement ? scriptElement.getAttribute('data-key') : 'lmd';
try {
sb.global.localStorage[storageKey] = sb.global.JSON.stringify({
modules: sb.modules,
// main module function
main: '(' + sb.main + ')',
// lmd function === arguments.callee
lmd: '(' + sb.lmd + ')',
modules_options: sb.modules_options,
options: sb.options
});
} catch(e) {}
}());
}
}(sandbox));