Skip to content

Commit

Permalink
#137 Custom localStorage key for lmd cache
Browse files Browse the repository at this point in the history
  • Loading branch information
azproduction committed May 30, 2013
1 parent 0d6cbbc commit 19abf67
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lmd_initializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
fallbackUrl = scriptElement[getAttribute](prefix + 'src'),
ls = global.localStorage,
// lmd:%version%:%module_name%
rx = /^lmd:([^:]+):(.*)$/,
rx = new RegExp('^' + storageKey + ':([^:]+):(.*)$'),

script, json, head, item, main, lmd, match;

Expand Down
5 changes: 4 additions & 1 deletion src/plugin/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
// 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['lmd'] = sb.global.JSON.stringify({
sb.global.localStorage[storageKey] = sb.global.JSON.stringify({
modules: sb.modules,
// main module function
main: '(' + sb.main + ')',
Expand Down

0 comments on commit 19abf67

Please sign in to comment.