diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index bf94e5674..5c9c3542b 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -1061,6 +1061,19 @@ define([ } }); }; + var saveAsTemplate = common.saveAsTemplate = function (Cryptput, data, cb) { + var p = parsePadUrl(window.location.href); + if (!p.type) { return; } + var hash = createRandomHash(); + var href = '/' + p.type + '/#' + hash; + Cryptput(hash, data.toSave, function (e) { + if (e) { throw new Error(e); } + common.addTemplate(makePad(href, data.title)); + whenRealtimeSyncs(getStore().getProxy().info.realtime, function () { + cb(); + }); + }); + }; common.createButton = function (type, rightside, data, callback) { var button; var size = "17px"; @@ -1149,17 +1162,12 @@ define([ console.error("Parse error while setting the title", e); } } - var p = parsePadUrl(window.location.href); - if (!p.type) { return; } - var hash = createRandomHash(); - var href = '/' + p.type + '/#' + hash; - data.Crypt.put(hash, toSave, function (e) { - if (e) { throw new Error(e); } - common.addTemplate(makePad(href, title)); - whenRealtimeSyncs(getStore().getProxy().info.realtime, function () { - common.alert(Messages.templateSaved); - common.feedback('TEMPLATE_CREATED'); - }); + saveAsTemplate(data.Crypt.put, { + title: title, + toSave: toSave + }, function () { + common.alert(Messages.templateSaved); + common.feedback('TEMPLATE_CREATED'); }); }; common.prompt(Messages.saveTemplatePrompt, title || document.title, todo); diff --git a/www/common/metadata-manager.js b/www/common/metadata-manager.js index 4956cda14..fdba66dee 100644 --- a/www/common/metadata-manager.js +++ b/www/common/metadata-manager.js @@ -32,6 +32,8 @@ define([], function () { }; metadataLazyObj = JSON.parse(JSON.stringify(metadataObj)); } + if (!metadataObj.users) { metadataObj.users = {}; } + if (!metadataLazyObj.users) { metadataLazyObj.users = {}; } var mdo = {}; // We don't want to add our user data to the object multiple times. //var containsYou = false; diff --git a/www/common/sframe-common.js b/www/common/sframe-common.js index 6cedc7235..121ad8105 100644 --- a/www/common/sframe-common.js +++ b/www/common/sframe-common.js @@ -138,11 +138,11 @@ define([ } break; case 'template': - if (!AppConfig.enableTemplates) { return; } + //if (!AppConfig.enableTemplates) { return; } button = $('