+ var text;
+ if(window.localStorage) {
+ text = window.localStorage.getItem(getLocalStorageKey(data.version).content);
+
+ var timestamp = window.localStorage.getItem(getLocalStorageKey(data.version).contentTimestamp),
+ usingDraft;
+ if(text) {
+ logger.debug('Local draft exists');
+ var dialog = Dialog.create({
+ title: gettext('Local draft of a document exists'),
+ text: gettext('Unsaved local draft of this version of the document exists in your browser. Do you want to load it instead?'),
+ executeButtonText: gettext('Yes, restore local draft'),
+ cancelButtonText: gettext('No, use version loaded from the server')
+ });
+ dialog.on('cancel', function() {
+ logger.debug('Bootstrapped version chosen');
+ usingDraft = false;
+ text = sandbox.getBootstrappedData().document;
+
+ });
+ dialog.on('execute', function(event) {
+ logger.debug('Local draft chosen');
+ usingDraft = true;
+ event.success();
+ });
+ dialog.show();
+ dialog.on('close', function() {
+ loadDocument(text, usingDraft, timestamp);
+ });
+ } else {
+ loadDocument(sandbox.getBootstrappedData().document, false);
+ }
+ } else {
+ loadDocument(sandbox.getBootstrappedData().document, false);
+ }